-
Notifications
You must be signed in to change notification settings - Fork 7.1k
[PoC] separate decoding from datasets #5105
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
Conversation
💊 CI failures summary and remediationsAs of commit 1406bd3 (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Please report bugs/suggestions to the (internal) Dr. CI Users group. |
After some more discussion, we want away from supplying custom file handles to the user, but rather will return the encoded data as uint8 tensors. See #5075 (comment) for details. With the current implementation, loading data from a dataset now looks like this: from torchvision.prototype import datasets
for sample in datasets.load("caltech101").map(datasets.utils.decode_images):
...
In the future we can also provide a transform that handles the decoding, so it can simply be used as first transform in an from torchvision.prototype import datasets, transforms
transform = transforms.Compose(
transforms.DecodeImages(),
transforms.Resize(...),
...
)
for sample in datasets.load(...).map(transform):
... |
Superseded by #5287 |
Addresses #5075 (comment).
With this patch samples will be undecoded by default, but can easily decoded:
Of course,
decode_sample
can be applied through.map
For even more convenience, this also adds a
SampleDecoder
datapipe, that is a thin wrapper aroundMapper
applyingdecode_sample
. Although, I generally favor using the class interface, I think this is a case where the functional interface comes in handy, because most users will want to use the default decoders:@ reviewers: Don't worry about the large diff. I already touched all datasets to see if I missed an edge case in my proposal. That was not the case, so it is sufficient to have a look at
torchvision/prototype/datasets/utils/_decoder.py
and one implementation for exampletorchvision/prototype/datasets/_builtin/caltech.py
. I did not yet fix the tests, so it is expected that they are failing. I'll only do that if you are otherwise happy with the proposal.cc @pmeier @bjuncek