handle 0 padding and set nans/infty to 0 #4
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello, ran into 2 issues when running DeepWaterMap that I think are easily resolvable.
If the image is exactly divisible by 32, then the padding indices are
pad_r == (0,0)
andpad_c = (0,0)
. This causes a problem when trying to use these padding indices to resize the output image as indexingdwm = dwm[0:-0, 0:-0]
returns an empty array. So by checking for 0s in the second values for the padding arrays and setting them to 1 if needed, this issue is resolved becausedwm = dwm[0:-1, 0:-1]
will return the entire array.If there are any NaN or infinity values in the input image, then the pre-processing step where the image is normalized can turn the entire array into NaNs. One potential fix is to check for an NaNs or infinity values and raise an error right after loading the image, I propose simply replacing the values with 0s if they are present instead.
These fixes appear to have resolved the problems I was running into. Again, not sure if they are the best solutions, but they're working for me.