Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,10 +2,10 @@ import gradio as gr
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
available_models = {
|
5 |
-
"
|
6 |
-
"
|
7 |
-
"
|
8 |
-
"
|
9 |
}
|
10 |
|
11 |
def translate_text(model_name, lang_dir, gender, input_text):
|
@@ -21,14 +21,13 @@ def translate_text(model_name, lang_dir, gender, input_text):
|
|
21 |
return output_text[0]['generated_text']
|
22 |
|
23 |
|
24 |
-
model_dropdown = gr.Dropdown(choices=list(available_models.keys()), label="Select Model", value="
|
25 |
lang_dropdown = gr.Dropdown(choices=["English -> Spanish", "Spanish -> English"], label="Language Direction", value="English -> Spanish")
|
26 |
gender_dropdown = gr.Dropdown(choices=["female", "male"], label="Select Gender", value=None)
|
27 |
|
28 |
iface = gr.Interface(fn=translate_text,
|
29 |
inputs=[model_dropdown, lang_dropdown, gender_dropdown, "text"],
|
30 |
outputs="text",
|
31 |
-
title="Translation Interface"
|
32 |
-
description="Select a model, language direction, and input text to translate.")
|
33 |
|
34 |
iface.launch()
|
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
available_models = {
|
5 |
+
"Baseline": pipeline("text2text-generation", model="samzirbo/mt5.baseline"),
|
6 |
+
"Genered": pipeline("text2text-generation", model="samzirbo/mt5.gendered"),
|
7 |
+
"Balanced": pipeline("text2text-generation", model="samzirbo/mt5.balanced"),
|
8 |
+
"Gendered and Balanced": pipeline("text2text-generation", model="samzirbo/mt5.gendered_balanced")
|
9 |
}
|
10 |
|
11 |
def translate_text(model_name, lang_dir, gender, input_text):
|
|
|
21 |
return output_text[0]['generated_text']
|
22 |
|
23 |
|
24 |
+
model_dropdown = gr.Dropdown(choices=list(available_models.keys()), label="Select Model", value="Baseline")
|
25 |
lang_dropdown = gr.Dropdown(choices=["English -> Spanish", "Spanish -> English"], label="Language Direction", value="English -> Spanish")
|
26 |
gender_dropdown = gr.Dropdown(choices=["female", "male"], label="Select Gender", value=None)
|
27 |
|
28 |
iface = gr.Interface(fn=translate_text,
|
29 |
inputs=[model_dropdown, lang_dropdown, gender_dropdown, "text"],
|
30 |
outputs="text",
|
31 |
+
title="Translation Interface")
|
|
|
32 |
|
33 |
iface.launch()
|