ShuttleBotVISION STUDIO

SHUTTLECOCK_DETECTION

ShuttleCock_Detection

Run YOLOv8n on your camera, the bundled test frame, or an image from your device.

Private by designYour camera feed never leaves this device.
Live viewSTANDBY
CAMERA OFF

Your next target starts here.

Point your camera at a shuttlecock.
We’ll take care of the coordinates.

Live bounding boxesInstant coordinates
IN FRAME◎
—Shuttlecocks detected
DETECTION SPEEDϟ
— FPSLive processing rate
FRAMES ANALYZED▥
0This camera session
SESSION TIME◷
00:00Waiting to start

Overview

A single-class YOLOv8n model locates badminton shuttlecocks for the ShuttleBot robotics project. The browser loads its ONNX export and WebAssembly runtime from this site. Live camera frames and the bundled test image are processed on the device, and the camera starts only on request.

What’s Inside

The browser detector is in docs/. The desktop runner adds robot guidance and CSV logging. The Gradio app runs inference in Python. Training artifacts, the original reports and the simulation video document the wider project.

FilePurpose
index.htmlBrowser entry point
app.jsCamera and still-image inference
detection.jsBox decoding and overlap suppression
models/shuttle.onnxBrowser checkpoint
videos/simulation-demo.mp4Saved simulation

Project Breakdown

From frame to bounding box

The camera frame is resized with preserved aspect ratio into a padded 320 × 320 RGB tensor. The model produces 2,100 candidates. The decoder filters by confidence, suppresses overlapping detections, and maps the boxes back to the original frame. The UI shows the highest-confidence target center in camera pixels. The original training run used 640-pixel inputs for 50 epochs.

Three ways to inspect a detection

Live camera mode continuously analyzes frames. Try test image uses a saved frame from the project. Choose a local image opens a file on your device. In still-image mode, moving the confidence slider updates the boxes using the saved model output. It takes one model pass per image.

The target center is reported in original image pixels, measured from the upper-left corner. Mirroring changes the preview while the coordinates remain tied to the source image. Save snapshot downloads the current annotated view.

Dataset

The preserved YOLO archive contains 14,991 images and matching label files: 10,816 training, 2,666 validation, and 1,509 test images. The dataset is packaged as two release files under 2 GB each. The reconstruction script checks the original ZIP checksum before extraction. Its original configuration contains a Kaggle path, so use the extraction helper for a portable local configuration.

Reassemble the dataset ZIP

  1. Download ShuttleCock_YOLO_Dataset.zip.part01 and ShuttleCock_YOLO_Dataset.zip.part02. Put both in ShuttleCock_Detection_Release, next to the cloned repo.
  2. Open PowerShell in the ShuttleCock_Detection repo and run:
    python scripts/join_dataset.py ../ShuttleCock_Detection_Release ../ShuttleCock_YOLO_Dataset.zip
  3. Wait for Verified dataset ZIP. The script joins the parts in order, verifies the original SHA-256, and saves the complete ZIP next to the repo.
  4. Extract the ZIP normally. For training, this command also creates a portable data_local.yaml:
    python scripts/prepare_dataset.py ../ShuttleCock_YOLO_Dataset.zip ../ShuttleCock_YOLO_Dataset

Setup

Run the web launcher from the repository root and open localhost. Choose Start camera or Try test image for camera-free inference. The browser app requires JavaScript and WebAssembly, and camera access requires HTTPS or localhost.

python app.py web --no-browser
# Open http://localhost:8000
npm test

Results

PrecisionRecallmAP50mAP50–95
0.746470.607960.647760.29328

The original epoch-50 validation history records precision 0.74647, recall 0.60796, mAP50 0.64776, and mAP50–95 0.29328. These saved scores describe the training run. The ONNX export was checked against PyTorch on three repository images, with maximum absolute raw-tensor difference 0.00048828125. The still-image demo runs the same browser model as the live camera.

ShuttleBot Simulation

Watch the saved robot scenario for the proposed search, approach and collection sequence. The video documents the simulated workflow. Use the detector above to inspect real model output on a camera frame or still image.

Project Evidence

Review the pipeline

  1. Open the bundled test image and note the predicted box, score and center.
  2. Raise the confidence cutoff to see when that detection is removed. The browser updates the overlay from cached predictions.
  3. Open the workbook to compare the saved epoch results with the separate held-out test and desktop logs.

Download the Excel workbook for all 50 training epochs, validation milestones, annotation counts, and both desktop frame logs. The workbook includes filters and charts. The original epoch CSV and desktop CSV remain available for inspection.

Dataset and annotation audit

The YOLO ZIP contains one class, 0 = shuttle. Each image has a matching text file. A populated row stores class, center x, center y, width and height in normalized coordinates. Empty files contribute zero annotated boxes.

Split Images / label files Empty labels Annotated boxes
Train 10,816 385 10,680
Validation 2,666 96 2,612
Test 1,509 53 1,493
Total 14,991 534 14,785

The archive does not establish whether related frames from the same recording were grouped when splitting the data. See the dataset audit for the ZIP checksum and portable extraction commands.

Training, test results and model export

The recorded run fine-tuned pretrained YOLOv8n for 50 epochs with input size 640, batch size 16, seed 0 and automatic optimizer selection. The browser model uses an RGB input tensor of shape [1, 3, 320, 320]. Its output shape is [1, 5, 2100], containing four box values and one class score per candidate. The browser reverses letterbox padding and scaling, clips boxes to the frame, and applies non-max suppression at IoU 0.50. The default confidence threshold is 0.35.

Validation metric Epoch 1 Epoch 50 Recorded peak
Precision 0.39654 0.74647 0.76121 at epoch 44
Recall 0.18951 0.60796 0.60796 at epoch 50
mAP50 0.15138 0.64776 0.64803 at epoch 49
mAP50–95 0.05306 0.29328 0.29328 at epoch 50

The notebook's saved test evaluation reports 0.829 precision, 0.624 recall, 0.708 mAP50 and 0.358 mAP50–95 across 1,509 images and 1,493 annotated instances. These scores belong to that saved test run. The browser parity checks used selected images, so full browser-resolution test-set accuracy remains unmeasured.

Desktop guidance and saved frame logs

The desktop runner picks the highest-confidence detection and computes the center, signed pixel offset from frame center and normalized bounding-box area. It defaults to confidence 0.35, overlap threshold 0.50, input size 640, horizontal tolerance 40 px and pick area threshold 0.08.

Decision Condition
SEARCH No box passes the detector threshold.
PICK The selected box covers at least 8% of the frame and is within 40 px of horizontal center.
TURN_LEFT / TURN_RIGHT The selected box center falls outside the horizontal tolerance.
FORWARD The box is centered and below the pick area threshold.

Saved session comparison

Saved session Rows Detected rows Median FPS SEARCH / LEFT / RIGHT / FORWARD / PICK
Repository log 3,153 56 5.30 3,097 / 27 / 19 / 9 / 1
Archived log 1,992 950 5.50 1,042 / 344 / 342 / 222 / 42

The logs store elapsed time, frame index, action, confidence, center pixels, signed offsets, normalized area and instantaneous FPS. They lack frame-by-frame ground truth and matched recording conditions, so detection counts describe the individual sessions. PICK records a software decision. The chassis, Raspberry Pi, camera and servo mechanism are described in the design report, and physical actuation remains unverified.

Reports, simulation and implementation

