Spaces:
Sleeping
Sleeping
| from fastai.vision.all import load_learner | |
| import gradio as gr | |
| labels=( | |
| 'Abyssinian cat', | |
| 'Aegean cat', | |
| 'Balinese cat', | |
| 'Bengal cat', | |
| 'Birman cat', | |
| 'Bombay cat', | |
| 'British Longhair cat', | |
| 'Burmese cat', | |
| 'Burmilla cat', | |
| 'Cornish Rex cat', | |
| 'Cymric cat', | |
| 'Donskoy cat', | |
| 'Oregon Rex cat', | |
| 'Oriental Bicolor cat', | |
| 'Persian cat', | |
| 'Pixie-Bob cat', | |
| 'Ragamuffin cat', | |
| 'Siamese cat', | |
| 'Siberian cat', | |
| 'Turkish Angora cat' | |
| ) | |
| model=load_learner(f'CatClassifier-v1.pkl') | |
| def recognize_image(image): | |
| pred, idx, probs=model.predict(image) | |
| print(pred) | |
| return dict(zip(labels, map(float, probs))) | |
| image = gr.inputs.Image(image_mode="RGB") | |
| label=gr.outputs.Label() | |
| iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label) | |
| iface.launch(inline=False, share=True) |