Open abdksyed opened 1 year ago
The workaround for this, which I am using for now is
def __init__(self, masks, height, width):
self.height = height
self.width = width
if len(masks) == 0:
self.masks = np.empty((0, self.height, self.width), dtype=np.uint8)
else:
assert isinstance(masks, (list, np.ndarray))
if isinstance(masks, list):
assert isinstance(masks[0], np.ndarray)
assert masks[0].ndim == 2 # (H, W)
else:
assert masks.ndim == 3 # (N, H, W)
# ----- CHANGES -----
# self.masks = np.stack(masks).reshape(-1, height, width)
self.masks = np.stack(masks)
# assert self.masks.shape[1] == self.height
# assert self.masks.shape[2] == self.width
self.height = self.masks.shape[1]
self.width = self.masks.shape[2]
I am overwriting the height
and width
parameter with the mask height
and width
.
The workaround for this, which I am using for now is
def __init__(self, masks, height, width): self.height = height self.width = width if len(masks) == 0: self.masks = np.empty((0, self.height, self.width), dtype=np.uint8) else: assert isinstance(masks, (list, np.ndarray)) if isinstance(masks, list): assert isinstance(masks[0], np.ndarray) assert masks[0].ndim == 2 # (H, W) else: assert masks.ndim == 3 # (N, H, W) # ----- CHANGES ----- # self.masks = np.stack(masks).reshape(-1, height, width) self.masks = np.stack(masks) # assert self.masks.shape[1] == self.height # assert self.masks.shape[2] == self.width self.height = self.masks.shape[1] self.width = self.masks.shape[2]
I am overwriting the height and width parameter with the mask height and width.
Now it can run but all mask lose turn to 0. So werid
I don't remember the loss going to 0. It's been over a year, so I don't remember much, but I am sure I was able to train the model.
Maybe you can visualise the actual mask it is creating.
Thanks for your error report and we appreciate it a lot.
Checklist
Describe the bug A clear and concise description of what the bug is.
I am using Albumentations for Augmentations.
I copied the transforms and pipeline from the given Albumentations example on top of mask rcnn. The given example works fine, but the pipeline fails with an error when I add any Albumentation augmentation related to cropping (Added error traceback below)
Reproduction
Here are the transformations and pipeline
Environment
python mmdet/utils/collect_env.py
to collect necessary environment information and paste it here.$PATH
,$LD_LIBRARY_PATH
,$PYTHONPATH
, etc.)Error traceback
The error is clear, the original image/mask is of size (715,895), but after applying the cropping augmentation, I have 5 masks cropped at 250x300. Which are being stacked and reshaped. But the height and weight when being reshaped is being taken from original shape from
ori_mask
object. The new height and width should be used since the mask has already been transformed using Cropping augmentation.Hence the size 450000 should be reshaped to (250,300) rather than original shape of (715,895).
Bug fix If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!