pispolita
commited on
Commit
·
9107495
1
Parent(s):
e9533e2
wip
Browse files
app.py
CHANGED
@@ -1,38 +1,18 @@
|
|
1 |
import gradio as gr
|
2 |
from fastai.vision.all import *
|
3 |
|
4 |
-
title = ""
|
5 |
-
<div style="text-align: center; max-width: 500px; margin: 0 auto;">
|
6 |
-
<div
|
7 |
-
style="
|
8 |
-
display: inline-flex;
|
9 |
-
align-items: center;
|
10 |
-
gap: 0.8rem;
|
11 |
-
font-size: 1.75rem;
|
12 |
-
margin-bottom: 10px;
|
13 |
-
"
|
14 |
-
>
|
15 |
-
<h1 style="font-weight: 600; margin-bottom: 7px;">
|
16 |
-
Grizzly/Black/Teddy bear classification
|
17 |
-
</h1>
|
18 |
-
</div>
|
19 |
-
<p style="margin-bottom: 10px;font-size: 94%;font-weight: 100;line-height: 1.5em;">
|
20 |
-
Please upload a Grizzly, Black or Teddy bear image for classification.
|
21 |
-
</p>
|
22 |
-
</div>
|
23 |
-
"""
|
24 |
|
25 |
learn = load_learner('export.pkl')
|
26 |
-
|
27 |
-
categories = ('grizzly', 'black', 'teddy')
|
28 |
|
29 |
def classify_image(img):
|
30 |
pred, idx, probs = learn.predict(img)
|
31 |
-
return
|
32 |
|
33 |
gr.HTML(title)
|
34 |
image = gr.inputs.Image(shape=(224, 224))
|
35 |
-
label = gr.outputs.Label()
|
36 |
|
37 |
-
iface = gr.Interface(fn=classify_image, inputs=image, outputs=label)
|
38 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from fastai.vision.all import *
|
3 |
|
4 |
+
title = "Grizzly/Black/Teddy bear classifier."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
learn = load_learner('export.pkl')
|
7 |
+
labels = learn.dls.vocab
|
|
|
8 |
|
9 |
def classify_image(img):
|
10 |
pred, idx, probs = learn.predict(img)
|
11 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
12 |
|
13 |
gr.HTML(title)
|
14 |
image = gr.inputs.Image(shape=(224, 224))
|
15 |
+
label = gr.outputs.Label(num_top_classes=3)
|
16 |
|
17 |
+
iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, title=title)
|
18 |
iface.launch()
|