Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -165,7 +165,7 @@ def _create_comparison_table(probs, preds):
|
|
| 165 |
</div>"""
|
| 166 |
return table_html
|
| 167 |
|
| 168 |
-
def predict_emotion(text,
|
| 169 |
if not state.ready:
|
| 170 |
return "<div style='padding:40px;text-align:center;background:#7f1d1d;border:2px solid #ef4444;border-radius:16px;'><div style='font-size:64px;'>⚠️</div><h2 style='color:#fecaca;'>Model Not Loaded</h2><p style='color:#fca5a5;'>Click Load Model button</p></div>", "", "", "{}", _create_controls_panel()
|
| 171 |
|
|
@@ -308,7 +308,6 @@ def create_interface():
|
|
| 308 |
analyze = gr.Button("🔍 Analyze Emotions", variant="primary", size="lg")
|
| 309 |
clear = gr.ClearButton([inp], value="🗑️ Clear", size="lg")
|
| 310 |
with gr.Row():
|
| 311 |
-
radar = gr.Checkbox(label="Show Radar Chart", value=True)
|
| 312 |
table = gr.Checkbox(label="Show Table", value=True)
|
| 313 |
gr.Examples([
|
| 314 |
["I'm absolutely thrilled and overjoyed! This is amazing!"],
|
|
@@ -343,8 +342,8 @@ def create_interface():
|
|
| 343 |
gr.HTML("<div style='margin-top:30px;padding:20px;background:#1f2937;border-radius:12px;border:2px solid #374151;'><h2 style='color:#f9fafb;margin-top:0;'>📚 Model Documentation</h2><p style='color:#d1d5db;line-height:1.8;'><strong>Architecture:</strong> RoBERTa-base (125M parameters) fine-tuned for multi-label emotion classification</p><p style='color:#d1d5db;line-height:1.8;'><strong>Classes:</strong> Anger, Fear, Joy, Sadness, Surprise</p><p style='color:#d1d5db;line-height:1.8;'><strong>Performance:</strong> F1 Score 0.872 on validation set</p></div>")
|
| 344 |
|
| 345 |
load_btn.click(load_model, outputs=[status, controls])
|
| 346 |
-
analyze.click(predict_emotion, inputs=[inp,
|
| 347 |
-
inp.submit(predict_emotion, inputs=[inp,
|
| 348 |
clear_res.click(lambda: ("", "", "", "{}", _create_controls_panel()), outputs=[summ, details, tbl, json_out, controls])
|
| 349 |
batch_btn.click(batch_predict, inputs=[batch_inp], outputs=[batch_out])
|
| 350 |
hist_btn.click(get_history, outputs=[hist_out])
|
|
|
|
| 165 |
</div>"""
|
| 166 |
return table_html
|
| 167 |
|
| 168 |
+
def predict_emotion(text, show_table=True):
|
| 169 |
if not state.ready:
|
| 170 |
return "<div style='padding:40px;text-align:center;background:#7f1d1d;border:2px solid #ef4444;border-radius:16px;'><div style='font-size:64px;'>⚠️</div><h2 style='color:#fecaca;'>Model Not Loaded</h2><p style='color:#fca5a5;'>Click Load Model button</p></div>", "", "", "{}", _create_controls_panel()
|
| 171 |
|
|
|
|
| 308 |
analyze = gr.Button("🔍 Analyze Emotions", variant="primary", size="lg")
|
| 309 |
clear = gr.ClearButton([inp], value="🗑️ Clear", size="lg")
|
| 310 |
with gr.Row():
|
|
|
|
| 311 |
table = gr.Checkbox(label="Show Table", value=True)
|
| 312 |
gr.Examples([
|
| 313 |
["I'm absolutely thrilled and overjoyed! This is amazing!"],
|
|
|
|
| 342 |
gr.HTML("<div style='margin-top:30px;padding:20px;background:#1f2937;border-radius:12px;border:2px solid #374151;'><h2 style='color:#f9fafb;margin-top:0;'>📚 Model Documentation</h2><p style='color:#d1d5db;line-height:1.8;'><strong>Architecture:</strong> RoBERTa-base (125M parameters) fine-tuned for multi-label emotion classification</p><p style='color:#d1d5db;line-height:1.8;'><strong>Classes:</strong> Anger, Fear, Joy, Sadness, Surprise</p><p style='color:#d1d5db;line-height:1.8;'><strong>Performance:</strong> F1 Score 0.872 on validation set</p></div>")
|
| 343 |
|
| 344 |
load_btn.click(load_model, outputs=[status, controls])
|
| 345 |
+
analyze.click(predict_emotion, inputs=[inp, table], outputs=[summ, details, tbl, json_out, controls])
|
| 346 |
+
inp.submit(predict_emotion, inputs=[inp, table], outputs=[summ, details, tbl, json_out, controls])
|
| 347 |
clear_res.click(lambda: ("", "", "", "{}", _create_controls_panel()), outputs=[summ, details, tbl, json_out, controls])
|
| 348 |
batch_btn.click(batch_predict, inputs=[batch_inp], outputs=[batch_out])
|
| 349 |
hist_btn.click(get_history, outputs=[hist_out])
|