Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,23 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
|
4 |
+
def is_cat(x): return x[0].isupper()
|
|
|
5 |
|
6 |
+
import pathlib
|
7 |
+
temp = pathlib.PosixPath
|
8 |
+
pathlib.PosixPath = pathlib.WindowsPath
|
9 |
+
|
10 |
+
learn = load_learner('model.pkl')
|
11 |
+
|
12 |
+
categories = ('Dog', 'Cat')
|
13 |
+
|
14 |
+
def classify_image(img):
|
15 |
+
pred, idx, probs = learn.predict(img)
|
16 |
+
return dict(zip(categories, map(float, probs)))
|
17 |
+
|
18 |
+
image = gr.components.Image(type="pil", height=192, width=192)
|
19 |
+
label = gr.Label()
|
20 |
+
examples = ['bear.jpg', 'cat.jpg', 'dog.jpg']
|
21 |
+
|
22 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
23 |
+
intf.launch(inline=False)
|