Personal project · 2026
CNN Architecture Comparison
The small model tied the big one at a fifth of the size.
Three image classifiers trained the same way on 120,842 fruit and vegetable photos, to pick the one my SnapShelf research would build on.
- Stack
- Python, TensorFlow, Keras, scikit-learn, Google Colab
- Dataset
- 120,842 images, 14 classes
- Research
- BSc dissertation, Anglia Ruskin
Why it matters
Bigger image models usually score higher, but they cost more to store and run, and on a phone that matters. This was the first of two experiments in my BSc dissertation at Anglia Ruskin, the research behind SnapShelf. Its job was to choose the classifier for the second, where a detector finds each item in a kitchen photo and the classifier names it.
How it works
Kaggle datasets
Three sources, merged
fruit and vegetables
163,316 images
Hashing
Drops every exact copy
SHA-256
- 42,474 copies removed
- 9,263 across sources
120,842 unique
Split
By class, no copy in two splits
70/15/15 · class weights
18,141 test images
Custom CNN
Built from scratch
4.96M params · 56.9 MB
98.34%
EfficientNetB0
Pretrained, tuned in two phases
4.07M params · 40.0 MB
99.75%
ResNet‑50
Pretrained, tuned in two phases
24.13M params · 211.0 MB
99.77%
Choice
A tie on accuracy, so size decides
Wilson 95% intervals
- intervals overlap
- smallest model
EfficientNetB0 selected
Decisions I made
Remove duplicates before splitting
The three Kaggle sets overlapped, and a random split would have put copies of training images in the test set and inflated the score. I hashed every file with SHA-256 and removed 42,474 exact duplicates, 9,263 of them across sources, before splitting by class.
Trade-off. Hashing only catches identical files. Most images are video frames of one fruit turning on a white background, so near-identical frames still sit on both sides of the split, and 99.7% is optimistic.
A bigger test set for the rare classes
Apples outnumbered carrots 113 to 1. I split 70/15/15 instead of the usual 80/10/10, so even the smallest classes had enough validation and test images for a reliable F1 score, and weighted the classes in training to balance them.
Trade-off. Ten percent of the images moved from training to validation and test. And it is one split with one seed: cross-validation would have been tighter, but it costs five times the compute, too much for a Colab budget.
Pick on size when accuracy ties
ResNet-50 scored 99.77% and EfficientNetB0 99.75% on 18,141 test images, but their Wilson 95% intervals overlap, so the gap is not significant. EfficientNetB0 is 5.3 times smaller, 40 MB against 211 MB, which matters when it has to name every item a detector finds in a photo. The custom CNN, at 98.34%, was significantly behind both.
Trade-off. ResNet-50 trained faster, 8.1 hours against 11.0. And with most classes perfect for every model, the choice rests on four classes and a few dozen images.
What it isn't
A classifier ready for a real kitchen. The 99.75% was measured on clean studio images. In the second experiment, on real kitchen photos, the pipeline that used this model scored F1 0.547, the weakest of the three.
Results on 18,141 test images
| Model | Test accuracy | Parameters | Size | Training time |
|---|---|---|---|---|
| Custom CNN | 98.34% | 4.96M | 56.9 MB | about 24.8 h |
| EfficientNetB0 | 99.75% | 4.07M | 40.0 MB | 10.96 h |
| ResNet-50 | 99.77% | 24.13M | 211.0 MB | 8.13 h |
The full engineering is on GitHub.