Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -47,11 +47,8 @@ download_file(url_eo, ckpt_path_eo)
|
|
47 |
|
48 |
# ---------- Import required modules from the cloned repository ----------
|
49 |
|
50 |
-
# Import the tokenizer and utility functions (shared by both models)
|
51 |
from tashkeel_tokenizer import TashkeelTokenizer
|
52 |
from utils import remove_non_arabic
|
53 |
-
|
54 |
-
# Import the two model implementations under different names
|
55 |
from ed_pl import TashkeelModel as TashkeelModel_ED
|
56 |
from eo_pl import TashkeelModel as TashkeelModel_EO
|
57 |
|
@@ -103,7 +100,7 @@ def diacritize_text(model_type, input_text):
|
|
103 |
text_clean = remove_non_arabic(input_text)
|
104 |
x = [text_clean]
|
105 |
|
106 |
-
batch_size = 16 #
|
107 |
verbose = False
|
108 |
|
109 |
try:
|
@@ -116,7 +113,6 @@ def diacritize_text(model_type, input_text):
|
|
116 |
except Exception as e:
|
117 |
return f"An error occurred during diacritization: {str(e)}"
|
118 |
|
119 |
-
# Return the first (and only) line from the output
|
120 |
return output_lines[0] if output_lines else "No output produced."
|
121 |
|
122 |
# ---------- Gradio Interface ----------
|
@@ -131,14 +127,14 @@ description = (
|
|
131 |
iface = gr.Interface(
|
132 |
fn=diacritize_text,
|
133 |
inputs=[
|
134 |
-
gr.
|
135 |
choices=["Encoder-Decoder", "Encoder-Only"],
|
136 |
-
|
137 |
label="Model Selection"
|
138 |
),
|
139 |
-
gr.
|
140 |
],
|
141 |
-
outputs=gr.
|
142 |
title=title,
|
143 |
description=description,
|
144 |
allow_flagging="never"
|
|
|
47 |
|
48 |
# ---------- Import required modules from the cloned repository ----------
|
49 |
|
|
|
50 |
from tashkeel_tokenizer import TashkeelTokenizer
|
51 |
from utils import remove_non_arabic
|
|
|
|
|
52 |
from ed_pl import TashkeelModel as TashkeelModel_ED
|
53 |
from eo_pl import TashkeelModel as TashkeelModel_EO
|
54 |
|
|
|
100 |
text_clean = remove_non_arabic(input_text)
|
101 |
x = [text_clean]
|
102 |
|
103 |
+
batch_size = 16 # Fixed batch size.
|
104 |
verbose = False
|
105 |
|
106 |
try:
|
|
|
113 |
except Exception as e:
|
114 |
return f"An error occurred during diacritization: {str(e)}"
|
115 |
|
|
|
116 |
return output_lines[0] if output_lines else "No output produced."
|
117 |
|
118 |
# ---------- Gradio Interface ----------
|
|
|
127 |
iface = gr.Interface(
|
128 |
fn=diacritize_text,
|
129 |
inputs=[
|
130 |
+
gr.Dropdown(
|
131 |
choices=["Encoder-Decoder", "Encoder-Only"],
|
132 |
+
value="Encoder-Only",
|
133 |
label="Model Selection"
|
134 |
),
|
135 |
+
gr.Textbox(lines=4, placeholder="Enter Arabic text here...", label="Input Text")
|
136 |
],
|
137 |
+
outputs=gr.Textbox(label="Diacritized Output"),
|
138 |
title=title,
|
139 |
description=description,
|
140 |
allow_flagging="never"
|