Spaces:
Build error
Build error
Manikandan Sivanesan
commited on
Commit
•
17c9cc7
1
Parent(s):
d7f7d52
update
Browse files- README.md +6 -0
- app.py +4 -2
- dog.png → beagle.png +0 -0
- requirements.txt +3 -1
README.md
CHANGED
@@ -10,10 +10,16 @@ pinned: false
|
|
10 |
license: apache-2.0
|
11 |
---
|
12 |
|
|
|
|
|
|
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
|
14 |
|
15 |
Steps
|
16 |
|
17 |
- Create a new hf space in your account
|
18 |
- Install git-lfs in order to manager our large model files. Jeremy provided this script https://gist.github.com/jph00/361a9b868aa3593f3fd8e930d0221266. I had to modify the PREFIX in the install.sh since I do not have enough space in PREFIX location. Instead I changed it to $HOME directory.
|
|
|
|
|
|
|
19 |
|
|
|
10 |
license: apache-2.0
|
11 |
---
|
12 |
|
13 |
+
# Disclaimer
|
14 |
+
Note: This is a reproduction of the amazing blogpost done by tmabraham https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial
|
15 |
+
|
16 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
|
17 |
|
18 |
Steps
|
19 |
|
20 |
- Create a new hf space in your account
|
21 |
- Install git-lfs in order to manager our large model files. Jeremy provided this script https://gist.github.com/jph00/361a9b868aa3593f3fd8e930d0221266. I had to modify the PREFIX in the install.sh since I do not have enough space in PREFIX location. Instead I changed it to $HOME directory.
|
22 |
+
- Add export.pkl manually using the hf space. We can directly push to hub using `push_to_hub_fastai` function provided (see app.py).
|
23 |
+
|
24 |
+
|
25 |
|
app.py
CHANGED
@@ -1,7 +1,9 @@
|
|
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
|
@@ -13,8 +15,8 @@ def predict(img):
|
|
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 |
article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
|
16 |
-
examples = ['
|
17 |
interpretation='default'
|
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()
|
|
|
1 |
import gradio as gr
|
2 |
from fastai.vision.all import *
|
3 |
+
from huggingface_hub import push_to_hub_fastai, from_pretrained_fastai
|
4 |
import skimage
|
5 |
|
6 |
+
# Alternatively you can use a pretrained model from huggingface hub
|
7 |
learn = load_learner('export.pkl')
|
8 |
|
9 |
labels = learn.dls.vocab
|
|
|
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 = ['beagle.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()
|
dog.png → beagle.png
RENAMED
File without changes
|
requirements.txt
CHANGED
@@ -1,3 +1,5 @@
|
|
1 |
fastai
|
2 |
scikit-image
|
3 |
-
gradio
|
|
|
|
|
|
1 |
fastai
|
2 |
scikit-image
|
3 |
+
gradio
|
4 |
+
git+https://github.com/huggingface/huggingface_hub
|
5 |
+
|