dL_avengers / app.py
manish-pro's picture
examples updated
42fb412
raw
history blame
749 Bytes
import gradio as gr
from fastai.vision.all import *
# load the trained model
learn = load_learner('model.pkl')
# learn.dls.vocab where dls in the dataloaders from DataBlock
categories = ['ant man', 'black panther', 'black widow', 'captain america', 'captain marvel',
'doctor strange', 'hulk', 'ironman', 'spiderman', 'thanos', 'thor', 'vision']
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','spiderman.jpg','captain.jpg','blackwidow.jpg','doctor_strange.jpg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False)