acc3d commited on
Commit
85a5bd8
·
1 Parent(s): 79480ca

initial commit

Browse files
Files changed (3) hide show
  1. app.py +23 -0
  2. chihuahua.jpg +0 -0
  3. siamese.jpg +0 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+
4
+ learn = load_learner(fname='pet_breeds.pkl')
5
+
6
+ labels = learn.dls.vocab
7
+ def predict(img):
8
+ img = PILImage.create(img)
9
+ pred,pred_idx,probs = learn.predict(img)
10
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
11
+
12
+ title = "Pet Breed Classifier"
13
+ description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
14
+ article = "<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
15
+ examples = ["chihuahua.jpg", "siamese.jpg"]
16
+
17
+ gr.Interface(fn=predict,
18
+ inputs=gr.Image(height=512, width=512),
19
+ outputs=gr.Label(num_top_classes=3),
20
+ title=title,
21
+ description=description,
22
+ article=article,
23
+ examples=examples).launch()
chihuahua.jpg ADDED
siamese.jpg ADDED