See results
Festival of Ideas 2026 · UniMAP

RiceVision

Machine vision classification of rice milling fractions

Drag to rotate, pinch to zoom. Tap a part to see what it does.

Mask R-CNN on 143 validation images (8,541 kernels).

Developed at
Universiti Malaysia Perlis (UniMAP)
In collaboration with
BERNAS (Padiberas Nasional Berhad)

Faculty of Mechanical Engineering & Technology, UniMAP

01The problem

Milling checks are still sorted by hand

Mills check their huller and whitener performance with an in-plant milling test. A sample is sorted by hand into paddy, husk, brown rice, head rice and broken rice, and each fraction is weighed.

Time

Manual sorting is slow, so machine settings are corrected late.

Repeatability

Whether a kernel counts as whole or broken is decided by eye.

Resolution

The test gives totals only, with no length profile of broken kernels.

Milling line from intake to graded white rice, with test sampling points S1 to S5
Where the test samples come from: sampling points S1 to S5 along the milling line.
Rice self-sufficiency, Malaysia 68% → 56%

Malaysia's rice self-sufficiency level fell from 68% to 56% between 2018 and 2023 (MyCC, 2024).

02How it works

One capture. Every kernel graded.

  1. SpreadSpread the sample in a single layer on the backlight.
  2. CapturePress Capture in the phone browser.
  3. SegmentMask R-CNN outlines and classifies each kernel.
  4. ReportThe device measures each kernel and reports the count and share of each class.
Raw backlit image of a paddy tray The same tray with all 49 grains masked by Mask R-CNN Raw imageMask R-CNN masks

Drag the slider. A validation tray the model never trained on: all 49 labelled paddy grains found and classed correctly, with no false detections (Mask R-CNN, confidence 0.50).

03The device

A sealed box, a backlight and a camera

Grading runs on the device itself; a phone browser is the screen. Rotate it in 3D ↑

ComputerRaspberry Pi 5
CameraArducam, 3264 × 2448 px, locked exposure
LightingLED backlight panel under the sample
Working distance102 mm, lens to backlight
EnclosureSealed, with no screen or ports in use
InterfacePhone or laptop browser over the device's own Wi-Fi hotspot
Grading modelsMask R-CNN (ONNX Runtime) or YOLO-seg (NCNN), chosen in Settings
RecordsEach result is logged on the device and synced to a server when a network is available
04What it sorts

Six classes

Real kernels from the device's own dataset, photographed on the backlight exactly as the model sees them.

Broken rule (measured): a kernel is broken when its length is less than 0.75 × the mean length of whole kernels. The model predicts the class, and the measurement checks it independently.
05The model

Mask R-CNN

Mask R-CNN is a two-stage instance segmentation network (He et al., 2017). It first proposes regions that may contain an object, then predicts a class, a bounding box and a pixel mask for each one. The per-pixel mask is what separates touching kernels and gives the length, width and area of each kernel.

573images (430 train · 143 val)
34,598kernels (26,057 · 8,541)
60epochs, validated every 5
40best checkpoint (epoch)

Each image shows one pure, hand-sorted pile, so the class of every kernel is known without labelling each kernel by hand. Kernel outlines were generated automatically by classical segmentation.

Architecture
Mask R-CNN, ResNet-50 FPN v2 (torchvision)
Input size
1024 px long side
Batch size
4
Training GPU
NVIDIA GeForce RTX 5060 Ti
Augmentation
Rotation and flips only. Hue is never changed (it separates brown from white), and scale is never changed (size separates whole from broken).
Max detections
300 per image (the densest labelled tray holds 188 kernels)
Deployment
Exported to ONNX and run with ONNX Runtime on the Pi
Confidence cut-off
0.50
06Accuracy

How well it grades

Validation set: 143 images, 8,541 kernels.

0.938Mask mAP@0.5 achieved. The target from the objectives was ≥ 0.90.
MetricValueMeaning

By class

Mask mAP by class

mAP@0.5mAP@0.5:0.95
ClassmAP@0.5mAP@ 0.5:0.95Correct class

Where it confuses classes

Confusion matrix (detected kernels)

Rows are the true class, columns the predicted class. Blue = correct, orange = mix-ups.

↓ true classpredicted class →
The most common mix-up is brown broken vs white broken (53 kernels). Small fragments show less of the bran layer, which is what makes brown look brown.
Husk vs paddy (19 kernels): an empty hull and a full paddy grain have the same outline.
Whole and broken kernels of the same material are rarely confused.
07Training progress

It levels off after epoch 20

Validation mask mAP by epoch

mAP@0.5mAP@0.5:0.95best (epoch 40)

Training loss

train loss
EpochTrain lossmAP@0.5mAP@0.5:0.95
50.5500.9170.745
100.4820.9300.761
200.4210.9360.778
300.3800.9360.775
40 ← best0.3550.9380.779
500.3480.9390.773
600.3440.9390.770

The validation score levels off after about epoch 20. The training loss keeps falling, but validation mAP@0.5:0.95 does not improve after epoch 40, so the epoch-40 weights are the ones deployed.

Overfitting check: scored the same way on training images, mask mAP@0.5 is 0.949 and mAP@0.5:0.95 is 0.781, almost identical to validation (0.938 / 0.779). The model is not memorising the training set.
08Benchmark

Mask R-CNN vs YOLO-seg

Both models were trained on the same split and scored by the same script, against the same ground truth and at the same mask resolution.

Mask R-CNNtwo-stage · 184 MB
VS
YOLO26n-segone-stage · 6.6 MB
Metric (validation)Mask R-CNNYOLO26n-seg
Mask mAP@0.50.9380.948
Mask mAP@0.5:0.950.7790.798
Recall93.6%94.1%
Precision96.4%95.3%
Class accuracy98.7%100.0%
Count error per image2.532.87
Time per image, laptop CPU6.34 s0.98 s
Time per image, Raspberry Pi 5tens of seconds*about 1 s*
Model file size184 MB6.6 MB

● marks the better value in each row.

Time per image, laptop CPU (seconds)

*Pi timings are from the project's comparison notes and were not measured with the benchmark script. Time a capture on the device before quoting a figure.

09Limitations

What is not proven yet

  • Validation is not an independent test. The validation images were taken in the same sessions as the training images.
  • Single-class trays. Every image holds one pure pile, so performance on mixed mill samples has not been measured yet.
  • Mass is not yet calibrated. Kernel mass is estimated as k × length × width² for each material, but the coefficients have not been fitted to weighed samples. The phone interface withholds grams until that is done.
  • Touching kernels are harder to detect than isolated ones. Spreading the sample thinly matters.
✦Live at the booth

Come and watch it grade a sample

Spread, capture, and see every kernel outlined. Ask us for a demo.

QR code to open this page
Pinch to zoom