File size: 522 Bytes
e0a6772
 
 
 
 
 
 
d2e57c6
e0a6772
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from fastai.vision.all import *
import gradio as gr

learn = load_learner('construction_things.pkl')

def classify_image(img):
    pred,idx,probs = learn.predict(img)
    return dict(zip(['construction boots', 'construction gloves', 'f150', 'hammer', 'hard hat', 'safety glasses', 'screw driver'],map(float,probs)))
    
image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
interface = gr.Interface(fn=classify_image,inputs=image,outputs=label)
# interface.launch(inline=True)
interface.launch(inline=False)