Update app.py
Browse files
app.py
CHANGED
@@ -13,9 +13,9 @@ classifier = VisionClassifierInference(
|
|
13 |
|
14 |
def classify_image(image_file):
|
15 |
"""Classify an image using a pre-trained ViT model."""
|
16 |
-
label = classifier.predict(
|
17 |
# Add a confidence score to the output
|
18 |
-
confidence = classifier.predict_proba(
|
19 |
|
20 |
# Get the PIL Image object for the uploaded image
|
21 |
image = Image.open(image_file)
|
@@ -33,6 +33,7 @@ def classify_image(image_file):
|
|
33 |
return output_image, f"Predicted class: {label} (confidence: {confidence:.2f})"
|
34 |
|
35 |
|
|
|
36 |
iface = gr.Interface(
|
37 |
fn=classify_image,
|
38 |
inputs=gr.inputs.Image(type="filepath", label="Upload an image"),
|
|
|
13 |
|
14 |
def classify_image(image_file):
|
15 |
"""Classify an image using a pre-trained ViT model."""
|
16 |
+
label = classifier.predict(img=Image.open(image_file.name))
|
17 |
# Add a confidence score to the output
|
18 |
+
confidence = classifier.predict_proba(img=Image.open(image_file.name))[0][label]
|
19 |
|
20 |
# Get the PIL Image object for the uploaded image
|
21 |
image = Image.open(image_file)
|
|
|
33 |
return output_image, f"Predicted class: {label} (confidence: {confidence:.2f})"
|
34 |
|
35 |
|
36 |
+
|
37 |
iface = gr.Interface(
|
38 |
fn=classify_image,
|
39 |
inputs=gr.inputs.Image(type="filepath", label="Upload an image"),
|