Skip to content

Comments

Parser generator differentiates YOLO subtypes#283

Open
aljazkonec1 wants to merge 1 commit intomainfrom
feat/yolo_subtype_differentiation
Open

Parser generator differentiates YOLO subtypes#283
aljazkonec1 wants to merge 1 commit intomainfrom
feat/yolo_subtype_differentiation

Conversation

@aljazkonec1
Copy link
Contributor

Purpose

Current implementation of parser generator preffers YoloExtendedParser for all YOLO models even though most models are now directly supported in dai.DetectionParser. One caveat is in the case of YOLO segmentation on RVC2 where dai only supports running the parser on the host side.

Specification

None / not applicable

Dependencies & Potential Impact

None / not applicable

Deployment Plan

None / not applicable

Testing & Validation

Tested on oak-examples generic example with the following models (both on RVC2 and RVC4):

  • luxonis/yolov8-nano-pose-estimation:coco-512x288
  • luxonis/yolov8-nano-pose-estimation:coco-640x352
  • luxonis/yolov8-instance-segmentation-nano:coco-512x288
  • luxonis/yolov8-large-pose-estimation:coco-640x352
  • agmo/yolov11n-512x288:model-variant-1
  • luxonis/yolov6-nano:r2-coco-512x288

Other models (yolo-p, yolo-world, yolo-e) crash their respective examples as oak-examples need to be updated to accmodate the change in segmentation mask.

Copilot AI review requested due to automatic review settings February 18, 2026 15:50
@github-actions github-actions bot added the enhancement New feature or request label Feb 18, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the parser generator to properly differentiate between YOLO model subtypes and leverage native DepthAI detection parsers where supported, instead of defaulting to YoloExtendedParser for all YOLO models. The implementation adds special handling for YOLO segmentation models on RVC2 devices, which must run parser logic on the host.

Changes:

  • Added logic to check YOLO subtypes against a list of models supported by dai.DetectionParser
  • Implemented RVC2-specific handling for segmentation models to force host-side parsing
  • Added logging to inform users when segmentation mask processing occurs on the host

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


_logger = get_logger(__name__)
DEVICE_PARSERS = ["YOLO", "SSD"]
DAI_SUPPORTED_YOLO_SUBTYPES = ["yolov6", "yolov8", "yolov10", "yolov6r2", "yolo-p", ]
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed trailing comma after the last element in the list for consistency with Python list formatting.

Suggested change
DAI_SUPPORTED_YOLO_SUBTYPES = ["yolov6", "yolov8", "yolov10", "yolov6r2", "yolo-p", ]
DAI_SUPPORTED_YOLO_SUBTYPES = ["yolov6", "yolov8", "yolov10", "yolov6r2", "yolo-p"]

Copilot uses AI. Check for mistakes.
parsers[index] = parser
continue

if parser_name in "YOLOExtendedParser":
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The in operator is being used incorrectly with a string literal. This will check if parser_name is a single character substring of 'YOLOExtendedParser', not an equality check. Use == instead: if parser_name == "YOLOExtendedParser":

Suggested change
if parser_name in "YOLOExtendedParser":
if parser_name == "YOLOExtendedParser":

Copilot uses AI. Check for mistakes.
Comment on lines +73 to +74
if head.metadata.maskOutputs is not None and pipeline.getDefaultDevice().getPlatform() == dai.Platform.RVC2:
self._logger.warning("Segmentation based model on RVC2 device (OAK 1) detected. Segmentation mask processing will be done on the host machine.")
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method pipeline.getDefaultDevice().getPlatform() is called for each head. Consider caching this value before the loop that processes heads to avoid repeated device queries.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


_logger = get_logger(__name__)
DEVICE_PARSERS = ["YOLO", "SSD"]
DAI_SUPPORTED_YOLO_SUBTYPES = ["yolov6", "yolov8", "yolov10", "yolov6r2", "yolo-p", ]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be using YOLOSubtype Enum and compare then to its values. Using "raw" strings is more error prone.


_logger = get_logger(__name__)
DEVICE_PARSERS = ["YOLO", "SSD"]
DAI_SUPPORTED_YOLO_SUBTYPES = ["yolov6", "yolov8", "yolov10", "yolov6r2", "yolo-p", ]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about others like v7 and v9 (maybe even v5 or gold)?

parser.setNNArchive(nn_archive)
parsers[index] = parser
if head.metadata.maskOutputs is not None and pipeline.getDefaultDevice().getPlatform() == dai.Platform.RVC2:
self._logger.warning("Segmentation based model on RVC2 device (OAK 1) detected. Segmentation mask processing will be done on the host machine.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is OAK 1? I would word the whole warning a bit clearer:

Segmentation based model detected with RVC2 device. Parser is going to run on host.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants