add files
Browse files- app.py +25 -0
- export.pkl +3 -0
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
learn = load_learner('export.pkl')
|
| 4 |
+
|
| 5 |
+
labels = learn.dls.vocab
|
| 6 |
+
|
| 7 |
+
|
| 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 |
+
|
| 14 |
+
title = "Pet Breed Classifier"
|
| 15 |
+
description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
| 16 |
+
article = "<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
|
| 17 |
+
examples = ['siamese.jpg']
|
| 18 |
+
interpretation = 'default'
|
| 19 |
+
enable_queue = True
|
| 20 |
+
|
| 21 |
+
gr.Interface(
|
| 22 |
+
fn=predict,
|
| 23 |
+
inputs=gr.Image(type="filepath"),
|
| 24 |
+
outputs=gr.Label(num_top_classes=3)
|
| 25 |
+
).launch(share=True)
|
export.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dea06a82cd0c7cec1c609e9b7d7208129af69e54205239c6e6c656d975fd0431
|
| 3 |
+
size 87560109
|