Spaces:
Sleeping
Sleeping
heisenberg3376
commited on
Commit
•
566593f
1
Parent(s):
ca3756e
Update app.py
Browse files
app.py
CHANGED
@@ -10,18 +10,16 @@ def classify_image(input_image):
|
|
10 |
results = pipe(input_image)
|
11 |
|
12 |
# Prepare the output string with all predictions
|
13 |
-
|
14 |
-
for result in results:
|
15 |
-
output_str += f"{result['label']}: {result['score']:.4f}\n"
|
16 |
|
17 |
# Return the concatenated string of predictions
|
18 |
-
return
|
19 |
|
20 |
# Create a Gradio interface
|
21 |
iface = gr.Interface(
|
22 |
fn=classify_image,
|
23 |
inputs=gr.Image(type="pil", label="Upload an image"),
|
24 |
-
outputs=gr.Label(num_top_classes=5
|
25 |
title="Image Classification",
|
26 |
description="Classify food items in images using heisenberg3376/vit-base-food-items-v1"
|
27 |
)
|
|
|
10 |
results = pipe(input_image)
|
11 |
|
12 |
# Prepare the output string with all predictions
|
13 |
+
confidences = {result['label']: float(result['score']) for result in results}
|
|
|
|
|
14 |
|
15 |
# Return the concatenated string of predictions
|
16 |
+
return confidences
|
17 |
|
18 |
# Create a Gradio interface
|
19 |
iface = gr.Interface(
|
20 |
fn=classify_image,
|
21 |
inputs=gr.Image(type="pil", label="Upload an image"),
|
22 |
+
outputs=gr.Label(num_top_classes=5),
|
23 |
title="Image Classification",
|
24 |
description="Classify food items in images using heisenberg3376/vit-base-food-items-v1"
|
25 |
)
|