-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
Contribution wantedbugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
Describe the bug
monai.transforms.RandomWeightedCrop uses the function monai.transforms.utils.weighted_patch_samples. At line 576 in utils the weighted_patch_samples function converts the datatype of the randomly generate number in the range of (0,1) to match the datatype of the input weightmap.
"""
r, *_ = convert_to_dst_type(r_state.random(n_samples), v)
"""
If the weightmap consisted of integers then the random value will always be the integer of 0, which disables random sampling and instead samples from the first valid region continuously.
To Reproduce
Steps to reproduce the behavior:
- Create a numpy weightmap with integer datatype
- Pass weightmap into RandomWeightedCrop
- Observe the "crop_center" value in the meta data of the cropped image after multiple iterations it will remain constant
Expected behavior
The random factor "r" should never be an converted to an integer.
Metadata
Metadata
Assignees
Labels
Contribution wantedbugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers