🚀 The feature
I propose adding a new meta-transform container to the v2 ecosystem. This container would accept a list of child transforms and execute a randomly sampled subset of them over a configurable number of successive passes, with randomized parameters applied at each step.
The container could take configuration arguments to dynamically shuffle and repeat operations from a pool of provided transforms.
Motivation, pitch
I am working on low-level image restoration and super-resolution pipelines. To train my models, I need to implement high-order degradation pipelines, similar to the double-pass loops pioneered by Real-ESRGAN in 2021. This process requires shuffling the execution order of operations and repeating a sequence of transformations across multiple successive loops to mimic complex, layered artifacts.
Currently, torchvision.transforms.v2 does not seem to have a container to execute this natively. While RandomOrder exists, it appears to enforce a single pass where every provided transform must run exactly once. I have not found a straightforward way to use it for dynamic multi-pass loops, subset sampling, or repeated execution paths.
Because of this limitation, it feels completely necessary to bypass the transform ecosystem for these workflows. Even when using wrap_dataset_for_transforms_v2 to get structured tv_tensors, I might have to manually unpack the data, handcode custom execution loops, and manage randomization myself. A native container could cleanly solve this and keep these workflows entirely within the v2 pipeline.
Alternatives
Nesting Existing Containers: I considered manually stacking combinations of RandomOrder, RandomChoice, and Compose. However this seems to create rigid blocks that may not easily handle dynamic multi-pass subsets or varying parameter ranges across different loop passes.
Custom Transforms: Writing a massive and monolithic custom transform wrapper for the entire pipeline, but this defeats the purpose of modular, reusable transform objects.
External Libraries: Moving away from Torchvision to third-party augmentation packages which fragments the codebase.
Additional context
This addition would provide a reusable structural utility for workflows involving complex data synthesis.
from torchvision.transforms import v2
pipeline = v2.RandomSequence(
[
v2.GaussianBlur(kernel_size=(7, 21)),
v2.GaussianBlur(kernel_size=(3, 11)),
v2.JPEGCompression(quality=(30, 95)),
v2.GaussianNoise(sigma=(0.0, 0.2))
],
num_passes=2,
num_ops_per_pass=2
)
If this fits the roadmap of the v2 framework, I would be happy to implement this container and open a pull request for it.
🚀 The feature
I propose adding a new meta-transform container to the v2 ecosystem. This container would accept a list of child transforms and execute a randomly sampled subset of them over a configurable number of successive passes, with randomized parameters applied at each step.
The container could take configuration arguments to dynamically shuffle and repeat operations from a pool of provided transforms.
Motivation, pitch
I am working on low-level image restoration and super-resolution pipelines. To train my models, I need to implement high-order degradation pipelines, similar to the double-pass loops pioneered by Real-ESRGAN in 2021. This process requires shuffling the execution order of operations and repeating a sequence of transformations across multiple successive loops to mimic complex, layered artifacts.
Currently, torchvision.transforms.v2 does not seem to have a container to execute this natively. While RandomOrder exists, it appears to enforce a single pass where every provided transform must run exactly once. I have not found a straightforward way to use it for dynamic multi-pass loops, subset sampling, or repeated execution paths.
Because of this limitation, it feels completely necessary to bypass the transform ecosystem for these workflows. Even when using wrap_dataset_for_transforms_v2 to get structured tv_tensors, I might have to manually unpack the data, handcode custom execution loops, and manage randomization myself. A native container could cleanly solve this and keep these workflows entirely within the v2 pipeline.
Alternatives
Nesting Existing Containers: I considered manually stacking combinations of RandomOrder, RandomChoice, and Compose. However this seems to create rigid blocks that may not easily handle dynamic multi-pass subsets or varying parameter ranges across different loop passes.
Custom Transforms: Writing a massive and monolithic custom transform wrapper for the entire pipeline, but this defeats the purpose of modular, reusable transform objects.
External Libraries: Moving away from Torchvision to third-party augmentation packages which fragments the codebase.
Additional context
This addition would provide a reusable structural utility for workflows involving complex data synthesis.
If this fits the roadmap of the v2 framework, I would be happy to implement this container and open a pull request for it.