Who_is_he / app.py
DanielV
updated app (3)
c4849ec
raw
history blame
729 Bytes
from fastai.vision import *
from fastai.learner import load_learner
from PIL import Image
import gradio as gr
from pathlib import Path
learn = load_learner(Path("model.pkl"))
categories = list(learn.dls.vocab)
def classify_image(img):
pred, ix, probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
# Whats the gradio input type? Image
image = gr.inputs.Image(shape=(192,192))
# Whats the gradio output type? Label
label = gr.outputs.Label()
# Set up some examples
examples = [Path("examples/kairi.jpg"), Path("examples/riku.jpg"), Path("examples/sora.jpg")]
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False)