Smart Waste Segregator: model weights
Weights for the Smart Waste Segregator, a Raspberry Pi bin that classifies incoming trash and sorts it with a dual-flap servo mechanism.
Code, notebooks and evaluation artifacts: https://github.com/divyanshuklai/smart-waste-segregator
Contents
mobilenetv3-small/
best_model.pth 18.5 MB trained PyTorch checkpoint
waste_classifier.onnx 6.1 MB ONNX export, this is what runs on the Pi
yolo11/
yolo11n.pt 5.6 MB detection weights
yolo11n-cls.pt 5.8 MB classification weights
yolo11n.torchscript 11.1 MB TorchScript export
yolo11n-cls.torchscript 11.5 MB TorchScript export
yolo11n_ncnn_model/ NCNN export (model.ncnn.bin, .param, model_ncnn.py, metadata.yaml)
yolo11n-cls_ncnn_model/ NCNN export
MobileNetV3-Small classifier
The shipped model is MobileNetV3-Small, not MobileNetV2. A MobileNetV2 was trained
as a separate experiment but did not ship. The checkpoint here has squeeze-and-excite
blocks and the ONNX graph contains 28 HardSigmoid nodes, both of which identify it
as V3-Small.
Classes, in the order the shipped weights expect:
0 metal
1 plastic
2 glass
3 biodegradable
Training
| Best validation accuracy | 91.63% (epoch 9 of 10) |
| Train accuracy that epoch | 98.15% |
| Optimizer | Adam, lr 1e-3 |
| Dataset | 6,571 images, four classes grouped from 8 source folders |
| Split | 5,256 train / 1,315 validation |
| PyTorch | 2.4.1 |
A second run in the same notebook used 20 epochs, 165 batches per epoch, OneCycleLR,
early stopping with patience 5, and heavier augmentation. Per-epoch numbers were not saved.
ONNX export
| Opset | 11 |
| Input | (1, 3, 224, 224) NCHW float32, dynamic batch axis |
| Output | (1, 4) |
| Constant folding | on |
| Parity vs PyTorch | rtol=1e-3, atol=1e-5 |
On-device inference uses onnxruntime with CPUExecutionProvider,
GraphOptimizationLevel.ORT_ENABLE_ALL and intra_op_num_threads = 4. Images are
captured with libcamera-still at 2592x1944, converted BGR to RGB with OpenCV and
resized to 224x224.
import onnxruntime, numpy as np
opts = onnxruntime.SessionOptions()
opts.graph_optimization_level = onnxruntime.GraphOptimizationLevel.ORT_ENABLE_ALL
opts.intra_op_num_threads = 4
sess = onnxruntime.InferenceSession(
"mobilenetv3-small/waste_classifier.onnx",
providers=["CPUExecutionProvider"],
sess_options=opts,
)
x = np.random.rand(1, 3, 224, 224).astype(np.float32)
logits = sess.run(None, {sess.get_inputs()[0].name: x})[0]
print(["metal", "plastic", "glass", "biodegradable"][int(logits.argmax())])
YOLO11 edge exports
A later pass exporting YOLO11n to formats that run on constrained hardware.
| Parameters (yolo11n-cls) | 2,807,024 |
| FLOPs | 4.2 G |
| Fused layers | 47 |
| TorchScript size | 10.9 MB |
| NCNN size | 10.7 MB |
| Ultralytics | 8.3.82 |
| torch | 2.6.0 |
NCNN classifier timing on the bus.jpg sample: 124.0 ms inference, 78.8 ms
preprocess, 1.3 ms postprocess.
Limitations
Read these before using the weights for anything.
- Real-world performance is poor. The training data came from public waste datasets whose images do not resemble real waste in a real bin.
- There is no valid test number. The 91.63% is validation accuracy measured on the same biased distribution the model trained on.
- The test notebook's 2.75% accuracy is a bug, not a result. It reads raw indices
from a six-class YOLO label set (
BIODEGRADABLE, CARDBOARD, GLASS, METAL, PAPER, PLASTIC), drops every index >= 4, which discards 860 of 1,042 images, then reads the surviving indices against a different four-class list. The large off-diagonal count in the repository's confusion matrix is that mismapping, not model error. - Three class orderings exist across the source repository. The order given above is
the one the shipped weights expect. The Pi runtime script
smart_waste_segregation.pyuses['plastic', 'paper', 'metal', 'glass'], which is wrong for the model it loads, so the device printed mislabelled class names. This is documented rather than silently corrected. - The YOLO11 weights are stock Ultralytics checkpoints and their exports. They were not fine-tuned on waste data.
Citation
Divyansh Shukla, 2024-2025. Smart Waste Segregator.