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

fix: input size setting #126

Merged
merged 12 commits into from
Nov 13, 2024
Merged

fix: input size setting #126

merged 12 commits into from
Nov 13, 2024

Conversation

jkbmrz
Copy link
Collaborator

@jkbmrz jkbmrz commented Nov 8, 2024

Adding a fix to the parsers that require model input size and cannot deduce it from the model outputs (YuNetParser and LaneDetectionParser) by extending the build() method to look for the the input_shape within the head_config. Additionally, ParserGenerator is updated to set the input_shape argument aromatically based on the relevant NN Archive.

Some additional changes:

  • the default input_size was removed for the LaneDetectionParser,
  • all input_shape variable/parameter names were changed to input_size because it better fits their meaning (shape resembles NCHW/NHWC whereas we only describe HW) → this is more or less a refactoring change only, but it also effects the input_size setters for the two parsers (setInputShapesetInputSize)

The implemented changes were tested on YuNet and Ultra Fast Lane Detection models.

@github-actions github-actions bot added parsers Changes affecting ml.parsers fix Fixing a bug labels Nov 8, 2024
@jkbmrz jkbmrz marked this pull request as ready for review November 8, 2024 14:34
@jkbmrz jkbmrz changed the title Fix/input shape setting fix: input size setting Nov 8, 2024
Copy link

github-actions bot commented Nov 8, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
3748 1249 33% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
depthai_nodes/ml/parsers/base_parser.py 70% 🟢
depthai_nodes/ml/parsers/lane_detection.py 20% 🟢
depthai_nodes/ml/parsers/utils/yunet.py 15% 🟢
depthai_nodes/ml/parsers/yunet.py 15% 🟢
depthai_nodes/parser_generator.py 24% 🟢
TOTAL 29% 🟢

updated for commit: 1ed14ba by action🐍

Copy link

github-actions bot commented Nov 8, 2024

Test Results

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

Results for commit 1ed14ba.

♻️ This comment has been updated with latest results.

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.

Generally this method could work but I wonder if there isn't a nicer way to infer input size based on the shape of the output and maybe some known stride information or something similar? We did it with YOLO but might not be applicable for all models so if this is not the case here then you can disregard this comment.
If we go ahead with using input_size let's make sure we update this in the whole package accordingly.

@jkbmrz
Copy link
Collaborator Author

jkbmrz commented Nov 9, 2024

Generally this method could work but I wonder if there isn't a nicer way to infer input size based on the shape of the output and maybe some known stride information or something similar?

I found no way of determining input size for YuNetParser and LaneDetection models (the problem is that we don't know the size ratio of the inputs and thus cannot reconstruct it based on the flattened outputs).

If we go ahead with using input_size let's make sure we update this in the whole package accordingly.

Let's wait for others to see what's their position on it and I can then proceed with changing it!

@jkbmrz jkbmrz requested a review from klemen1999 November 9, 2024 10:29
@jkbmrz jkbmrz requested review from kkeroo and aljazkonec1 November 12, 2024 15:07
@jkbmrz jkbmrz requested a review from klemen1999 November 12, 2024 15:07
@codecov-commenter
Copy link

codecov-commenter commented Nov 12, 2024

Codecov Report

Attention: Patch coverage is 2.63158% with 37 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@94a3043). Learn more about missing BASE report.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
depthai_nodes/ml/parsers/lane_detection.py 5.26% 18 Missing ⚠️
depthai_nodes/ml/parsers/yunet.py 0.00% 10 Missing ⚠️
depthai_nodes/parser_generator.py 0.00% 5 Missing ⚠️
depthai_nodes/ml/parsers/utils/yunet.py 0.00% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #126   +/-   ##
=======================================
  Coverage        ?   33.27%           
=======================================
  Files           ?       68           
  Lines           ?     3754           
  Branches        ?        0           
=======================================
  Hits            ?     1249           
  Misses          ?     2505           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jkbmrz jkbmrz merged commit 869ed96 into main Nov 13, 2024
10 checks passed
@jkbmrz jkbmrz deleted the fix/input_shape_setting branch November 13, 2024 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Fixing a bug parsers Changes affecting ml.parsers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants