from fastai.vision.all import * | |
import gradio as gr | |
learner = load_learner('export.pkl') | |
labels = learner.dls.vocab | |
def predict(inputImage): | |
image = PILImage.create(inputImage) | |
pred, pred_index, probs = learner.predict(image) | |
return dict(zip(labels, map(float,probs))) | |
interface = gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)) | |
interface.Launch() |