Create a better error handling for RGBA images.
@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.
-
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?
-
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
- 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
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.
@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 which image are you talking about?
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/
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
Is this still open? I would like to work on this issue.
@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.
I have added sample 4 band data in https://github.com/Mu-Magdy/DeepForest/pull/1
@henrykironde , I am sorry, I missed that. Will take care in future.
Fixed in 0f43dda68670a5673e670016c05c9760370567f0