Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiplicativeNoise(elementwise=True) fails when image shape is (H,W,1) #792

Closed
mjkvaak opened this issue Dec 16, 2020 · 1 comment
Closed

Comments

@mjkvaak
Copy link

mjkvaak commented Dec 16, 2020

Hi,
first of all thanks for one of the most useful ML packages I have found so far! I noticed that albumentations.MultiplicativeNoise fails under these conditions:

  • Image is unsqueezed grayscale with shape (H,W,1)
  • elementwise parameter has been set to True

Below is the minimal reproducing example:

h,w = 28,28
img = np.zeros((h,w))
tfm_img = albumentations.MultiplicativeNoise(elementwise=True, p=1)(image=img)
print(tfm_img['image'].shape) #prints (28,28) as it should

img = np.zeros((h,w,1))
tfm_img = albumentations.MultiplicativeNoise(elementwise=True, p=1)(image=img)
print(tfm_img['image'].shape) #prints (28,28,28) which is a bug

img = np.zeros((h,w,3))
tfm_img = albumentations.MultiplicativeNoise(elementwise=True, p=1)(image=img)
print(tfm_img['image'].shape) #prints (28,28,3) as it should

Also, if h and w are unequal, the script will crash with ValueError:

h,w = 256,28
img = np.zeros((h,w,1))
tfm_img = albumentations.MultiplicativeNoise(elementwise=True, p=1)(image=img)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-152-5abd2e633fe7> in <module>
      5 
      6 img = np.zeros((h,w,1))
----> 7 tfm_img = albumentations.MultiplicativeNoise(elementwise=True, p=1)(image=img)

...

ValueError: operands could not be broadcast together with shapes (256,30,1) (256,30) 
@BloodAxe
Copy link
Contributor

Thanks for your report. We will investigate this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants