|
|
|
|
|
|
|
|
|
|
|
__all__ = ['learn', 'image', 'label', 'examples', 'intf', 'classify_car'] |
|
|
|
|
|
|
|
|
from fastbook import * |
|
|
import gradio as gr |
|
|
|
|
|
|
|
|
learn=load_learner('models/car_classifier.pkl') |
|
|
|
|
|
|
|
|
def classify_car(img): |
|
|
img = PILImage.create(img) |
|
|
pred, pred_idx, probs = learn.predict(img) |
|
|
|
|
|
return {learn.dls.vocab[i]: probs[i].item() for i in range(len(learn.dls.vocab))} |
|
|
|
|
|
|
|
|
image=gr.components.Image() |
|
|
label=gr.components.Label() |
|
|
examples=[['examples/example_0.png'], ['examples/example_1.png'], ['examples/example_2.png']] |
|
|
intf=gr.Interface(fn=classify_car, inputs=image, outputs=label, examples=examples).launch() |
|
|
intf.launch(inline=False) |
|
|
|