Download app.py from bijaydu/notebooks: direct link, hf CLI and curl.
- Browser
- Download file 792 Bytes
-
https://huggingface.co/spaces/bijaydu/notebooks/resolve/main/app.py
- Command line
-
hf download hf://spaces/bijaydu/notebooks/app.py
-
curl -L -o app.py https://huggingface.co/spaces/bijaydu/notebooks/resolve/main/app.py
792 Bytes
| import gradio as gr | |
| from fastai.vision.all import * | |
| learn_shiva=load_learner('spotter.pkl') | |
| labels = learn_shiva.dls.vocab | |
| def predict(img): | |
| img = PILImage.create(img) | |
| pred,pred_idx,probs = learn_shiva.predict(img) | |
| return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
| title = "Shiva Spotter" | |
| description = "A Shiva Finder classifier trained on the duckduckgo image search with fastai. Created as a demo for Gradio and HuggingFace Spaces." | |
| article="<p style='text-align: center'><a href='https://github.com/dulBijay/shivaSpotter' target='_blank'>Git Repo</a></p>" | |
| examples = ['shiva.jpg'] | |
| thumbnail = 'shiva.jpg' | |
| gr.Interface(fn=predict,inputs="image",outputs="label",title=title,description=description,article=article,examples=examples,thumbnail=thumbnail).launch() | |