DeepForest icon indicating copy to clipboard operation
DeepForest copied to clipboard

Create a better error handling for RGBA images.

Open bw4sz opened this issue 2 years ago • 9 comments

@agentmorris gave some feedback directly. We should anticipate that many users will arrive not knowing they have four channel RGBA images instead of three channel RGB. I think it is safe to just warn users and then drop the alpha 4th channel. Questions I have.

  1. Is the alpha channel always the last channel? In both opencv and rasterio? I would like to see evidence of this using a test dataset. @agentmorris can you drop that sample image in the issue to use for testing?

  2. We need warnings to let the user know we are dropping the alpha channel. We have that in one spot: https://github.com/weecology/DeepForest/blob/f1e439d2872ce55f5e087389001abefc679eeefd/deepforest/preprocess.py#L188

which catches in split_raster. We probably want to move this check into predict_tile and predict_image as well.

See: https://github.com/weecology/DeepForest/blob/046bc26e1cae0664b6bdfe1315486c7167d320d5/deepforest/predict.py#L19

  1. We need unit tests to confirm that these warnings are being thrown as expected. https://github.com/weecology/DeepForest/blob/f1e439d2872ce55f5e087389001abefc679eeefd/tests/test_preprocess.py#L146

bw4sz avatar Mar 06 '23 18:03 bw4sz

I don't own the images so can't add them to the issue, but I added you to a relevant email thread, I'm sure the data owner will be happy to share some images with you.

agentmorris avatar Mar 06 '23 18:03 agentmorris

@henrykironde do you have that original RGBA image from the everglades orthomosaic. Can you crop a small piece and upload it here to use?

bw4sz avatar Mar 09 '23 18:03 bw4sz

@bw4sz which image are you talking about?

henrykironde avatar Mar 09 '23 19:03 henrykironde

When we saved the ortho from agisoft the first time, there was a RGBA version by accident. We could use it here.

On Thu, Mar 9, 2023 at 11:00 AM henry senyondo @.***> wrote:

@bw4sz https://github.com/bw4sz which image are you talking about?

— Reply to this email directly, view it on GitHub https://github.com/weecology/DeepForest/issues/392#issuecomment-1462608296, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJHBLFQ5UWAPMNQBR6TMDLW3ISFXANCNFSM6AAAAAAVRPFIKE . You are receiving this because you were mentioned.Message ID: @.***>

-- Ben Weinstein, Ph.D. Research Scientist University of Florida http://benweinstein.weebly.com/

bw4sz avatar Mar 09 '23 19:03 bw4sz

For your questions @bw4sz 1 - Yes Alpha is always the forth channel in OpenCV and rasterio (from documentation) 2 - I added warnings to predict.py in predict_tile and predict_image 3 - I tried to add unittest to test_preprocess.py (not sure if it is right) I made a pull request #398 waiting for review

Mu-Magdy avatar Mar 10 '23 01:03 Mu-Magdy

Is this still open? I would like to work on this issue.

ayeankit avatar Mar 10 '23 12:03 ayeankit

@ayeankit, Please take time to read through the issues. You may have missed seeing that @Mu-Magdy just recently put in a PR. Feel free to comment on the PR if you feel there are some areas that could be improved on.

henrykironde avatar Mar 10 '23 22:03 henrykironde

I have added sample 4 band data in https://github.com/Mu-Magdy/DeepForest/pull/1

henrykironde avatar Mar 10 '23 23:03 henrykironde

@henrykironde , I am sorry, I missed that. Will take care in future.

ayeankit avatar Mar 11 '23 16:03 ayeankit

Fixed in 0f43dda68670a5673e670016c05c9760370567f0

ethanwhite avatar Apr 16 '25 01:04 ethanwhite