Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6766 data analyser label argmax #6852

Merged
merged 1 commit into from
Aug 10, 2023
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 @@
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 @@
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]

Check warning on line 354 in monai/apps/auto3dseg/data_analyzer.py

View check run for this annotation

Codecov / codecov/patch

monai/apps/auto3dseg/data_analyzer.py#L353-L354

Added lines #L353 - L354 were not covered by tests
batch_data[self.label_key] = label.to("cpu")
d = summarizer(batch_data)

Expand Down
Loading