Spaces:
Runtime error
Runtime error
Commit
·
26fb56e
1
Parent(s):
2619944
fix2
Browse files
app.py
CHANGED
@@ -1,49 +1,52 @@
|
|
1 |
-
|
2 |
# %% [markdown]
|
3 |
# Dogs vs Cats
|
4 |
|
5 |
# %%
|
6 |
-
|
7 |
# !pip install gradio
|
8 |
|
9 |
# %%
|
10 |
-
|
11 |
from fastai.vision.all import *
|
12 |
import gradio as gr
|
13 |
|
14 |
-
|
|
|
|
|
|
|
15 |
|
16 |
# %%
|
17 |
-
im = PILImage.create(
|
18 |
-
im.thumbnail((192,192))
|
19 |
im
|
20 |
|
21 |
# %%
|
22 |
-
|
23 |
|
24 |
learn = load_learner("model.pkl")
|
25 |
|
26 |
# %%
|
27 |
-
%time learn.predict(im)
|
|
|
28 |
|
29 |
# %%
|
30 |
-
|
31 |
-
categories = (
|
|
|
32 |
|
33 |
def classify_image(img):
|
34 |
-
pred,idx,probs = learn.predict(img)
|
35 |
return dict(zip(categories, map(float, probs)))
|
36 |
|
|
|
37 |
# %%
|
38 |
classify_image(im)
|
39 |
|
40 |
# %%
|
41 |
-
|
42 |
-
image = gr.inputs.Image(shape=(192,192))
|
43 |
label = gr.outputs.Label()
|
44 |
-
examples = [
|
45 |
|
46 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
47 |
intf.launch(inline=False)
|
48 |
-
|
49 |
-
|
|
|
|
|
1 |
# %% [markdown]
|
2 |
# Dogs vs Cats
|
3 |
|
4 |
# %%
|
5 |
+
# |default_exp app
|
6 |
# !pip install gradio
|
7 |
|
8 |
# %%
|
9 |
+
# |export
|
10 |
from fastai.vision.all import *
|
11 |
import gradio as gr
|
12 |
|
13 |
+
|
14 |
+
def is_cat(x):
|
15 |
+
return x[0].isupper()
|
16 |
+
|
17 |
|
18 |
# %%
|
19 |
+
im = PILImage.create("dog.jpg")
|
20 |
+
im.thumbnail((192, 192))
|
21 |
im
|
22 |
|
23 |
# %%
|
24 |
+
# |export
|
25 |
|
26 |
learn = load_learner("model.pkl")
|
27 |
|
28 |
# %%
|
29 |
+
# %time learn.predict(im)
|
30 |
+
learn.predict(im)
|
31 |
|
32 |
# %%
|
33 |
+
# |export
|
34 |
+
categories = ("Dog", "Cat")
|
35 |
+
|
36 |
|
37 |
def classify_image(img):
|
38 |
+
pred, idx, probs = learn.predict(img)
|
39 |
return dict(zip(categories, map(float, probs)))
|
40 |
|
41 |
+
|
42 |
# %%
|
43 |
classify_image(im)
|
44 |
|
45 |
# %%
|
46 |
+
# |export
|
47 |
+
image = gr.inputs.Image(shape=(192, 192))
|
48 |
label = gr.outputs.Label()
|
49 |
+
examples = ["dog.jpg", "cat.jpg", "dunno.jpg"]
|
50 |
|
51 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
52 |
intf.launch(inline=False)
|
|
|
|