Spaces:
Sleeping
Sleeping
Commit ·
b39d5ba
1
Parent(s): 1de4271
done?
Browse files- .gitignore +2 -0
- app.py +9 -10
.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
notebook2script.py
|
| 2 |
+
02_exp_app.ipynb
|
app.py
CHANGED
|
@@ -1,30 +1,29 @@
|
|
| 1 |
-
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
from fastai.vision.all import *
|
| 4 |
import gradio as gr
|
| 5 |
-
import pathlib
|
| 6 |
-
import platform
|
| 7 |
|
| 8 |
def is_sea(x) : return x[0].isupper()
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
plt = platform.system()
|
| 12 |
-
|
| 13 |
-
# If the platform is Linux, redirect WindowsPath to PosixPath
|
| 14 |
-
if plt == 'Linux':
|
| 15 |
-
pathlib.WindowsPath = pathlib.PosixPath
|
| 16 |
-
|
| 17 |
learn = load_learner('export.pkl')
|
| 18 |
|
|
|
|
| 19 |
categories = ('River', "Sea", "Stuffed")
|
| 20 |
|
| 21 |
def classify_image(img):
|
| 22 |
pred,idx,probs = learn.predict(img)
|
| 23 |
return dict(zip(categories,map(float,probs)))
|
| 24 |
|
|
|
|
| 25 |
image = gr.inputs.Image(shape = (192,192))
|
| 26 |
label = gr.outputs.Label()
|
| 27 |
examples = ['images/seaotter.jpg' , 'images/riverotter.jpg' , 'images/stuffedotter.jpg']
|
| 28 |
|
| 29 |
intf = gr.Interface(fn=classify_image, inputs=image,outputs=label,examples=examples)
|
| 30 |
intf.launch(inline=False)
|
|
|
|
|
|
| 1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../02_exp_app.ipynb.
|
| 2 |
|
| 3 |
+
# %% auto 0
|
| 4 |
+
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'is_sea', 'classify_image']
|
| 5 |
+
|
| 6 |
+
# %% ../02_exp_app.ipynb 1
|
| 7 |
from fastai.vision.all import *
|
| 8 |
import gradio as gr
|
|
|
|
|
|
|
| 9 |
|
| 10 |
def is_sea(x) : return x[0].isupper()
|
| 11 |
|
| 12 |
+
# %% ../02_exp_app.ipynb 3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
learn = load_learner('export.pkl')
|
| 14 |
|
| 15 |
+
# %% ../02_exp_app.ipynb 5
|
| 16 |
categories = ('River', "Sea", "Stuffed")
|
| 17 |
|
| 18 |
def classify_image(img):
|
| 19 |
pred,idx,probs = learn.predict(img)
|
| 20 |
return dict(zip(categories,map(float,probs)))
|
| 21 |
|
| 22 |
+
# %% ../02_exp_app.ipynb 7
|
| 23 |
image = gr.inputs.Image(shape = (192,192))
|
| 24 |
label = gr.outputs.Label()
|
| 25 |
examples = ['images/seaotter.jpg' , 'images/riverotter.jpg' , 'images/stuffedotter.jpg']
|
| 26 |
|
| 27 |
intf = gr.Interface(fn=classify_image, inputs=image,outputs=label,examples=examples)
|
| 28 |
intf.launch(inline=False)
|
| 29 |
+
|