Spaces:
Build error
Build error
Update app.py
Browse filesadd download button
app.py
CHANGED
|
@@ -99,6 +99,13 @@ def save_feedback(img_hash, model_prediction, user_feedback, confidence):
|
|
| 99 |
df_new.to_csv(FEEDBACK_FILE, index=False)
|
| 100 |
return "✅ Vielen Dank für dein Feedback!"
|
| 101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
# Kombinierte Funktion
|
| 103 |
def full_pipeline(image, user_feedback):
|
| 104 |
prediction, confidence_text, top3, fig, img_hash = predict_emotion(image)
|
|
@@ -112,6 +119,7 @@ with gr.Blocks() as interface:
|
|
| 112 |
image_input = gr.Image(type="pil", label="Lade dein Bild hoch")
|
| 113 |
feedback_input = gr.Dropdown(choices=labels, label="Dein Feedback: Was ist die richtige Emotion?")
|
| 114 |
submit_btn = gr.Button("Absenden")
|
|
|
|
| 115 |
with gr.Column():
|
| 116 |
prediction_output = gr.Textbox(label="Vorhergesagte Emotion")
|
| 117 |
confidence_output = gr.Textbox(label="Confidence + Einschätzung")
|
|
@@ -125,4 +133,10 @@ with gr.Blocks() as interface:
|
|
| 125 |
outputs=[prediction_output, confidence_output, top3_output, plot_output, feedback_message_output]
|
| 126 |
)
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
interface.launch()
|
|
|
|
| 99 |
df_new.to_csv(FEEDBACK_FILE, index=False)
|
| 100 |
return "✅ Vielen Dank für dein Feedback!"
|
| 101 |
|
| 102 |
+
# Download Funktion
|
| 103 |
+
def download_feedback():
|
| 104 |
+
if os.path.exists(FEEDBACK_FILE):
|
| 105 |
+
return FEEDBACK_FILE
|
| 106 |
+
else:
|
| 107 |
+
return None
|
| 108 |
+
|
| 109 |
# Kombinierte Funktion
|
| 110 |
def full_pipeline(image, user_feedback):
|
| 111 |
prediction, confidence_text, top3, fig, img_hash = predict_emotion(image)
|
|
|
|
| 119 |
image_input = gr.Image(type="pil", label="Lade dein Bild hoch")
|
| 120 |
feedback_input = gr.Dropdown(choices=labels, label="Dein Feedback: Was ist die richtige Emotion?")
|
| 121 |
submit_btn = gr.Button("Absenden")
|
| 122 |
+
download_btn = gr.Button("Feedback-Daten herunterladen")
|
| 123 |
with gr.Column():
|
| 124 |
prediction_output = gr.Textbox(label="Vorhergesagte Emotion")
|
| 125 |
confidence_output = gr.Textbox(label="Confidence + Einschätzung")
|
|
|
|
| 133 |
outputs=[prediction_output, confidence_output, top3_output, plot_output, feedback_message_output]
|
| 134 |
)
|
| 135 |
|
| 136 |
+
download_btn.click(
|
| 137 |
+
fn=download_feedback,
|
| 138 |
+
inputs=[],
|
| 139 |
+
outputs=[gr.File()]
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
interface.launch()
|