Spaces:
Sleeping
Sleeping
File size: 616 Bytes
8733ee9 2a9077b e37addc cb3af6d 2a9077b a3ce06f 36bc1a1 cb3af6d 36bc1a1 306483c 36bc1a1 0df88dd 9e3a1dc 36bc1a1 c6a71ed 36bc1a1 55d3e69 | 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 | from fastai.vision.all import *
import gradio as gr
# import pathlib
# temp = pathlib.PosixPath
# pathlib.PosixPath = pathlib.WindowsPath
model = load_learner('cap-recognizer-v3.pkl')
cap_labels = model.dls.vocab
def recognize_image(image):
pred, idx, probs = model.predict(image)
return dict(zip(cap_labels, map(float, probs)))
image = gr.Image()
label = gr.Label(num_top_classes=5)
examples = [
'unknown00.png',
'unknown01.png',
'unknown02.png',
'unknown03.png'
]
iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label, examples=examples)
iface.launch(inline=False) |