Parser generator differentiates YOLO subtypes#283
Conversation
There was a problem hiding this comment.
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", ] |
There was a problem hiding this comment.
Removed trailing comma after the last element in the list for consistency with Python list formatting.
| DAI_SUPPORTED_YOLO_SUBTYPES = ["yolov6", "yolov8", "yolov10", "yolov6r2", "yolo-p", ] | |
| DAI_SUPPORTED_YOLO_SUBTYPES = ["yolov6", "yolov8", "yolov10", "yolov6r2", "yolo-p"] |
| parsers[index] = parser | ||
| continue | ||
|
|
||
| if parser_name in "YOLOExtendedParser": |
There was a problem hiding this comment.
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":
| if parser_name in "YOLOExtendedParser": | |
| if parser_name == "YOLOExtendedParser": |
| 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.") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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", ] |
There was a problem hiding this comment.
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", ] |
There was a problem hiding this comment.
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.") |
There was a problem hiding this comment.
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.
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):
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.