Spaces:
Runtime error
Runtime error
Safi
commited on
Commit
·
6320c2c
1
Parent(s):
0a8d0e5
deploy
Browse files- app.ipynb +0 -0
- app.py +14 -4
- apple.png +0 -0
- export.pkl +3 -0
- guacamole.png +0 -0
- my_first_space/__init__.py +1 -0
- my_first_space/app.py +26 -0
- owl.png +0 -0
- parrot.png +0 -0
app.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
app.py
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
learn = load_learner('export.pkl')
|
|
|
|
| 5 |
|
| 6 |
+
catagories = 'apple','barn owl','guacamole','parrot',
|
| 7 |
+
|
| 8 |
+
def classify_img(img):
|
| 9 |
+
pred_class,pred_idx,probs = learn.predict(img)
|
| 10 |
+
return dict(zip(catagories, map(float,probs)))
|
| 11 |
+
|
| 12 |
+
image = gr.inputs.Image(shape=(256,256))
|
| 13 |
+
label = gr.outputs.Label()
|
| 14 |
+
examples = ['apple.png','owl.png','parrot.png','guacamole.png']
|
| 15 |
+
|
| 16 |
+
intf = gr.Interface(fn=classify_img, inputs=image, outputs=label, examples=examples)
|
| 17 |
+
intf.launch(share = True)
|
apple.png
ADDED
|
export.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6c789dde10e144e3bfd2792c39db679dd02c4c12985873422f34f01a35d0507b
|
| 3 |
+
size 46976421
|
guacamole.png
ADDED
|
my_first_space/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
__version__ = "0.0.1"
|
my_first_space/app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ..\app.ipynb.
|
| 2 |
+
|
| 3 |
+
# %% auto 0
|
| 4 |
+
__all__ = ['learn', 'catagories', 'image', 'label', 'examples', 'intf', 'classify_img']
|
| 5 |
+
|
| 6 |
+
# %% ..\app.ipynb 1
|
| 7 |
+
from fastai.vision.all import *
|
| 8 |
+
import gradio as gr
|
| 9 |
+
|
| 10 |
+
# %% ..\app.ipynb 5
|
| 11 |
+
learn = load_learner('export.pkl')
|
| 12 |
+
|
| 13 |
+
# %% ..\app.ipynb 7
|
| 14 |
+
catagories = 'apple','barn owl','guacamole','parrot',
|
| 15 |
+
|
| 16 |
+
def classify_img(img):
|
| 17 |
+
pred_class,pred_idx,probs = learn.predict(img)
|
| 18 |
+
return dict(zip(catagories, map(float,probs)))
|
| 19 |
+
|
| 20 |
+
# %% ..\app.ipynb 9
|
| 21 |
+
image = gr.inputs.Image(shape=(256,256))
|
| 22 |
+
label = gr.outputs.Label()
|
| 23 |
+
examples = ['apple.png','owl.png','parrot.png','guacamole.png']
|
| 24 |
+
|
| 25 |
+
intf = gr.Interface(fn=classify_img, inputs=image, outputs=label, examples=examples)
|
| 26 |
+
intf.launch(share = True)
|
owl.png
ADDED
|
parrot.png
ADDED
|