Baking Soda Bread and Training a Food Classifier in the Cork Campus Kitchen

Monday night, 11 PM. While the loss curve was plotting on my laptop screen, the oven timer went off. I pulled the loaf out and flipped it over. The bottom was slightly burned. On the terminal, validation accuracy read 0.43. Both were too ambiguous to call failures, yet too poor to call successes. The entire week had been like that.

Monday, Tuesday: The Dataset Swamp

As a side project during the semester, I decided to build a CNN model that classifies images of Irish food. The plan was to collect photos of traditional dishes like coddle, boxty, colcannon, and black pudding and train the model on them. The problem was the dataset. There was no decent publicly available Irish food dataset, so I had to gather the data myself. I ran a web scraping script all day Monday, but nearly half the images I collected were unusable. Some had watermarks, some were too low-resolution, and some had completely different potato dishes labelled as colcannon.

On Tuesday, I cleaned the data by hand. I kept checking mislabelled images one by one, making calls like "Is this colcannon or champ?" over and over. Ironically, I was doing the exact task I wanted the model to do, hundreds of times over. The number of images per class was uneven, with boxty being especially scarce, and I had no sense of how much augmentation could compensate. I was working with earphones in on the second floor of the UCC library, and before I knew it, the sun had set.

Wednesday: First Bread, First Model

Wednesday morning, I decided to bake some soda bread to clear my head. The ingredients are simple: wholemeal flour, plain flour, buttermilk, baking soda, and salt. Since there's no yeast, there's no rising time, and over-kneading the dough actually makes it tough. You just mix it lightly, score a cross on top, and put it in the oven. The kitchen in my campus accommodation is so small that a single cutting board fills the entire counter, but soda bread works even in that cramped space.

Forty minutes in the oven. In the meantime, I set up the model architecture in PyTorch. I went with transfer learning based on ResNet18, swapping out only the final fully connected layer. Training from scratch was out of the question; I simply didn't have enough data. The bread finished baking while the first training run was going. The outside looked fine, but when I cut it open, the centre was soggy. I think I used too much buttermilk. The model's first results were similar. The loss was going down, but accuracy couldn't break past 0.5. Signs of overfitting were already showing.

A halved soda bread with a doughy center sits next to a laptop showing model training progress

Thursday, Friday: The Fine-Tuning Cycle

Thursday, I spent the entire day tweaking hyperparameters. I lowered the learning rate from 0.001 to 0.0001 and added random rotation and colour jitter to the data augmentation pipeline. I set it running in the lab after class and checked in the evening. Accuracy had climbed to 0.61. The confusion between boxty and colcannon was still bad. They're both potato-based and look similar when plated, so it was only natural for the model to mix them up.

Friday morning, I baked soda bread again. This time I used a bit less buttermilk and consciously reduced the number of times I mixed the dough. The result was noticeably better. Crispy on the outside, fluffy on the inside, with that slight springiness when you press a knife into it. It tasted rich and savoury even without butter. One thing I've learned living in Cork: soda bread is best eaten hot, right out of the oven. Once it cools, the texture changes completely.

In the afternoon, I gave the model another pass. Looking at the confusion matrix, it was classifying black pudding almost perfectly; its colour is just that distinctive. On the other hand, distinguishing shepherd's pie from cottage pie was virtually impossible, and even a person would often struggle to tell them apart from photos alone. In the end, I decided to merge the two classes. Acknowledging the model's limitations is part of the design process, something this project reminded me of once again.

Saturday: English Market

On Saturday, I went to the English Market. I'd gone to buy things to go with the soda bread, but I ended up standing in front of the cheese shop for ages. Gubbeen cheese was about 4 euros per 100g. I also bought a pack of smoked salmon. As I wandered through the market, I kept thinking about the project. It occurred to me that I should take some photos of the food on display and add them to the dataset, so I actually stopped at each stall and took pictures from various angles. One shop owner asked what I was doing, and when I said I was building an AI that recognises Irish food, he laughed and told me to take a photo of his sausages too.

The English Market in Cork with food stalls displaying cheese and cured meats under a glass roof

Back home, I preprocessed the photos from the market and added them to the dataset. Since the lighting and backgrounds of photos I took myself were different from the images scraped off the web, I expected them to actually help with model generalisation. I kicked off retraining that night.

Sunday: 0.74, and the Third Loaf

The accuracy I checked Sunday morning was 0.74. Considering I'd started at 0.43 a week ago, it had come a long way. It still wasn't good enough for real-world use, but since the goal of this project was the learning process itself rather than production deployment, I was satisfied.

In the afternoon, I baked soda bread one more time. This time I sprinkled oats on top. I broke the bread fresh from the oven and ate it topped with the smoked salmon and cream cheese I'd bought at the market. That might have been the best moment of the whole week.

Looking back, the CNN and the soda bread went through remarkably similar processes. Both produced terrible results at first, and both improved little by little as I changed one variable at a time. Neither needed to turn out perfect. Bread can be a bit ugly as long as it tastes good, and a model can still do meaningful classification even if you have to merge a few classes. The patience needed to accept imperfect results uses the same muscle, whether you're standing in front of code or in front of an oven.

Next week, I'm planning to use Grad-CAM to visualise what parts of the image the model is looking at when it makes decisions. And I'm going to try adding raisins to the soda bread, a variation called spotted dog that I've never made before.

Comments