DanielViniciusAlves commited on
Commit
1084064
·
1 Parent(s): 96ca4f4

Update app.py

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