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)