Spaces:
Sleeping
Sleeping
| # %% auto 0 | |
| __all__ = ['dls', 'labels', 'interface', 'predict'] | |
| import gradio as gr | |
| from fastai.vision.all import * | |
| learn = load_learner('export.pkl') | |
| labels = learn.dls.vocab | |
| def classify_image(img): | |
| img = PILImage.create(img) | |
| pred, idx, probs = learn.predict(img) | |
| return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
| interface = gr.Interface( | |
| fn=classify_image, | |
| inputs=gr.Image(height=512, width=512), | |
| outputs=gr.Label(num_top_classes=3), | |
| title="Mexican Muralist Classifier", | |
| description="Upload a photo of a mural created by Rivera, Orozco or Siqueiros.", | |
| article="This classifier can distinguish between the murals created by these three great artists.", | |
| examples=['siqueiros.jpg', 'rivera.jpg', 'orozco.jpg'] | |
| ) | |
| interface.launch(share=True) |