File size: 795 Bytes
e28289d
0dccf94
 
e28289d
 
 
1fc4cca
d9b5bb2
e28289d
b6f165e
e28289d
b6f165e
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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)