Spaces:
Runtime error
Runtime error
attempt to import fastai lib
Browse files- app.py +14 -8
- app.py.3ec09d1ad4059228116e1fb9e618c954.tmp +0 -20
app.py
CHANGED
@@ -1,19 +1,25 @@
|
|
1 |
-
__all__ = ['learn','classify_image','categories',
|
|
|
2 |
|
3 |
-
from huggingface_hub import
|
|
|
4 |
import gradio as gr
|
5 |
|
6 |
learn = load_learner('model.pkl')
|
7 |
|
8 |
-
categories = ('airbaby','airchair','airflare','headspin','hollow back')
|
|
|
9 |
|
10 |
def classify_image(img):
|
11 |
pred, idx, probs = learn.predict(img)
|
12 |
-
return dict(zip(categories, map(float,probs)))
|
|
|
13 |
|
14 |
-
image = gr.inputs.Image(shape=(192,192))
|
15 |
label = gr.outputs.Label()
|
16 |
-
examples = ['air_chair.jpg','hollowback.jpeg',
|
|
|
17 |
|
18 |
-
intf = gr.Interface(fn=classify_image, inputs=image,
|
19 |
-
|
|
|
|
1 |
+
__all__ = ['learn', 'classify_image', 'categories',
|
2 |
+
'image', 'label', 'examples', 'intf']
|
3 |
|
4 |
+
from huggingface_hub import hf_hub_download
|
5 |
+
from fastai.learner import *
|
6 |
import gradio as gr
|
7 |
|
8 |
learn = load_learner('model.pkl')
|
9 |
|
10 |
+
categories = ('airbaby', 'airchair', 'airflare', 'headspin', 'hollow back')
|
11 |
+
|
12 |
|
13 |
def classify_image(img):
|
14 |
pred, idx, probs = learn.predict(img)
|
15 |
+
return dict(zip(categories, map(float, probs)))
|
16 |
+
|
17 |
|
18 |
+
image = gr.inputs.Image(shape=(192, 192))
|
19 |
label = gr.outputs.Label()
|
20 |
+
examples = ['air_chair.jpg', 'hollowback.jpeg',
|
21 |
+
'airbaby.jpeg', 'airflare.jpeg', 'headspin.jpeg']
|
22 |
|
23 |
+
intf = gr.Interface(fn=classify_image, inputs=image,
|
24 |
+
outputs=label, examples=examples)
|
25 |
+
intf.launch(inline=False)
|
app.py.3ec09d1ad4059228116e1fb9e618c954.tmp
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
__all__ = ['learn','classify_image','categories','image','label','examples','intf']
|
2 |
-
|
3 |
-
from huggingface_hub import hf_hub_download
|
4 |
-
from fastai.learner import *
|
5 |
-
import gradio as gr
|
6 |
-
|
7 |
-
learn = load_learner('model.pkl')
|
8 |
-
|
9 |
-
categories = ('airbaby','airchair','airflare','headspin','hollow back')
|
10 |
-
|
11 |
-
def classify_image(img):
|
12 |
-
pred, idx, probs = learn.predict(img)
|
13 |
-
return dict(zip(categories, map(float,probs)))
|
14 |
-
|
15 |
-
image = gr.inputs.Image(shape=(192,192))
|
16 |
-
label = gr.outputs.Label()
|
17 |
-
examples = ['air_chair.jpg','hollowback.jpeg','airbaby.jpeg','airflare.jpeg','headspin.jpeg']
|
18 |
-
|
19 |
-
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
20 |
-
intf.launch(inline=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|