Update app.py
Browse files
app.py
CHANGED
|
@@ -10,13 +10,22 @@ def score_translation(src_text, mt_text):
|
|
| 10 |
results = model.predict(translations, batch_size=1, gpus=1)
|
| 11 |
return results["scores"][0]
|
| 12 |
|
| 13 |
-
|
| 14 |
["The weather is beautiful today.", "วันนี้อากาศดีมาก"],
|
| 15 |
["I need to go to the hospital.", "ฉันต้องไปโรงพยาบาล"],
|
| 16 |
["This restaurant serves delicious food.", "ร้านอาหารนี้เสิร์ฟอาหารอร่อย"],
|
| 17 |
["Can you help me find the nearest train station?", "คุณช่วยฉันหาสถานีรถไฟที่ใกล้ที่สุดได้ไหม"]
|
| 18 |
]
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
font_css = """
|
| 21 |
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&display=swap");
|
| 22 |
|
|
@@ -35,7 +44,12 @@ with gr.Blocks(theme=gr.themes.Soft(), css=font_css) as demo:
|
|
| 35 |
with gr.Column():
|
| 36 |
score_output = gr.Label(label="Quality Scores")
|
| 37 |
gr.Markdown("### Higher scores indicate better translation quality across multiple dimensions")
|
| 38 |
-
gr.Examples(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
score_button.click(fn=score_translation, inputs=[src_input, mt_input], outputs=score_output)
|
| 40 |
|
| 41 |
if __name__ == "__main__":
|
|
|
|
| 10 |
results = model.predict(translations, batch_size=1, gpus=1)
|
| 11 |
return results["scores"][0]
|
| 12 |
|
| 13 |
+
good_examples = [
|
| 14 |
["The weather is beautiful today.", "วันนี้อากาศดีมาก"],
|
| 15 |
["I need to go to the hospital.", "ฉันต้องไปโรงพยาบาล"],
|
| 16 |
["This restaurant serves delicious food.", "ร้านอาหารนี้เสิร์ฟอาหารอร่อย"],
|
| 17 |
["Can you help me find the nearest train station?", "คุณช่วยฉันหาสถานีรถไฟที่ใกล้ที่สุดได้ไหม"]
|
| 18 |
]
|
| 19 |
|
| 20 |
+
bad_examples = [
|
| 21 |
+
["The weather is beautiful today.", "วันนี้อากาศแย่สุดๆ"],
|
| 22 |
+
["I need to go to the hospital.", "ฉันอยากกินข้าว"],
|
| 23 |
+
["This restaurant serves delicious food.", "ร้านนี้ไม่อร่อยเลย"],
|
| 24 |
+
["Can you help me find the nearest train station?", "คุณพูดภาษาอังกฤษได้ไหม?"],
|
| 25 |
+
]
|
| 26 |
+
|
| 27 |
+
examples = good_examples + bad_examples
|
| 28 |
+
|
| 29 |
font_css = """
|
| 30 |
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&display=swap");
|
| 31 |
|
|
|
|
| 44 |
with gr.Column():
|
| 45 |
score_output = gr.Label(label="Quality Scores")
|
| 46 |
gr.Markdown("### Higher scores indicate better translation quality across multiple dimensions")
|
| 47 |
+
gr.Examples(
|
| 48 |
+
examples=examples,
|
| 49 |
+
inputs=[src_input, mt_input],
|
| 50 |
+
outputs=score_output,
|
| 51 |
+
fn=score_translation
|
| 52 |
+
)
|
| 53 |
score_button.click(fn=score_translation, inputs=[src_input, mt_input], outputs=score_output)
|
| 54 |
|
| 55 |
if __name__ == "__main__":
|