Skip to content

Commit

Permalink
Fix randomness for threading
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-wirtz-snkeos committed Jul 17, 2024
1 parent 4fbe800 commit fa4ceb7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion monai/transforms/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ def execute_compose(

for _transform in transforms[start:end]:
if threading:
_transform = deepcopy(_transform) if isinstance(_transform, ThreadUnsafe) else _transform
if isinstance(_transform, ThreadUnsafe):
if isinstance(_transform, Randomizable):
# update the random state before deepcopy, otherwise there is no randomness
_transform.randomize()
_transform = deepcopy(_transform)
data = apply_transform(
_transform, data, map_items, unpack_items, lazy=lazy, overrides=overrides, log_stats=log_stats
)
Expand Down

0 comments on commit fa4ceb7

Please sign in to comment.