ClassesToIndicesd limit the cache memory#6284
Merged
wyli merged 6 commits intoProject-MONAI:devfrom Apr 6, 2023
myron:class_ind
Merged
ClassesToIndicesd limit the cache memory#6284wyli merged 6 commits intoProject-MONAI:devfrom myron:class_ind
wyli merged 6 commits intoProject-MONAI:devfrom
myron:class_ind
Conversation
Signed-off-by: myron <[email protected]>
wyli
reviewed
Apr 4, 2023
Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>
wyli
reviewed
Apr 5, 2023
Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>
Collaborator
Author
|
looks great! let's merge. thank you |
Contributor
|
/build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
to solve: #6285
Currently ClassesToIndicesd can be used to pre-compute and cache the locations of all background/foreground classes.
This significantly speedups the cropping transform RandCropByLabelClassesd, since the coordinates of class voxels do not need to be computed every time.
Unfortunately for an average dataset it requires ~80gb of extra RAM, with an average cache (per image) is on the order of image size itself. (most of it due to background coordinates, or by some large segmentation classes).
This PR clips (optionally) the number of coordinates in each class to a parameter max_indices_per_class. (e.g. 5000), which greatly reduces cache size requirements only to a few MB. Generally these coordinates are used to random choose a cropping center at each epoch, e.g. for 1000 epochs -> 1000 centers per image, so we don't need to store ALL the foreground coordinates, it's sufficient to store just some large random subset.
PS: I wasn't sure if it's better to also change ClassesToIndices (not ClassesToIndicesD), feel free edit this PR.
thank you
Description
A few sentences describing the changes proposed in this pull request.
Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests --disttests.make htmlcommand in thedocs/folder.