NLTuan's picture
first added
a126d2e
raw
history blame
432 Bytes
import gradio as gr
from fastai.vision.all import *
categories = ["great white", "zebra", "whale", "lemon", "thresher"]
learner = load_learner("shark_recognizer.pkl")
def recognize_shark(img):
pred, idx, probs = learner.predict(img)
return dict(zip(categories, map(float, probs)))
image = gr.inputs.Image()
label = gr.outputs.Label()
iface = gr.Interface(fn=recognize_shark, inputs=image, outputs=label)
iface.launch()