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

Train-Only Heads #83

Merged
merged 2 commits into from
Sep 28, 2024
Merged

Train-Only Heads #83

merged 2 commits into from
Sep 28, 2024

Conversation

JSabadin
Copy link
Contributor

Luxonis Train - Remove on Export Feature

The remove_on_export option allows users to exclude specific nodes during model export. This is useful for auxiliary nodes that are not required in the final exported model.

Example Usage:

model:
  name: ddrnet_segmentation
  nodes:
    - name: DDRNet
      params:
        use_aux_heads: true
    - name: DDRNetSegmentationHead
      inputs: ["DDRNet"]
      alias: "segmentation_head"
      params:
           attach_index: -1
    - name: DDRNetSegmentationHead
      inputs: ["DDRNet"]
      alias: "aux_segmentation_head"
      params:
           attach_index: -2
           remove_on_export: true  # This node will be ignored during export

Nodes marked with remove_on_export: true will be skipped when exporting the model.

@JSabadin JSabadin self-assigned this Sep 27, 2024
@github-actions github-actions bot added enhancement New feature or request tests Adding or changing tests DevOps Changes related to DevOps CLI Changes affecting the CLI release New version release labels Sep 27, 2024
@JSabadin JSabadin changed the base branch from main to dev September 27, 2024 06:56
@JSabadin JSabadin requested a review from a team as a code owner September 27, 2024 06:56
Copy link

codecov bot commented Sep 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (dev@e16cde6). Learn more about missing BASE report.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@          Coverage Diff           @@
##             dev      #83   +/-   ##
======================================
  Coverage       ?   97.07%           
======================================
  Files          ?      140           
  Lines          ?     6120           
  Branches       ?        0           
======================================
  Hits           ?     5941           
  Misses         ?      179           
  Partials       ?        0           

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

@kozlov721 kozlov721 changed the title Feat/remove on export Train-Only Heads Sep 27, 2024
@kozlov721 kozlov721 removed DevOps Changes related to DevOps CLI Changes affecting the CLI release New version release labels Sep 27, 2024
Copy link
Collaborator

@kozlov721 kozlov721 left a comment

Choose a reason for hiding this comment

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

Left a small comment, otherwise LGTM.
However, it would be good to add a simple test case for a dummy network with a train-only head:

model = ...
results = model.eval()
# test results contain all heads
output_names = model.export_onnx()
# test output_names don't contain the train-only heads

"""Getter for the remove_on_export attribute."""
return self._remove_on_export

def set_remove_on_export_mode(self, mode: bool = True) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think the setter is necessary. There shouldn't be a need to change the value once it's set, and if a niche use case arises, we can rely on the underlying _remove_on_export.

IMHO, implementing a setter suggests that it's reasonable for the user to change the once-set value, which isn't the case here. Instead, making it accessible only via the original _remove_on_export attribute indicates that the value shouldn't be modified in regular use cases.

If we'd want to keep the setter anyway, I think implementing it as an actual setter:

@remove_on_export.setter
def remove_on_export(self, mode: bool) -> None:
    ...

is a bit nicer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree, I don't think we need setter for this. I don't see it being changed after init in 99% of the cases

@JSabadin JSabadin requested a review from kozlov721 September 27, 2024 09:59
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.

Thanks, LGTM!

@JSabadin JSabadin merged commit 121c8b9 into dev Sep 28, 2024
9 checks passed
@JSabadin JSabadin deleted the feat/remove-on-export branch September 28, 2024 05:48
@kozlov721 kozlov721 mentioned this pull request Oct 9, 2024
kozlov721 pushed a commit that referenced this pull request Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tests Adding or changing tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants