MiriamCamachodQ commited on
Commit
eb3cfa7
·
verified ·
1 Parent(s): 1596b2c

Upload 8 files

Browse files
.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/animal_images/cat.png filter=lfs diff=lfs merge=lfs -text
37
+ animal_images/animal_images/frog.png filter=lfs diff=lfs merge=lfs -text
38
+ animal_images/animal_images/hippo.png filter=lfs diff=lfs merge=lfs -text
39
+ animal_images/animal_images/jaguar.png filter=lfs diff=lfs merge=lfs -text
40
+ animal_images/animal_images/sloth.png filter=lfs diff=lfs merge=lfs -text
41
+ animal_images/animal_images/toucan.png filter=lfs diff=lfs merge=lfs -text
42
+ animal_images/animal_images/turtle.png filter=lfs diff=lfs merge=lfs -text
animal_images/animal_images/cat.png ADDED

Git LFS Details

  • SHA256: 8dbe0fc8a74b0c8d146ec75f337713082fdc40ac2c43e986fa0c8c8f2ff14d80
  • Pointer size: 131 Bytes
  • Size of remote file: 139 kB
animal_images/animal_images/frog.png ADDED

Git LFS Details

  • SHA256: cf168ff5d42d4659ee810c4be7da623969106f4eecf0438ce8ad0104955ce20e
  • Pointer size: 131 Bytes
  • Size of remote file: 314 kB
animal_images/animal_images/hippo.png ADDED

Git LFS Details

  • SHA256: a1085c6fbec1b0378e500d603c07670402c9c875827ceda32fb85305f3cc41ef
  • Pointer size: 131 Bytes
  • Size of remote file: 552 kB
animal_images/animal_images/jaguar.png ADDED

Git LFS Details

  • SHA256: 086fe443bdbc479ff3d380f5a3ec2d348158bebb83a33f43263c3eaad593b33b
  • Pointer size: 131 Bytes
  • Size of remote file: 578 kB
animal_images/animal_images/sloth.png ADDED

Git LFS Details

  • SHA256: 69f7720ee894a7472eb1c65f07726be7d2f1c293fed0b702e0d8b2b4363d78cd
  • Pointer size: 131 Bytes
  • Size of remote file: 414 kB
animal_images/animal_images/toucan.png ADDED

Git LFS Details

  • SHA256: fe3ad6b6c8a78bd2e2c563002a251fbd1ce74e6728c201e4654e582d0dbed893
  • Pointer size: 131 Bytes
  • Size of remote file: 112 kB
animal_images/animal_images/turtle.png ADDED

Git LFS Details

  • SHA256: 672334ae4126ea106db7c1a5850b68bee39d5d13badfea909a2c421639d767c6
  • Pointer size: 131 Bytes
  • Size of remote file: 426 kB
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Initialize the image classification pipeline with the Google ViT model
5
+ # This model is trained on ImageNet-1k and works well for general animal classification
6
+ classifier = pipeline("image-classification", model="google/vit-base-patch16-224")
7
+
8
+ def classify_image(image):
9
+ """
10
+ Takes an image, runs it through the classifier, and returns the top predictions.
11
+ """
12
+ if image is None:
13
+ return None
14
+
15
+ predictions = classifier(image)
16
+ # Gradio's Label component expects a dictionary of {label: confidence}
17
+ return {p["label"]: p["score"] for p in predictions}
18
+
19
+ # List of example images located in the nested animal_images folder
20
+ # Note: Based on your folder structure, the images are in 'animal_images/animal_images/'
21
+ examples = [
22
+ ["animal_images/animal_images/cat.png"],
23
+ ["animal_images/animal_images/frog.png"],
24
+ ["animal_images/animal_images/hippo.png"],
25
+ ["animal_images/animal_images/jaguar.png"],
26
+ ["animal_images/animal_images/sloth.png"],
27
+ ["animal_images/animal_images/toucan.png"],
28
+ ["animal_images/animal_images/turtle.png"]
29
+ ]
30
+
31
+ # Create the Gradio Interface
32
+ # We map the inputs and outputs to match the labels seen in your screenshot ("inp", "output")
33
+ demo = gr.Interface(
34
+ fn=classify_image,
35
+ inputs=gr.Image(type="pil", label="inp"),
36
+ outputs=gr.Label(num_top_classes=3, label="output"),
37
+ examples=examples,
38
+ title="Animal Classifier",
39
+ description="Upload an image of an animal to classify it using the Google ViT model."
40
+ )
41
+
42
+ if __name__ == "__main__":
43
+ demo.launch()