Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

flash.image.SemanticSegmentationData dataloaders to convert greyscale/RGBA to RGB for train and val source images. #420

Closed
kurtjcu opened this issue Jun 16, 2021 · 2 comments · Fixed by #669
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@kurtjcu
Copy link

kurtjcu commented Jun 16, 2021

🚀 Feature

Have The dataloaders convert any image type to rgb for use in segmentation.

Motivation

greyscale or RGBA image types crash a training run

Pitch

Most generic segmentation models work with RGB images [3 x length x width], some sources of images may contain either greyscale or RGBA image types. This simple modification would make the Flash segmentation more robust and easier to use.

Alternatives

Check image formats and give a clear error as to the the problem, current stack trace is not indicative of the problem.

Additional context

@kurtjcu kurtjcu added enhancement New feature or request help wanted Extra attention is needed labels Jun 16, 2021
@ethanwharris
Copy link
Collaborator

Hi @kurtjcu Thanks for the issue!

I think the problem is here: https://github.com/PyTorchLightning/lightning-flash/blob/113efabc3e28e80ef03f9b3ed92b11156a4a3ca5/flash/image/segmentation/data.py#L146
We should be loading the image with torchvision.datasets.folder.default_loader and then using torchvision.transforms.ToTensor() to convert it to a tensor. Those methods in torchvision will ensure that the final tensors always have three channels even if the image was greyscale.

Would you be interested in making a PR that implements this fix?

@stale
Copy link

stale bot commented Aug 17, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the won't fix This will not be worked on label Aug 17, 2021
@ananyahjha93 ananyahjha93 removed the won't fix This will not be worked on label Aug 17, 2021
@ananyahjha93 ananyahjha93 self-assigned this Aug 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants