@@ -224,8 +224,8 @@ def resize_center(img: np.ndarray, *resize_dims: Optional[int], fill_value: floa
224224
225225 resize_dims = fall_back_tuple (resize_dims , img .shape )
226226
227- half_img_shape = np .asarray (img .shape ) // 2
228- half_dest_shape = np .asarray (resize_dims ) // 2
227+ half_img_shape = ( np .asarray (img .shape ) // 2 ). tolist ()
228+ half_dest_shape = ( np .asarray (resize_dims ) // 2 ). tolist ()
229229 srcslices , destslices = copypaste_arrays (img .shape , resize_dims , half_img_shape , half_dest_shape , resize_dims )
230230
231231 if not inplace :
@@ -318,7 +318,7 @@ def generate_pos_neg_label_crop_centers(
318318 label_spatial_shape : Sequence [int ],
319319 fg_indices : np .ndarray ,
320320 bg_indices : np .ndarray ,
321- rand_state : np .random .RandomState = np . random ,
321+ rand_state : Optional [ np .random .RandomState ] = None ,
322322) -> List [List [np .ndarray ]]:
323323 """
324324 Generate valid sample locations based on the label with option for specifying foreground ratio
@@ -338,6 +338,8 @@ def generate_pos_neg_label_crop_centers(
338338 ValueError: When the foreground and background indices lengths are 0.
339339
340340 """
341+ if rand_state is None :
342+ rand_state = np .random .random .__self__ # type: ignore
341343 spatial_size = fall_back_tuple (spatial_size , default = label_spatial_shape )
342344 if not (np .subtract (label_spatial_shape , spatial_size ) >= 0 ).all ():
343345 raise ValueError ("The size of the proposed random crop ROI is larger than the image size." )
@@ -602,7 +604,7 @@ def get_largest_connected_component_mask(img: torch.Tensor, connectivity: Option
602604
603605
604606def get_extreme_points (
605- img : np .ndarray , rand_state : np .random .RandomState = np . random , background : int = 0 , pert : float = 0.0
607+ img : np .ndarray , rand_state : Optional [ np .random .RandomState ] = None , background : int = 0 , pert : float = 0.0
606608) -> List [Tuple [int , ...]]:
607609 """
608610 Generate extreme points from an image. These are used to generate initial segmentation
@@ -624,6 +626,8 @@ def get_extreme_points(
624626 Raises:
625627 ValueError: When the input image does not have any foreground pixel.
626628 """
629+ if rand_state is None :
630+ rand_state = np .random .random .__self__ # type: ignore
627631 indices = np .where (img != background )
628632 if np .size (indices [0 ]) == 0 :
629633 raise ValueError ("get_extreme_points: no foreground object in mask!" )
0 commit comments