Skip to content

Commit

Permalink
further optimize ConvertSegmentationToRegionsTransform
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianIsensee committed Apr 26, 2024
1 parent f14188b commit 60b23b4
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ def __call__(self, **data_dict):
b, c, *shape = seg.shape
region_output = np.zeros((b, len(self.regions), *shape), dtype=bool)
for region_id, region_labels in enumerate(self.regions):
if not isinstance(region_labels, (list, tuple)):
region_labels = (region_labels, )
for label_value in region_labels:
region_output[:, region_id] |= (seg[:, self.seg_channel] == label_value)
region_output[:, region_id] |= np.isin(seg[:, self.seg_channel], region_labels)
data_dict[self.output_key] = region_output.astype(np.uint8, copy=False)
return data_dict

0 comments on commit 60b23b4

Please sign in to comment.