@@ -800,9 +800,9 @@ def __init__(
800800 self .padder = Pad (mode = mode , ** pad_kwargs )
801801
802802 @Crop .lazy_evaluation .setter # type: ignore
803- def lazy_evaluation (self , val : bool ):
804- self .lazy_evaluation = val
805- self .padder .lazy_evaluation = val
803+ def lazy_evaluation (self , _val : bool ):
804+ self ._lazy_evaluation = False # foreground can't be computed lazily
805+ self .padder .lazy_evaluation = False
806806
807807 def compute_bounding_box (self , img : torch .Tensor ):
808808 """
@@ -839,10 +839,8 @@ def crop_pad(
839839 ret = self .padder .__call__ (img = cropped , to_pad = pad_width , mode = mode , ** pad_kwargs )
840840 # combine the traced cropping and padding into one transformation
841841 # by taking the padded info and placing it in a key inside the crop info.
842- if get_track_meta ():
843- ret_ : MetaTensor = ret # type: ignore
844- app_op = ret_ .applied_operations .pop (- 1 )
845- ret_ .applied_operations [- 1 ][TraceKeys .EXTRA_INFO ]["pad_info" ] = app_op
842+ if get_track_meta () and isinstance (ret , MetaTensor ):
843+ ret .applied_operations [- 1 ][TraceKeys .EXTRA_INFO ]["pad_info" ] = ret .applied_operations .pop ()
846844 return ret
847845
848846 def __call__ (self , img : torch .Tensor , mode : str | None = None , ** pad_kwargs ): # type: ignore
0 commit comments