Spaces:
Sleeping
Sleeping
File size: 943 Bytes
0c03a0b 990e9e8 b561682 6819837 722f1de 0c03a0b 6819837 ce10a39 6819837 205302e 6819837 8d7e9fb 6819837 ce10a39 976b813 6819837 5a6049a 6819837 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import gradio as gr
from fastai.vision.all import *
import os
# Load a pre-trained image classification model
root = os.path.dirname(__file__)
learn = load_learner(os.path.join(root, "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 = [os.path.join(root, sample_images, "AcuraTLType-S2008.jpg"), os.path.join(root, sample_images, "AudiR8Coupe2012.jpg"),
os.path.join(root, 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()
|