Skip to content

Commit

Permalink
Fix for albumentations transform
Browse files Browse the repository at this point in the history
  • Loading branch information
JBWilkie committed Sep 13, 2024
1 parent 943684c commit 93d1f4b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions darwin/torch/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,11 @@ def _pre_process(self, image: np.ndarray, annotation: dict) -> dict:
if (
masks is not None and masks.numel() > 0
): # using numel() to check if tensor is non-empty
print("WE GOT MASKS")
albumentation_dict["masks"] = masks.numpy()
if isinstance(masks, torch.Tensor):
masks = masks.numpy()
if masks.ndim == 3: # Ensure masks is a list of numpy arrays
masks = [masks[i] for i in range(masks.shape[0])]
albumentation_dict["masks"] = masks

return albumentation_dict

Expand Down

0 comments on commit 93d1f4b

Please sign in to comment.