From 2bd59165e0bd3077e6efc6546e56c1031ded2c1b Mon Sep 17 00:00:00 2001 From: Yiheng Wang Date: Mon, 14 Feb 2022 21:12:07 +0800 Subject: [PATCH] change raise error to warnings for some metrics Signed-off-by: Yiheng Wang --- monai/metrics/hausdorff_distance.py | 2 +- monai/metrics/meandice.py | 2 +- monai/metrics/surface_distance.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/monai/metrics/hausdorff_distance.py b/monai/metrics/hausdorff_distance.py index 7644e52f83..51748c43c1 100644 --- a/monai/metrics/hausdorff_distance.py +++ b/monai/metrics/hausdorff_distance.py @@ -85,7 +85,7 @@ def _compute_tensor(self, y_pred: torch.Tensor, y: torch.Tensor): # type: ignor if not torch.all(y_pred.byte() == y_pred): warnings.warn("y_pred should be a binarized tensor.") if not torch.all(y.byte() == y): - raise ValueError("y should be a binarized tensor.") + warnings.warn("y should be a binarized tensor.") dims = y_pred.ndimension() if dims < 3: raise ValueError("y_pred should have at least three dimensions.") diff --git a/monai/metrics/meandice.py b/monai/metrics/meandice.py index f1e272bbe5..15635ff2d9 100644 --- a/monai/metrics/meandice.py +++ b/monai/metrics/meandice.py @@ -72,7 +72,7 @@ def _compute_tensor(self, y_pred: torch.Tensor, y: torch.Tensor): # type: ignor if not torch.all(y_pred.byte() == y_pred): warnings.warn("y_pred should be a binarized tensor.") if not torch.all(y.byte() == y): - raise ValueError("y should be a binarized tensor.") + warnings.warn("y should be a binarized tensor.") dims = y_pred.ndimension() if dims < 3: raise ValueError("y_pred should have at least three dimensions.") diff --git a/monai/metrics/surface_distance.py b/monai/metrics/surface_distance.py index 11b472185d..fce4b735e5 100644 --- a/monai/metrics/surface_distance.py +++ b/monai/metrics/surface_distance.py @@ -78,7 +78,7 @@ def _compute_tensor(self, y_pred: torch.Tensor, y: torch.Tensor): # type: ignor if not torch.all(y_pred.byte() == y_pred): warnings.warn("y_pred should be a binarized tensor.") if not torch.all(y.byte() == y): - raise ValueError("y should be a binarized tensor.") + warnings.warn("y should be a binarized tensor.") dims = y_pred.ndimension() if dims < 3: raise ValueError("y_pred should have at least three dimensions.")