Spaces:
Runtime error
Runtime error
Download app.py from sheteentz/ImageClassifier: direct link, hf CLI and curl.
- Browser
- Download file 609 Bytes
-
https://huggingface.co/spaces/sheteentz/ImageClassifier/resolve/main/app.py
- Command line
-
hf download hf://spaces/sheteentz/ImageClassifier/app.py
-
curl -L -o app.py https://huggingface.co/spaces/sheteentz/ImageClassifier/resolve/main/app.py
609 Bytes
| from fastai.vision.all import * | |
| import gradio as gr | |
| import skimage | |
| learn = load_learner('model.pkl') | |
| labels = learn.dls.vocab | |
| def classify_image(img): | |
| img = PILImage.create(img) | |
| pred,pred_idx,probs = learn.predict(img) | |
| return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
| image = gr.inputs.Image(shape=(192,192)) | |
| label = gr.outputs.Label() | |
| examples = ['grizzly bear.png', 'black bear.png', 'teddy bear.png'] | |
| demo = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, title="Image Classifier", description="Upload an image to classify it.") | |
| demo.launch() | |