# AUTOGENERATED! DO NOT EDIT! File to edit: evclassifierapp.ipynb. | |
# %% auto 0 | |
__all__ = ['learn', 'labels', 'title', 'description', 'interpretation', 'examples', 'enable_queue', 'intf', 'classify_image'] | |
# %% evclassifierapp.ipynb 1 | |
from fastai.vision.all import * | |
# %% evclassifierapp.ipynb 2 | |
learn = load_learner('export.pkl') | |
# %% evclassifierapp.ipynb 4 | |
labels = learn.dls.vocab | |
def classify_image(img): | |
img = PILImage.create(img) | |
pred,idx,probs = learn.predict(img) | |
return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
# %% evclassifierapp.ipynb 5 | |
title = "EV Car Classifier" | |
description = "This model will recognise the EV car in question" | |
interpretation='default' | |
examples = ['bmw ix.jpg','merc eqc.jpg','tesla model 3.jpg'] | |
enable_queue=True | |
# %% evclassifierapp.ipynb 6 | |
import gradio as gr | |
intf = gr.Interface(fn=classify_image, | |
inputs=gr.inputs.Image(shape=(512, 512)), | |
outputs=gr.outputs.Label(num_top_classes=3), | |
title=title, | |
description=description, | |
examples=examples, | |
interpretation=interpretation, | |
enable_queue=enable_queue) | |
intf.launch() | |