Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -16,6 +16,7 @@ def predict(image: Image.Image):
|
|
16 |
return result, f"Confidence: {confidence:.2f}%"
|
17 |
|
18 |
def report_feedback():
|
|
|
19 |
if last_prediction is not None:
|
20 |
image, predicted_label = last_prediction
|
21 |
correct_label = 1 if predicted_label == 0 else 0 # Invert the label
|
@@ -24,20 +25,20 @@ def report_feedback():
|
|
24 |
return "No prediction available to report."
|
25 |
|
26 |
# Define the Gradio interface for prediction
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
39 |
|
40 |
# Launch the Gradio interface
|
41 |
if __name__ == "__main__":
|
42 |
-
demo.launch(share=True)
|
43 |
-
feedback_button.launch()
|
|
|
16 |
return result, f"Confidence: {confidence:.2f}%"
|
17 |
|
18 |
def report_feedback():
|
19 |
+
global last_prediction
|
20 |
if last_prediction is not None:
|
21 |
image, predicted_label = last_prediction
|
22 |
correct_label = 1 if predicted_label == 0 else 0 # Invert the label
|
|
|
25 |
return "No prediction available to report."
|
26 |
|
27 |
# Define the Gradio interface for prediction
|
28 |
+
with gr.Blocks() as demo:
|
29 |
+
gr.Markdown("### Vision Transformer Model")
|
30 |
+
gr.Markdown("Upload an image to classify it using the Vision Transformer model.")
|
31 |
+
|
32 |
+
image_input = gr.Image(type="pil", label="Upload Image")
|
33 |
+
prediction_output = gr.Textbox(label="Prediction")
|
34 |
+
confidence_output = gr.Textbox(label="Confidence")
|
35 |
+
|
36 |
+
submit_btn = gr.Button("Submit")
|
37 |
+
feedback_btn = gr.Button("The model was wrong")
|
38 |
+
|
39 |
+
submit_btn.click(predict, inputs=image_input, outputs=[prediction_output, confidence_output])
|
40 |
+
feedback_btn.click(report_feedback)
|
41 |
|
42 |
# Launch the Gradio interface
|
43 |
if __name__ == "__main__":
|
44 |
+
demo.launch(share=True)
|
|