classfify_breed / app.py
AlexLinh12's picture
initial commit
9184687
raw
history blame
573 Bytes
from fastai.vision.all import *
import gradio as gr
learn = load_learner('export.pkl')
labels = learn.dls.vocab
def predict(img):
img = PILImage.create(img)
pred,pred_idx,probs = learn.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
gr.Interface(
fn=predict,
inputs=gr.Image(type="pil", image_mode="RGB", height=512, width=512, sources=["upload"]),
outputs=gr.Label(num_top_classes=3),
title="Image Classifier",
description="Upload an image; the app resizes to 512Γ—512 inside predict()."
).launch(share=True)