Spaces:
Runtime error

swagclassifier / app.py
Mapakashi's picture
up
3f6e4c3 verified
Raw History Blame Contribute Delete
748 Bytes
# app.py
from fastai.vision.all import *
import gradio as gr
# Load the trained model
learn = load_learner('export.pkl')
# Define the classification function that Gradio will use
def classify_image(img):
pred, idx, probs = learn.predict(img)
# Assuming your model's predictions are 'T-shirt' and 'Trousers'
return {pred: max(probs.tolist())}
# Define the Gradio interface
gr_interface = gr.Interface(fn=classify_image,
inputs=gr.inputs.Image(type='pil'),
outputs=gr.outputs.Label(num_top_classes=2),
examples=['path/to/sample_tshirt.jpg', 'path/to/sample_trousers.jpg'])
# Launch the Gradio app
if __name__ == "__main__":
gr_interface.launch()