Strawberry Image Analysis

Nov 2026

PythonPythonPyTorchPyTorchUltralyticsYOLORoboflowRoboflowKaggleKaggle

A personal project to discover computer vision. I took a public dataset (CC BY 4.0) of strawberry photos, 566 images and 1,734 strawberries each labelled ripe, intermediate or unripe, and trained two object detectors on it: YOLO26s from UltralyticsUltralytics and RF-DETR Small from RoboflowRoboflow.

Converting the dataset outlines

In the dataset, each strawberry is outlined with a polygon, but both detectors train on boxes. So the first step is a script that turns every outline into its bounding box. This job is done by the function polygons_to_box():

src/data/polygons_to_boxes.py
def polygon_to_box(class_id: int, xs: list[float], ys: list[float]) -> Box:    x_min, x_max, y_min, y_max = min(xs), max(xs), min(ys), max(ys)    if x_min < 0 or y_min < 0 or x_max > 1 or y_max > 1:        raise ValueError("polygon outside the image")    if x_min == x_max or y_min == y_max:        raise ValueError("polygon has no area")    return Box(        class_id=class_id,        x_center=(x_min + x_max) / 2,        y_center=(y_min + y_max) / 2,        width=x_max - x_min,        height=y_max - y_min,    )

Running the experimentation

The images are then split: 70% into the training set, 15% into the validation set and 15% into the test set.

Both models were trained with the same settings and scored on the same test images.

The whole experiment was carried out in a KaggleKaggle notebook on a Tesla T4.

Benchmarks

I trained each model five times, changing only the seed. Below is the average of those five runs, with the ± showing how much the score moved from one run to the next:

Model mAP50 mAP50-95 Latency
YOLO26s 0.759 ± 0.017 0.643 ± 0.015 15.8 ms
RF-DETR Small 0.806 ± 0.007 0.679 ± 0.008 50.2 ms

For this task, RoboflowRF-DETR Small is the better choice. It is more accurate, since its worst run (0.671 mAP50-95) still beats YOLO’s best (0.661), and steadier, with about half YOLO’s variation from run to run. UltralyticsYOLO26s is about three times faster, but both are fast enough for real time.