Upload app.py
Browse files
app.py
CHANGED
|
@@ -83,6 +83,10 @@ def predict(pil_img: Image.Image) -> dict:
|
|
| 83 |
}
|
| 84 |
return emoji_labels
|
| 85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
# ββ Gradio UI ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 87 |
DESCRIPTION = """
|
| 88 |
Upload a photo of a person performing an activity, and the model will predict which of **15 activities** they are doing.
|
|
@@ -128,9 +132,8 @@ with gr.Blocks(
|
|
| 128 |
height=380,
|
| 129 |
)
|
| 130 |
with gr.Row():
|
| 131 |
-
clear_btn = gr.
|
| 132 |
-
|
| 133 |
-
value="ποΈ Clear",
|
| 134 |
variant="secondary",
|
| 135 |
size="lg",
|
| 136 |
)
|
|
@@ -158,6 +161,11 @@ with gr.Blocks(
|
|
| 158 |
)
|
| 159 |
|
| 160 |
# Event handlers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
submit_btn.click(
|
| 162 |
fn=predict,
|
| 163 |
inputs=image_input,
|
|
|
|
| 83 |
}
|
| 84 |
return emoji_labels
|
| 85 |
|
| 86 |
+
def clear_all():
|
| 87 |
+
"""Reset both image and predictions."""
|
| 88 |
+
return None, None
|
| 89 |
+
|
| 90 |
# ββ Gradio UI ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 91 |
DESCRIPTION = """
|
| 92 |
Upload a photo of a person performing an activity, and the model will predict which of **15 activities** they are doing.
|
|
|
|
| 132 |
height=380,
|
| 133 |
)
|
| 134 |
with gr.Row():
|
| 135 |
+
clear_btn = gr.Button(
|
| 136 |
+
"ποΈ Clear",
|
|
|
|
| 137 |
variant="secondary",
|
| 138 |
size="lg",
|
| 139 |
)
|
|
|
|
| 161 |
)
|
| 162 |
|
| 163 |
# Event handlers
|
| 164 |
+
clear_btn.click(
|
| 165 |
+
fn=clear_all,
|
| 166 |
+
inputs=[],
|
| 167 |
+
outputs=[image_input, label_output],
|
| 168 |
+
)
|
| 169 |
submit_btn.click(
|
| 170 |
fn=predict,
|
| 171 |
inputs=image_input,
|