Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion monai/apps/auto3dseg/data_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

Expand Down