Udyan commited on
Commit
8bf433a
·
verified ·
1 Parent(s): 605257d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ classifier = pipeline(
5
+ "image-classification",
6
+ model="google/vit-base-patch16-224"
7
+ )
8
+
9
+ def classify_image(image):
10
+ results = classifier(image)
11
+
12
+ output = ""
13
+ for item in results[:5]:
14
+ output += f"{item['label']} : {item['score']:.2%}\n"
15
+
16
+ return output
17
+
18
+ demo = gr.Interface(
19
+ fn=classify_image,
20
+ inputs=gr.Image(type="pil"),
21
+ outputs=gr.Textbox(label="Classification Results"),
22
+ title="Image Classification App",
23
+ description="Upload an image and let AI identify what it contains."
24
+ )
25
+
26
+ demo.launch()