Commit
·
64a9be8
1
Parent(s):
6f015bd
Update app.py
Browse files
app.py
CHANGED
@@ -4,17 +4,30 @@ from transformers import pipeline
|
|
4 |
import os
|
5 |
TOKEN = os.getenv('HUGGING_FACE_HUB_TOKEN')
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
|
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
13 |
|
14 |
demo = gr.Interface(
|
15 |
-
fn
|
16 |
-
inputs
|
17 |
-
|
|
|
|
|
|
|
18 |
)
|
19 |
-
|
20 |
-
demo.launch(share=True,debug=True)
|
|
|
4 |
import os
|
5 |
TOKEN = os.getenv('HUGGING_FACE_HUB_TOKEN')
|
6 |
|
7 |
+
models = [
|
8 |
+
"barghavani/en_to_fr_translation_model",
|
9 |
+
"barghavani/my_translation_machine_en_to_de",
|
10 |
+
#"Helsinki-NLP/opus-mt-fr-ber",
|
11 |
+
#"Helsinki-NLP/opus-mt-ber-fr",
|
12 |
+
#"Helsinki-NLP/opus-mt-es-ber",
|
13 |
+
#"Helsinki-NLP/opus-mt-ber-es",
|
14 |
+
#"Helsinki-NLP/opus-mt-kab-en"
|
15 |
+
]
|
16 |
|
17 |
+
pipes = {}
|
18 |
|
19 |
+
def predict(text, model):
|
20 |
+
if model not in pipes:
|
21 |
+
pipes[model] = pipeline("translation", model=model)
|
22 |
+
pipe = pipes[model]
|
23 |
+
return pipe(text)[0]['translation_text']
|
24 |
|
25 |
demo = gr.Interface(
|
26 |
+
fn=predict,
|
27 |
+
inputs=[
|
28 |
+
gr.Textbox(lines=5, label="Input Text"),
|
29 |
+
gr.Dropdown(models, label="Model")
|
30 |
+
],
|
31 |
+
outputs='text',
|
32 |
)
|
33 |
+
demo.launch(share=True,debug=True)demo.launch(share=True,debug=True)
|
|