Updated app.py
Browse files
app.py
CHANGED
@@ -36,11 +36,11 @@ models = {
|
|
36 |
"BBGM Model": bbgm_model
|
37 |
}
|
38 |
|
39 |
-
def translate(model_name, source_sentence
|
40 |
if isinstance(source_sentence, str):
|
41 |
source_sentence = [source_sentence]
|
42 |
model = models[model_name]
|
43 |
-
predictions = model.predict(
|
44 |
return [i.replace('β', ' ') for i in predictions[0]]
|
45 |
|
46 |
# Gradio interface
|
@@ -49,7 +49,6 @@ interface = gr.Interface(
|
|
49 |
inputs=[
|
50 |
gr.Dropdown(choices=["BM Model", "BBGM Model"], label="Model Selection"),
|
51 |
gr.Textbox(placeholder="Enter English sentence here...", label="Source Sentence"),
|
52 |
-
gr.Slider(minimum=1, maximum=10, default=5, step=1, label="Number of Beams"),
|
53 |
],
|
54 |
outputs=[
|
55 |
gr.Textbox(label="Prediction 1"),
|
@@ -60,13 +59,15 @@ interface = gr.Interface(
|
|
60 |
description='Type your English text in the left text box to get π³π¬ Pidgin translations on the right. '
|
61 |
'Tell us the best translation by clicking one of the buttons below.',
|
62 |
examples=[
|
63 |
-
['BBGM Model', 'Who are you?'
|
64 |
-
['BBGM Model', 'Is a personal philosophy of moral relativism, the only way to survive in this ethically complex world, or is it just an excuse to justify doing bad things?'
|
65 |
-
['
|
66 |
-
['BBGM Model', 'I know every song by that artiste.'
|
67 |
-
['
|
68 |
-
['BBGM Model', '
|
69 |
-
['BM Model', '
|
|
|
|
|
70 |
]
|
71 |
)
|
72 |
|
|
|
36 |
"BBGM Model": bbgm_model
|
37 |
}
|
38 |
|
39 |
+
def translate(model_name, source_sentence):
|
40 |
if isinstance(source_sentence, str):
|
41 |
source_sentence = [source_sentence]
|
42 |
model = models[model_name]
|
43 |
+
predictions = model.predict(source_sentence)
|
44 |
return [i.replace('β', ' ') for i in predictions[0]]
|
45 |
|
46 |
# Gradio interface
|
|
|
49 |
inputs=[
|
50 |
gr.Dropdown(choices=["BM Model", "BBGM Model"], label="Model Selection"),
|
51 |
gr.Textbox(placeholder="Enter English sentence here...", label="Source Sentence"),
|
|
|
52 |
],
|
53 |
outputs=[
|
54 |
gr.Textbox(label="Prediction 1"),
|
|
|
59 |
description='Type your English text in the left text box to get π³π¬ Pidgin translations on the right. '
|
60 |
'Tell us the best translation by clicking one of the buttons below.',
|
61 |
examples=[
|
62 |
+
['BBGM Model', 'Who are you?'],
|
63 |
+
['BBGM Model', 'Is a personal philosophy of moral relativism, the only way to survive in this ethically complex world, or is it just an excuse to justify doing bad things?'],
|
64 |
+
['BM Model', 'Is a personal philosophy of moral relativism, the only way to survive in this ethically complex world, or is it just an excuse to justify doing bad things?'],
|
65 |
+
['BBGM Model', 'I know every song by that artiste.'],
|
66 |
+
['BM Model', 'I know every song by that artiste.'],
|
67 |
+
['BBGM Model', 'They should not be permitted here.'],
|
68 |
+
['BM Model', 'They should not be permitted here.'],
|
69 |
+
['BBGM Model', 'I am lost, please help me find my way to the market.'],
|
70 |
+
['BM Model', 'I am lost, please help me find my way to the market.'],
|
71 |
]
|
72 |
)
|
73 |
|