import gradio as gr from fastai.vision.all import * import os # Load a pre-trained image classification model learn = load_learner('./models/model.pth') # Function to make predictions from an image def classify_image(image): # Make a prediction # Decode the prediction and get the class name name = learn.predict(image) return name[0] # Sample images for user to choose from sample_images = ["./sample_images/AcuraTLType-S2008.jpg", "./sample_images/AudiR8Coupe2012.jpg", "./sample_images/DodgeMagnumWagon2008.jpg"] iface = gr.Interface( fn=classify_image, inputs=gr.Image(label="Select an image", type="filepath"), outputs="text", live=True, title="Car image classifier", description="Upload a car image or select one of the examples below", examples=sample_images ) iface.launch()