File size: 458 Bytes
e8eab24
9b678af
 
3156679
9b678af
3156679
9b678af
f953b0c
9b678af
3156679
9b678af
 
9a6f531
3156679
c0f7da9
9b678af
213c1f3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from fastai.vision.all import *
import gradio as gr

learn=load_learner("model.pkl")

labels=learn.dls.vocab
def sample_predict(img):
    print(img)
    img = PILImage.create(img)
    pred,pred_idx,probs=learn.predict(img)
    return {labels[i]: float(probs[i]) for i in range(len(labels))}

intf=gr.Interface(fn=sample_predict, 
                  inputs=gr.components.Image(shape=(256, 256)), 
                  outputs=gr.components.Label())

intf.launch()