Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -476,18 +476,18 @@ def swap_languages(src_lang, tgt_lang):
|
|
| 476 |
|
| 477 |
def get_info(model_name: str, sl: str = None, tl: str = None):
|
| 478 |
helsinki = '### [Helsinki-NLP](https://huggingface.co/Helsinki-NLP "Helsinki-NLP")'
|
| 479 |
-
if model_name == "Helsinki-NLP" and sl
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
|
|
|
| 483 |
return response
|
| 484 |
-
|
| 485 |
-
return helsinki
|
| 486 |
-
if model_name == "Argos":
|
| 487 |
return requests.get(f'https://huggingface.co/TiberiuCristianLeon/Argostranslate/raw/main/README.md').text
|
| 488 |
-
|
| 489 |
return "Google Translate"
|
| 490 |
-
|
|
|
|
| 491 |
|
| 492 |
def create_interface():
|
| 493 |
with gr.Blocks() as interface:
|
|
@@ -507,7 +507,7 @@ def create_interface():
|
|
| 507 |
message_text = gr.Textbox(label="Messages:", placeholder="Display field for status and error messages", interactive=False,
|
| 508 |
value=f'Default translation settings: from {s_language.value} to {t_language.value} with {model_name.value}.')
|
| 509 |
allmodels = gr.HTML(label="Model links:", value=', '.join([f'<a href="https://huggingface.co/{model}">{model}</a>' for model in models]))
|
| 510 |
-
model_info = gr.Markdown(label="Model info:", value=DEFAULTS[2], show_copy_button=True)
|
| 511 |
model_name.change(fn=get_info, inputs=[model_name, s_language, t_language], outputs=model_info, api_name=False, show_api=False)
|
| 512 |
|
| 513 |
translate_btn.click(
|
|
|
|
| 476 |
|
| 477 |
def get_info(model_name: str, sl: str = None, tl: str = None):
|
| 478 |
helsinki = '### [Helsinki-NLP](https://huggingface.co/Helsinki-NLP "Helsinki-NLP")'
|
| 479 |
+
if model_name == "Helsinki-NLP" and sl and tl:
|
| 480 |
+
url = f'https://huggingface.co/{model_name}/opus-mt-{sl}-{tl}/raw/main/README.md'
|
| 481 |
+
response = requests.get(url).text
|
| 482 |
+
if 'Repository not found' in response or 'Invalid username or password' in response:
|
| 483 |
+
return helsinki
|
| 484 |
return response
|
| 485 |
+
elif model_name == "Argos":
|
|
|
|
|
|
|
| 486 |
return requests.get(f'https://huggingface.co/TiberiuCristianLeon/Argostranslate/raw/main/README.md').text
|
| 487 |
+
elif model_name == "Google":
|
| 488 |
return "Google Translate"
|
| 489 |
+
else:
|
| 490 |
+
return requests.get(f'https://huggingface.co/{model_name}/raw/main/README.md').text
|
| 491 |
|
| 492 |
def create_interface():
|
| 493 |
with gr.Blocks() as interface:
|
|
|
|
| 507 |
message_text = gr.Textbox(label="Messages:", placeholder="Display field for status and error messages", interactive=False,
|
| 508 |
value=f'Default translation settings: from {s_language.value} to {t_language.value} with {model_name.value}.')
|
| 509 |
allmodels = gr.HTML(label="Model links:", value=', '.join([f'<a href="https://huggingface.co/{model}">{model}</a>' for model in models]))
|
| 510 |
+
model_info = gr.Markdown(label="Model info:", value=get_info(DEFAULTS[2], DEFAULTS[0], DEFAULTS[1], show_copy_button=True)
|
| 511 |
model_name.change(fn=get_info, inputs=[model_name, s_language, t_language], outputs=model_info, api_name=False, show_api=False)
|
| 512 |
|
| 513 |
translate_btn.click(
|