import gradio as gr from fastai.text.all import * learn = load_learner('export.pkl') def reviews_generator(text,n_words): preds = learn.predict(text, n_words) return preds examples = [["The beauty of this book", "45"], ["I did not like this book because", "30"]] gr.Interface(fn = reviews_generator, title = "Book reviews generator", description = "Type the beginning of a review, and the machine will generate a full review.", inputs = [gr.Textbox(lines=1, placeholder="Enter the beginning of the review here", label="Starter text"), gr.Slider(0, 100, label="Length of desired review")], outputs = gr.outputs.Textbox(label="Generated Text"), examples = examples ).launch(share=True)