#9050·vision

Add Unlabeled Image Dataset for Unsupervised Training

Author: mduszykCreated May 2, 2025Updated Aug 29, 2026

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.