notsahil commited on
Commit
695dba7
·
1 Parent(s): bb9faca

feat: inital demo app

Browse files

Signed-off-by: Sahil <[email protected]>

README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  title: Image Classification
3
- emoji: 🏃
4
  colorFrom: green
5
  colorTo: green
6
  sdk: gradio
 
1
  ---
2
  title: Image Classification
3
+ emoji: 🖼️
4
  colorFrom: green
5
  colorTo: green
6
  sdk: gradio
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+
4
+ from transformers import pipeline
5
+
6
+ image_classifier = pipeline(task="zero-shot-image-classification", model="google/siglip-so400m-patch14-384")
7
+ labels = ['street sweeping', 'litter pickup', 'pothole repair', 'parking enforcement']
8
+
9
+ def image_mod(image):
10
+ outputs = image_classifier(image, candidate_labels=labels)
11
+ result = {dic["label"]: dic["score"] for dic in outputs}
12
+ return result
13
+
14
+ app = gr.Interface(
15
+ image_mod,
16
+ gr.Image(type="pil"),
17
+ gr.Label(),
18
+ examples=[
19
+ os.path.join(os.path.dirname(__file__), "images/garbage-pickup.jpg"),
20
+ os.path.join(os.path.dirname(__file__), "images/litter.jpg"),
21
+ os.path.join(os.path.dirname(__file__), "images/wrong-park.jpg"),
22
+ os.path.join(os.path.dirname(__file__), "images/pothole.jpg"),
23
+ ],
24
+ )
25
+
26
+ if __name__ == "__main__":
27
+ app.launch()
images/garbage-pickup.jpg ADDED
images/litter.jpg ADDED
images/pothole.jpg ADDED
images/wrong-park.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ gradio==4.22.0
2
+ tensorflow==2.16.1
3
+ torch==2.2.2
4
+ transformers==4.39.2
5
+ sentencepiece==0.2.0