"""Utility functions for evaluation."""importnumpyasnpfromvis4d.common.arrayimportarray_to_numpyfromvis4d.common.typingimportArrayLike,NDArrayNumber
[docs]defdense_inputs_to_numpy(prediction:ArrayLike,target:ArrayLike)->tuple[NDArrayNumber,NDArrayNumber]:"""Convert dense prediction and target to numpy arrays."""prediction=array_to_numpy(prediction,n_dims=None,dtype=np.float32)target=array_to_numpy(target,n_dims=None,dtype=np.float32)returnprediction,target
[docs]defcheck_shape_match(prediction:NDArrayNumber,target:NDArrayNumber)->None:"""Check if the shape of prediction and target matches."""assertprediction.shape==target.shape,(f"Shape mismatch between prediction {prediction.shape} and target"f"{target.shape}.")