File size: 539 Bytes
d999716
370a91d
 
 
 
f22b93e
d999716
f22b93e
370a91d
f22b93e
 
d999716
f22b93e
370a91d
f22b93e
 
ecefea5
 
f22b93e
 
 
370a91d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from fastai.vision.all import load_learner


def label_func(fn:str): 
    return fn[0].isupper()

model = load_learner('./model.pkl')

import gradio as gr
categories = ('dog', 'cat')
def image_classifier(input): 
    pred, idx, probs = model.predict(input) 
    result = dict(zip(categories, map(float, probs)))
    print('result', result)
    return result



gr.Interface(fn=image_classifier,
             inputs=gr.Image(type="pil"),
             outputs=gr.Label(),
             examples=['./cat.jpeg', './dog.jpg']).launch(share=True)