import gradio as gr import numpy as np # Load a pre-trained image classification model # Function to make predictions from an image def classify_image(image): # Resize the image to the required input size of the model # Preprocess the image to match the model's requirements # Make a prediction # Decode the prediction and get the class name class_name = np.random.randint(0,3) classes = ["Acura", "Audi", "Dodge"] return classes[class_name] # Sample images for user to choose from sample_images = ["AcuraTLType-S2008.jpg", "AudiR8Coupe2012.jpg", "DodgeMagnumWagon2008.jpg"] iface = gr.Interface( fn=classify_image, inputs=gr.Image(label="Select an image", type="filepath"), outputs="text", live=True, title="Identify the car", examples=sample_images ) iface.launch()