Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsers and Messages V2 #116

Merged
merged 75 commits into from
Oct 24, 2024
Merged

Parsers and Messages V2 #116

merged 75 commits into from
Oct 24, 2024

Conversation

jkbmrz
Copy link
Collaborator

@jkbmrz jkbmrz commented Oct 24, 2024

This PR merges the dev branch into the main for the v0.0.3 release of the depthai-nodes library. Primarily, it updates how parsers are structured (as defined by the BaseParser) and built - manually (1) during or (2) after initialization (using setters), or (3) automatically by calling the build() method. The latter allows building the parser from a NN Archive (see the newly added ParserGenerator). Moreover, we are adding the ParsingNeuralNetwork node that wraps the NeuralNetwork node with parsing capabilities. Additionally, we have updated numerous parsers, messages and creator functions.

Overview:

  • parsers
    • adding an abstract BaseParser that defines basic parser structure and that all parsers must inherit from.
    • adding: ClassificationSequenceParser, DetectionParser, EmbeddingsParser, LaneDetectionParser, MapOutputParser, PPTextDetectionParser, RegressionParser, XFeatMonoParser, XFeatStereoParser (+ relevant utils);
    • removing: AgeGenderParser, MPHandLandmarkParser, MonocularDepthParser, ThermalImageParser, XFeatParser (+ relevant utils);
  • messages
    • adding: Cluster/s, Keypoint, Map2D, Prediction/s, SegmentationMask (+ relevant utils);
    • updates:
      • ImgDetectionExtended: bbox coordinates changed from xyxy to xywh and must be relative;
      • Keypoints: keypoint coordinates must be relative;
    • removing: HandKeypoints, AgeGender, SegmentationMasks (+ relevant utils);
    • adding improved type hinting and type checking;
  • creators
    • adding new ones for the newly added messages and removing the outdated;
  • misc
    • adding ParserGenerator, a general interface for instantiating parsers from NN Archives;
    • adding ParsingNeuralNetwork node that wraps the NeuralNetwork node and adds parsing capabilities;
    • adding TilesPatcher and Tiling helper nodes (+ relevant utils);
    • fixing pre-commit version
    • fixing tests

klemen1999 and others added 30 commits October 24, 2024 13:50
* Add support for different input sizes.

* Support extended palm detection in examples.

* Pre-commit fix.

* Add normalization.
…r characters.

This PR adds a classification_sequence_message that returns a sequence of charecters corresponding to maximum probability in the sequence.
The message has optional parameters to remove duplicates and ignore background class indexes.

In addition this PR also adds a PaddleOCR Parser, which utilizes the classification_sequence message.
Co-authored-by: KlemenSkrlj <[email protected]>
* Add LaneDetectionParser.

* Add tests.

* Add LaneDetection parser to parsers.

* Example added.

* typo.

* Precommit fix.

* [Automated] Updated coverage badge

---------

Co-authored-by: GitHub Actions <[email protected]>
jkbmrz and others added 6 commits October 24, 2024 13:52
* fix: ParsingNeuralNetwork build overload method names

* fix: YoloExtendedParser imports

* fix: remove double-calling the np.array()

* fix: make sure we pass floats to the ImgDetectionExtended setters
* Add keypoint confidences to YOLO.

* Refactor FastSAM.

* Fix Yolo build method.

* Get subtype from archive instead of yolo_version.

* Typo.

* Move mask related functions.

* Docstring fix.

* Docstring fix.

* Remove comments.

* Change yolo_version to subtype.

* Update arguments.

* Update depthai_nodes/ml/parsers/yolo.py

Co-authored-by: KlemenSkrlj <[email protected]>

* Docstring fix.

Co-authored-by: KlemenSkrlj <[email protected]>

* Docstring param description fix.

Co-authored-by: KlemenSkrlj <[email protected]>

* Error printing fix.

Co-authored-by: KlemenSkrlj <[email protected]>

---------

Co-authored-by: KlemenSkrlj <[email protected]>
* Add a simple parser for embeddings models

* add setOutputLayerNames set method
* fix: update config usage to latest DAIv3 version

* fix: clip scores in HRNetParser

* feat: allow keypoints message creation with no conf threshold

* refactor: unify docstrings

* feat: remove run() method and output_layer_name parameter from the DetectionParser

* refactor: unify the order of parser methods

* feat: add missing setters and unify existing ones

* feat: remove default values from DetectionParser

* feat: move score_threshold from children to KeypointParser

* feat: unify how to handle missing output names

* feat: remove default output_layer_name option for HRNetParser

* feat: call head_config arguments with .get() to prevent errors

* updated pre-commit version

* added manual end2end test script

* feat: refactor messages

* fix: creators unittests

* feat: remove SegmentationMask message

* fix: pre-commit formatting

* Correct build in PalmDetection parser.

* Correct build in PPTextDetection parser.

* Correct build in SCRFD.

* Small fix in YuNet.

* Python v3.8 supported.

* Python v3.8 support in helpers.

* Use alpha4.

* Small SCRFD fix.

* fix: ImageOutputParser get outputs

* fix: MapOutputParser set timestamp

* feat: rename SegmentationMasks to SegmentationMask

* feat: force keypoint and bbox coordinates to 0-1

* fix: PPTextDetectionParser docstring

* fix: keypoint and bbox requirements

* Boundaries fix.

* Masks fix.

