Spaces:
Sleeping
Sleeping
Commit
·
eeec6c9
1
Parent(s):
69e4902
fix app 2
Browse files
app.py
CHANGED
@@ -12,13 +12,11 @@ labels_animals10 = [
|
|
12 |
]
|
13 |
|
14 |
def classify_animal(image):
|
15 |
-
# Run ViT classifier
|
16 |
vit_results = vit_classifier(image)
|
17 |
-
vit_output = {result['label']: result['score'] for result in vit_results}
|
18 |
|
19 |
-
# Run CLIP zero-shot classifier
|
20 |
clip_results = clip_detector(image, candidate_labels=[f"a photo of a {label}" for label in labels_animals10])
|
21 |
-
clip_output = {result['label']: result['score'] for result in clip_results}
|
22 |
|
23 |
return {
|
24 |
"ViT Classification": vit_output,
|
@@ -31,7 +29,6 @@ example_images = [
|
|
31 |
"example_images/chicken1.jpeg",
|
32 |
"example_images/chicken2.jpeg",
|
33 |
"example_images/elefant.jpg",
|
34 |
-
"example_images/spider.jpeg",
|
35 |
"example_images/butterfly.jpg"
|
36 |
]
|
37 |
|
@@ -42,8 +39,7 @@ iface = gr.Interface(
|
|
42 |
outputs=gr.JSON(),
|
43 |
title="Animals-10 Classification: ViT vs CLIP",
|
44 |
description="Upload an animal image to compare predictions from your trained ViT model and a zero-shot CLIP model.",
|
45 |
-
examples=example_images
|
46 |
)
|
47 |
|
48 |
-
|
49 |
-
iface.launch()
|
|
|
12 |
]
|
13 |
|
14 |
def classify_animal(image):
|
|
|
15 |
vit_results = vit_classifier(image)
|
16 |
+
vit_output = {str(result['label']): float(result['score']) for result in vit_results}
|
17 |
|
|
|
18 |
clip_results = clip_detector(image, candidate_labels=[f"a photo of a {label}" for label in labels_animals10])
|
19 |
+
clip_output = {str(result['label']): float(result['score']) for result in clip_results}
|
20 |
|
21 |
return {
|
22 |
"ViT Classification": vit_output,
|
|
|
29 |
"example_images/chicken1.jpeg",
|
30 |
"example_images/chicken2.jpeg",
|
31 |
"example_images/elefant.jpg",
|
|
|
32 |
"example_images/butterfly.jpg"
|
33 |
]
|
34 |
|
|
|
39 |
outputs=gr.JSON(),
|
40 |
title="Animals-10 Classification: ViT vs CLIP",
|
41 |
description="Upload an animal image to compare predictions from your trained ViT model and a zero-shot CLIP model.",
|
42 |
+
examples=example_images
|
43 |
)
|
44 |
|
45 |
+
iface.launch(ssr_mode=False)
|
|