← All projects

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
GitHub ↗

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

  1. Loaded the 75,000 images and split them into training, validation and test sets.
  2. Transfer learning: used a pretrained MobileNetV2 as a feature extractor and trained a classifier on top for 10 epochs.
  3. Custom CNN: designed a smaller network from scratch, improving on a first baseline version, and trained it for 10 epochs.
  4. 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.

Confusion matrix for the five rice varieties, with nearly every test image on the diagonal.
Custom CNN test results. Almost every grain lands on the diagonal.

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

View code on GitHub ↗