Spaces:
Running
Running
Commit
·
c1146a2
1
Parent(s):
23d96a2
Upload 2 files
Browse files- app.py +17 -0
- requirements.txt +6 -0
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from parrot import Parrot
|
3 |
+
import torch
|
4 |
+
import warnings
|
5 |
+
warnings.filterwarnings("ignore")
|
6 |
+
|
7 |
+
parrot = Parrot(model_tag="prithivida/parrot_paraphraser_on_T5", use_gpu=False)
|
8 |
+
|
9 |
+
def paraphrase_text(input_text):
|
10 |
+
para_phrases = parrot.augment(input_phrase=input_text,
|
11 |
+
max_return_phrases = 3)
|
12 |
+
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 ''
|
13 |
+
|
14 |
+
examples = [["Uploading a video to YouTube can help exposure for your business.", "45"], ["Niagara Falls is viewed by thousands of tourists every year.", "30"]]
|
15 |
+
|
16 |
+
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)
|
17 |
+
demo.launch( debug = True )
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
timm
|
3 |
+
sentencepiece
|
4 |
+
transformers
|
5 |
+
protobuf
|
6 |
+
git+https://github.com/PrithivirajDamodaran/Parrot_Paraphraser.git
|