Spaces:
Sleeping
Sleeping
File size: 1,466 Bytes
6b26348 348515d 6b26348 348515d 6b26348 |
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
import gradio as gr
from fastai.vision.all import load_learner
from fastai.vision.all import PILImage
shoe_labels = (
'Army boots',
'Ballet flats',
'Basketball shoes',
'Brogues',
'Chelsea Boot',
'Chuck Taylor',
'Climbing shoes',
'Cone heels',
'Court shoes',
'Cowboy boots',
'Derby shoes',
'Dress shoe',
'Flip flop',
'Golf shoes',
'High heels',
'High-tops shoes',
'Hiking boots',
'Ice-skates shoes',
'Kitten heels',
'Knee high boots',
'Laced booties',
'Lita shoe',
'Loafer',
'Mary Jane platforms',
'Moccasin',
'Mule shoes',
'Old skool',
'Oxford shoe',
'Platform heels',
'Running shoes',
'Sandal',
'Sneakers ',
'Soccer shoes',
'Uggs',
'Wedges shoe',
'Wellington boots'
)
model = load_learner('models/shoes-recognizer-v4.pkl')
def recognize_image(image):
pred, idx, probs = model.predict(image)
print(pred, probs)
return dict(zip(shoe_labels, map(float, probs)))
image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label(num_top_classes=5)
examples = [
'test_image\image-01.jpg',
'test_image\image-02.jpg',
'test_image\image-03.jpg',
'test_image\image-06.jpg',
'test_image\image-07.jpg',
'test_image\image-08.jpg',
'test_image\image-09.jpg',
'test_image\image-10.jpg'
]
iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label, examples=examples)
iface.launch(inline=False, share=True) |