Spaces:
Sleeping
Sleeping
File size: 840 Bytes
4bdbe22 fe3a33c 4bdbe22 fe3a33c 4bdbe22 7cfbcdb 4bdbe22 c7f71fd 324b185 4bdbe22 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
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) |