Spaces:
Runtime error
Runtime error
Commit
·
3795da0
0
Parent(s):
first
Browse files- README.md +37 -0
- app.py +20 -0
- requirements.txt +2 -0
- siamese.jpg +0 -0
README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Pet_classifier
|
| 3 |
+
emoji: 🏃
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: gradio
|
| 7 |
+
app_file: app.py
|
| 8 |
+
pinned: false
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# Configuration
|
| 12 |
+
|
| 13 |
+
`title`: _string_
|
| 14 |
+
Display title for the Space
|
| 15 |
+
|
| 16 |
+
`emoji`: _string_
|
| 17 |
+
Space emoji (emoji-only character allowed)
|
| 18 |
+
|
| 19 |
+
`colorFrom`: _string_
|
| 20 |
+
Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
|
| 21 |
+
|
| 22 |
+
`colorTo`: _string_
|
| 23 |
+
Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
|
| 24 |
+
|
| 25 |
+
`sdk`: _string_
|
| 26 |
+
Can be either `gradio` or `streamlit`
|
| 27 |
+
|
| 28 |
+
`sdk_version` : _string_
|
| 29 |
+
Only applicable for `streamlit` SDK.
|
| 30 |
+
See [doc](https://hf.co/docs/hub/spaces) for more info on supported versions.
|
| 31 |
+
|
| 32 |
+
`app_file`: _string_
|
| 33 |
+
Path to your main application file (which contains either `gradio` or `streamlit` Python code).
|
| 34 |
+
Path is relative to the root of the repository.
|
| 35 |
+
|
| 36 |
+
`pinned`: _boolean_
|
| 37 |
+
Whether the Space stays on top of your list.
|
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
import skimage
|
| 4 |
+
|
| 5 |
+
learn = load_learner('export.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. Created as a demo for Gradio and HuggingFace Spaces."
|
| 15 |
+
interpretation='default'
|
| 16 |
+
examples = ['siamese.jpg']
|
| 17 |
+
article="<p style='text-align: center'><a href='https://dicksonneoh.com' target='_blank'>Blog post</a></p>"
|
| 18 |
+
enable_queue=True
|
| 19 |
+
|
| 20 |
+
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()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastai
|
| 2 |
+
scikit-image
|
siamese.jpg
ADDED
|