File size: 494 Bytes
cc00492
bf22d26
 
 
409647d
48ed32b
bf22d26
409647d
 
bf22d26
 
33ddabb
 
7380f80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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()