diff --git a/monai/apps/auto3dseg/data_analyzer.py b/monai/apps/auto3dseg/data_analyzer.py index 350bb61a34..2a04c9bb50 100644 --- a/monai/apps/auto3dseg/data_analyzer.py +++ b/monai/apps/auto3dseg/data_analyzer.py @@ -332,9 +332,11 @@ def _get_all_case_stats( batch_data = batch_data[0] try: batch_data[self.image_key] = batch_data[self.image_key].to(device) + _label_argmax = False if self.label_key is not None: label = batch_data[self.label_key] label = torch.argmax(label, dim=0) if label.shape[0] > 1 else label[0] + _label_argmax = True # track if label is argmaxed batch_data[self.label_key] = label.to(device) d = summarizer(batch_data) except BaseException as err: @@ -348,7 +350,8 @@ def _get_all_case_stats( batch_data[self.image_key] = batch_data[self.image_key].to("cpu") if self.label_key is not None: label = batch_data[self.label_key] - label = torch.argmax(label, dim=0) if label.shape[0] > 1 else label[0] + if not _label_argmax: + label = torch.argmax(label, dim=0) if label.shape[0] > 1 else label[0] batch_data[self.label_key] = label.to("cpu") d = summarizer(batch_data)