Skip to content

Commit

Permalink
Update monai/transforms/compose.py
Browse files Browse the repository at this point in the history
Co-authored-by: Ben Murray <[email protected]>
Signed-off-by: Marcus Wirtz <[email protected]>
  • Loading branch information
marcus-wirtz-snkeos and atbenmurray authored Oct 21, 2024
1 parent dd45f3b commit 4d49755
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions monai/transforms/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,13 @@ def execute_compose(
return data

for _transform in transforms[start:end]:
if threading and isinstance(_transform, ThreadUnsafe):
if isinstance(_transform, Randomizable):
# iterate the random state before deepcopy, otherwise there is no randomness
d = dict(data) if isinstance(data, Mapping) else data
_transform.randomize(d)
_transform = deepcopy(_transform)
with lock:
if threading and isinstance(_transform, ThreadUnsafe):
if isinstance(_transform, Randomizable):
# iterate the random state before deepcopy, otherwise there is no randomness
d = dict(data) if isinstance(data, Mapping) else data
_transform.randomize(d)
_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 4d49755

Please sign in to comment.