Spaces:
Runtime error
Runtime error
import gradio as gr | |
from fastai import * | |
from fastai.vision.all import * | |
def is_holdingweapon(x): | |
return parent_label(x) | |
learn = load_learner('model_resnet34.pkl') | |
categories = ('Human holding Weapon','No Weapon detected','Weapon') | |
def classify_image(img): | |
pred,idx,probs = learn.predict(img) | |
return dict(zip(categories,map(float,probs))) #float because gradio doesnt take tensors | |
image = gr.inputs.Image(shape=(192,192)) | |
label = gr.outputs.Label() | |
examples = ['human_weapon1.jpg','weapon22.jpg'] | |
intf = gr.Interface(fn = classify_image,inputs = image,outputs=label,examples=examples) | |
intf.launch(inline = False) |