vision icon indicating copy to clipboard operation
vision copied to clipboard

request for adding 4 bands-image training

Open Floyd2yh opened this issue 1 year ago • 6 comments

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.

Floyd2yh avatar May 03 '24 11:05 Floyd2yh

:link: Helpful Links

:test_tube: See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/8405

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.

pytorch-bot[bot] avatar May 03 '24 11:05 pytorch-bot[bot]

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!

facebook-github-bot avatar May 03 '24 11:05 facebook-github-bot

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

facebook-github-bot avatar May 03 '24 12:05 facebook-github-bot

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 avatar May 03 '24 13:05 abhi-glitchhg

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?

Floyd2yh avatar May 04 '24 09:05 Floyd2yh

uploaded modified code

Floyd2yh avatar May 04 '24 09:05 Floyd2yh

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 avatar May 07 '24 06:05 abhi-glitchhg

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?

Floyd2yh avatar May 07 '24 12:05 Floyd2yh

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.

NicolasHug avatar May 14 '24 14:05 NicolasHug