File size: 518 Bytes
c8523d1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e043434
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import timm
from fastai.vision.all import *
import gradio as gr


path = Path()
path
learn = load_learner('export.pkl')

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

title = "Chocolate Classifier"
interpretation='default'
enable_queue=True
gr.Interface(fn=roofpredict, inputs="image",  outputs="label",title=title).launch()