Spaces:
Sleeping
Sleeping
Delete app.py
Browse filesRemove old app.py
app.py
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
__all__ = ['learn', 'categories', 'examples', 'image', 'label', 'intf', 'classify_image']
|
2 |
-
|
3 |
-
from fastai.vision.all import *
|
4 |
-
import gradio as gr
|
5 |
-
import timm
|
6 |
-
|
7 |
-
# the get_y function
|
8 |
-
def has_tori_logo_parent(o):
|
9 |
-
p = Path(o).parent.name
|
10 |
-
return p == 'tori-logo'
|
11 |
-
|
12 |
-
learn = load_learner('tori-model.pkl')
|
13 |
-
|
14 |
-
categories = ['Something else', 'Tori logo']
|
15 |
-
|
16 |
-
def classify_image(img):
|
17 |
-
is_tori_logo, idx, probs = learn.predict(img)
|
18 |
-
return dict(zip(categories, map(float,probs)))
|
19 |
-
|
20 |
-
examples = [
|
21 |
-
'images/dog.jpeg',
|
22 |
-
'images/cat.jpeg',
|
23 |
-
'images/face.jpg',
|
24 |
-
'images/profile-avatar.jpeg',
|
25 |
-
'images/tori-logo.png'
|
26 |
-
]
|
27 |
-
|
28 |
-
image = gr.Image()
|
29 |
-
label = gr.Label()
|
30 |
-
|
31 |
-
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
32 |
-
intf.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|