File size: 1,048 Bytes
6dbdc0a
 
 
cc5feed
6dbdc0a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47fe1a3
 
6dbdc0a
 
7036bea
47fe1a3
cc5feed
 
 
 
 
 
 
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
# AUTOGENERATED! DO NOT EDIT! File to edit: ../01.ipynb.

# %% auto 0
__all__ = ['learner', 'labels', 'image', 'outputs', 'title', 'description', 'examples', 'interpretation', 'predict']

# %% ../01.ipynb 3
from fastai.vision.all import *

# %% ../01.ipynb 4
learner = load_learner('model.pkl')

# %% ../01.ipynb 5
labels = learner.dls.vocab
def predict(img):
    img = PILImage.create(img)
    pred,pred_idx,probs = learner.predict(img)
    return {labels[i]: float(probs[i]) for i in range(len(labels))}

# %% ../01.ipynb 7
import gradio as gr

# %% ../01.ipynb 8
image = gr.inputs.Image(shape=(512, 512))
outputs = gr.outputs.Label(num_top_classes=3)

title = "Road vs Gravel Bike Classifier"
description = "Since for a human it's sometimes almost impossible to distuingish the two, let's see if an AI is better at telling them apart!"
examples = ['gravelbike.jpeg', 'roadbike.jpeg']
interpretation='default'


gr.Interface(fn=predict, inputs=image, outputs=outputs, title=title, description=description, examples=examples).launch(inline=False)