-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdataloader_utils.py
90 lines (80 loc) · 3.35 KB
/
dataloader_utils.py
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
def get_dataloader(args):
args_data = args.data
if (
hasattr(args_data, "video_frames")
and args_data.video_frames > 0
and "indices" in args_data.name
):
from datasets_wds.indices_h5_dataloader_video import (
get_inf_h5_dataloader,
)
loader = get_inf_h5_dataloader(**args_data)
return loader
elif hasattr(args_data, "video_frames") and args_data.video_frames > 0:
from datasets_wds.h5_dataloader_video import (
get_inf_h5_dataloader,
)
loader = get_inf_h5_dataloader(**args_data)
return loader
elif args_data.name in [
"scratch_imagenet512_cond",
"scratch_imagenet256_cond",
"scratchv2_imagenet256_uncond",
"scratchv2_imagenet256_cond",
"scratchv2_imagenet512_cond",
]:
from datasets_wds.web_dataloader_rawbyte import SimpleImageDataset
datamod = SimpleImageDataset(**args_data)
if args_data.subset == "train":
loader = datamod.train_dataloader()
elif args_data.subset == "val":
loader = datamod.eval_dataloader()
else:
raise ValueError(f"subset {args_data.subset} not supported")
return loader
elif "indices" in args_data.name and args_data.name.startswith("coco"):
from datasets_wds.indices_web_dataloader_t2i import SimpleImageDataset_T2I
datamod = SimpleImageDataset_T2I(**args_data)
if args_data.subset == "train":
loader = datamod.train_dataloader()
elif args_data.subset == "val":
loader = datamod.eval_dataloader()
else:
raise ValueError(f"subset {args_data.subset} not supported")
return loader
elif "indices" in args_data.name and "imagenet" in args_data.name:
from datasets_wds.indices_web_dataloader_rawbyte import SimpleImageDataset
datamod = SimpleImageDataset(**args_data)
if args_data.subset == "train":
loader = datamod.train_dataloader()
elif args_data.subset == "val":
loader = datamod.eval_dataloader()
else:
raise ValueError(f"subset {args_data.subset} not supported")
return loader
elif args_data.name.startswith("coco"):
from datasets_wds.web_dataloader_t2i import SimpleImageDataset_T2I
datamod = SimpleImageDataset_T2I(**args_data)
if args_data.subset == "train":
loader = datamod.train_dataloader()
elif args_data.subset == "val":
loader = datamod.eval_dataloader()
else:
raise ValueError(f"subset {args_data.subset} not supported")
return loader
elif args_data.name.startswith("cifar10"):
from datasets_wds.web_dataloader_v2 import SimpleImageDataset
datamod = SimpleImageDataset(**args_data)
if args_data.subset == "train":
loader = datamod.train_dataloader()
elif args_data.subset == "val":
loader = datamod.eval_dataloader()
else:
raise ValueError(f"subset {args_data.subset} not supported")
return loader
elif args_data.name.startswith("cs"):
from datasets_wds.h5_dataloader_cs import get_inf_h5_dataloader
loader = get_inf_h5_dataloader(**args_data)
return loader
else:
raise NotImplementedError(f"data {args_data.name} not supported")