Spaces:
Runtime error
Runtime error
Commit
·
664e825
1
Parent(s):
7a2d477
"Adding all Files"
Browse files
app.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
|
| 2 |
+
|
| 3 |
+
# %% auto 0
|
| 4 |
+
__all__ = ['temp', 'learn', 'categories', 'image', 'label', 'examples', 'intf', 'is_cat', 'classify_image']
|
| 5 |
+
|
| 6 |
+
# %% ../app.ipynb 2
|
| 7 |
+
import pathlib
|
| 8 |
+
temp = pathlib.PosixPath
|
| 9 |
+
pathlib.PosixPath = pathlib.WindowsPath
|
| 10 |
+
|
| 11 |
+
from fastai.vision.all import *
|
| 12 |
+
|
| 13 |
+
import gradio as gr
|
| 14 |
+
|
| 15 |
+
def is_cat(x): return x[0].isupper()
|
| 16 |
+
|
| 17 |
+
# %% ../app.ipynb 4
|
| 18 |
+
learn = load_learner('model.pkl')
|
| 19 |
+
|
| 20 |
+
# %% ../app.ipynb 6
|
| 21 |
+
categories = ('Dog','Cat')
|
| 22 |
+
|
| 23 |
+
def classify_image(img):
|
| 24 |
+
pred,idx,probs = learn.predict(img)
|
| 25 |
+
return dict(zip(categories, map(float, probs)))
|
| 26 |
+
|
| 27 |
+
# %% ../app.ipynb 10
|
| 28 |
+
image = gr.components.Image(shape=(192, 192))
|
| 29 |
+
label = gr.components.Label()
|
| 30 |
+
examples = ['dog.jpeg', 'cat.jpeg', 'bird.jpeg']
|
| 31 |
+
|
| 32 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 33 |
+
intf.launch(inline=False, share=True)
|
bird.jpeg
ADDED
|
cat.jpeg
ADDED
|
dog.jpeg
ADDED
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:71ce15dc99db36a37475d30beb7f51e739cadf17869d0b50a0ec0a747358ea23
|
| 3 |
+
size 47058385
|