Evidence What it covers
Robot design report Proposed chassis, power, camera, Raspberry Pi and servo-based collection.
ML design notes Detection task, model options, proposed data acquisition and camera integration.
Project slides Dataset, preprocessing, training and evaluation summary.
Training notebook Colab training, checkpoint selection, test metrics and prediction workflow.
Colab PDF Readable export of the notebook.
Simulation video Recorded demonstration of the proposed robot workflow.
Desktop runner Webcam loop, guidance thresholds and frame logging.
Browser controller and decoder Camera and still-image state, ONNX inference, box recovery and overlay rendering.
Export parity check Numerical comparison of PyTorch and ONNX tensors on selected images.

To regenerate the workbook, install openpyxl and run the workbook builder from the repository root.

python scripts/build_evidence_workbook.py ../ShuttleCock_YOLO_Dataset.zip

CSV and Code Reference

Reading the CSV files

File Rows Contents
Training results 50 One row per epoch, with training and validation losses, validation scores, elapsed training time and learning rates for three parameter groups.
Desktop session 3,153 One row per processed webcam frame, including the detector output and selected guidance action.
Archived desktop session 1,992 An earlier capture using the same column layout.
Evidence workbook 8 sheets Split audit, epoch history, milestones, saved test scores and both frame logs in filterable sheets.

In the training CSV, train/*_loss and val/*_loss record box localization, classification and distribution focal loss (DFL). The metrics/*(B) columns are bounding-box validation metrics. The lr/pg0 through lr/pg2 columns save optimizer learning rates. Read the metrics by epoch to trace progress, and use the workbook's peak-epoch table to compare each metric separately.

In the desktop logs, timestamp_s is elapsed session time and frame_index starts at zero. detected is 0 or 1. When it is 0, center coordinates use -1, and confidence, offsets and normalized area are zero. Filter to detected rows when analyzing target positions or confidence. target_cx and target_cy are frame pixels, dx and dy are signed offsets from the frame center, and norm_area is box area divided by frame area. fps is the desktop loop's per-frame estimate. A row describes one frame, so repeated action labels can belong to the same continuous event.

Follow the code from input to output

File Role in the pipeline
Launcher Serves the Pages folder over localhost or dispatches to desktop, Gradio, and export entry points.
Browser controller Starts and stops the source, reuses the WASM model session, renders overlays and handles snapshot downloads. The still-image path caches the raw output for threshold changes.
Browser decoder Calculates letterbox padding, builds the normalized RGB tensor, maps boxes into original frame pixels, and suppresses overlapping detections.
Desktop runner Takes camera frames through Ultralytics YOLO, selects the strongest box, calculates a guidance action and writes CSV rows. Use --log-csv with a fresh path to preserve the saved sample log.
Export script Exports the canonical checkpoint to ONNX and writes input metadata and model checksums.
Numerical parity check Reads selected saved inputs, runs the PyTorch and ONNX models, and compares raw tensors within tolerance.
Browser checks Exercises themes, responsive navigation, gallery, still-image detection and simulated camera behavior.

For local inference, start with python app.py web from the repo folder. The HTML file also supports a direct preview for project content, theme and gallery. The local server supplies the JavaScript modules and model files used by the detector.

Limitations

Small and fast-moving shuttlecocks, clutter, lighting and motion blur can reduce confidence. Accuracy on one saved evaluation set cannot establish performance on every court or camera. WebAssembly speed depends on the device. The browser shows boxes and coordinates. Robot commands and CSV logging belong to the desktop application.

Folder Structure

docs/                     Pages app, ONNX, WASM, gallery, video
ShuttleBotRealtime/       Canonical PyTorch checkpoint
My Drive/ShuttleBot/      Saved training and evaluation artifacts
webapp/                   Gradio application
scripts/                  Export, dataset preparation, figure generation
tests/                    Decoder and model checks
archive/                  Earlier submission variants

About the Author

Mohammad Rohaan developed ShuttleBot’s vision workflow as part of a machine learning and robotics project. His work spans fine-tuning a YOLOv8n detector, examining validation and test results, and connecting detections to desktop guidance rules. The browser demo makes the same trained checkpoint accessible through an ONNX export.