Skip to content

Unsupervised Images Dataset? #660

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

Closed
devforfu opened this issue Nov 14, 2018 · 3 comments
Closed

Unsupervised Images Dataset? #660

devforfu opened this issue Nov 14, 2018 · 3 comments

Comments

@devforfu
Copy link

How do you think, would it be reasonable to have an "unsupervised" mode for DatasetFolder class? Now it expects each image to sit in its own folder but sometimes I would like to just load a bunch of images from the unlabelled test set, like:

dataset = DatasetFolder(path, loader=open_image, unsupervised=True)
image = dataset[i]  # or maybe (image, None), or (image, -1)
@fmassa
Copy link
Member

fmassa commented Nov 16, 2018

Hi,

I believe we can always create a folder with a single folder in it (for example via symlinks if we don't want to copy the data), which makes it possible to use DatasetFolder straight away.

Would that be a solution? It would return (image, 0), which you can discard

@devforfu
Copy link
Author

@fmassa Yes, agree, that sounds like a valid solution.

I guess the only drawback is that you need to remember about this additional step in data preprocessing pipeline each time when you start working on a new dataset :)

@fmassa
Copy link
Member

fmassa commented Nov 23, 2018

Or a very basic implementation:

import os
import glob

class BunchOfImagesDataset(object):
    def __init__(self, folder, transforms=None):
        self.folder = folder
        self.files = glob.glob(os.path.join(folder, '*.jpg'))
    
    def __getitem__(self, idx):
        ...
    def __len__(self):
        return len(self.files)

I think that the proposed solutions are simple enough, so that it might not be necessary to add one more level of complexity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants