Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -16,19 +16,18 @@ def predict(image: Image.Image):
|
|
16 |
# Define the Gradio interface
|
17 |
with gr.Blocks() as demo:
|
18 |
image_input = gr.Image(type="pil", label="Upload an image")
|
19 |
-
animation = gr.Video("https://cdn-uploads.huggingface.co/production/uploads/66d6f1b3b50e35e1709bfdf7/x7Ud8PO9QPfmrTvBVcCKE.mp4", visible=False)
|
20 |
output_label = gr.Textbox(label="Classification Result", interactive=False)
|
21 |
output_confidence = gr.Textbox(label="Confidence", interactive=False)
|
22 |
|
23 |
def show_animation(image):
|
24 |
-
animation.visible
|
25 |
-
return animation, "", "" # 诇讛爪讬讙 讗转 讛讗谞讬诪爪讬讛
|
26 |
|
27 |
def hide_animation(image):
|
28 |
result, confidence = predict(image)
|
29 |
-
animation.visible
|
30 |
-
return result, confidence # 诇讛讞讝讬专 讗转 讛转讜爪讗讜转
|
31 |
|
|
|
32 |
image_input.change(show_animation, inputs=image_input, outputs=[animation, output_label, output_confidence])
|
33 |
image_input.submit(hide_animation, inputs=image_input, outputs=[output_label, output_confidence])
|
34 |
|
|
|
16 |
# Define the Gradio interface
|
17 |
with gr.Blocks() as demo:
|
18 |
image_input = gr.Image(type="pil", label="Upload an image")
|
19 |
+
animation = gr.Video("https://cdn-uploads.huggingface.co/production/uploads/66d6f1b3b50e35e1709bfdf7/x7Ud8PO9QPfmrTvBVcCKE.mp4", visible=False)
|
20 |
output_label = gr.Textbox(label="Classification Result", interactive=False)
|
21 |
output_confidence = gr.Textbox(label="Confidence", interactive=False)
|
22 |
|
23 |
def show_animation(image):
|
24 |
+
return animation.update(visible=True), "", "" # 诇讛爪讬讙 讗转 讛讗谞讬诪爪讬讛
|
|
|
25 |
|
26 |
def hide_animation(image):
|
27 |
result, confidence = predict(image)
|
28 |
+
return animation.update(visible=False), result, confidence # 诇讛住转讬专 讗转 讛讗谞讬诪爪讬讛 讜诇讛讞讝讬专 讗转 讛转讜爪讗讜转
|
|
|
29 |
|
30 |
+
# 注讚讻讜谉 注诇 讛讗讬专讜注讬诐
|
31 |
image_input.change(show_animation, inputs=image_input, outputs=[animation, output_label, output_confidence])
|
32 |
image_input.submit(hide_animation, inputs=image_input, outputs=[output_label, output_confidence])
|
33 |
|