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

Add parsers for HRNet and AgeGender models #16

Merged
merged 9 commits into from
Aug 28, 2024
Merged

Add parsers for HRNet and AgeGender models #16

merged 9 commits into from
Aug 28, 2024

Conversation

jkbmrz
Copy link
Collaborator

@jkbmrz jkbmrz commented Jul 30, 2024

This PR proposed two additional parsers - HRNetParser and AgeGenderParser - and adds all the required support.

  • For HRNet, should we control for output transposes in DLC models (HW_ instead of _HW) or should this be fixed at the level of export. EDIT: Will open discussion on Slack.
  • For HRNet, should we provide relative instead of absolute (pixel-based) keypoints. EDIT: fixed in ec9ad5a.

@tersekmatija
Copy link

For HRNet can we use or modify some existing parser? It would be good it's normalized if we are using normalized coordinates elsewhere.

And then, for NCHW (OAK) vs NHWC (OAK4), we should be able to handle this. Might be worth opening a discussion on Slack whether we want this to be handled by DAI directly or somehow differently? I assume it's the same for all other parsers?

@jkbmrz
Copy link
Collaborator Author

jkbmrz commented Aug 16, 2024

For HRNet can we use or modify some existing parser?

I would leave it separate because it uses heatmaps. Moreover, other keypoint detection parsers are also separated. We could, however, think about joining them all together (but I'd do that in a separate PR)

It would be good it's normalized if we are using normalized coordinates elsewhere.

Added in ec9ad5a.

And then, for NCHW (OAK) vs NHWC (OAK4), we should be able to handle this. Might be worth opening a discussion on Slack whether we want this to be handled by DAI directly or somehow differently? I assume it's the same for all other parsers?

True, we are currently solving this individually for each parser. Might be good to solve at the level of DAI (will open discussion on Slack)

@jkbmrz
Copy link
Collaborator Author

jkbmrz commented Aug 16, 2024

I'm opening this PR for review (cc @kkeroo, @klemen1999). Note that AgeGender model is a half-regression (age) half-classification (gender) model. I've currently put its message inside "misc.py" because we don't have the classification/regression messages in place yet. Once we merge the classification PR (#15) we can add this message to "classification.py". Moreover, we can keep the "misc.py" (or rename it to "mixed.py" maybe) and import there objects both from classification and regression messages (would make a separate PR for the second one). Thoughts?

@jkbmrz jkbmrz requested a review from kkeroo August 16, 2024 12:37
Copy link
Collaborator

@kkeroo kkeroo left a comment

Choose a reason for hiding this comment

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

LGTM, just one suggestion. Not necessary to implement though - open for discussion.


age_gender_message = AgeGender()
age_gender_message.age = age
age_gender_message.gender_prob = gender_prob
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we rather have gender (male or female based on threshold) rather than probabilities. It would give better info -> user does not need to know if 1 is male or female?

Copy link
Collaborator Author

@jkbmrz jkbmrz Aug 16, 2024

Choose a reason for hiding this comment

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

I agree it would be more straight-forward but I also see added value of having the probability information. It might not be desired we abstract everything at the level of the parser not to make things too "simplistic" (it might help some users but be annoying for others who want to do something more advanced). Moreover, I think this message can be related to the classification message (once added) which will require probability values but also the class names (preventing the user from getting lost too much). So I'd leave it as it is for now (cc @klemen1999 on this also).

"""Initializes the AgeGenderParser node."""
dai.node.ThreadedHostNode.__init__(self)
self.input = dai.Node.Input(self)
self.out = dai.Node.Output(self)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If going with the proposed change add parameter for thresholding?

@kkeroo
Copy link
Collaborator

kkeroo commented Aug 16, 2024

I'm opening this PR for review (cc @kkeroo, @klemen1999). Note that AgeGender model is a half-regression (age) half-classification (gender) model. I've currently put its message inside "misc.py" because we don't have the classification/regression messages in place yet. Once we merge the classification PR (#15) we can add this message to "classification.py". Moreover, we can keep the "misc.py" (or rename it to "mixed.py" maybe) and import there objects both from classification and regression messages (would make a separate PR for the second one). Thoughts?

Yeah agree, I wouldnt go into trying to abstract it too much right now but rather adjust the messages once new models are added. Potentially, in the future we might have Classification-regression msg having class and value atributes but we can add this when the opportunity arises?

@klemen1999
Copy link
Collaborator

Related to classification messages: Would it make sense to first merge in #15 and then make changes to this PR so it uses Classification msg type?

@kkeroo kkeroo requested a review from klemen1999 August 27, 2024 15:05
@kkeroo kkeroo changed the title [draft] Add parsers for HRNet and AgeGender models Add parsers for HRNet and AgeGender models Aug 27, 2024
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 just left some comments

depthai_nodes/ml/parsers/age_gender.py Outdated Show resolved Hide resolved
depthai_nodes/ml/messages/creators/misc.py Outdated Show resolved Hide resolved
@kkeroo kkeroo merged commit 1043366 into main Aug 28, 2024
1 check passed
@kkeroo kkeroo deleted the feat/add_parsers branch September 9, 2024 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants