Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -37,7 +37,7 @@ def translate_msa_to_syrian(text):
|
|
37 |
|
38 |
try:
|
39 |
input_ids = msa_to_syrian_tokenizer(text, return_tensors="pt").input_ids.to(device)
|
40 |
-
outputs = msa_to_syrian_model.generate(input_ids, max_length=
|
41 |
translated_text = msa_to_syrian_tokenizer.decode(outputs[0], skip_special_tokens=True)
|
42 |
return translated_text
|
43 |
except Exception as e:
|
@@ -51,7 +51,7 @@ def translate_syrian_to_msa(text):
|
|
51 |
|
52 |
try:
|
53 |
input_ids = syrian_to_msa_tokenizer(text, return_tensors="pt").input_ids.to(device)
|
54 |
-
outputs = syrian_to_msa_model.generate(input_ids, max_length=
|
55 |
translated_text = syrian_to_msa_tokenizer.decode(outputs[0], skip_special_tokens=True)
|
56 |
return translated_text
|
57 |
except Exception as e:
|
@@ -67,7 +67,7 @@ def bidirectional_translate(text, direction):
|
|
67 |
return "Please select a translation direction"
|
68 |
|
69 |
# Create Gradio interface
|
70 |
-
with gr.Blocks(title="SHAMI-MT: Bidirectional Arabic
|
71 |
|
72 |
gr.HTML("""
|
73 |
<div style="text-align: center; margin-bottom: 2rem;">
|
|
|
37 |
|
38 |
try:
|
39 |
input_ids = msa_to_syrian_tokenizer(text, return_tensors="pt").input_ids.to(device)
|
40 |
+
outputs = msa_to_syrian_model.generate(input_ids, max_length=128, num_beams=5, early_stopping=True)
|
41 |
translated_text = msa_to_syrian_tokenizer.decode(outputs[0], skip_special_tokens=True)
|
42 |
return translated_text
|
43 |
except Exception as e:
|
|
|
51 |
|
52 |
try:
|
53 |
input_ids = syrian_to_msa_tokenizer(text, return_tensors="pt").input_ids.to(device)
|
54 |
+
outputs = syrian_to_msa_model.generate(input_ids, max_length=128, num_beams=5, early_stopping=True)
|
55 |
translated_text = syrian_to_msa_tokenizer.decode(outputs[0], skip_special_tokens=True)
|
56 |
return translated_text
|
57 |
except Exception as e:
|
|
|
67 |
return "Please select a translation direction"
|
68 |
|
69 |
# Create Gradio interface
|
70 |
+
with gr.Blocks(title="SHAMI-MT: Bidirectional Syria Arabic Dialect MT Framework") as demo:
|
71 |
|
72 |
gr.HTML("""
|
73 |
<div style="text-align: center; margin-bottom: 2rem;">
|