Spaces:
Runtime error
Runtime error
Brian Sigafoos
commited on
Commit
Β·
051daf1
1
Parent(s):
9dc272e
Add title and link to blog post
Browse files
README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
title: Fastai Trees
|
3 |
emoji: π
|
4 |
colorFrom: green
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.14.0
|
8 |
app_file: app.py
|
|
|
2 |
title: Fastai Trees
|
3 |
emoji: π
|
4 |
colorFrom: green
|
5 |
+
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.14.0
|
8 |
app_file: app.py
|
app.ipynb
CHANGED
@@ -79,7 +79,6 @@
|
|
79 |
"\n",
|
80 |
"categories = ('ash', 'chestnut', 'ginkgo biloba', 'silver maple', 'willow oak')\n",
|
81 |
"\n",
|
82 |
-
"\n",
|
83 |
"def classify_image(img):\n",
|
84 |
" pred, idx, probs = learn.predict(img)\n",
|
85 |
" # Change each probability to a float, since Gradio doesn't support Tensors or NumPy\n",
|
@@ -109,15 +108,21 @@
|
|
109 |
"metadata": {},
|
110 |
"outputs": [],
|
111 |
"source": [
|
112 |
-
"
|
113 |
"image = gr.inputs.Image(shape=(192, 192))\n",
|
114 |
"label = gr.outputs.Label()\n",
|
115 |
"examples = ['images/ash.jpg', 'images/chestnut.jpg', 'images/ginkgo_biloba.jpg',\n",
|
116 |
" 'images/silver_maple.jpg', 'images/willow_oak.jpg']\n",
|
|
|
|
|
|
|
|
|
|
|
117 |
"\n",
|
118 |
-
"interface = gr.Interface(fn=classify_image, inputs=image,\n",
|
119 |
-
"
|
120 |
-
"
|
|
|
121 |
]
|
122 |
},
|
123 |
{
|
|
|
79 |
"\n",
|
80 |
"categories = ('ash', 'chestnut', 'ginkgo biloba', 'silver maple', 'willow oak')\n",
|
81 |
"\n",
|
|
|
82 |
"def classify_image(img):\n",
|
83 |
" pred, idx, probs = learn.predict(img)\n",
|
84 |
" # Change each probability to a float, since Gradio doesn't support Tensors or NumPy\n",
|
|
|
108 |
"metadata": {},
|
109 |
"outputs": [],
|
110 |
"source": [
|
111 |
+
"# |export\n",
|
112 |
"image = gr.inputs.Image(shape=(192, 192))\n",
|
113 |
"label = gr.outputs.Label()\n",
|
114 |
"examples = ['images/ash.jpg', 'images/chestnut.jpg', 'images/ginkgo_biloba.jpg',\n",
|
115 |
" 'images/silver_maple.jpg', 'images/willow_oak.jpg']\n",
|
116 |
+
"# More useful args\n",
|
117 |
+
"title = \"Tree leaf classifier demo\"\n",
|
118 |
+
"description = \"A tree leaf classifier demo, trained on images downloaded from DuckDuckGo. Created as a demo of HuggingFace Spaces and Gradio.\"\n",
|
119 |
+
"article = \"<p>From this blog post: <a href='https://briansigafoos.com/ml-quick-start' target='_blank'>Machine Learning quick start by Brian Sigafoos</a></p>\"\n",
|
120 |
+
"interpretation = 'default'\n",
|
121 |
"\n",
|
122 |
+
"interface = gr.Interface(fn=classify_image, inputs=image, outputs=label,\n",
|
123 |
+
" examples=examples, title=title, description=description,\n",
|
124 |
+
" article=article, interpretation=interpretation)\n",
|
125 |
+
"interface.launch(inline=False)\n"
|
126 |
]
|
127 |
},
|
128 |
{
|
app.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
2 |
|
3 |
# %% auto 0
|
4 |
-
__all__ = ['learn', 'categories', 'image', 'label',
|
5 |
-
'
|
6 |
|
7 |
# %% app.ipynb 2
|
8 |
from fastai.vision.all import *
|
@@ -14,19 +14,24 @@ learn = load_learner('model.pkl')
|
|
14 |
# %% app.ipynb 7
|
15 |
categories = ('ash', 'chestnut', 'ginkgo biloba', 'silver maple', 'willow oak')
|
16 |
|
17 |
-
|
18 |
def classify_image(img):
|
19 |
pred, idx, probs = learn.predict(img)
|
20 |
# Change each probability to a float, since Gradio doesn't support Tensors or NumPy
|
21 |
return dict(zip(categories, map(float, probs)))
|
22 |
|
23 |
-
|
24 |
# %% app.ipynb 10
|
25 |
image = gr.inputs.Image(shape=(192, 192))
|
26 |
label = gr.outputs.Label()
|
27 |
examples = ['images/ash.jpg', 'images/chestnut.jpg', 'images/ginkgo_biloba.jpg',
|
28 |
'images/silver_maple.jpg', 'images/willow_oak.jpg']
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
interface.launch(inline=False)
|
|
|
|
1 |
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
2 |
|
3 |
# %% auto 0
|
4 |
+
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'title', 'description', 'article', 'interpretation', 'interface',
|
5 |
+
'classify_image']
|
6 |
|
7 |
# %% app.ipynb 2
|
8 |
from fastai.vision.all import *
|
|
|
14 |
# %% app.ipynb 7
|
15 |
categories = ('ash', 'chestnut', 'ginkgo biloba', 'silver maple', 'willow oak')
|
16 |
|
|
|
17 |
def classify_image(img):
|
18 |
pred, idx, probs = learn.predict(img)
|
19 |
# Change each probability to a float, since Gradio doesn't support Tensors or NumPy
|
20 |
return dict(zip(categories, map(float, probs)))
|
21 |
|
|
|
22 |
# %% app.ipynb 10
|
23 |
image = gr.inputs.Image(shape=(192, 192))
|
24 |
label = gr.outputs.Label()
|
25 |
examples = ['images/ash.jpg', 'images/chestnut.jpg', 'images/ginkgo_biloba.jpg',
|
26 |
'images/silver_maple.jpg', 'images/willow_oak.jpg']
|
27 |
+
# More useful args
|
28 |
+
title = "Tree leaf classifier demo"
|
29 |
+
description = "A tree leaf classifier demo, trained on images downloaded from DuckDuckGo. Created as a demo of HuggingFace Spaces and Gradio."
|
30 |
+
article = "<p>From this blog post: <a href='https://briansigafoos.com/ml-quick-start' target='_blank'>Machine Learning quick start by Brian Sigafoos</a></p>"
|
31 |
+
interpretation = 'default'
|
32 |
+
|
33 |
+
interface = gr.Interface(fn=classify_image, inputs=image, outputs=label,
|
34 |
+
examples=examples, title=title, description=description,
|
35 |
+
article=article, interpretation=interpretation)
|
36 |
interface.launch(inline=False)
|
37 |
+
|