CV · Data science project
Rice Variety Detection
Identifying five rice varieties from a photo of one grain
- Custom CNN, test accuracy
- 99.53%
- MobileNetV2, test accuracy
- 98.31%
- Grain images
- 75,000
The problem
Tell Arborio, Basmati, Ipsala, Jasmine and Karacadag rice apart from a photo of a single grain. The differences are small changes in shape and texture. The project also asks whether a network built for this job can beat a large pretrained one.
The data
Rice image dataset, included in the repo
75,000 photos of single grains across 5 varieties, split into training, validation and test sets
Approach
- Loaded the 75,000 images and split them into training, validation and test sets.
- Transfer learning: used a pretrained MobileNetV2 as a feature extractor and trained a classifier on top for 10 epochs.
- Custom CNN: designed a smaller network from scratch, improving on a first baseline version, and trained it for 10 epochs.
- Compared both on the held-out test set with confusion matrices.
Results
The custom CNN reached 99.53% test accuracy and beat transfer learning with MobileNetV2 (98.31%). Its most common mistake is Karacadag grains read as Arborio: 18 out of 1,522.

What I'd do next
- Fine-tune more of MobileNetV2's layers at a lower learning rate to close the gap.
- Test on photos taken with different lighting and cameras before relying on it in the real world.
Tools
- Python
- TensorFlow
- Keras
- scikit-learn
- NumPy
- matplotlib
