facehuggerai commited on
Commit
0fda521
·
1 Parent(s): 5d7c4f5

pet predictor

Browse files
Files changed (5) hide show
  1. app.py +15 -3
  2. lion.jpg +0 -0
  3. model.pkl +3 -0
  4. pomeranian.jpg +0 -0
  5. siamese.jpg +0 -0
app.py CHANGED
@@ -1,7 +1,19 @@
1
  import gradio as gr
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
 
 
 
 
 
7
  iface.launch()
 
1
  import gradio as gr
2
+ from fastai.vision.all import *
3
+ import skimage
4
 
5
+ learn = load_learner('model.pkl')
 
6
 
7
+ labels = learn.dls.vocab
8
+ def predict(img):
9
+ img = PILImage.create(img)
10
+ pred,pred_idx,probs = learn.predict(img)
11
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
12
+
13
+ title = "Pet Breed Classifier"
14
+ description = "A pet breed classifier trained on the Oxford Pets dataset with fastai."
15
+ examples = ['siamese.jpg', 'pomeranian.jpg', 'lion.jpg']
16
+ enable_queue=True
17
+
18
+ iface = gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples,interpretation=interpretation,enable_queue=enable_queue)
19
  iface.launch()
lion.jpg ADDED
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:533e0c7829751d14e0f347f8416612d288c8b2f55260940c896a0765acf6d75a
3
+ size 47061483
pomeranian.jpg ADDED
siamese.jpg ADDED