@@ -395,7 +395,7 @@ def __init__(
395395 self .zoomer = Zoom (zoom = zoom , keep_size = keep_size , ** kwargs )
396396 self .keep_size = keep_size
397397
398- def __call__ (self , data : Mapping [Hashable , NdarrayOrTensor ]) -> Dict [Hashable , NdarrayOrTensor ]:
398+ def __call__ (self , data : Mapping [Hashable , torch . Tensor ]) -> Dict [Hashable , torch . Tensor ]:
399399 d = dict (data )
400400
401401 # zoom box
@@ -408,7 +408,7 @@ def __call__(self, data: Mapping[Hashable, NdarrayOrTensor]) -> Dict[Hashable, N
408408 box_key ,
409409 extra_info = {"zoom" : self .zoomer .zoom , "src_spatial_size" : src_spatial_size , "type" : "box_key" },
410410 )
411- d [box_key ] = ZoomBox (zoom = self .zoomer .zoom , keep_size = self .keep_size )(
411+ d [box_key ] = ZoomBox (zoom = self .zoomer .zoom , keep_size = self .keep_size )( # type: ignore
412412 d [box_key ], src_spatial_size = src_spatial_size
413413 )
414414
@@ -431,7 +431,7 @@ def __call__(self, data: Mapping[Hashable, NdarrayOrTensor]) -> Dict[Hashable, N
431431
432432 return d
433433
434- def inverse (self , data : Mapping [Hashable , NdarrayOrTensor ]) -> Dict [Hashable , NdarrayOrTensor ]:
434+ def inverse (self , data : Mapping [Hashable , torch . Tensor ]) -> Dict [Hashable , torch . Tensor ]:
435435 d = deepcopy (dict (data ))
436436
437437 for key in self .key_iterator (d ):
@@ -461,7 +461,7 @@ def inverse(self, data: Mapping[Hashable, NdarrayOrTensor]) -> Dict[Hashable, Nd
461461 zoom = np .array (transform [TraceKeys .EXTRA_INFO ]["zoom" ])
462462 src_spatial_size = transform [TraceKeys .EXTRA_INFO ]["src_spatial_size" ]
463463 box_inverse_transform = ZoomBox (zoom = (1 / zoom ).tolist (), keep_size = self .zoomer .keep_size )
464- d [key ] = box_inverse_transform (d [key ], src_spatial_size = src_spatial_size )
464+ d [key ] = box_inverse_transform (d [key ], src_spatial_size = src_spatial_size ) # type: ignore
465465
466466 # Remove the applied transform
467467 self .pop_transform (d , key )
@@ -545,7 +545,7 @@ def set_random_state(
545545 self .rand_zoom .set_random_state (seed , state )
546546 return self
547547
548- def __call__ (self , data : Mapping [Hashable , NdarrayOrTensor ]) -> Dict [Hashable , NdarrayOrTensor ]:
548+ def __call__ (self , data : Mapping [Hashable , torch . Tensor ]) -> Dict [Hashable , torch . Tensor ]:
549549 d = dict (data )
550550 first_key : Union [Hashable , List ] = self .first_key (d )
551551 if first_key == []:
@@ -568,7 +568,7 @@ def __call__(self, data: Mapping[Hashable, NdarrayOrTensor]) -> Dict[Hashable, N
568568 box_key ,
569569 extra_info = {"zoom" : self .rand_zoom ._zoom , "src_spatial_size" : src_spatial_size , "type" : "box_key" },
570570 )
571- d [box_key ] = ZoomBox (zoom = self .rand_zoom ._zoom , keep_size = self .keep_size )(
571+ d [box_key ] = ZoomBox (zoom = self .rand_zoom ._zoom , keep_size = self .keep_size )( # type: ignore
572572 d [box_key ], src_spatial_size = src_spatial_size
573573 )
574574
@@ -595,7 +595,7 @@ def __call__(self, data: Mapping[Hashable, NdarrayOrTensor]) -> Dict[Hashable, N
595595
596596 return d
597597
598- def inverse (self , data : Mapping [Hashable , NdarrayOrTensor ]) -> Dict [Hashable , NdarrayOrTensor ]:
598+ def inverse (self , data : Mapping [Hashable , torch . Tensor ]) -> Dict [Hashable , torch . Tensor ]:
599599 d = deepcopy (dict (data ))
600600
601601 for key in self .key_iterator (d ):
@@ -626,7 +626,7 @@ def inverse(self, data: Mapping[Hashable, NdarrayOrTensor]) -> Dict[Hashable, Nd
626626 zoom = np .array (transform [TraceKeys .EXTRA_INFO ]["zoom" ])
627627 src_spatial_size = transform [TraceKeys .EXTRA_INFO ]["src_spatial_size" ]
628628 box_inverse_transform = ZoomBox (zoom = (1.0 / zoom ).tolist (), keep_size = self .rand_zoom .keep_size )
629- d [key ] = box_inverse_transform (d [key ], src_spatial_size = src_spatial_size )
629+ d [key ] = box_inverse_transform (d [key ], src_spatial_size = src_spatial_size ) # type: ignore
630630
631631 # Remove the applied transform
632632 self .pop_transform (d , key )
@@ -667,7 +667,7 @@ def __call__(self, data: Mapping[Hashable, NdarrayOrTensor]) -> Dict[Hashable, N
667667 d = dict (data )
668668
669669 for key in self .image_keys :
670- d [key ] = self .flipper (d [key ])
670+ d [key ] = self .flipper (d [key ]) # type: ignore
671671 self .push_transform (d , key , extra_info = {"type" : "image_key" })
672672
673673 for box_key , box_ref_image_key in zip (self .box_keys , self .box_ref_image_keys ):
@@ -685,7 +685,7 @@ def inverse(self, data: Mapping[Hashable, NdarrayOrTensor]) -> Dict[Hashable, Nd
685685
686686 # flip image, copied from monai.transforms.spatial.dictionary.Flipd
687687 if key_type == "image_key" :
688- d [key ] = self .flipper (d [key ])
688+ d [key ] = self .flipper (d [key ]) # type: ignore
689689
690690 # flip boxes
691691 if key_type == "box_key" :
@@ -743,7 +743,7 @@ def __call__(self, data: Mapping[Hashable, NdarrayOrTensor]) -> Dict[Hashable, N
743743
744744 for key in self .image_keys :
745745 if self ._do_transform :
746- d [key ] = self .flipper (d [key ], randomize = False )
746+ d [key ] = self .flipper (d [key ], randomize = False ) # type: ignore
747747 self .push_transform (d , key , extra_info = {"type" : "image_key" })
748748
749749 for box_key , box_ref_image_key in zip (self .box_keys , self .box_ref_image_keys ):
@@ -763,7 +763,7 @@ def inverse(self, data: Mapping[Hashable, NdarrayOrTensor]) -> Dict[Hashable, Nd
763763 if transform [TraceKeys .DO_TRANSFORM ]:
764764 # flip image, copied from monai.transforms.spatial.dictionary.RandFlipd
765765 if key_type == "image_key" :
766- d [key ] = self .flipper (d [key ], randomize = False )
766+ d [key ] = self .flipper (d [key ], randomize = False ) # type: ignore
767767
768768 # flip boxes
769769 if key_type == "box_key" :
@@ -1271,7 +1271,7 @@ def __call__(self, data: Mapping[Hashable, NdarrayOrTensor]) -> Mapping[Hashable
12711271 self .push_transform (d , key , extra_info = {"spatial_size" : spatial_size , "type" : "box_key" })
12721272
12731273 for key in self .image_keys :
1274- d [key ] = self .img_rotator (d [key ])
1274+ d [key ] = self .img_rotator (d [key ]) # type: ignore
12751275 self .push_transform (d , key , extra_info = {"type" : "image_key" })
12761276 return d
12771277
@@ -1285,7 +1285,7 @@ def inverse(self, data: Mapping[Hashable, NdarrayOrTensor]) -> Dict[Hashable, Nd
12851285
12861286 if key_type == "image_key" :
12871287 inverse_transform = Rotate90 (num_times_to_rotate , self .img_rotator .spatial_axes )
1288- d [key ] = inverse_transform (d [key ])
1288+ d [key ] = inverse_transform (d [key ]) # type: ignore
12891289 if key_type == "box_key" :
12901290 spatial_size = transform [TraceKeys .EXTRA_INFO ]["spatial_size" ]
12911291 inverse_transform = RotateBox90 (num_times_to_rotate , self .box_rotator .spatial_axes )
@@ -1329,7 +1329,7 @@ def __init__(
13291329 super ().__init__ (self .image_keys + self .box_keys , prob , max_k , spatial_axes , allow_missing_keys )
13301330 self .box_ref_image_keys = ensure_tuple_rep (box_ref_image_keys , len (self .box_keys ))
13311331
1332- def __call__ (self , data : Mapping [Hashable , NdarrayOrTensor ]) -> Mapping [Hashable , NdarrayOrTensor ]:
1332+ def __call__ (self , data : Mapping [Hashable , NdarrayOrTensor ]) -> Mapping [Hashable , NdarrayOrTensor ]: # type: ignore
13331333 self .randomize ()
13341334 d = dict (data )
13351335
@@ -1357,11 +1357,11 @@ def __call__(self, data: Mapping[Hashable, NdarrayOrTensor]) -> Mapping[Hashable
13571357
13581358 for key in self .image_keys :
13591359 if self ._do_transform :
1360- d [key ] = img_rotator (d [key ])
1360+ d [key ] = img_rotator (d [key ]) # type: ignore
13611361 self .push_transform (d , key , extra_info = {"rand_k" : self ._rand_k , "type" : "image_key" })
13621362 return d
13631363
1364- def inverse (self , data : Mapping [Hashable , NdarrayOrTensor ]) -> Dict [Hashable , NdarrayOrTensor ]:
1364+ def inverse (self , data : Mapping [Hashable , NdarrayOrTensor ]) -> Dict [Hashable , NdarrayOrTensor ]: # type: ignore
13651365 d = deepcopy (dict (data ))
13661366 if self ._rand_k % 4 == 0 :
13671367 return d
@@ -1376,7 +1376,7 @@ def inverse(self, data: Mapping[Hashable, NdarrayOrTensor]) -> Dict[Hashable, Nd
13761376 # flip image, copied from monai.transforms.spatial.dictionary.RandFlipd
13771377 if key_type == "image_key" :
13781378 inverse_transform = Rotate90 (num_times_to_rotate , self .spatial_axes )
1379- d [key ] = inverse_transform (d [key ])
1379+ d [key ] = inverse_transform (d [key ]) # type: ignore
13801380 if key_type == "box_key" :
13811381 spatial_size = transform [TraceKeys .EXTRA_INFO ]["spatial_size" ]
13821382 inverse_transform = RotateBox90 (num_times_to_rotate , self .spatial_axes )
0 commit comments