Spaces:
Runtime error
Runtime error
Download app.py from CitizenDick/minima: direct link, hf CLI and curl.
- Browser
- Download file 536 Bytes
-
https://huggingface.co/spaces/CitizenDick/minima/resolve/main/app.py
- Command line
-
hf download hf://spaces/CitizenDick/minima/app.py
-
curl -L -o app.py https://huggingface.co/spaces/CitizenDick/minima/resolve/main/app.py
536 Bytes
| import gradio as gr | |
| from fastai.vision.all import * | |
| import PIL | |
| def is_cat(x): return x[0].isupper() | |
| learned = load_learner('model.pkl') | |
| labels = learned.dls.vocab | |
| def predict (img): | |
| img = PILImage.create(img) | |
| pred, pred_idx, probs = learned.predict(img) | |
| return dict(zip(labels, map(float, probs))) | |
| title = "Cat Predictor" | |
| examples= ["tabby.jpg"] | |
| iface = gr.Interface(fn=predict, title=title, examples=examples, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)) | |
| iface.launch(debug=True) |