request for adding 4 bands-image training
Aerial and satellite images taken with a drone are,typically in 4-band geotiff format. A 4-band image is an RBGN image, which is a 3-band RGB plus near-infrared (NIR) to the 3-band RGB. This modification is needed to train the 4band-image without processing.
:link: Helpful Links
:test_tube: See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/8405
- :page_facing_up: Preview Python docs built from this PR
Note: Links to docs will display an error until the docs builds have been completed.
This comment was automatically generated by Dr. CI and updates every 15 minutes.
Hi @Floyd2yh!
Thank you for your pull request and welcome to our community.
Action Required
In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.
Process
In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.
Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.
If you have received this in error or have any questions, please contact us at [email protected]. Thanks!
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!
If image has 4 channels, doesn't mean we should load all 4 channels. It would be better if pil_loader takes optional parameter which indicates whether to return RGB only or PIL image without any conversion
Because sometimes images have alpha channel (RGBA image) which are mostly constant value. In those cases, it's required to get rid of alpha channel.
abhi-glitchhg, thank you for your advice. I agree with your point about PNG (RBGA). However, adding an optional argument would also cause changes to the caller, which would be a major modification. Also, the conversion to RGBX is necessary even for a 4-band image. I have uploaded a corrected version. What do you think?
uploaded modified code
I think we need to take a review/comments from maintainers in this approach. Maybe @pmeier or @NicolasHug ?? What do you guys think??
abhi-glitchhg, ok I understood. but how can I set loader?
train_data = datasets.ImageFolder(root=train_dataset_dir, transform=train_transforms, loader=????????) will you teach me?
Thanks for the PR @Floyd2yh .
The ImageFolder class exposes a loader attribute that you can override to a custom loader. I'd suggest simply doing that locally.
Unfortunately we won't be able to include the change within torchvision, because our transforms expect RGB images with 3 channels instead of 4.