File size: 703 Bytes
98b6bde
 
 
0f69abe
98b6bde
 
 
06cd147
 
98b6bde
 
 
 
 
 
 
 
 
 
 
06cd147
98b6bde
0f69abe
f829721
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# AUTOGENERATED! DO NOT EDIT! File to edit: is_a_cat.ipynb.

# %% auto 0
__all__ = ['learn', 'labels', 'examples', 'is_cat', 'predict']

# %% is_a_cat.ipynb 1
from fastai.vision.all import *
import gradio as gr

def is_cat(x): return x[0].isupper() 

# %% is_a_cat.ipynb 2
learn = load_learner('model.pkl')

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

# %% is_a_cat.ipynb 4
examples = ["example1.webp","example2.webp","example3.webp"]
    
gr.Interface(fn=predict, inputs="image", examples=examples, outputs="label").launch(share=False)