Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,7 +10,8 @@ all_langs = languagecodes.iso_languages
|
|
| 10 |
# Language options as list, add favourite languages first
|
| 11 |
options = list(favourite_langs.keys())
|
| 12 |
options.extend(list(all_langs.keys()))
|
| 13 |
-
models = ["Helsinki-NLP",
|
|
|
|
| 14 |
"facebook/nllb-200-distilled-600M",
|
| 15 |
"facebook/nllb-200-distilled-1.3B",
|
| 16 |
"facebook/mbart-large-50-many-to-many-mmt",
|
|
@@ -35,7 +36,7 @@ def eurollm(model_name, sl, tl, input_text):
|
|
| 35 |
inputs = tokenizer(prompt, return_tensors="pt")
|
| 36 |
outputs = model.generate(**inputs, max_new_tokens=512)
|
| 37 |
output = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 38 |
-
result = output.rsplit(f'{tl}:')[-1].strip()
|
| 39 |
return result
|
| 40 |
|
| 41 |
def nllb(model_name, sl, tl, input_text):
|
|
@@ -117,10 +118,10 @@ def swap_languages(src_lang, tgt_lang):
|
|
| 117 |
|
| 118 |
def create_interface():
|
| 119 |
with gr.Blocks() as interface:
|
| 120 |
-
gr.Markdown("### Machine Text Translation
|
| 121 |
|
| 122 |
with gr.Row():
|
| 123 |
-
input_text = gr.Textbox(label="Enter text to translate:", placeholder="Type your text here
|
| 124 |
|
| 125 |
with gr.Row():
|
| 126 |
sselected_language = gr.Dropdown(choices=options, value = options[0], label="Source language", interactive=True)
|
|
|
|
| 10 |
# Language options as list, add favourite languages first
|
| 11 |
options = list(favourite_langs.keys())
|
| 12 |
options.extend(list(all_langs.keys()))
|
| 13 |
+
models = ["Helsinki-NLP",
|
| 14 |
+
"t5-base", "t5-small", "t5-large",
|
| 15 |
"facebook/nllb-200-distilled-600M",
|
| 16 |
"facebook/nllb-200-distilled-1.3B",
|
| 17 |
"facebook/mbart-large-50-many-to-many-mmt",
|
|
|
|
| 36 |
inputs = tokenizer(prompt, return_tensors="pt")
|
| 37 |
outputs = model.generate(**inputs, max_new_tokens=512)
|
| 38 |
output = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 39 |
+
result = output.rsplit(f'{tl}:')[-1].strip()
|
| 40 |
return result
|
| 41 |
|
| 42 |
def nllb(model_name, sl, tl, input_text):
|
|
|
|
| 118 |
|
| 119 |
def create_interface():
|
| 120 |
with gr.Blocks() as interface:
|
| 121 |
+
gr.Markdown("### Machine Text Translation")
|
| 122 |
|
| 123 |
with gr.Row():
|
| 124 |
+
input_text = gr.Textbox(label="Enter text to translate:", placeholder="Type your text here, maximum 512 tokens")
|
| 125 |
|
| 126 |
with gr.Row():
|
| 127 |
sselected_language = gr.Dropdown(choices=options, value = options[0], label="Source language", interactive=True)
|