File size: 467 Bytes
56f2be3
58de492
 
56f2be3
58de492
 
 
 
 
 
 
 
 
56f2be3
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import gradio as gr
from fastai.vision.all import *
from pathlib import Path

learn = load_learner("model.pkl")
labels = learn.dls.vocab
def predict(img):
    pred, idx, probs = learn.predict(PILImage.create(img))
    return {labels[i]: float(probs[i]) for i,_ in enumerate(probs)}

examples = list(map(str, get_image_files(Path(""), recurse=False)))
print(examples)
iface = gr.Interface(fn=predict, inputs="image", outputs="label", examples=examples)

iface.launch()