Download app.py from Gesetz13/MBears: direct link, hf CLI and curl.
- Browser
- Download file 642 Bytes
-
https://huggingface.co/spaces/Gesetz13/MBears/resolve/main/app.py
- Command line
-
hf download hf://spaces/Gesetz13/MBears/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Gesetz13/MBears/resolve/main/app.py
642 Bytes
| 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) | |