|
import gradio as gr |
|
from fastai.vision.all import * |
|
|
|
learn = load_learner("export.pkl") |
|
|
|
labels = learn.dls.vocab |
|
|
|
|
|
def predict(img): |
|
img = PILImage.create(img) |
|
_, _, probs = learn.predict(img) |
|
return {labels[i]: float(probs[i]) for i in range(len(labels))} |
|
|
|
gr.Interface( |
|
fn=predict, |
|
inputs=gr.components.Image(shape=(400, 400)), |
|
outputs=gr.components.Label(num_top_classes=2), |
|
title="Does my sighthound have a corn?", |
|
description="Given a picture of a paw, does it have a corn?", |
|
examples=[ |
|
"corn_01.jpg", |
|
"corn_02.jpg", |
|
"corn_03.jpg", |
|
"no_corn_01.jpg", |
|
"no_corn_02.jpg", |
|
], |
|
).launch(enable_queue=True) |
|
|