Download app.py from Rayzar142/Fishv2: direct link, hf CLI and curl.
- Browser
- Download file 577 Bytes
-
https://huggingface.co/spaces/Rayzar142/Fishv2/resolve/main/app.py
- Command line
-
hf download hf://spaces/Rayzar142/Fishv2/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Rayzar142/Fishv2/resolve/main/app.py
577 Bytes
| from fastai.vision.all import * | |
| import gradio as gr | |
| import pathlib | |
| learn = load_learner('sunfish_vs_perch.pkl') | |
| def predict(img): | |
| pred_class, pred_idx, outputs = learn.predict(img) | |
| return {learn.dls.vocab[i]: float(outputs[i]) for i in range(len(outputs))} | |
| demo = gr.Interface( | |
| fn=predict, | |
| inputs=gr.Image(type="pil"), | |
| outputs=gr.Label(num_top_classes=2), | |
| title="Sunfish vs Perch Classifier", | |
| description="Classify fish as Sunfish (Lepomis) or Perch (Perca) using fastai and ResNet18", | |
| examples=["sunfish.jpg", "perch.jpeg"] | |
| ) | |
| demo.launch() | |