Spaces:
Sleeping
Sleeping
from parrot import Parrot | |
import torch | |
import warnings | |
warnings.filterwarnings("ignore") | |
import gradio as gr | |
''' | |
uncomment to get reproducable paraphrase generations | |
def random_state(seed): | |
torch.manual_seed(seed) | |
if torch.cuda.is_available(): | |
torch.cuda.manual_seed_all(seed) | |
random_state(1234) | |
''' | |
#Init models (make sure you init ONLY once if you integrate this to your code) | |
parrot = Parrot(model_tag="prithivida/parrot_paraphraser_on_T5", use_gpu=False) | |
def generate_paraphrases(phrase): | |
para_phrases = parrot.augment(input_phrase=phrase) | |
return [para_phrase['phrase'] for para_phrase in para_phrases] | |
iface = gr.Interface( | |
fn=generate_paraphrases, | |
inputs=gr.inputs.Textbox(lines=2, placeholder='Input Phrase...'), | |
outputs=gr.outputs.Textbox() | |
) | |
iface.launch() |