Spaces:
Build error
Build error
Download app.py from NataCalc/minimaModel: direct link, hf CLI and curl.
- Browser
- Download file 630 Bytes
-
https://huggingface.co/spaces/NataCalc/minimaModel/resolve/main/app.py
- Command line
-
hf download hf://spaces/NataCalc/minimaModel/app.py
-
curl -L -o app.py https://huggingface.co/spaces/NataCalc/minimaModel/resolve/main/app.py
630 Bytes
| #/export | |
| from fastai.vision.all import * | |
| import gradio as gr | |
| def is_cat(x): | |
| return x[0].isupper() | |
| #/export | |
| learn=load_learner('model.pkl') | |
| #/export | |
| categories=('Dog','Cat') | |
| def classify_image(img): | |
| img=img.resize((192,192)) | |
| pred,idx,probs=learn.predict(img) | |
| return dict(zip(categories,map(float,probs))) | |
| #/export | |
| image=gr.Image(type='pil',label='Upload Image') | |
| label=gr.Label() | |
| #Example images for testing | |
| examples=['dog.jpg','cat.jpg','dunno.jpg'] | |
| intf=gr.Interface( | |
| fn=classify_image, | |
| inputs=image, | |
| outputs=label, | |
| examples=examples) | |
| #Launch the interface | |
| intf.launch(inline=False) | |