Skip to content

Commit f6f9e81

Browse files
authored
Use int16 instead of int8 in LabelStats (#7489)
Use uint8 instead of int8 in `LabelStats`. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: YunLiu <[email protected]>
1 parent 9c77a04 commit f6f9e81

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

monai/auto3dseg/analyzer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ def __call__(self, data: Mapping[Hashable, MetaTensor]) -> dict[Hashable, MetaTe
460460
torch.set_grad_enabled(False)
461461

462462
ndas: list[MetaTensor] = [d[self.image_key][i] for i in range(d[self.image_key].shape[0])] # type: ignore
463-
ndas_label: MetaTensor = d[self.label_key].astype(torch.int8) # (H,W,D)
463+
ndas_label: MetaTensor = d[self.label_key].astype(torch.int16) # (H,W,D)
464464

465465
if ndas_label.shape != ndas[0].shape:
466466
raise ValueError(f"Label shape {ndas_label.shape} is different from image shape {ndas[0].shape}")
@@ -472,7 +472,7 @@ def __call__(self, data: Mapping[Hashable, MetaTensor]) -> dict[Hashable, MetaTe
472472
if isinstance(ndas_label, (MetaTensor, torch.Tensor)):
473473
unique_label = unique_label.data.cpu().numpy()
474474

475-
unique_label = unique_label.astype(np.int8).tolist()
475+
unique_label = unique_label.astype(np.int16).tolist()
476476

477477
label_substats = [] # each element is one label
478478
pixel_sum = 0

0 commit comments

Comments
 (0)