Spaces:
Build error
Build error
Download app.py from LDKien/HelloWorld: direct link, hf CLI and curl.
- Browser
- Download file 700 Bytes
-
https://huggingface.co/spaces/LDKien/HelloWorld/resolve/main/app.py
- Command line
-
hf download hf://spaces/LDKien/HelloWorld/app.py
-
curl -L -o app.py https://huggingface.co/spaces/LDKien/HelloWorld/resolve/main/app.py
700 Bytes
| # AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb. | |
| # %% auto 0 | |
| __all__ = ['learn', 'catergories', 'image', 'label', 'examples', 'is_cat', 'classify_image'] | |
| # %% app.ipynb 3 | |
| from fastai.vision.all import * | |
| import gradio as gr | |
| def is_cat(x): return x[0].isupper() | |
| # %% app.ipynb 5 | |
| learn = load_learner('model.pkl') | |
| # %% app.ipynb 7 | |
| catergories = ('Dog', 'Cat') | |
| def classify_image(img): | |
| pred,idx,probs = learn.predict(img) | |
| return dict(zip(catergories, map(float, probs))) | |
| # %% app.ipynb 9 | |
| image = gr.Image(height=192, width=192) | |
| label = gr.Label() | |
| examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg'] | |
| gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples).launch() | |