Update app.py
Browse files
app.py
CHANGED
@@ -1,52 +1,32 @@
|
|
1 |
from multilingual_translation import text_to_text_generation
|
2 |
-
from utils import
|
3 |
import gradio as gr
|
4 |
|
5 |
-
lang_list = list(lang_ids.keys())
|
6 |
model_list = data_scraping()
|
7 |
|
8 |
-
def multilingual_translate(
|
9 |
-
|
10 |
-
model_id: str,
|
11 |
-
target_lang: str
|
12 |
-
):
|
13 |
-
|
14 |
return text_to_text_generation(
|
15 |
prompt=prompt,
|
16 |
model_id=model_id,
|
17 |
device='cpu',
|
18 |
-
target_lang=
|
19 |
-
|
20 |
-
|
21 |
|
22 |
inputs = [
|
23 |
gr.Textbox(lines=4, value="Hello world!", label="Input Text"),
|
24 |
gr.Dropdown(model_list, value="facebook/m2m100_418M", label="Model"),
|
25 |
-
gr.Dropdown(lang_list, value="Turkish", label="Target Language"),
|
26 |
]
|
27 |
|
28 |
output = gr.outputs.Textbox(label="Output Text")
|
29 |
|
30 |
examples = [
|
31 |
-
[
|
32 |
-
|
33 |
-
|
34 |
-
"Turkish",
|
35 |
-
],
|
36 |
-
[
|
37 |
-
"Omar ve Merve çok iyi arkadaşlar.",
|
38 |
-
"facebook/m2m100_418M",
|
39 |
-
"Spanish",
|
40 |
-
],
|
41 |
-
[
|
42 |
-
"Hugging Face is a great company.",
|
43 |
-
"facebook/m2m100_418M",
|
44 |
-
"French",
|
45 |
-
]
|
46 |
]
|
47 |
|
48 |
title = "Beyond English-Centric Multilingual Machine Translation"
|
49 |
-
|
50 |
description = "M2M100 is a multilingual encoder-decoder (seq-to-seq) model trained for Many-to-Many multilingual translation. It was introduced in this [paper](https://arxiv.org/abs/2010.11125) and first released in [this](https://github.com/pytorch/fairseq/tree/master/examples/m2m_100) repository."
|
51 |
|
52 |
app = gr.Interface(
|
|
|
1 |
from multilingual_translation import text_to_text_generation
|
2 |
+
from utils import data_scraping
|
3 |
import gradio as gr
|
4 |
|
|
|
5 |
model_list = data_scraping()
|
6 |
|
7 |
+
def multilingual_translate(prompt: str, model_id: str):
|
8 |
+
target_lang = "en" # English language code
|
|
|
|
|
|
|
|
|
9 |
return text_to_text_generation(
|
10 |
prompt=prompt,
|
11 |
model_id=model_id,
|
12 |
device='cpu',
|
13 |
+
target_lang=target_lang
|
14 |
+
)
|
|
|
15 |
|
16 |
inputs = [
|
17 |
gr.Textbox(lines=4, value="Hello world!", label="Input Text"),
|
18 |
gr.Dropdown(model_list, value="facebook/m2m100_418M", label="Model"),
|
|
|
19 |
]
|
20 |
|
21 |
output = gr.outputs.Textbox(label="Output Text")
|
22 |
|
23 |
examples = [
|
24 |
+
["Hello world!", "facebook/m2m100_418M"],
|
25 |
+
["Omar ve Merve çok iyi arkadaşlar.", "facebook/m2m100_418M"],
|
26 |
+
["Hugging Face is a great company.", "facebook/m2m100_418M"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
]
|
28 |
|
29 |
title = "Beyond English-Centric Multilingual Machine Translation"
|
|
|
30 |
description = "M2M100 is a multilingual encoder-decoder (seq-to-seq) model trained for Many-to-Many multilingual translation. It was introduced in this [paper](https://arxiv.org/abs/2010.11125) and first released in [this](https://github.com/pytorch/fairseq/tree/master/examples/m2m_100) repository."
|
31 |
|
32 |
app = gr.Interface(
|