Spaces:
Sleeping
Sleeping
Unityraptor
commited on
Commit
•
c8766ff
1
Parent(s):
adca670
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,7 @@
|
|
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
|
3 |
device = "cpu"
|
4 |
|
@@ -6,7 +9,7 @@ tokenizer = AutoTokenizer.from_pretrained("humarin/chatgpt_paraphraser_on_T5_bas
|
|
6 |
|
7 |
model = AutoModelForSeq2SeqLM.from_pretrained("humarin/chatgpt_paraphraser_on_T5_base").to(device)
|
8 |
|
9 |
-
|
10 |
|
11 |
def paraphrase(
|
12 |
question,
|
@@ -38,12 +41,12 @@ def paraphrase(
|
|
38 |
return res
|
39 |
|
40 |
|
41 |
-
def
|
42 |
-
myout =
|
43 |
return myout
|
44 |
|
45 |
def launch(input):
|
46 |
-
out =
|
47 |
return out
|
48 |
|
49 |
iface = gr.Interface(launch,
|
|
|
1 |
+
|
2 |
import gradio as gr
|
3 |
+
import torch
|
4 |
+
|
5 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
|
6 |
device = "cpu"
|
7 |
|
|
|
9 |
|
10 |
model = AutoModelForSeq2SeqLM.from_pretrained("humarin/chatgpt_paraphraser_on_T5_base").to(device)
|
11 |
|
12 |
+
translator = pipeline(task="translation", model="./models/facebook/nllb-200-distilled-600M", torch_dtype=torch.bfloat16)
|
13 |
|
14 |
def paraphrase(
|
15 |
question,
|
|
|
41 |
return res
|
42 |
|
43 |
|
44 |
+
def translate(myinput):
|
45 |
+
myout = translator(myinput,src_lang="eng_Latn",tgt_lang="fra_Latn")
|
46 |
return myout
|
47 |
|
48 |
def launch(input):
|
49 |
+
out = translate(paraphrase(input))
|
50 |
return out
|
51 |
|
52 |
iface = gr.Interface(launch,
|