Spaces:
Sleeping
Sleeping
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() |