Update app.py
Browse files
app.py
CHANGED
@@ -11,8 +11,11 @@ classifier = VisionClassifierInference(
|
|
11 |
|
12 |
# Define a Gradio interface
|
13 |
def classify_image(image_file):
|
|
|
14 |
label = classifier.predict(img_path=image_file.name)
|
15 |
-
|
|
|
|
|
16 |
|
17 |
iface = gr.Interface(
|
18 |
fn=classify_image,
|
|
|
11 |
|
12 |
# Define a Gradio interface
|
13 |
def classify_image(image_file):
|
14 |
+
"""Classify an image using a pre-trained ViT model."""
|
15 |
label = classifier.predict(img_path=image_file.name)
|
16 |
+
# Add a confidence score to the output
|
17 |
+
confidence = classifier.predict_proba(img_path=image_file.name)[0][label]
|
18 |
+
return f"Predicted class: {label} (confidence: {confidence:.2f})"
|
19 |
|
20 |
iface = gr.Interface(
|
21 |
fn=classify_image,
|