Sek2810 commited on
Commit
934edec
·
verified ·
1 Parent(s): e369819

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
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()