added app for deploy to spaces
Browse files- .ipynb_checkpoints/app-checkpoint.ipynb +0 -0
- app.ipynb +0 -0
- app.py +31 -0
- grizzly.jpg +0 -0
.ipynb_checkpoints/app-checkpoint.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
app.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
app.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
|
| 2 |
+
|
| 3 |
+
# %% auto 0
|
| 4 |
+
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'classify_img']
|
| 5 |
+
|
| 6 |
+
# %% ../app.ipynb 3
|
| 7 |
+
from fastai.vision.all import *
|
| 8 |
+
import gradio as gr
|
| 9 |
+
import nbdev as nb
|
| 10 |
+
import pathlib
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# %% ../app.ipynb 6
|
| 15 |
+
learn = load_learner('export.pkl')
|
| 16 |
+
|
| 17 |
+
# %% ../app.ipynb 8
|
| 18 |
+
categories = learn.dls.vocab
|
| 19 |
+
|
| 20 |
+
def classify_img(img):
|
| 21 |
+
pred, idx, probs = learn.predict(img)
|
| 22 |
+
return dict(zip(categories, map(float, probs)))
|
| 23 |
+
|
| 24 |
+
# %% ../app.ipynb 10
|
| 25 |
+
image = gr.components.Image(shape=(192,192))
|
| 26 |
+
label = gr.components.Label()
|
| 27 |
+
examples = ['grizzly.jpg']
|
| 28 |
+
|
| 29 |
+
# %% ../app.ipynb 11
|
| 30 |
+
intf = gr.Interface(fn=classify_img, inputs=image, outputs=label, examples=examples)
|
| 31 |
+
intf.launch(inline=False, share=True)
|
grizzly.jpg
ADDED
|