Spaces:
Runtime error
Runtime error
Upload 10 files
Browse files- .gitattributes +7 -0
- animal_images/cat.jpeg +0 -0
- animal_images/cat.png +3 -0
- animal_images/frog.png +3 -0
- animal_images/hippo.png +3 -0
- animal_images/jaguar.png +3 -0
- animal_images/sloth.png +3 -0
- animal_images/toucan.png +3 -0
- animal_images/turtle.png +3 -0
- app_v4.py +40 -0
- requirements.txt +6 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,10 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
animal_images/cat.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
animal_images/frog.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
animal_images/hippo.png filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
animal_images/jaguar.png filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
animal_images/sloth.png filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
animal_images/toucan.png filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
animal_images/turtle.png filter=lfs diff=lfs merge=lfs -text
|
animal_images/cat.jpeg
ADDED
|
animal_images/cat.png
ADDED
|
Git LFS Details
|
animal_images/frog.png
ADDED
|
Git LFS Details
|
animal_images/hippo.png
ADDED
|
Git LFS Details
|
animal_images/jaguar.png
ADDED
|
Git LFS Details
|
animal_images/sloth.png
ADDED
|
Git LFS Details
|
animal_images/toucan.png
ADDED
|
Git LFS Details
|
animal_images/turtle.png
ADDED
|
Git LFS Details
|
app_v4.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load the image classification pipeline
|
| 5 |
+
classifier = pipeline("image-classification", model="google/vit-base-patch16-224")
|
| 6 |
+
|
| 7 |
+
def predict(image):
|
| 8 |
+
if image is None:
|
| 9 |
+
return None
|
| 10 |
+
predictions = classifier(image)
|
| 11 |
+
return {p["label"]: p["score"] for p in predictions}
|
| 12 |
+
|
| 13 |
+
# Updated examples list to use cat.jpeg instead of cat.png
|
| 14 |
+
examples = [
|
| 15 |
+
"animal_images/hippo.png",
|
| 16 |
+
"animal_images/jaguar.png",
|
| 17 |
+
"animal_images/toucan.png",
|
| 18 |
+
"animal_images/sloth.png",
|
| 19 |
+
"animal_images/cat.jpeg", # Changed to jpeg
|
| 20 |
+
"animal_images/frog.png",
|
| 21 |
+
"animal_images/turtle.png"
|
| 22 |
+
]
|
| 23 |
+
|
| 24 |
+
demo = gr.Interface(
|
| 25 |
+
fn=predict,
|
| 26 |
+
inputs=gr.Image(
|
| 27 |
+
type="pil",
|
| 28 |
+
label="Input Image",
|
| 29 |
+
interactive=True,
|
| 30 |
+
height=None
|
| 31 |
+
),
|
| 32 |
+
outputs=gr.Label(num_top_classes=3, label="Predictions"),
|
| 33 |
+
examples=examples,
|
| 34 |
+
title="Animal Classifier",
|
| 35 |
+
description="Upload an image of an animal."
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
if __name__ == "__main__":
|
| 39 |
+
demo.launch()
|
| 40 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
transformers
|
| 3 |
+
torch
|
| 4 |
+
pillow
|
| 5 |
+
|
| 6 |
+
|