Object detection, bread and bubbles

How many bubbles can you count?

Posted by Gregor Tätzner


This is a short story about my tries to detect the fermentation progress of my sourdough.

For reference, at the beginning it looks kinda dead like this: Dough start

But after some hours it will be very bubbly: Dough finish

The Model

So can I train a model to somehow count the bubbles? Lets try with YOLOv8! I took a couple of images and annotated all bubbles in Roboflow. Very tedious work! The data set consists only of 4 images, but anyway lets give it a try: Roboflow data set

The preview created by roboflow doesnt look too bad: Preview roboflow

The tool also provides easy export options for the yolo data format. You can find some code on my bread model repository. There are several scripts to train a new yolov8 model with the data set and predict results on provided source images. My default model trains 100 epochs and uses the medium yolov8 pretrained model. I also decided to grayscale all images and add some augmentations to generate more variety. Lets see the results of the training run: Train batch 0

The red markers are detected bubbles. Will it also work with a new image outside the training set?

Predict bubbles 1

Yay some bubbles! It also highlights the bigger holes. We get slightly weird results with this top view without bubbles, also a perspective we didnt train:

Top no bubbles

And finish with a fresh starter without bubbles:

Side no bubbles

There are 3 labels in the background, the dark patches are mistaken with bubbles. But inside the glass there are no false positives.

Verdict

For my first try and this minimal data set I’m quite happy. Lets see if I can find another way to create a more robust model without annotating hundreds of images!