Mondelez: X-ray AI that found over 85% of hazelnut shell fragments in chocolate
Mondelez makes chocolate with whole and chopped hazelnuts. A fragment of shell left in a bar is a hard foreign body a customer can bite on. Mondelez asked us whether AI could find it on X-ray images of the finished product.

shell fragments found by the first models
X-ray images the first model was trained on
detection expected once the models get more data
The challenge
Metal and glass stand out on an X-ray image. A piece of hazelnut shell does not: it is organic, like the nut and the chocolate around it, so it shows as a faint difference in a busy image.
That is where fixed thresholds in a standard X-ray machine struggle, and where a model trained on images of the product itself has a chance.
What we did
- Samples of chocolate with hazelnuts, some with shell fragments, scanned in an X-ray lab in 2024.
- A first model trained on 15 X-ray images.
Results
- The first models found over 85% of the shell fragments, from a training set of 15 images.
- With more images of real defects, our forecast is detection well above 95%.
How a test works
You send samples, including some with the defect you want to catch. We scan them, label the images and train a model, then report what it found and what it missed, before anything is installed on a line. That is the first step of a two-week proof of concept.
When the real defect is rare, generated images can stretch a small real set, as we explain in synthetic data for rare defects.