Spaces:
Runtime error
Runtime error
Gu Andres
Merge branch 'main' of https://huggingface.co/spaces/Robotanica/trashsort into main
a2fbe82 Download app.py from Robotanica/trashsort: direct link, hf CLI and curl.
- Browser
- Download file 811 Bytes
-
https://huggingface.co/spaces/Robotanica/trashsort/resolve/main/app.py
- Command line
-
hf download hf://spaces/Robotanica/trashsort/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Robotanica/trashsort/resolve/main/app.py
811 Bytes
| from fastbook import * | |
| from fastai.vision.widgets import * | |
| import gradio as gr | |
| path = Path() | |
| learn = load_learner('trashsort.pkl') | |
| categories = ("Aluminium foil","Battery","Blister pack","Bottle","Bottle cap","Broken glass","Can","Carton","Cigarette","Cup","Food waste","Glass jar","Lid","Other plastic","Paper","Paper bag","Plastic bag & wrapper","Plastic container","Plastic gloves") | |
| def classify_image(img): | |
| pred,idx,probs = learn.predict(img) | |
| return dict(zip(categories, map(float,probs))) | |
| #image = gr.inputs.Image(shape=(192, 192)) | |
| image = gr.Image(source="webcam", streaming=True) | |
| label = gr.outputs.Label() | |
| intf= gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=[]) | |
| intf.launch(inline=False) | |
| #iface = gr.Interface(fn=greet, inputs="text", outputs="text") | |
| #iface.launch() | |