book_reviews / app.py
shainis's picture
Update app.py
e918475
raw
history blame
823 Bytes
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 didn't 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=False)