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

Expose parsers when building a pipeline through ParsingNeuralNetwork #149

Merged
merged 3 commits into from
Dec 6, 2024

Conversation

ptoupas
Copy link
Contributor

@ptoupas ptoupas commented Dec 5, 2024

  • Added getParser() method to ParsingNeuralNetwork Class with a default value for parserID = 0

@ptoupas ptoupas self-assigned this Dec 5, 2024
@github-actions github-actions bot added the enhancement New feature or request label Dec 5, 2024
@codecov-commenter
Copy link

codecov-commenter commented Dec 5, 2024

Codecov Report

Attention: Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 33.30%. Comparing base (dbb9dff) to head (71f054d).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
depthai_nodes/parsing_neural_network.py 25.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #149   +/-   ##
=======================================
  Coverage   33.29%   33.30%           
=======================================
  Files          69       69           
  Lines        3835     3840    +5     
=======================================
+ Hits         1277     1279    +2     
- Misses       2558     2561    +3     

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

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 LGTM

depthai_nodes/parsing_neural_network.py Outdated Show resolved Hide resolved
@@ -127,6 +127,13 @@ def setBackend(self, setBackend: str) -> None:
"""Sets the backend of the NeuralNetwork node."""
self._nn.setBackend(setBackend)

def getParser(self, parserID: int = 0) -> BaseParser:
Copy link
Collaborator

Choose a reason for hiding this comment

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

What are your thoughts on having default value here? The other option is that you have to explicitly speciffy the parserID but I agree that in 90% of the cases users are dealing with 1parser NNs so this would be then the desired behaviour. CC: @jkbmrz @kkeroo @aljazkonec1

Copy link
Collaborator

Choose a reason for hiding this comment

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

We could also set the default value to None and if no value is provided:

  • return the parser at zero index if there is only one parser available,
  • error out if there is multiple parsers available to avoid mistakes.

BTW, is parserID a good naming? I think parser_index would be more appropriate.

Copy link
Contributor

Choose a reason for hiding this comment

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

Having an int value set to None would work but could cause issues down the line when porting to depthai. The function name getParser implies that only one is returned and I would just update the docstring such that it explicitly states which one is returned ( i.e. something like: The first parser is returned by default if multiple parsers available).

Regarding the naming, I would switch to snake case (to be consistent with other variables/attributes). index does make slightly more sense.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would leave the default option, so calling getParser() returns the first one. I'm fine with both ways of doing it (Petros' way and Jakob's way).

@ptoupas ptoupas merged commit 88bc218 into main Dec 6, 2024
10 checks passed
@ptoupas ptoupas deleted the feat/expose-parser-on-ParsingNeuralNetwork branch December 6, 2024 13:01
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.

6 participants