imgaug-doc icon indicating copy to clipboard operation
imgaug-doc copied to clipboard

AssertionError: Expected number of channels to be three, got 3 channels with shape (512, 512, 1).

Open nickshawn opened this issue 5 years ago • 1 comments

Hi, when I augment a array with shape (H, W), it is ok sometimes, but failed with the above error sometimes, too. could someone tell me how to avoid it?

nickshawn avatar Dec 06 '19 03:12 nickshawn

@nickshawn You're probably trying to apply augmentations that expect the input image to have 3 color channels. If you have a gray-scale image as your input - which it seems like you do - then you need to make sure you don't use augmentations that work with color channels. For example, an augmenter such as AddToHueAndSaturation would raise that error since it expects the input image to have color channels as far as I can tell.

So the solution is to use augmenters that don't work on color channels or to convert your images to RGB, augment, and then convert back (not ideal performance-wise).

csmcallister avatar Feb 07 '20 17:02 csmcallister