Tsunnami commited on
Commit
8e8e504
·
verified ·
1 Parent(s): 993563f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -8,7 +8,7 @@ model = load_from_checkpoint(model_path)
8
  def score_translation(src_text, mt_text):
9
  translations = [{"src": src_text, "mt": mt_text}]
10
  results = model.predict(translations, batch_size=1, gpus=1)
11
- return results['scores'][0]
12
 
13
  examples = [
14
  ["The weather is beautiful today.", "วันนี้อากาศดีมาก"],
@@ -17,21 +17,25 @@ examples = [
17
  ["Can you help me find the nearest train station?", "คุณช่วยฉันหาสถานีรถไฟที่ใกล้ที่สุดได้ไหม"]
18
  ]
19
 
20
- with gr.Blocks(theme=gr.themes.Soft()) as demo:
 
 
 
 
 
 
 
 
21
  gr.Markdown("# ComeTH Translation Quality Evaluator")
22
-
23
  with gr.Row():
24
  with gr.Column():
25
  src_input = gr.Textbox(label="Source Text (English)", placeholder="Enter English text here...")
26
  mt_input = gr.Textbox(label="Candidate Translation (Thai)", placeholder="Enter Thai translation here...")
27
  score_button = gr.Button("Evaluate Translation", variant="primary")
28
-
29
  with gr.Column():
30
  score_output = gr.Label(label="Quality Scores")
31
  gr.Markdown("### Higher scores indicate better translation quality across multiple dimensions")
32
-
33
  gr.Examples(examples=examples, inputs=[src_input, mt_input], outputs=score_output, fn=score_translation)
34
-
35
  score_button.click(fn=score_translation, inputs=[src_input, mt_input], outputs=score_output)
36
 
37
  if __name__ == "__main__":
 
8
  def score_translation(src_text, mt_text):
9
  translations = [{"src": src_text, "mt": mt_text}]
10
  results = model.predict(translations, batch_size=1, gpus=1)
11
+ return results["scores"][0]
12
 
13
  examples = [
14
  ["The weather is beautiful today.", "วันนี้อากาศดีมาก"],
 
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
+
23
+ * {
24
+ font-family: 'JetBrains Mono', monospace !important;
25
+ }
26
+ """
27
+
28
+ with gr.Blocks(theme=gr.themes.Soft(), css=font_css) as demo:
29
  gr.Markdown("# ComeTH Translation Quality Evaluator")
 
30
  with gr.Row():
31
  with gr.Column():
32
  src_input = gr.Textbox(label="Source Text (English)", placeholder="Enter English text here...")
33
  mt_input = gr.Textbox(label="Candidate Translation (Thai)", placeholder="Enter Thai translation here...")
34
  score_button = gr.Button("Evaluate Translation", variant="primary")
 
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(examples=examples, inputs=[src_input, mt_input], outputs=score_output, fn=score_translation)
 
39
  score_button.click(fn=score_translation, inputs=[src_input, mt_input], outputs=score_output)
40
 
41
  if __name__ == "__main__":