Sbwg commited on
Commit
4a0a554
·
verified ·
1 Parent(s): 4105c5c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -25
app.py CHANGED
@@ -1,26 +1,26 @@
1
- import gradio as gr
2
- from transformers import pipeline
3
-
4
- # Load a simple image classification model
5
- classifier = pipeline("image-classification", model="google/vit-base-patch16-224")
6
-
7
- def classify_image(image):
8
- # Run prediction
9
- results = classifier(image)
10
- # Get top label and confidence
11
- top_result = results[0]
12
- label = top_result["label"]
13
- score = round(top_result["score"] * 100, 2)
14
- return f"{label} ({score}%)"
15
-
16
- # Simple Gradio UI
17
- demo = gr.Interface(
18
- fn=classify_image,
19
- inputs=gr.Image(type="pil"),
20
- outputs="text",
21
- title="🖼️ Simple Image Classifier",
22
- description="Upload an image and I'll tell you what it is!"
23
- )
24
-
25
- if __name__ == "__main__":
26
  demo.launch()
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load a simple image classification model
5
+ classifier = pipeline("image-classification", model="google/vit-base-patch16-224")
6
+
7
+ def classify_image(image):
8
+ # Run prediction
9
+ results = classifier(image)
10
+ # Get top label and confidence
11
+ top_result = results[0]
12
+ label = top_result["label"]
13
+ score = round(top_result["score"] * 100, 2)
14
+ return f"{label} ({score}%)"
15
+
16
+ # Simple Gradio UI
17
+ demo = gr.Interface(
18
+ fn=classify_image,
19
+ inputs=gr.Image(type="pil"),
20
+ outputs="text",
21
+ title="🖼️ Simple Image Classifier",
22
+ description="what is this food"
23
+ )
24
+
25
+ if __name__ == "__main__":
26
  demo.launch()