Spaces:
Runtime error
Runtime error
File size: 782 Bytes
bd2e2fd da8b83a bd2e2fd da8b83a bd2e2fd da8b83a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import gradio as gr
from fastai.vision.all import *
# load the trained model
learn = load_learner('model.pkl')
categories = ['ironman','hulk','captain america','captain marvel','thanos','thor','vision','ant man','black panther','black widow','doctor strange','spiderman']
def classify_image(img):
pred, idx, probab = learn.predict(img)
return dict(zip(categories, map(float, probab)))
image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
examples = ['ironman.jpg','hulk.jpg','captainamerica.jpg','captainmarvel.jpg','thanos.jpg',
'thor.jpg','vision.jpg','ant man.jpg','blackpanther.jpg','blackwidow.jpg','doctorstrange.jpg','spiderman.jpg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False)
|