Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -110,7 +110,6 @@ translations = {
|
|
| 110 |
"progress": "Progress",
|
| 111 |
"logs": "Logs",
|
| 112 |
"refresh": "🔄 Refresh",
|
| 113 |
-
"auto_refresh": "Auto-refresh every 5s",
|
| 114 |
"export_logs": "📥 Export Logs",
|
| 115 |
"language": "Language"
|
| 116 |
},
|
|
@@ -131,7 +130,6 @@ translations = {
|
|
| 131 |
"progress": "پرمختګ",
|
| 132 |
"logs": "لاګونه",
|
| 133 |
"refresh": "🔄 تازه کړئ",
|
| 134 |
-
"auto_refresh": "هر ۵ ثانیې تازه کړئ",
|
| 135 |
"export_logs": "📥 لاګونه ډاونلوډ کړئ",
|
| 136 |
"language": "ژبه"
|
| 137 |
}
|
|
@@ -205,73 +203,17 @@ def export_logs():
|
|
| 205 |
buffer = io.StringIO()
|
| 206 |
df.to_csv(buffer, index=False)
|
| 207 |
buffer.seek(0)
|
| 208 |
-
return
|
| 209 |
|
| 210 |
with gr.Blocks(title="Pashto Base Bloom Trainer", theme="soft") as demo:
|
| 211 |
lang_selector = gr.Dropdown(choices=["English", "پښتو"], value="English", label="Language")
|
| 212 |
labels = translations["English"]
|
| 213 |
|
| 214 |
-
def update_labels(lang):
|
| 215 |
-
return translations[lang]
|
| 216 |
-
|
| 217 |
-
lang_selector.change(fn=update_labels, inputs=lang_selector, outputs=[])
|
| 218 |
-
|
| 219 |
-
gr.Markdown(lambda: f"# {labels['title']}")
|
| 220 |
-
|
| 221 |
gr.Markdown(f"# {labels['title']}")
|
| 222 |
|
| 223 |
with gr.Tab(labels["load_dataset"]):
|
| 224 |
gr.Markdown(f"### {labels['load_dataset']}")
|
| 225 |
with gr.Row():
|
| 226 |
dataset_btn = gr.Button(labels["load_dataset"])
|
| 227 |
-
dataset_status = gr.Textbox(label=labels["status"], lines=2, interactive
|
| 228 |
-
|
| 229 |
-
dataset_btn.click(load_hf_dataset, outputs=[dataset_status, dataset_preview])
|
| 230 |
-
|
| 231 |
-
gr.Markdown(f"### {labels['upload_file']}")
|
| 232 |
-
file_upload = gr.File(label=labels["upload_file"])
|
| 233 |
-
file_upload.change(load_local_dataset, inputs=file_upload, outputs=[dataset_status, dataset_preview])
|
| 234 |
-
|
| 235 |
-
with gr.Tab(labels["test"]):
|
| 236 |
-
with gr.Row():
|
| 237 |
-
test_input = gr.Textbox(label=labels["test_input"], lines=3)
|
| 238 |
-
test_btn = gr.Button(labels["test"])
|
| 239 |
-
test_output = gr.Textbox(label=labels["test_output"], lines=3, interactive=False)
|
| 240 |
-
test_btn.click(test_model, inputs=test_input, outputs=test_output)
|
| 241 |
-
|
| 242 |
-
with gr.Tab(labels["train"]):
|
| 243 |
-
train_input = gr.Textbox(label=labels["train_data"], lines=6)
|
| 244 |
-
train_btn = gr.Button(labels["train"])
|
| 245 |
-
train_output = gr.Textbox(label=labels["status"], lines=2, interactive=False)
|
| 246 |
-
train_btn.click(train_model, inputs=train_input, outputs=train_output)
|
| 247 |
-
|
| 248 |
-
with gr.Tab(labels["finetune"]):
|
| 249 |
-
finetune_input = gr.Textbox(label=labels["finetune_data"], lines=6)
|
| 250 |
-
finetune_btn = gr.Button(labels["finetune"])
|
| 251 |
-
finetune_output = gr.Textbox(label=labels["status"], lines=2, interactive=False)
|
| 252 |
-
finetune_btn.click(finetune_model, inputs=finetune_input, outputs=finetune_output)
|
| 253 |
-
|
| 254 |
-
with gr.Tab(labels["logs"]):
|
| 255 |
-
with gr.Row():
|
| 256 |
-
status_box = gr.Textbox(label=labels["current_status"], interactive=False)
|
| 257 |
-
progress_bar = gr.Slider(minimum=0, maximum=1, value=0, step=0.01, interactive=False, label=labels["progress"])
|
| 258 |
-
log_output = gr.Textbox(label=labels["logs"], lines=10, interactive=False)
|
| 259 |
-
refresh_btn = gr.Button(labels["refresh"])
|
| 260 |
-
auto_refresh = gr.Checkbox(label=labels["auto_refresh"], value=True)
|
| 261 |
-
export_btn = gr.Button(labels["export_logs"])
|
| 262 |
-
refresh_btn.click(get_current_status, outputs=[status_box, progress_bar, log_output])
|
| 263 |
-
export_btn.click(export_logs, outputs=[export_btn])
|
| 264 |
-
|
| 265 |
-
def auto_refresh_loop(auto_enabled):
|
| 266 |
-
if auto_enabled:
|
| 267 |
-
return get_current_status()
|
| 268 |
-
else:
|
| 269 |
-
return gr.update(), gr.update(), gr.update()
|
| 270 |
-
|
| 271 |
-
auto_refresh = gr.Checkbox(label=labels["auto_refresh"], value=True)
|
| 272 |
-
refresh_loop = gr.Button(visible=False)
|
| 273 |
-
refresh_loop.click(fn=auto_refresh_loop, inputs=auto_refresh, outputs=[status_box, progress_bar, log_output], every=5)
|
| 274 |
-
|
| 275 |
-
if __name__ == "__main__":
|
| 276 |
-
demo.launch(share=True)
|
| 277 |
-
|
|
|
|
| 110 |
"progress": "Progress",
|
| 111 |
"logs": "Logs",
|
| 112 |
"refresh": "🔄 Refresh",
|
|
|
|
| 113 |
"export_logs": "📥 Export Logs",
|
| 114 |
"language": "Language"
|
| 115 |
},
|
|
|
|
| 130 |
"progress": "پرمختګ",
|
| 131 |
"logs": "لاګونه",
|
| 132 |
"refresh": "🔄 تازه کړئ",
|
|
|
|
| 133 |
"export_logs": "📥 لاګونه ډاونلوډ کړئ",
|
| 134 |
"language": "ژبه"
|
| 135 |
}
|
|
|
|
| 203 |
buffer = io.StringIO()
|
| 204 |
df.to_csv(buffer, index=False)
|
| 205 |
buffer.seek(0)
|
| 206 |
+
return buffer.getvalue()
|
| 207 |
|
| 208 |
with gr.Blocks(title="Pashto Base Bloom Trainer", theme="soft") as demo:
|
| 209 |
lang_selector = gr.Dropdown(choices=["English", "پښتو"], value="English", label="Language")
|
| 210 |
labels = translations["English"]
|
| 211 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
gr.Markdown(f"# {labels['title']}")
|
| 213 |
|
| 214 |
with gr.Tab(labels["load_dataset"]):
|
| 215 |
gr.Markdown(f"### {labels['load_dataset']}")
|
| 216 |
with gr.Row():
|
| 217 |
dataset_btn = gr.Button(labels["load_dataset"])
|
| 218 |
+
dataset_status = gr.Textbox(label=labels["status"], lines=2, interactive
|
| 219 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|