Today was a productive day. The key lesson: the models learn best from exactly the kind of images they will see in real use - and I now have plenty of those, because every pile photographed on the phone and checked by hand becomes training material.
Segmentation: whole photos instead of single cut-outs
The first stage of the pipeline finds the bricks in the photo and separates them pixel by pixel. Until now, retraining used cut-outs showing exactly one brick each. The training metric even looked good, but in practice the model collapsed: it learned "the image is a brick" and drew large boxes around whole groups of parts on real piles.
Now I export every checked pile as whole photos with all bricks marked - in the first run 90 photos with around 2,000 parts, with three piles held back as a test set. Measured against the manual correction:
- Recall (bricks found): 86 % → 99 %
- Precision (hits without false detections): 91 % → 94 %
- Boxes spanning several parts: 3 → 1
On top of that, the app now processes the photos at a higher resolution (640 instead of 512 px). With both changes it reaches 96.5 % recall on the phone, with practically no false detections. The price is runtime: 16 to 22 seconds per photo on a mid-range phone. There is still work to do here.
Recognition: real cut-outs as reference examples
The second stage determines which part exactly it is. Each cut-out is turned into a feature vector and compared against a catalogue. Since yesterday the phone has been running a retrained recognition model. Today I also added every cut-out from checked piles to the training and to the catalogue. The catalogue now holds around 13,000 entries, roughly a quarter of them real photos and the rest rendered views.
On four test piles that were never part of the training (222 individual views, 81 bricks):
- base model: 77 % per view, 83 % per brick
- retrained (yesterday): 88 % per view, 89 % per brick
- retrained (today): 89 % per view, 93 % per brick
Most of the gain comes from the real examples in the catalogue, not from the training itself. To be fair, I have to add one caveat: the test piles consisted of the same physical bricks as some of the catalogue examples. With completely new parts the gain will be smaller.
Cleaning up the parts catalogue
The error analysis showed that some of the apparent misrecognitions were caused by inconsistencies in the parts catalogue. A few parts are listed there under two numbers because they were renamed or merged over time. In these cases the app had identified the part correctly, but the evaluation counted the differing number as an error. Such aliases are now mapped consistently to one canonical number in the catalogue, the training and the evaluation.
Parts the app only knows from renders
The most exciting question of the day: what happens with parts for which there is not a single real photo? To find out I photographed three piles of gears. Results per brick:
- the two large gears: 16 out of 16 correct - from renders alone
- small gear and an inconspicuous little part: often mixed up with similar parts
- overall: 28 out of 43, and 41 out of 43 with real cut-outs from the other two piles
So distinctive parts can already be recognised from renders alone. Small and similar parts need real photos.
Tools
The tool on my PC that I use to correct the phone photos now uses the same recognition as the app: 88 % instead of 47 % correct suggestions per view. It also rebuilds the app's catalogue at the push of a button whenever new checked piles or new parts come in.
Next steps
Cut the runtime on the phone, test recognition on a completely new set of parts, and teach the app to tell me while taking photos when the distance is right and there is enough light.