Paraphrasing / app.py
FahadAlam's picture
Update app.py
bb46bbf
raw
history blame contribute delete
928 Bytes
import gradio as gr
from parrot import Parrot
import torch
import warnings
warnings.filterwarnings("ignore")
parrot = Parrot(model_tag="prithivida/parrot_paraphraser_on_T5", use_gpu=False)
def paraphrase_text(input_text):
para_phrases = parrot.augment(input_phrase=input_text,
max_return_phrases = 3)
return para_phrases[0][0], para_phrases[1][0] if len(para_phrases) > 1 else '' , para_phrases[2][0] if len(para_phrases) > 2 else ''
examples = [["Uploading a video to YouTube can help exposure for your business.", "45"], ["Niagara Falls is viewed by thousands of tourists every year.", "30"]]
demo = gr.Interface(fn=paraphrase_text, inputs=gr.Textbox(lines=3, placeholder="Enter sample text here", label="Original text"), outputs=[gr.Textbox(label="Paraphrasing 1"), gr.Textbox(label="Paraphrasing 2"), gr.Textbox(label="Paraphrasing 3")], examples=examples)
demo.launch( debug = True )