Turn the pages with the arrows below or the ← → keys. M picks up the magnifying glass; + / − zoom.
Ripeness is a scale, not a set of unrelated labels. We train a CNN with an ordinal-regression loss (CORAL) and compare it with a standard cross-entropy classifier on identical splits.
Plate I — four grades of tomato and banana, from unripe to overripe.
A grader that calls an unripe tomato overripe has made a far worse mistake than one that calls it turning. Ordinary multi-class training cannot see that: cross-entropy only asks “was the right box ticked?”, so every wrong answer costs the same.
Ripeness grades have a natural order — Unripe < Turning < Ripe < Overripe — and an ordinal model uses it. It learns how far along the fruit is, so its mistakes tend to land next to the truth.
Every error costs 1.
Cost grows with distance |true − predicted|.
MAE is measured in grades: 0.10 means the average prediction is a tenth of a grade off. Two models can have the same accuracy and very different MAE.
| Source | What it adds |
|---|---|
| Fruits-360 | Studio photos of whole fruit rotating on a white ground. Folders mapped to a grade by colour and condition (e.g. Tomato 11 → Unripe, Tomato 9 → Overripe). Cultivar colours (yellow, maroon tomatoes) are excluded. |
| Real-world bananas | 240 phone photos with captions (“peel partially green”, “rotten”) mapped to grades by keyword rules; 12 ambiguous captions dropped. |
| Self-collected | Not in these results yet (0 photos). Plate IX prepares labelled photos for data/self_collected/; the next run splits them 70/15/15. |
Fruits-360 has no green bananas — the reason a self-collected subset is part of the brief.
Click a specimen to grade it on the bench (Plate V). Pick up the lens to look closer.
Both models share everything except the last layer and the loss: an ImageNet-pretrained ResNet-18, 112 × 112 inputs, AdamW (lr 3·10⁻⁴, 10× for the new head, cosine schedule), 8 epochs, batch 32, grade-balanced sampling, and the same augmentations, seeds and splits.
Random crops, flips, ±20° rotation, brightness and contrast jitter — but no hue jitter. Colour is the ripeness signal; shifting the hue would turn a green tomato red and keep the label “Unripe”.
4 logits → softmax → pick the largest.
Grades are treated as unrelated categories.
Three yes/no questions: is the grade > 0? > 1? > 2? All three share one weight vector w and differ only in a bias bk:
A “Ripe” label (grade 2) becomes the targets [1, 1, 0]. The loss is the sum of three binary cross-entropies, so predicting Overripe for a Turning fruit gets two questions wrong, not one.
Sharing w keeps the answers rank-consistent: P(y>0) ≥ P(y>1) ≥ P(y>2), so the model can never say “not past Turning, but past Ripe”.
Both models grade the same photo. The ripeness score is the expected grade, Σ k · P(k), a continuous 0–3 reading of how far along the fruit is.
Results appear after bash run_experiments.sh.
Rows are the true grade, columns the prediction; the outlined diagonal is “exactly right”. For an ordinal task the question is not only how many errors, but how far from the diagonal they fall.
Cells far from the diagonal — Unripe called Ripe, Turning called Overripe — are the costly mistakes. Hover a cell for counts.
All three test sets pooled.
Validation MAE per epoch. The checkpoint with the lowest validation MAE is kept for both heads, so neither gets a selection advantage. Hover the chart to read an epoch.
Seed 42: unseen-variety and real-world images where the heads disagree, one per variety. Both models get some of these wrong.
Photograph a fruit, pick its grade, and save it. Photos land in data/self_collected/<fruit>/<grade>/ and join the next training run (70% train, 15% val, 15% real-world test).
Labelling guide — Unripe: no yellow/red at all. Turning: colour change has started but green remains. Ripe: full colour, firm. Overripe: dark patches, wrinkles, rot or many brown spots.
Image sources. Fruits-360 by Mihai Oltean (CC BY-SA 4.0), github.com/fruits-360. Real-world bananas: josedonoso/bananas-dataset-v1 on Hugging Face (no licence stated). Used here for a course project.