forked from NVlabs/FastGen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.py
More file actions
127 lines (110 loc) · 4.43 KB
/
Copy pathdata.py
File metadata and controls
127 lines (110 loc) · 4.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
import os
from fastgen.datasets.class_cond_dataloader import ImageLoader
from fastgen.datasets.wds_dataloaders import (
WDSLoader,
ImageWDSLoader,
VideoWDSLoader,
)
from fastgen.utils import LazyCall as L
OUTPUT_ROOT = os.environ.get("FASTGEN_OUTPUT_ROOT", "FASTGEN_OUTPUT")
DATA_ROOT_DIR = os.getenv("DATA_ROOT_DIR", f"{OUTPUT_ROOT}/DATA")
S3_DATA_ROOT_DIR = os.getenv("DATA_ROOT_DIR", "s3://data")
# ################################################################################
# Generic Loaders (for config templates - override datatags for actual use)
# ################################################################################
# See fastgen/datasets/README.md for more details.
ImageLoaderConfig = L(ImageWDSLoader)(
datatags=["WDS:/path/to/images"],
batch_size=32,
key_map={"real": "jpg", "condition": "txt"},
presets_map={"neg_condition": "empty_string"},
input_res=512,
)
ImageLatentLoaderConfig = L(WDSLoader)(
datatags=["WDS:/path/to/image_latents"],
batch_size=32,
key_map={"real": "latent.pth", "condition": "txt_emb.pth"},
# Negative condition embedding loaded from a shared file (same for all samples)
files_map={"neg_condition": "/path/to/neg_prompt_emb.npy"},
)
VideoLoaderConfig = L(VideoWDSLoader)(
datatags=["WDS:/path/to/videos"],
batch_size=2,
key_map={"real": "mp4", "condition": "txt"},
presets_map={"neg_condition": "neg_prompt_wan"},
sequence_length=81,
img_size=(832, 480),
num_workers=2,
)
VideoLatentLoaderConfig = L(WDSLoader)(
datatags=["WDS:/path/to/video_latents"],
batch_size=2,
key_map={"real": "latent.pth", "condition": "txt_emb.pth"},
# Negative condition embedding loaded from a shared file (same for all samples)
files_map={"neg_condition": "/path/to/neg_prompt_emb.npy"},
num_workers=2,
# NOTE: For v2v tasks, add condition latent (e.g., depth) to key_map:
# key_map={"real": "latent.pth", "condition": "txt_emb.pth", "depth_latent": "depth_latent.pth"}
)
# ################################################################################
# Generic KD Loaders (for paired/path data)
# ################################################################################
# See fastgen/methods/knowledge_distillation/README.md for more details.
# For single-step KD: provides (real, noise, condition) pairs
# Data requirements: {"real": clean, "noise": noise, "condition": cond}
PairLoaderConfig = L(WDSLoader)(
datatags=["WDS:/path/to/pairs"],
batch_size=2,
key_map={"real": "latent.pth", "noise": "noise.pth", "condition": "txt_emb.pth"},
shuffle_size=100,
)
# For multi-step KD: provides (real, path, condition) with denoising trajectory
# Data requirements: {"real": clean, "path": [B, steps, C, ...], "condition": cond}
# path contains intermediate denoising steps (typically 4 steps)
PathLoaderConfig = L(WDSLoader)(
datatags=["WDS:/path/to/paths"],
batch_size=2,
key_map={"real": "latent.pth", "path": "path.pth", "condition": "txt_emb.pth"},
shuffle_size=100,
)
# ################################################################################
# Specific Datasets
# ################################################################################
CIFAR10_Loader_Config = L(ImageLoader)(
dataset_path=f"{DATA_ROOT_DIR}/cifar10/cifar10-32x32.zip",
s3_path=f"{S3_DATA_ROOT_DIR}/cifar10/cifar10-32x32.zip",
use_labels=True,
cache=True,
batch_size=128,
shuffle=True,
sampler_start_idx=None,
)
ImageNet64_Loader_Config = L(ImageLoader)(
dataset_path=f"{DATA_ROOT_DIR}/imagenet-64/imagenet-64x64.zip",
s3_path=f"{S3_DATA_ROOT_DIR}/imagenet-64/imagenet-64x64.zip",
use_labels=True,
cache=True,
batch_size=32,
shuffle=True,
sampler_start_idx=None,
)
ImageNet256_Loader_Config = L(ImageLoader)(
dataset_path=f"{DATA_ROOT_DIR}/imagenet-256/imagenet_256_sd.zip",
s3_path=f"{S3_DATA_ROOT_DIR}/imagenet-256/imagenet_256_sd.zip",
use_labels=True,
cache=True,
batch_size=32,
shuffle=True,
sampler_start_idx=None,
)
ImageNet64_EDMV2_Loader_Config = L(ImageLoader)(
dataset_path=f"{DATA_ROOT_DIR}/imagenet-64/imagenet-64x64-edmv2.zip",
s3_path=f"{S3_DATA_ROOT_DIR}/imagenet-64/imagenet-64x64-edmv2.zip",
use_labels=True,
cache=True,
batch_size=32,
shuffle=True,
sampler_start_idx=None,
)