File size: 495 Bytes
799709b
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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()