pytorch / pytorch/vision

Add a new parameter to skip conversion to PIL Image for VisionDataset Loading

Open
#2,564 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

module: datasets module: io needs discussion
Dominant language
Python
Stars
17.9k
Forks
7.3k
Avg merge
1d 15h
Merged PRs (30d)
13

Description

🚀 Feature

Add a new parameter to skip conversion to PIL Image for VisionDataset Loading

Motivation

The original slowness-related issue was brought up in https://github.com/pytorch/pytorch/issues/42405. This SO question: https://stackoverflow.com/questions/63202478/why-pytorch-is-slower-than-tensorflow-in-read-data/63204186#63204186 is a live example.

The investigation (https://github.com/pytorch/pytorch/issues/42405#issuecomment-670971616) pointed to the fact that we are converting from Tensor -> PIL Image -> Tensor (via a toTensor Transform), which seems unnecessary.

Pitch

We want to allow VisionDataset to directly return Tensor without converting to PIL Image. This will be controlled by a parameter which for BC will be turned off by default.

Alternatives

Additional context

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

Start at the VisionDataset loading path and trace the Tensor → PIL Image → Tensor conversion described in the issue. Define the parameter's default behavior for backward compatibility and verify that tensor-returning datasets avoid the conversion while existing behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-vision
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.