eclfe commited on
Commit
6057f8d
·
verified ·
1 Parent(s): 9f4e3e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -16
app.py CHANGED
@@ -1,17 +1,17 @@
1
- import gradio as gr
2
- from fastai.vision.all import *
3
-
4
- learn = load_learner('export.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
- enable_queue=True
16
-
17
  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()
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+
4
+ learn = load_learner('model.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
+ enable_queue=True
16
+
17
  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()