File size: 846 Bytes
c3119d9
 
 
caf9f8a
c3119d9
 
 
 
93712b8
c3119d9
c5f331a
c3119d9
 
c5f331a
c3119d9
 
e00389c
c3119d9
e00389c
 
c3119d9
e00389c
caf9f8a
 
93712b8
 
caf9f8a
 
 
c3119d9
e00389c
 
 
 
 
 
 
 
c3119d9
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
38
39
40
# AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.

# %% auto 0
__all__ = ['learn', 'categories', 'image', 'label', 'path', 'examples', 'intf', 'classify_img']

# %% ../app.ipynb 1
from fastai.vision.all import *
import gradio as gr
import timm

# %% ../app.ipynb 2
learn = load_learner("model.pkl")

# %% ../app.ipynb 3
categories = learn.dls.vocab


def classify_img(img):
    pred_class, pred_idx, probs = learn.predict(img)
    return dict(zip(categories, map(float, probs)))

# %% ../app.ipynb 4
from pathlib import Path

image = gr.Image(shape=(192, 192))
label = gr.Label()

path = Path("examples")
examples = [file for file in path.iterdir()]

intf = gr.Interface(
    fn=classify_img,
    inputs=image,
    outputs=label,
    examples=examples,
    title="The GOAT",
    description="Is it The GOAT?",
)
intf.launch(inline=False)