Datasets
Data loaders for FastGen training, supporting class-conditional image datasets and scalable WebDataset-based loaders for large-scale image, video, and video+audio training.
Overview
Class-Conditional Datasets
In the following, we provide commands to prepare different versions of CIFAR-10 and ImageNet. For FID reference statistics computations, see scripts/README.md.
CIFAR-10
Preprocess the data using:
This prepares the dataset as described in the EDM repo and places it at $DATA_ROOT_DIR/cifar10/cifar10-32x32.zip, compatible with CIFAR10_Loader_Config.
ImageNet-64
ImageNet datasets require downloading ImageNet from Kaggle. For instance, after installing pip install kaggle and retrieving your API token, you can download it using:
Then, preprocess the data using:
The --imagenet-source flag points to the unzipped directory containing ILSVRC/Data/CLS-LOC/train. This prepares the datasets as described in the EDM and EDM2 (with --resolution=64x64 and skipping the VAE encoder) repos and places them at $DATA_ROOT_DIR/imagenet-64/imagenet-64x64.zip and $DATA_ROOT_DIR/imagenet-64/imagenet-64x64-edmv2.zip, compatible with the ImageNet64_Loader_Config and ImageNet64_EDMV2_Loader_Config configs.
ImageNet-256
Preprocess the data using:
This creates the latent dataset according to the DiT/SiT preprocessing (mean and std from SD VAE, input normalized to [-1, 1]) and places it at $DATA_ROOT_DIR/imagenet-256/imagenet_256_sd.zip, compatible with the ImageNet256_Loader_Config config.
WebDataset Loaders
FastGen provides WebDataset loaders for scalable training on large image and video datasets, supporting both local storage and S3 paths.
Preparing Your Data
WebDataset stores data as tar archives (shards) containing files grouped by a common key:
Create shards using the webdataset library:
Generic Loaders
FastGen comes with predefined loaders for common WDS layouts. In the following, we show how to adapt them to your specific dataset.
In each loader config, key_map links an output key in the batch to a file extension in the shard. Decoded media and prompt text use the explicit raw keys: key_map={"real_raw": "mp4", "condition_raw": "txt"} loads {sample_id}.mp4 and {sample_id}.txt into real_raw and condition_raw. Precomputed model-space latents and embeddings instead use the plain real and condition keys, as in the next example.
WDSLoader
Base loader for precomputed latents and embeddings. Supports .npy, .npz, .pth, .json, and text files.
ImageWDSLoader
For raw images (jpg, png, etc.) with automatic resize, center crop, and normalization.
Use raw-key names for every decoded image role. For example, an image-edit loader maps the edited
target to real_raw and the source/reference image to condition_image_raw. A top-level
condition_image is reserved for a precomputed model-space reference latent; the network packages
that latent under the same name inside its completed rich condition mapping.
ImageLatentLoaderConfig
For precomputed image latents and text embeddings (faster than encoding on-the-fly):
Expected shard contents:
latent.pth- Precomputed image latenttxt_emb.pth- Precomputed text embedding
PromptLoaderConfig
For recipes whose student inputs come from its own trajectories (backward_simulation) and therefore read only
prompts:
Expected shard contents:
txt- Prompt (the negative prompt is the empty string by default)
VideoWDSLoader
For raw videos (mp4, avi, etc.) with frame extraction and transforms.
VideoAudioLoaderConfig
For raw videos with embedded audio tracks (e.g., for multimodal video+audio models like LTX-2). Extends VideoWDSLoader to additionally decode the audio waveform from the video container.
For each video key key in video_keys (default: "real_raw"), the loader produces a modality dict at {key} with the following entries:
{key}["video"]: Video tensor(C, T, H, W)normalized to[-1, 1]{key}["audio"]: Stereo audio waveformTensor[A_C, num_samples], resampled totarget_sample_ratewhen provided (otherwise kept at the clip’s native rate) and trimmed/padded tonum_video_frames / fpsseconds. Omitted for clips whose container has no audio stream.
Camera-Conditioned Video Loader
For raw videos paired with pre-computed camera poses and intrinsics (e.g., from VIPE).
Expected shard contents:
mp4- Videotxt- Captionposes.npy- Camera-to-world poses,[T, 4, 4](OpenCV convention)intrinsics.npy- Per-frame intrinsics,[T, 4]as[fx, fy, cx, cy]
Preparing camera poses from a video (requires VIPE):
VideoLatentLoaderConfig
For precomputed video latents and text embeddings (faster than encoding on-the-fly):
Expected shard contents:
latent.pth- Precomputed video latenttxt_emb.pth- Precomputed text embedding
Knowledge Distillation Loaders
Specialized loaders for knowledge distillation training; see the section on KD in Trajectory Matching for more details.
PairLoaderConfig
For single-step KD with (real, noise, condition) pairs:
Expected shard contents:
latent.pth- Clean latent (target)noise.pth- Noise sampletxt_emb.pth- Text embedding
PathLoaderConfig
For multi-step KD with denoising trajectories:
Expected shard contents:
latent.pth- Clean latent (target)path.pth- Denoising trajectory with shape[steps, C, ...], with one non-clean state per interval of the anchored student base gridtxt_emb.pth- Text embedding
Key Parameters
Deterministic loading resumes by sample count, so a sample not listed in ignore_index_paths that fails or is
dropped makes a later resume repeat one sample (or raises with strict=True), and presets_filter is rejected.
See the wds_utils.py module docstring for sample order, shard counts, and multi-rank behavior.