* feat: modify masks setter and getter methods in ImgDetectionsExtended message

---------

Co-authored-by: klemen1999 <[email protected]>
Co-authored-by: kkeroo <[email protected]>
@github-actions github-actions bot added messages Changes affecting ml.messages parsers Changes affecting ml.parsers examples Changes affecting examples. release New version release labels Oct 24, 2024
Copy link

Test Results

125 tests   125 ✅  1s ⏱️
  1 suites    0 💤
  1 files      0 ❌

Results for commit 78d2914.

Copy link

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
3716 1190 32% 0% 🟢

New Files

File Coverage Status
depthai_nodes/ml/messages/creators/regression.py 100% 🟢
depthai_nodes/ml/messages/prediction.py 89% 🟢
depthai_nodes/ml/parsers/base_parser.py 70% 🟢
depthai_nodes/ml/parsers/classification_sequence.py 21% 🟢
depthai_nodes/ml/parsers/detection.py 29% 🟢
depthai_nodes/ml/parsers/embeddings.py 36% 🟢
depthai_nodes/ml/parsers/regression.py 29% 🟢
depthai_nodes/ml/parsers/utils/bbox_format_converters.py 8% 🟢
depthai_nodes/ml/parsers/utils/decode_head.py 25% 🟢
depthai_nodes/ml/parsers/utils/keypoints.py 44% 🟢
depthai_nodes/ml/parsers/utils/masks_utils.py 24% 🟢
depthai_nodes/ml/parsers/utils/yunet.py 15% 🟢
depthai_nodes/ml/parsers/xfeat.py 19% 🟢
depthai_nodes/parser_generator.py 0% 🟢
depthai_nodes/parsing_neural_network.py 0% 🟢
TOTAL 34% 🟢

Modified Files

File Coverage Status
depthai_nodes/ml/helpers/tiles_patcher.py 0% 🟢
depthai_nodes/ml/helpers/tiling.py 0% 🟢
depthai_nodes/ml/helpers/utils/nms.py 0% 🟢
depthai_nodes/ml/helpers/utils/to_planar.py 0% 🟢
depthai_nodes/ml/messages/init.py 100% 🟢
depthai_nodes/ml/messages/classification.py 84% 🟢
depthai_nodes/ml/messages/clusters.py 79% 🟢
depthai_nodes/ml/messages/creators/init.py 100% 🟢
depthai_nodes/ml/messages/creators/classification.py 98% 🟢
depthai_nodes/ml/messages/creators/detection.py 94% 🟢
depthai_nodes/ml/messages/creators/keypoints.py 100% 🟢
depthai_nodes/ml/messages/creators/segmentation.py 65% 🟢
depthai_nodes/ml/messages/img_detections.py 74% 🟢
depthai_nodes/ml/messages/keypoints.py 84% 🟢
depthai_nodes/ml/messages/lines.py 89% 🟢
depthai_nodes/ml/messages/map.py 90% 🟢
depthai_nodes/ml/messages/segmentation.py 43% 🟢
depthai_nodes/ml/parsers/init.py 100% 🟢
depthai_nodes/ml/parsers/classification.py 21% 🟢
depthai_nodes/ml/parsers/fastsam.py 16% 🟢
depthai_nodes/ml/parsers/hrnet.py 25% 🟢
depthai_nodes/ml/parsers/image_output.py 26% 🟢
depthai_nodes/ml/parsers/keypoints.py 22% 🟢
depthai_nodes/ml/parsers/lane_detection.py 21% 🟢
depthai_nodes/ml/parsers/map_output.py 24% 🟢
depthai_nodes/ml/parsers/mediapipe_palm_detection.py 16% 🟢
depthai_nodes/ml/parsers/mlsd.py 22% 🟢
depthai_nodes/ml/parsers/ppdet.py 30% 🟢
depthai_nodes/ml/parsers/scrfd.py 19% 🟢
depthai_nodes/ml/parsers/segmentation.py 20% 🟢
depthai_nodes/ml/parsers/superanimal_landmarker.py 30% 🟢
depthai_nodes/ml/parsers/utils/init.py 100% 🟢
depthai_nodes/ml/parsers/utils/fastsam.py 13% 🟢
depthai_nodes/ml/parsers/utils/nms.py 16% 🟢
depthai_nodes/ml/parsers/utils/ppdet.py 10% 🟢
depthai_nodes/ml/parsers/utils/scrfd.py 8% 🟢
depthai_nodes/ml/parsers/utils/yolo.py 22% 🟢
depthai_nodes/ml/parsers/yolo.py 20% 🟢
depthai_nodes/ml/parsers/yunet.py 15% 🟢
TOTAL 43% 🟢

updated for commit: 78d2914 by action🐍

@jkbmrz jkbmrz marked this pull request as ready for review October 24, 2024 13:27
Copy link
Collaborator

@klemen1999 klemen1999 left a comment

Choose a reason for hiding this comment

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

LGTM, already checked when merging from parsers-v2 branch to dev

@klemen1999 klemen1999 merged commit b4a44e3 into main Oct 24, 2024
@klemen1999 klemen1999 deleted the dev branch October 24, 2024 13:32
@klemen1999 klemen1999 restored the dev branch October 24, 2024 13:32
@jkbmrz jkbmrz deleted the dev branch October 30, 2024 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
examples Changes affecting examples. messages Changes affecting ml.messages parsers Changes affecting ml.parsers release New version release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants