-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to load indexed images (color maps) using dataset loader #622
Comments
The You can very easily write your own dataset class that satisfies the constraints of your dataset. It's very simple, something like class Dataset(object):
def __init__(self):
# load paths for your dataset and put in self.data
self.data = ...
def __getitem__(self, idx):
# get path to both images and mask
data_path, mask_path = self.data[idx]
# load images
image = Image.open(data_path).convert("RGB")
mask = Image.open(mask_path)
# add transforms
return image, mask
def __len__(self):
return len(self.data) |
I can write my own loader yes. But essentially, segmentation is classification of each pixel. So essentially, at this moment there are no in-built methods to load segmentation maps, yes (Also transforms on color maps, such that pixel values are maintained and not further interpolated) ? Can we have a feature request for that ? Willing to chip in, since I realized I spent a considerable amount of time writing the same segmentation ingestion pipeline for different projects. Thanks for the quick reply 👍 |
Hey, There have been a number of requests for adding support for masks or segmentation data in torchvision. The current recommended way of handling arbitrary transforms on both images and masks is by using the functional transforms. This lets you choose the right interpolation method for whichever data type you want (images usually use bilinear interpolation, masks require nearest interpolation, etc). BTW, what's the segmentation dataset that you are currently working on? |
I am working on a domain adaptation task, with source domains as GTA and synthia and target domain as the cityscapes dataset. It's basically an improvement to this paper I understand your point of diversity between the different formats but adding support for the popular ones, coco, voc, cityscapes, mapilliary, etc, even if not synthetic ones would be a big help. Thanks for your time. |
I think COCO, VOC and potentially Cityscapes could be added. I haven't heard of mapilliary before. At some point we should decide if we want all possible datasets in torchvision, or only the most used ones. In one hand, providing all possible datasets might make the user not realize that, if a dataset is not present in torchvision, he can also without much troubles implement his own logic for loading the data. |
…ytorch#622) * Align optimizer parameters for embeddings and dense layers * Remove weight_decay for embedding optimizer as it has no effect * Use eps=1e-8 for Adagrad as it yields better AUROC results * Rewrite so that it works for SGD as well
The dataset loader returns image loaded as rgb. Which is great for all other purposes, but loading an indexed image for example segmentation mask is a pain.
This is the line :
https://github.com/pytorch/vision/blob/master/torchvision/datasets/folder.py#L161
The PIL module does load images by default if they are just color maps, can we not just return without conversion to rgb or pass a flag to convert to rgb ?
OR is there any other better way of creating a dataloader with the masks folder ?
The text was updated successfully, but these errors were encountered: