Skip to content

Add Unlabeled Image Dataset for Unsupervised Training #9050

Description

@mduszyk

🚀 The feature

I’m proposing to add a dataset class for unsupervised learning (e.g., generative models), where the dataset consists of a flat folder of unlabeled images.

Introduce a new class, e.g. UnlabeledImageDataset, that:

  • Accepts a flat folder of image files
  • Returns only images (no labels)
  • Follows ImageFolder conventions where applicable
  • Resides in torchvision/datasets/folder.py and reuses existing utilities
  • Introducing a new class avoids increasing complexity in ImageFolder

Motivation, pitch

torchvision.datasets.ImageFolder and DatasetFolder are designed for supervised tasks, requiring a specific directory structure and class-label mappings. In unsupervised scenarios, I end up writing custom datasets for this case. A built-in dataset would improve usability and consistency across the PyTorch ecosystem.

This feature request is similar in spirit to Issue #660, where a user suggested supporting unlabeled or unsupervised datasets. The use case remains common, and a lightweight, built-in solution would reduce boilerplate and improve consistency.

Alternatives

An alternative would be to have an "unsupervised" mode for ImageFolder as suggested in Issue #660. But that would result in increased complexity in this class as pointed out in the comment of the issue.

Additional context

It feels like this functionality belongs in a common library especially that ImageFolder is already present in torchvision.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions