Spaces:
Runtime error
Runtime error
Added more examples.
Browse files- README.md +5 -3
- app.py +8 -8
- sample_images/comparison.jpg +3 -0
- sample_images/grizzly_bear3.jpeg +3 -0
- sample_images/{grizzly_bear.jpeg → grizzly_bear4.jpeg} +2 -2
- sample_images/massive_bear.jpg +3 -0
- sample_images/polar_bear.jpg +3 -0
- sample_images/sloth_bear.jpg +3 -0
- sample_images/teddy_bear.jpeg +3 -0
README.md
CHANGED
@@ -12,6 +12,8 @@ license: apache-2.0
|
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
14 |
|
15 |
+
Reproduced Lesson #2 fast.ai Practical Deep Learning for Coders.
|
16 |
+
|
17 |
+
Inspiration:
|
18 |
+
- https://huggingface.co/spaces/jph00/testing
|
19 |
+
- https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial
|
app.py
CHANGED
@@ -1,25 +1,25 @@
|
|
1 |
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
import PIL
|
|
|
4 |
|
|
|
|
|
|
|
5 |
|
6 |
-
categories = ('black', 'grizzly', 'teddy') # very careful here, order matters and it should be the same as when training
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
def classify_image(img):
|
12 |
-
pred, idx, probs = learn.predict(img)
|
13 |
return dict(zip(categories, map(float, probs)))
|
14 |
|
15 |
|
16 |
image = gr.inputs.Image(shape=(192, 192))
|
17 |
label = gr.outputs.Label()
|
18 |
-
examples =
|
19 |
|
20 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, title='Bear Classifier',
|
21 |
description='Predicts between black, grizzly, and teddy bears.')
|
22 |
-
|
23 |
|
24 |
|
25 |
intf.launch(inline=False)
|
|
|
1 |
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
import PIL
|
4 |
+
import glob
|
5 |
|
6 |
+
# very careful here, order matters, and it should be the same as when training
|
7 |
+
categories = ('black', 'grizzly', 'teddy')
|
8 |
+
learner = load_learner('bear_model.pkl')
|
9 |
|
|
|
10 |
|
11 |
+
def classify_image(img: PILImage):
|
12 |
+
pred, idx, probs = learner.predict(img)
|
|
|
|
|
|
|
13 |
return dict(zip(categories, map(float, probs)))
|
14 |
|
15 |
|
16 |
image = gr.inputs.Image(shape=(192, 192))
|
17 |
label = gr.outputs.Label()
|
18 |
+
examples = glob.glob('sample_images/*.*')
|
19 |
|
20 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, title='Bear Classifier',
|
21 |
description='Predicts between black, grizzly, and teddy bears.')
|
22 |
+
# article="<p style='text-align: center'><a href='some URL' target='_blank'>Bear classifier</a></p>"
|
23 |
|
24 |
|
25 |
intf.launch(inline=False)
|
sample_images/comparison.jpg
ADDED
Git LFS Details
|
sample_images/grizzly_bear3.jpeg
ADDED
Git LFS Details
|
sample_images/{grizzly_bear.jpeg → grizzly_bear4.jpeg}
RENAMED
File without changes
|
sample_images/massive_bear.jpg
ADDED
Git LFS Details
|
sample_images/polar_bear.jpg
ADDED
Git LFS Details
|
sample_images/sloth_bear.jpg
ADDED
Git LFS Details
|
sample_images/teddy_bear.jpeg
ADDED
Git LFS Details
|