Back to portfolio

Case study· Mar 2025 – Aug 2025

YOLOv8 for Real-Time Fruit Ninja — Why Nano Beats Extra-Large

A comparative study of five YOLOv8 variants on a custom 8,423-frame Fruit Ninja dataset. The largest model has the highest mAP, but the smallest model wins the game — by 76% more points.

5 (n/s/m/l/x)Variants benchmarked
8,423 framesDataset size
28.50Best FPS (n)
0.90Best mAP@0.5–0.95
539Best game score (n)
306Worst game score (x)
YOLOv8Computer VisionPyTorchReal-time inferenceUndergraduate thesis

Problem

Object detectors in academic papers get ranked by mAP. But in interactive systems — games, robotics, AR — accuracy is only half the story. A frame that arrives 50 ms late has zero value, no matter how sharp the bounding box.

Fruit Ninja is a clean test bed for this trade-off. The bot must detect rapidly moving fruit and bombs, plan a swipe, and execute — all before the fruit leaves the screen. Miss the window and you lose. So the question worth asking isn't "which YOLOv8 variant has the highest mAP?" — it's "which variant maximizes points actually scored?"

This case study answers that question with a controlled experiment across all five YOLOv8 sizes.

Data

A custom primary dataset was built end-to-end:

  • Source. Gameplay sessions recorded from Fruit Ninja running in the LDPlayer Android emulator, screen-captured to video.
  • Selection. Frames extracted and hand-curated for object diversity (fruit types, bombs, varied positions and orientations) on a relatively clean background.
  • Annotation. Manual bounding boxes drawn in Label Studio for every fruit and bomb instance.
  • Final size. 8,423 annotated frames.
  • Split. 7,369 train · 702 val · 352 test (87.5 / 8.3 / 4.2). Held out by frame, not by session — a known caveat for future work.
  • Augmentation. Random rotations, scaling, brightness, and contrast shifts on the train set only.

The split is intentionally weighted toward training because the visual domain — emulator-clean fruit on a dark background — is much narrower than COCO. The model only needs to learn a handful of objects under predictable lighting.

Approach

The experiment compared five YOLOv8 variants released by Ultralytics, chosen specifically because they share a common architecture and differ only in width and depth:

VariantParameters (M)FLOPs (G) @ 640px
Nano (n)3.28.7
Small (s)11.228.6
Medium (m)25.978.9
Large (l)43.7165.2
Extra-large (x)68.2257.8

Each variant inherits the same three architectural innovations from YOLOv8:

  1. C2f module (cross-stage partial with convolutions and fusion) — concatenates the output of every bottleneck block, not just the last one. Richer gradient flow, smaller vanishing-gradient surface, lighter weight than the C3 block in YOLOv5.
  2. SPPF (Spatial Pyramid Pooling — Fast) — replaces parallel max-pools with sequential 5×5 max-pools. Mathematically equivalent to SPP, far cheaper FLOPs.
  3. Anchor-free decoupled head — separate convolutions for classification and box regression, no pre-defined anchors. Simpler training, slightly better recall on irregular aspect ratios.

For the real-time test, each trained model was wired into a Python script that:

  • Captured frames via bettercam for sub-millisecond DXGI screen grabs (the GDI alternative caps near 30 FPS, which would have made the comparison meaningless).
  • Ran inference on the 640×640 frame.
  • Issued mouse swipes via input automation to slice detected fruit while avoiding bombs.

Two metric families were tracked:

  • Detection quality: Precision, Recall, mAP@0.5, mAP@0.5–0.95.
  • Real-time performance: average FPS during live play, plus the high score actually achieved by the bot — a proxy for how well the latency-accuracy trade-off lands.

Results

Detection quality plateaued early. All five variants landed within a single mAP point of each other, despite the largest having ~21× more parameters than the smallest:

ModelPrecisionRecallmAP@0.5mAP@0.5–0.95
Nano (n)0.880.850.920.89
Small (s)0.890.860.930.89
Medium (m)0.900.860.940.89
Large (l)0.900.870.94—
Extra-large (x)0.910.870.950.90

A 1.3% mAP gain for 21× the parameters. Capacity saturated.

Real-time performance collapsed predictably. Compute scaled linearly; FPS fell off a cliff:

ModelFPSHigh score
Nano (n)28.50539
Small (s)26.34530
Medium (m)23.18536
Large (l)19.71412
Extra-large (x)17.07306

The smallest model — with the lowest mAP@0.5 — scored 76% more points than the largest model with the highest mAP. At 17.07 FPS the per-frame budget is ~58.6 ms; at 28.50 FPS it is ~35.1 ms. That ~23 ms gap was enough to miss fruit consistently.

Lessons learned

  • mAP is not the right metric for interactive systems. Past a "good enough" accuracy threshold, every additional parameter just buys latency. For Fruit Ninja the threshold sat near yolov8n — the smallest variant Ultralytics ships.
  • Visual domains differ. COCO punishes lightweight models because of occlusion, lighting variance, and intra-class diversity. A constrained domain (clean background, distinct classes, predictable motion) flips the calculus — the architecture saturates fast.
  • Capture stack is non-negotiable. Switching from PrintScreen-grade capture to bettercam was worth more than any model upgrade. If your detector is faster than your input pipeline, you are spending compute on stale frames.
  • Frame-split leakage is a real caveat. Splitting by frame inside a session likely inflates val/test mAP because adjacent frames are nearly identical. Future work should split by session.
  • Repo: LvnnnX/FruitNinjaAUTO
  • Underlying study: undergraduate thesis at Universitas Udayana — "Analisis Kinerja Convolutional Neural Network dengan YOLO-v8 untuk Mendeteksi Buah dalam Permainan 'Fruit Ninja'" (Pande Gede Dani Wismagatha, advisor I Wayan Santiyasa).