thejb2014 commited on
Commit
c0cb33b
·
verified ·
1 Parent(s): f700482

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ from PIL import Image
4
+
5
+ classifier = pipeline("image-classification", model="microsoft/resnet-50")
6
+
7
+ def classify(image):
8
+ results = classifier(image)
9
+ top = results[0]
10
+ label = top['label']
11
+ score = round(top['score'] * 100, 2)
12
+ return f"{label} ({score}%)"
13
+
14
+ gr.Interface(fn=classify, inputs=gr.Image(type="pil"), outputs="text", title="Cat Classifier").launch()