minimal / app.py
zhongdj's picture
fix app
71a2079
raw
history blame contribute delete
419 Bytes
import gradio as gr
from fastai.vision.all import *
f = Path() / 'bamboo_or_butterfly.pkl'
learn_inf = load_learner(f)
def predict(img):
pred, pred_idx, probs = learn_inf.predict(img)
return f'Prediction: {pred}; Probability:{probs[pred_idx]:.04f}'
image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
iface = gr.Interface(fn=predict, inputs=image, outputs=label)
iface.launch(inline=False)