Spaces:
Runtime error
Runtime error
File size: 575 Bytes
f4ba9fe a552536 f4ba9fe a552536 f4ba9fe a552536 f4ba9fe |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import gradio as gr
from fastai.vision.all import *
from duckduckgo_search import ddg_images
from pathlib import Path
examples = [i for i in Path("./examples").glob("*")]
categories = ["great white", "lemon", "thresher", "whale", "zebra"]
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, examples = examples)
iface.launch() |