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

model = load_learner('model.pkl')
labels = model.dls.vocab

def predict(img):
    pred, pred_idex, probs = model.predict(img)
    return {labels[i] : float(probs[i]) for i in range(len(labels))}

ip = gr.Image(type="pil")
op = gr.Label(num_top_classes=10)

interface = gr.Interface(fn=predict, inputs=ip, outputs=op)
interface.launch()