Spaces:
Sleeping
Sleeping
Egan Bisma
commited on
Commit
·
01401fb
1
Parent(s):
befe55d
add generated app.py and requirements.txt
Browse files- app.py +29 -0
- requirements.txt +1 -0
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../00_core.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['learn', 'categories', 'image', 'label', 'intf', 'classify_image']
|
5 |
+
|
6 |
+
# %% ../00_core.ipynb 3
|
7 |
+
from pathlib import Path
|
8 |
+
from fastai.vision.all import *
|
9 |
+
from fastai.vision.widgets import *
|
10 |
+
import gradio as gr
|
11 |
+
|
12 |
+
# %% ../00_core.ipynb 4
|
13 |
+
learn = load_learner('export.pkl')
|
14 |
+
|
15 |
+
# %% ../00_core.ipynb 5
|
16 |
+
categories=['black', 'grizzly', 'teddy']
|
17 |
+
|
18 |
+
def classify_image(img):
|
19 |
+
"classifies bear image as either a black, grizzly, or teddy bear"
|
20 |
+
pred,idx,props = learn.predict(img)
|
21 |
+
return dict(zip(categories, map(float, props)))
|
22 |
+
|
23 |
+
# %% ../00_core.ipynb 7
|
24 |
+
image = gr.inputs.Image(shape=(192, 192))
|
25 |
+
label = gr.outputs.Label()
|
26 |
+
# examples = ['do']
|
27 |
+
|
28 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label)
|
29 |
+
intf.launch(inline=False)
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fastai
|