matterport / Mask_RCNN

Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow
Other
24.52k stars 11.68k forks source link

Error using augmentation #2201

Open lamtrinhthanh opened 4 years ago

lamtrinhthanh commented 4 years ago

Hi everyone,

I use augmentation as follows:

> ``seq = iaa.Sometimes(0.833, iaa.Sequential([
    iaa.Fliplr(0.5), # horizontal flips
    iaa.Crop(percent=(0, 0.1)), # random crops
    # Small gaussian blur with random sigma between 0 and 0.5.
    # But we only blur about 50% of all images.
    iaa.Sometimes(0.5,
        iaa.GaussianBlur(sigma=(0, 0.5))
    ),
    # Strengthen or weaken the contrast in each image.
    iaa.ContrastNormalization((0.75, 1.5)),
    # Add gaussian noise.
    # For 50% of all images, we sample the noise once per pixel.
    # For the other 50% of all images, we sample the noise per pixel AND
    # channel. This can change the color (not only brightness) of the
    # pixels.
    iaa.AdditiveGaussianNoise(loc=0, scale=(0.0, 0.05*255), per_channel=0.5),
    # Make some images brighter and some darker.
    # In 20% of all cases, we sample the multiplier once per channel,
    # which can end up changing the color of the images.
    iaa.Multiply((0.8, 1.2), per_channel=0.2),
    # Apply affine transformations to each image.
    # Scale/zoom them, translate/move them, rotate them and shear them.
    iaa.Affine(
        scale={"x": (0.8, 1.2), "y": (0.8, 1.2)},
        translate_percent={"x": (-0.2, 0.2), "y": (-0.2, 0.2)},
        rotate=(-25, 25),
        shear=(-8, 8)
    )
], random_order=True)) # apply augmenters in random order``

and the errors happen with the input array, mask:

ERROR:root:Error processing image {'id': '1281', 'source': 'dataset', 'path': '/content/drive/My Drive/mask rcnn/train_image/1281.jpg', 'annotation': '/content/drive/My Drive/mask rcnn/train_annotation/1281.xml'}
Traceback (most recent call last):
  File "/content/drive/My Drive/mask rcnn/mrcnn/model.py", line 1709, in data_generator
    use_mini_mask=config.USE_MINI_MASK)
  File "/content/drive/My Drive/mask rcnn/mrcnn/model.py", line 1254, in load_image_gt
    hooks=imgaug.HooksImages(activator=hook))
  File "/usr/local/lib/python3.6/dist-packages/imgaug/augmenters/meta.py", line 470, in augment_image
    return self.augment_images([image], hooks=hooks)[0]
  File "/usr/local/lib/python3.6/dist-packages/imgaug/augmenters/meta.py", line 603, in augment_images
    hooks=hooks
  File "/usr/local/lib/python3.6/dist-packages/imgaug/augmenters/meta.py", line 3386, in _augment_images
    hooks=hooks
  File "/usr/local/lib/python3.6/dist-packages/imgaug/augmenters/meta.py", line 603, in augment_images
    hooks=hooks
  File "/usr/local/lib/python3.6/dist-packages/imgaug/augmenters/meta.py", line 2816, in _augment_images
    hooks=hooks
  File "/usr/local/lib/python3.6/dist-packages/imgaug/augmenters/meta.py", line 603, in augment_images
    hooks=hooks
  File "/usr/local/lib/python3.6/dist-packages/imgaug/augmenters/size.py", line 795, in _augment_images
    image_cr_pa = ia.imresize_single_image(image_cr_pa, (height, width))
  File "/usr/local/lib/python3.6/dist-packages/imgaug/imgaug.py", line 1289, in imresize_single_image
    rs = imresize_many_images(image[np.newaxis, :, :, :], sizes, interpolation=interpolation)
  File "/usr/local/lib/python3.6/dist-packages/imgaug/imgaug.py", line 1253, in imresize_many_images
    result[i] = result_img
ValueError: could not broadcast input array from shape (1024,1024,512) into shape (1024,1024,0)
`Traceback (most recent call last):
  File "/content/drive/My Drive/mask rcnn/mrcnn/model.py", line 1709, in data_generator
    use_mini_mask=config.USE_MINI_MASK)
  File "/content/drive/My Drive/mask rcnn/mrcnn/model.py", line 1257, in load_image_gt
    assert mask.shape == mask_shape, "Augmentation shouldn't change mask size"
AssertionError: Augmentation shouldn't change mask size`

Hope you guys can help me,

innat commented 4 years ago

iaa.Crop(percent=(0, 0.1)), # random crops remove it!