Skip to content

map_classes_to_indices() ClassesToIndices() update #6468

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

Merged
merged 4 commits into from
May 5, 2023

Conversation

myron
Copy link
Collaborator

@myron myron commented May 5, 2023

map_classes_to_indices utility (and ClassesToIndices transforms) currently returns a list of coordinates for each class, but the type is List[ of MetaTensors], where each class coordinate sub-list is its own MetaTensor. This PR changes it to return a list of torch.Tensors (or ndarray), since we don't need a MetaTensor here.

I ran into an issue with current MetaTensor list, where it would just freeze without any errors, when trying to save the cached indices (returned from ClassesToIndices to cache, which is ListProxy shared mem). It randomly happens, but much more frequently when the number of classes is large (e.g. 105 output classes, so ClassesToIndices returns a list of 105 MetaTensors). I'm not sure what the cause of the freeze is, but my guess is that ListProxy tries to pickle each element of this list (and struggles with MetaTensors). Disabling MetaTensor return type here, solves the issue.

since we don't really need meta tensor return type for each class (coordinates), this seems like harmless fix. the original image/label always will have meta info.

@wyli plz check.

Description

A few sentences describing the changes proposed in this pull request.

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

myron added 3 commits May 4, 2023 13:18
Signed-off-by: myron <amyronenko@nvidia.com>
Signed-off-by: myron <amyronenko@nvidia.com>
@myron myron added this to the Auto3DSeg enhancement [P0 v1.2] milestone May 5, 2023
Signed-off-by: myron <amyronenko@nvidia.com>
@myron myron changed the title Mapclass map_classes_to_indices update May 5, 2023
@myron myron changed the title map_classes_to_indices update map_classes_to_indices() ClassesToIndices() update May 5, 2023
@wyli
Copy link
Contributor

wyli commented May 5, 2023

/build

Copy link
Contributor

@wyli wyli left a comment

Choose a reason for hiding this comment

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

Looks good to me, I'll also look into the metatensor issue

@wyli wyli merged commit c2a9a31 into Project-MONAI:dev May 5, 2023
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.

2 participants