Spaces:
Runtime error
Runtime error
| from fastai.vision.all import * | |
| import gradio as gr | |
| learn = load_learner('resnet50_30_categories.pkl') | |
| def classify_image(img): | |
| pred, idx, probs = learn.predict(img) | |
| return {learn.dls.vocab[i]: float(probs[i]) for i in range(len(probs))} | |
| iface = gr.Interface( | |
| fn=classify_image, | |
| inputs=gr.Image(type="pil"), | |
| outputs=gr.Label(num_top_classes=3), | |
| title="Flower Classifier", | |
| description="Upload an image of a flower and the model will predict its category." | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() | |