Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,7 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import os
|
3 |
import warnings
|
4 |
import random
|
5 |
import torch
|
|
|
6 |
from parrot import Parrot
|
7 |
|
8 |
# Suppress warnings
|
@@ -10,16 +9,13 @@ warnings.filterwarnings("ignore")
|
|
10 |
os.environ['TRANSFORMERS_NO_ADVISORY_WARNINGS'] = '1'
|
11 |
|
12 |
# Set random state for reproducibility
|
13 |
-
|
14 |
-
|
|
|
15 |
torch.cuda.manual_seed_all(1234)
|
16 |
-
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
17 |
-
print(f"Using device: {device}")
|
18 |
-
|
19 |
|
20 |
# Initialize Parrot model
|
21 |
-
parrot = Parrot(model_tag="prithivida/parrot_paraphraser_on_T5")
|
22 |
-
parrot.model.to(device)
|
23 |
# Function to paraphrase a single sentence
|
24 |
def paraphrase_sentence(sentence):
|
25 |
paraphrases = parrot.augment(input_phrase=sentence, max_return_phrases=10, max_length=100, adequacy_threshold=0.75, fluency_threshold=0.75)
|
|
|
|
|
|
|
1 |
import warnings
|
2 |
import random
|
3 |
import torch
|
4 |
+
|
5 |
from parrot import Parrot
|
6 |
|
7 |
# Suppress warnings
|
|
|
9 |
os.environ['TRANSFORMERS_NO_ADVISORY_WARNINGS'] = '1'
|
10 |
|
11 |
# Set random state for reproducibility
|
12 |
+
def random_state(seed):
|
13 |
+
torch.manual_seed(seed)
|
14 |
+
if torch.cuda.is_available():
|
15 |
torch.cuda.manual_seed_all(1234)
|
|
|
|
|
|
|
16 |
|
17 |
# Initialize Parrot model
|
18 |
+
parrot = Parrot(model_tag="prithivida/parrot_paraphraser_on_T5")
|
|
|
19 |
# Function to paraphrase a single sentence
|
20 |
def paraphrase_sentence(sentence):
|
21 |
paraphrases = parrot.augment(input_phrase=sentence, max_return_phrases=10, max_length=100, adequacy_threshold=0.75, fluency_threshold=0.75)
|