pytorch / pytorch/vision

Add Unlabeled Image Dataset for Unsupervised Training

Open
#9,050 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
17.9k
Forks
7.3k
Avg merge
1d 15h
Merged PRs (30d)
13

Description

🚀 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read torchvision/datasets/folder.py and the existing ImageFolder and DatasetFolder utilities first. Define the class around the requested flat image folder while reusing applicable conventions and utilities without adding unsupervised behavior to ImageFolder. Done means the dataset returns images without labels and supports the stated folder-based use case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-vision, machine-learning
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.