book_reviews / app.py
shainis's picture
Update app.py
1fc4cca
raw
history blame
724 Bytes
import gradio as gr
import fastbook
from fastbook import *
from pathlib import Path
from fastai.text.all import *
fastbook.setup_book()
learn = load_learner('export.pkl')
def reviews_generator(text,n_words):
preds = learn.predict(text, n_words)
return outputs
examples = [["The beauty of this books", "45"], ["I didn't like this book because", "30"]]
demo = gr.Interface(fn=reviews_generator,
inputs=[gr.Textbox(lines=2, placeholder="Enter the beginning of the book review here", label="Sample text"), gr.Textbox(lines=1, label="Length of generated text")],
outputs=[gr.Textbox(label="Sample text")],
examples=examples)
demo.launch( debug = True )