@@ -341,12 +341,14 @@ def get_edge_surface_distance(
341341 if not edges_gt .any ():
342342 warnings .warn (
343343 f"the ground truth of class { class_index if class_index != - 1 else 'Unknown' } is all 0,"
344- " this may result in nan/inf distance."
344+ " this may result in nan/inf distance." ,
345+ stacklevel = 2 ,
345346 )
346347 if not edges_pred .any ():
347348 warnings .warn (
348349 f"the prediction of class { class_index if class_index != - 1 else 'Unknown' } is all 0,"
349- " this may result in nan/inf distance."
350+ " this may result in nan/inf distance." ,
351+ stacklevel = 2 ,
350352 )
351353 distances : tuple [torch .Tensor , torch .Tensor ] | tuple [torch .Tensor ]
352354 if symmetric :
@@ -375,7 +377,7 @@ def is_binary_tensor(input: torch.Tensor, name: str) -> None:
375377 if not isinstance (input , torch .Tensor ):
376378 raise ValueError (f"{ name } must be of type PyTorch Tensor." )
377379 if not torch .all (input .byte () == input ) or input .max () > 1 or input .min () < 0 :
378- warnings .warn (f"{ name } should be a binarized tensor." )
380+ warnings .warn (f"{ name } should be a binarized tensor." , stacklevel = 2 )
379381
380382
381383def remap_instance_id (pred : torch .Tensor , by_size : bool = False ) -> torch .Tensor :
@@ -510,7 +512,8 @@ def compute_voronoi_regions_fast(labels: np.ndarray | torch.Tensor) -> torch.Ten
510512 if isinstance (labels , torch .Tensor ):
511513 warnings .warn (
512514 "Voronoi computation is running on CPU. "
513- "To accelerate, move the input tensor to GPU and ensure 'cupy' with 'cupyx.scipy.ndimage' is installed."
515+ "To accelerate, move the input tensor to GPU and ensure 'cupy' with 'cupyx.scipy.ndimage' is installed." ,
516+ stacklevel = 2 ,
514517 )
515518 x = labels .cpu ().numpy ()
516519 else :
0 commit comments