File size: 909 Bytes
60bc679
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cea761f
 
60bc679
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cea761f
60bc679
 
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

# def greet(name):
#     return "Hello " + name + "!!"

# demo = gr.Interface(fn=greet, inputs="text", outputs="text")
# demo.launch()

# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.

# %% auto 0
__all__ = ["learn", "categories", "image", "label", "examples", "intf", "classify_bike"]

# %% app.ipynb 5
from fastai.vision.all import *
import gradio as gr

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

# %% app.ipynb 11
categories = ["giant", "specialized", "trek"]


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


# %% app.ipynb 13
image = gr.Image(height=192, width=192, label="Bike Image")
label = gr.Label(label="Predicted Bike Type")
examples = ["trek.jpg", "specialized.jpg"]

intf = gr.Interface(fn=classify_bike, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False)