MCPcopy Create free account
hub / github.com/NVlabs/SPADE / CustomDataset

Class CustomDataset

data/custom_dataset.py:10–50  ·  view source on GitHub ↗

Dataset that loads images from directories Use option --label_dir, --image_dir, --instance_dir to specify the directories. The images in the directories are sorted in alphabetical order and paired in order.

Source from the content-addressed store, hash-verified

8
9
10class CustomDataset(Pix2pixDataset):
11 """ Dataset that loads images from directories
12 Use option --label_dir, --image_dir, --instance_dir to specify the directories.
13 The images in the directories are sorted in alphabetical order and paired in order.
14 """
15
16 @staticmethod
17 def modify_commandline_options(parser, is_train):
18 parser = Pix2pixDataset.modify_commandline_options(parser, is_train)
19 parser.set_defaults(preprocess_mode='resize_and_crop')
20 load_size = 286 if is_train else 256
21 parser.set_defaults(load_size=load_size)
22 parser.set_defaults(crop_size=256)
23 parser.set_defaults(display_winsize=256)
24 parser.set_defaults(label_nc=13)
25 parser.set_defaults(contain_dontcare_label=False)
26
27 parser.add_argument('--label_dir', type=str, required=True,
28 help='path to the directory that contains label images')
29 parser.add_argument('--image_dir', type=str, required=True,
30 help='path to the directory that contains photo images')
31 parser.add_argument('--instance_dir', type=str, default='',
32 help='path to the directory that contains instance maps. Leave black if not exists')
33 return parser
34
35 def get_paths(self, opt):
36 label_dir = opt.label_dir
37 label_paths = make_dataset(label_dir, recursive=False, read_cache=True)
38
39 image_dir = opt.image_dir
40 image_paths = make_dataset(image_dir, recursive=False, read_cache=True)
41
42 if len(opt.instance_dir) > 0:
43 instance_dir = opt.instance_dir
44 instance_paths = make_dataset(instance_dir, recursive=False, read_cache=True)
45 else:
46 instance_paths = []
47
48 assert len(label_paths) == len(image_paths), "The #images in %s and %s do not match. Is there something wrong?"
49
50 return label_paths, image_paths, instance_paths

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected