File size: 1,037 Bytes
77a5b6f
b838192
77a5b6f
21c7ff6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
853b0b0
77a5b6f
853b0b0
 
 
 
 
 
 
 
 
 
8cee1e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import gradio as gr
from fastai.vision.all import *

title = """
    <div style="text-align: center; max-width: 500px; margin: 0 auto;">
        <div
        style="
            display: inline-flex;
            align-items: center;
            gap: 0.8rem;
            font-size: 1.75rem;
            margin-bottom: 10px;
        "
        >
        <h1 style="font-weight: 600; margin-bottom: 7px;">
            Grizzly/Black/Teddy bear classification
        </h1>
        </div>
        <p style="margin-bottom: 10px;font-size: 94%;font-weight: 100;line-height: 1.5em;">
        Please upload a Grizzly, Black or Teddy bear image for classification. 
        </p>
    </div>
"""

learn = load_learner('export.pkl')

categories = ('grizzly', 'black', 'teddy')

def classify_image(img):
    pred, idx, probs = learn.predict(img)
    return dict(zip(categories, map(float, probs)))

image = gr.inputs.Image(shape=(224, 224))
label = gr.outputs.Label()

iface = gr.Interface(fn=classify_image, inputs=image, outputs=label)
iface.launch()