Work 12 / 18
Finding the four corners of a bin
An HRNet model that finds the four corners of a waste container in a camera frame, so the fill-level pipeline can crop to the bin.
- April model on a new camera
- AP 0.010
- No fine-tuning
- After a 20-epoch fine-tune
- AP 1.000
- 15 validation images
- Validation sets
- 5–25 images
- Treat AP 1.0 with care
- Archived runs
- 14
- Each with checkpoint, ONNX export and dataset snapshot
What it does
The model is HRNet-W32 with a four-channel heatmap head, exported to ONNX (about 114 MB) with the preprocessing and heatmap decoding rewritten in NumPy. I trained it for three camera fleets. The project keeps 14 archived runs, each with its checkpoint, ONNX export, dataset snapshot and manifest.
Bugs I found
- Horizontal flip augmentation was on with no swap indices, so flipped images kept their left and right corner labels. On the deployed model the first corner’s x position only ever moved between 658 and 694 pixels.
- An augmentation called RandomHalfBody had been copied through four client configs. It needs 11 keypoints to fire and this model has 4, so it had never run.
- I spent a sweep on input sizes before finding that the real variable was how the crop was centred on the bounding box.
How to read the score
Validation AP is between 0.95 and 1.00 on the best runs. Those validation sets hold 5 to 25 images, so 1.00 means every corner was within tolerance on a handful of images.
The more useful number is the transfer test: my April model scored AP 0.010 on a camera it had never seen. After a 20-epoch fine-tune on 285 images from that camera it scored 1.000 on 15 validation images. So the pipeline retrains for each camera fleet.
I saw the same thing when I ran the model on public photos of bins for this page. Its strongest heatmap peaks were between 0.01 and 0.07, so it found no corners at all. That is why this page has a diagram and no model output.
- Camera frameOne fixed camera per bin
- HRNet-W32Four heatmaps, one per corner
- Decode peaksRewritten in NumPy, no MMPose at run time
- Crop to the binHanded to the fill-level stage
From the run log
kp.01Flip augmentation with no swap indicesConstant predictionsKilled
Setup: Horizontal flip p = 0.5, flip indices left as identity
All four legacy configs flipped the image and left the corner labels where they were. The model collapsed: on the deployed ONNX the first corner’s x only moved between 658 and 694 pixels across completely different scenes. It had shipped before anyone noticed.
kp.07RandomHalfBody: an augmentation that never ranNever executedKilled
Setup: 4 keypoints, all marked as upper body
Inherited from a human-pose config. It needs 11 keypoints in total and 8 in a half to trigger, and this model has 4. It had been configured, committed and carried across four client configs without running once. I removed it.
kp.08April model on a new cameraAP 0.010 (AP@0.5 0.104)Finding
Setup: April checkpoint on the new camera’s set (285 training, 15 validation images), no fine-tuning
A model trained on other camera fleets scored AP 0.010 on a camera it had never seen. This is the number that explains why the pipeline has one model per fleet.
kp.09Fine-tune on the new cameraAP 1.000 on 15 validation imagesFinding
Setup: 20 epochs on an RTX 3090, 285 training images
A fresh 20-epoch fine-tune on that camera’s data brought AP back to 1.000. With 15 validation images, that means every corner was within tolerance on those 15.
Tools
MMPose, HRNet-W32, ONNX Runtime, NumPy.
The full write-up
There is a longer write-up of this project. It has client details in it, so email me if you’d like a redacted copy.