Spaces:
Sleeping
Sleeping
sebdef123 commited on
Commit ·
56cb4a2
1
Parent(s): 3893a37
first
Browse files- app.py +22 -0
- export.pkl +3 -0
- grizzly.jpg +0 -0
- requirements.txt +1 -0
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
examples = ['siamese.jpg']
|
| 16 |
+
interpretation='default'
|
| 17 |
+
enable_queue=True
|
| 18 |
+
|
| 19 |
+
gr.Interface(fn=predict,
|
| 20 |
+
inputs=gr.Image(type="pil"),
|
| 21 |
+
outputs=gr.Label(num_top_classes=3),
|
| 22 |
+
examples=["grizzly.jpg"]).launch()
|
export.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:062dac4bacf2753c615f86417a633d046be864304909fdd1e18116dd4c7b9a5b
|
| 3 |
+
size 46961933
|
grizzly.jpg
ADDED
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
fastai
|