Spaces:
Runtime error
Runtime error
bigyunicorn
commited on
Commit
Β·
a644801
1
Parent(s):
6420339
uploading app.py with all images and my model
Browse files
app.py
CHANGED
@@ -1,7 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
iface = gr.Interface(fn=
|
7 |
-
iface.launch()
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: testnbdev.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'iface', 'is_cat', 'classify_image']
|
5 |
+
|
6 |
+
# %% testnbdev.ipynb 34
|
7 |
+
learn = load_learner("model.pkl")
|
8 |
+
|
9 |
+
# %% testnbdev.ipynb 53
|
10 |
+
from fastai.vision.all import *
|
11 |
import gradio as gr
|
12 |
|
13 |
+
def is_cat(x): return x[0].isupper()
|
14 |
+
|
15 |
+
# %% testnbdev.ipynb 57
|
16 |
+
learn = load_learner("model.pkl")
|
17 |
+
|
18 |
+
# %% testnbdev.ipynb 65
|
19 |
+
categories = ('Dog', 'Cat')
|
20 |
+
|
21 |
+
def classify_image(img):
|
22 |
+
pred,idx,probs = learn.predict(img)
|
23 |
+
return dict(zip(categories, map(float,probs))) # need to understand this line.
|
24 |
+
|
25 |
+
# %% testnbdev.ipynb 67
|
26 |
+
image = gr.inputs.Image(shape=(192,192))
|
27 |
+
label = gr.outputs.Label()
|
28 |
+
examples = ["cat.jpg", "dog.jpg", "grizzlybear.jpg", "box.jpg", "boxes.jpg", "dog_and_cat.jpg", "dog_and_cat2.jpg", "dog_and_cat3.png"]
|
29 |
|
30 |
+
iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
31 |
+
iface.launch()
|