File size: 642 Bytes
58d86aa | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | from fastai.vision.all import *
from huggingface_hub import hf_hub_download
import gradio as gr
# Modell aus HuggingFace Model-Repo laden
model_path = hf_hub_download(repo_id="Gesetz13/bear-model", filename="bears_cleaned.pkl")
learn = load_learner(model_path)
categories = ['Black', 'Grizzly', 'Teddy']
def classify_image(img):
pred, idx, probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
image = gr.Image(type="pil")
label = gr.Label()
examples = ['black.jpg', 'teddy.jpg', 'grizzly.jpg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False)
|