Skip to content

examples: use public COCO128 dataset and YOLOv8n model in YOLO tutorial - #641

Open
ashishsoni-ai wants to merge 1 commit into
JdeRobot:masterfrom
ashishsoni-ai:fix/yolo-tutorial-public-assets
Open

ashishsoni-ai wants to merge 1 commit into
JdeRobot:masterfrom
ashishsoni-ai:fix/yolo-tutorial-public-assets

Conversation

@ashishsoni-ai

Copy link
Copy Markdown

YOLO tutorial: use public COCO128 dataset and YOLOv8n model

What

Fixes examples/tutorial_image_detection_yolo.ipynb so it runs end-to-end without access to
private assets, following the same pattern as #613 (COCO tutorial).

Why

The notebook hard-coded three local paths that only exist on the original authors' machines:

  • local/data/datasets/TACObboxSkewedResized.yaml
  • local/data/datasets/TACOskewedBBoxResized
  • local/data/models/best.torchscript

with no download links or preparation steps, so new contributors could not run the tutorial at
all (reported in #634).

Changes

  • Automated asset download (new cells): a cross-platform, stdlib-only cell downloads and
    extracts two small public GPL-3.0 assets into local/data/ on first run, skipping when already
    present:
  • TorchScript export step (new cell): one-time ultralytics export of yolov8n.pt to
    yolov8n.torchscript with dynamic=True, with a clear ImportError hint to
    pip install ultralytics if the package is missing. Pre-exported YOLO-NAS checkpoints were not
    usable because they emit tuple outputs that the repo's parser does not accept.
  • Model configuration: adds "resize": {"closest_divisor": 32} so images are padded to a
    multiple of the YOLO stride (the exported dynamic model rejects other sizes); keeps
    model_format: "yolo".
  • Dataset/evaluation: the dataset and model cells now consume the variables set by the setup
    cells instead of re-declaring private paths; the inference and evaluation cells use the val
    split because COCO128 has no separate test split.
  • Stale outputs cleared: the stored cell outputs (1500 samples / 28 classes / AUC-PR 0.942)
    belonged to the private TACO assets and would be misleading next to COCO128.

Testing

Validated the exact notebook flow with the repo's own code (YOLODataset,
TorchImageDetectionModel.predict, .eval) on the downloaded assets:

  • dataset loads: 128 samples / 80 classes, split {'val': 128}
  • single-image inference works, e.g. bowl 0.93, broccoli 0.76 on a 640×480 image
  • full evaluation (128 images, CPU, ~30 s) returns
    {'metrics_df', 'metrics_factory'} with mAP@[0.5:0.95] ≈ 0.300 and AUC-PR ≈ 0.330
  • all notebook cells pass ast.parse; no stale TACO references remain

Fixes #634

Replaces the private TACO dataset and TorchScript model files
(TACObboxSkewedResized.yaml / best.torchscript) with automated
downloads of public GPL-3.0 assets:
- COCO128 dataset (128 images, 80 classes, ~7 MB)
- YOLOv8n pretrained weights (~6 MB) exported to TorchScript
  with dynamic=True and closest_divisor=32 padding

Also switches evaluation split from test to val (matching
COCO128's layout) and clears stale TACO cell outputs.

Fixes JdeRobot#634.
@ashishsoni-ai ashishsoni-ai changed the title examples: use public COCO128 dataset and YOLOv8n model in YLO tutorial examples: use public COCO128 dataset and YOLOv8n model in YOLO tutorial Sep 25, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Loss of TACObbox dataset resources

2 participants