devseek's picture
resolving errors
33ddabb
raw
history blame contribute delete
494 Bytes
import gradio as gr
from fastbook import *
from fastai.vision.widgets import *
import timm
categories = ['accident' , 'non-accident']
learn = load_learner('model.pkl')
def classify(img):
category,index,probs = learn.predict(img)
return (dict(zip(categories , map(float,probs))))
img = gr.inputs.Image(shape=(224))
label = gr.outputs.Label()
example = ['accident.jpg' , 'non-accident.jpg']
iface = gr.Interface(fn=classify, inputs="image", outputs="label" , examples= example)
iface.launch()