dL_avengers / app.py
manish-pro's picture
model file inlcuded, app updated
da8b83a
raw
history blame
782 Bytes
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)