Spaces:
Runtime error
Runtime error
Oleh Hnashuk
commited on
Commit
•
bdd9afb
1
Parent(s):
814ade9
fastai in requirements file
Browse files- app.ipynb +3 -1
- app/app.py +26 -0
- requirements.txt +1 -0
app.ipynb
CHANGED
@@ -18,6 +18,8 @@
|
|
18 |
"outputs": [],
|
19 |
"source": [
|
20 |
"#|export\n",
|
|
|
|
|
21 |
"from fastai.vision.all import *\n",
|
22 |
"import gradio as gr"
|
23 |
]
|
@@ -271,7 +273,7 @@
|
|
271 |
},
|
272 |
{
|
273 |
"cell_type": "code",
|
274 |
-
"execution_count":
|
275 |
"id": "c0c533db",
|
276 |
"metadata": {},
|
277 |
"outputs": [],
|
|
|
18 |
"outputs": [],
|
19 |
"source": [
|
20 |
"#|export\n",
|
21 |
+
"!pip install fastai\n",
|
22 |
+
"!pip install gradio\n",
|
23 |
"from fastai.vision.all import *\n",
|
24 |
"import gradio as gr"
|
25 |
]
|
|
|
273 |
},
|
274 |
{
|
275 |
"cell_type": "code",
|
276 |
+
"execution_count": 15,
|
277 |
"id": "c0c533db",
|
278 |
"metadata": {},
|
279 |
"outputs": [],
|
app/app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image']
|
5 |
+
|
6 |
+
# %% ../app.ipynb 1
|
7 |
+
from fastai.vision.all import *
|
8 |
+
import gradio as gr
|
9 |
+
|
10 |
+
# %% ../app.ipynb 2
|
11 |
+
learn = load_learner('model.pk1')
|
12 |
+
|
13 |
+
# %% ../app.ipynb 3
|
14 |
+
categories = ('ocean', 'space', 'money')
|
15 |
+
|
16 |
+
def classify_image(img):
|
17 |
+
pred, idx, probs = learn.predict(img)
|
18 |
+
return dict(zip(categories, map(float, probs)))
|
19 |
+
|
20 |
+
# %% ../app.ipynb 5
|
21 |
+
image = gr.inputs.Image(shape=(192,192))
|
22 |
+
label = gr.outputs.Label()
|
23 |
+
examples = ['ocean.jpg', 'space.jpg', 'money.jpg']
|
24 |
+
|
25 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
26 |
+
intf.launch(inline=False)
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fastai
|