what-the-fruit / app.py
NLTuan's picture
again???
58de492
raw
history blame contribute delete
467 Bytes
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()