funkelab / gunpowder

A library to facilitate machine learning on multi-dimensional images.
https://funkelab.github.io/gunpowder/
MIT License
79 stars 56 forks source link

In NoiseAugment, call assert for data in [0, 1] only if clip is True #153

Closed Steffen-Wolf closed 2 years ago

Steffen-Wolf commented 3 years ago

Just a small fix that removes an unnecessary assert in NoiseAugment.

Calling NoiseAugment for data that is not in the range of [0, 1] should be possible. Noise augment warps skimage.util.random_noise internally, that can handle any input range.

For clip==False there should be no assert in any case. I have left the assert in place for when clip==True as it seems reasonable. Note however that this creates an arbitrary restriction. Even for clip==True, skimage.util.random_noise can handle inputs outside of the range [0,1] it just clips the output after adding the noise.

Pre-Merge Checklist:

pattonw commented 2 years ago

Seems reasonable to move the assert. I agree that the assert seems overkill. Maybe we could just change it to a warning or a debugging message?

pattonw commented 2 years ago

Otherwise can probably go ahead and merge this

pattonw commented 2 years ago

merged into the patch-1.2.3 branch