Spaces:
Build error
Build error
| import gradio as gr | |
| from fastai.vision.all import load_learner, PILImage | |
| # Import any custom code here (if needed) | |
| # Example: | |
| # from your_module import CustomTransform, CustomModel | |
| learn = load_learner('export.pkl') | |
| def predict(img): | |
| img = PILImage.create(img) | |
| pred, pred_idx, probs = learn.predict(img) | |
| labels = learn.dls.vocab | |
| return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
| interface = gr.Interface(fn=predict, inputs=gr.Image(), outputs=gr.Label(num_top_classes=3)) | |
| interface.launch(share=True) | |