added model
Browse files
app-0.py
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
def greet(name):
|
4 |
+
return "Hello " + name + "!!"
|
5 |
+
|
6 |
+
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
+
iface.launch()
|
app.py
CHANGED
@@ -1,7 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ..\lesson2-app.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['posix_backup', 'categories', 'image', 'label', 'examples', 'intf', 'is_cat', 'classify_image']
|
5 |
+
|
6 |
+
# %% ..\lesson2-app.ipynb 2
|
7 |
+
from fastai.vision.all import *
|
8 |
import gradio as gr
|
9 |
|
10 |
+
def is_cat(x): return x[0].isupper()
|
11 |
+
|
12 |
+
# %% ..\lesson2-app.ipynb 4
|
13 |
+
#learn = load_learner('model.pkl')
|
14 |
+
import pathlib
|
15 |
+
posix_backup = pathlib.PosixPath
|
16 |
+
try:
|
17 |
+
pathlib.PosixPath = pathlib.WindowsPath
|
18 |
+
learn = load_learner('model.pkl')
|
19 |
+
finally:
|
20 |
+
pathlib.PosixPath = posix_backup
|
21 |
+
|
22 |
+
# %% ..\lesson2-app.ipynb 6
|
23 |
+
categories = ('Dog','Cat')
|
24 |
+
def classify_image(img):
|
25 |
+
pred, idx, probs = learn.predict(img)
|
26 |
+
return dict(zip(categories, map(float,probs)))
|
27 |
|
28 |
+
# %% ..\lesson2-app.ipynb 8
|
29 |
+
image = gr.inputs.Image(shape=(192,192))
|
30 |
+
label = gr.outputs.Label()
|
31 |
+
examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
|
32 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
33 |
+
intf.launch(inline=False)
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b440be75447ed6f29821e760162328fe1eb743a7faf7c88d5012e010d7f86fa8
|
3 |
+
size 47064702
|