Spaces:
Sleeping
Sleeping
# AUTOGENERATED! DO NOT EDIT! File to edit: Train_class.ipynb. | |
# %% auto 0 | |
__all__ = ['model', 'cat', 'image', 'label', 'eg', 'classify_vehicle'] | |
# %% Train_class.ipynb 1 | |
from fastai.vision.all import * | |
import gradio as gr | |
# %% Train_class.ipynb 2 | |
model = load_learner('train_model.pkl') | |
# %% Train_class.ipynb 3 | |
cat = ('Bus','Train') | |
def classify_vehicle(img): | |
pred, idx, probs = model.predict(img) | |
return dict(zip(cat, map(lambda x: f"{float(x):.7f}", probs))) | |
# %% Train_class.ipynb 8 | |
image = gr.Image() | |
label = gr.Label() | |
#eg = ['train.jpg','bike.jpg','bus.jpg','car.jpeg'] | |
gr.Interface( | |
fn=classify_vehicle, | |
inputs=image, | |
outputs=label, | |
title="Vehicle Classifier", | |
description="This application classifies images of vehicles into two categories: Bus and Train. Upload an image of a vehicle, and the model will predict whether it is a Bus or a Train. The app will display the probabilities for each category." | |
).launch(inline=False) | |