Spaces:
Runtime error
Runtime error
Updating Application File
Browse files
app.py
CHANGED
@@ -1,7 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def
|
4 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image']
|
5 |
+
|
6 |
+
# %% ../app.ipynb 0
|
7 |
+
from fastai.vision.all import *
|
8 |
+
import PIL
|
9 |
import gradio as gr
|
10 |
|
11 |
+
def is_cat(x):
|
12 |
+
return x[0].isupper()
|
13 |
+
# %% ../app.ipynb 3
|
14 |
+
learn = load_learner('model.pkl')
|
15 |
+
|
16 |
+
# %% ../app.ipynb 5
|
17 |
+
categories = ('American Bulldog', 'American Pit Bull Terrier', 'Basset Hound',
|
18 |
+
'Beagle', 'Boxer', 'Chihuahua', 'English Cocker Spaniel', 'English Setter', 'German Shorthaired',
|
19 |
+
'Great Pyrenees', 'Havanese', 'Japanese Chin', 'Keeshond', 'Leonberger', 'Miniature Pinscher', 'Newfoundland',
|
20 |
+
'Pomeranian', 'Pug', 'St.Bernard', 'Samyoed', 'Scottish Terrier', 'Shiba Inu', 'Staffordshire Bull Terrier',
|
21 |
+
'Wheaten Terrier', 'Yorkshire Terrier', 'Abyssian', 'Bengal', 'Birman', 'Bombay', 'British Shorthair',
|
22 |
+
'Egyptian Mau', 'Main Coon', 'Persian', 'Ragdoll', 'Russian Blue', 'Siamese', 'Sphynx')
|
23 |
+
|
24 |
+
def classify_image(img):
|
25 |
+
pred, idx, probs = learn.predict(img)
|
26 |
+
return dict(zip(categories, map(float, probs)))
|
27 |
|
28 |
+
# %% ../app.ipynb
|
29 |
+
image = gr.Image(shape=(192,192))
|
30 |
+
label = gr.Label()
|
31 |
+
examples = ['americanBulldog.jpg', 'bernard.jpg', 'ragdoll.jpg']
|
32 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
33 |
+
intf.launch(inline=False)
|