Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,19 @@
|
|
1 |
-
__all__ = ['is_katy', 'learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
|
2 |
-
|
3 |
-
# Cell
|
4 |
from fastai.vision.all import *
|
5 |
import gradio as gr
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
# Cell
|
10 |
learn = load_learner('model.pkl')
|
11 |
|
12 |
-
#
|
13 |
categories = ('Katy', 'Zooey')
|
14 |
|
|
|
15 |
def classify_image(img):
|
16 |
pred, idx, probs = learn.predict(img)
|
17 |
-
return
|
18 |
|
19 |
-
#
|
20 |
-
image = gr.Image(type="pil"
|
21 |
label = gr.Label()
|
22 |
examples = ['katy.jpg', 'katy2.jpg', 'zooey1.jpg', 'zooey2.jpg']
|
23 |
|
|
|
|
|
|
|
|
|
1 |
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
|
4 |
+
# pretrained model
|
|
|
|
|
5 |
learn = load_learner('model.pkl')
|
6 |
|
7 |
+
# The categories
|
8 |
categories = ('Katy', 'Zooey')
|
9 |
|
10 |
+
# Define the prediction function
|
11 |
def classify_image(img):
|
12 |
pred, idx, probs = learn.predict(img)
|
13 |
+
return {categories[i]: float(probs[i]) for i in range(len(categories))}
|
14 |
|
15 |
+
# Gradio interface
|
16 |
+
image = gr.Image(type="pil")
|
17 |
label = gr.Label()
|
18 |
examples = ['katy.jpg', 'katy2.jpg', 'zooey1.jpg', 'zooey2.jpg']
|
19 |
|