Python data.image_folder.make_dataset() Examples

The following are 30 code examples of data.image_folder.make_dataset(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module data.image_folder , or try the search function .
Example #1
Source File: gta5_cityscapes.py    From MADAN with MIT License 6 votes vote down vote up
def initialize(self, opt):
		self.opt = opt
		self.root = opt.dataroot
		self.dir_A = os.path.join(opt.dataroot, 'gta5', 'images')
		self.dir_B = os.path.join(opt.dataroot, 'cityscapes', 'leftImg8bit')
		self.dir_A_label = os.path.join(opt.dataroot, 'gta5', 'labels')
		self.dir_B_label = os.path.join(opt.dataroot, 'cityscapes', 'gtFine')
		
		self.A_paths = make_dataset(self.dir_A)
		self.B_paths = make_dataset(self.dir_B)
		
		self.A_paths = sorted(self.A_paths)
		self.B_paths = sorted(self.B_paths)
		self.A_size = len(self.A_paths)
		self.B_size = len(self.B_paths)
		
		self.A_labels = make_dataset(self.dir_A_label)
		self.B_labels = make_cs_labels(self.dir_B_label)
		
		self.A_labels = sorted(self.A_labels)
		self.B_labels = sorted(self.B_labels)
		
		self.transform = get_transform(opt)
		self.label_transform = get_label_transform(opt) 
Example #2
Source File: unaligned_dataset.py    From 2019-CCF-BDCI-OCR-MCZJ-OCR-IdentificationIDElement with MIT License 6 votes vote down vote up
def __init__(self, opt):
        """Initialize this dataset class.

        Parameters:
            opt (Option class) -- stores all the experiment flags; needs to be a subclass of BaseOptions
        """
        BaseDataset.__init__(self, opt)
        self.dir_A = os.path.join(opt.dataroot, opt.phase + 'A')  # create a path '/path/to/data/trainA'
        self.dir_B = os.path.join(opt.dataroot, opt.phase + 'B')  # create a path '/path/to/data/trainB'

        self.A_paths = sorted(make_dataset(self.dir_A, opt.max_dataset_size))   # load images from '/path/to/data/trainA'
        self.B_paths = sorted(make_dataset(self.dir_B, opt.max_dataset_size))    # load images from '/path/to/data/trainB'
        self.A_size = len(self.A_paths)  # get the size of dataset A
        self.B_size = len(self.B_paths)  # get the size of dataset B
        btoA = self.opt.direction == 'BtoA'
        input_nc = self.opt.output_nc if btoA else self.opt.input_nc       # get the number of channels of input image
        output_nc = self.opt.input_nc if btoA else self.opt.output_nc      # get the number of channels of output image
        self.transform_A = get_transform(self.opt, grayscale=(input_nc == 1))
        self.transform_B = get_transform(self.opt, grayscale=(output_nc == 1)) 
Example #3
Source File: synthia_cityscapes.py    From MADAN with MIT License 6 votes vote down vote up
def initialize(self, opt):
		self.opt = opt
		self.root = opt.dataroot
		self.dir_A = os.path.join(opt.dataroot, 'synthia', 'RGB')
		self.dir_B = os.path.join(opt.dataroot, 'cityscapes', 'leftImg8bit')
		self.dir_A_label = os.path.join(opt.dataroot, 'synthia', 'GT', 'parsed_LABELS')
		self.dir_B_label = os.path.join(opt.dataroot, 'cityscapes', 'gtFine')
		
		self.A_paths = make_dataset(self.dir_A)
		self.B_paths = make_dataset(self.dir_B)
		
		self.A_paths = sorted(self.A_paths)
		self.B_paths = sorted(self.B_paths)
		self.A_size = len(self.A_paths)
		self.B_size = len(self.B_paths)
		
		self.A_labels = make_dataset(self.dir_A_label)
		self.B_labels = make_cs_labels(self.dir_B_label)
		
		self.A_labels = sorted(self.A_labels)
		self.B_labels = sorted(self.B_labels)
		
		self.transform = get_transform(opt)
		self.label_transform = get_label_transform(opt) 
Example #4
Source File: unaligned_triplet_dataset.py    From Recycle-GAN with MIT License 6 votes vote down vote up
def initialize(self, opt):
        self.opt = opt
        self.root = opt.dataroot
        self.dir_A = os.path.join(opt.dataroot, opt.phase + 'A')
        self.dir_B = os.path.join(opt.dataroot, opt.phase + 'B')

        self.A_paths = make_dataset(self.dir_A)
        self.B_paths = make_dataset(self.dir_B)

        self.A_paths = sorted(self.A_paths)
        self.B_paths = sorted(self.B_paths)
        self.A_size = len(self.A_paths)
        self.B_size = len(self.B_paths)
        # self.transform = get_transform(opt)
        transform_list = [transforms.ToTensor(),
                          transforms.Normalize((0.5, 0.5, 0.5),
                                               (0.5, 0.5, 0.5))]
        self.transform = transforms.Compose(transform_list) 
Example #5
Source File: aligned_dataset_GAN.py    From EverybodyDanceNow-Temporal-FaceGAN with MIT License 6 votes vote down vote up
def initialize(self, opt):
		self.opt = opt

		### input A (label maps)
		self.label_paths = sorted(make_dataset(opt.label_root))
		# self.simage_paths = sorted(make_dataset(opt.input_image_root))
		### input B (real images)
		if opt.isTrain:
			self.rimage_paths = sorted(make_dataset(opt.real_image_root))

		### instance maps
		if not opt.no_instance:
			self.dir_inst = os.path.join(opt.dataroot, opt.phase + '_inst')
			self.inst_paths = sorted(make_dataset(self.dir_inst))

		### load precomputed instance-wise encoded features
		if opt.load_features:                              
			self.dir_feat = os.path.join(opt.dataroot, opt.phase + '_feat')
			print('----------- loading features from %s ----------' % self.dir_feat)
			self.feat_paths = sorted(make_dataset(self.dir_feat))

		x = 'train' if opt.isTrain else 'test'
		self.crop_coor = torch.load('../data/%s/%s/face_crop_coor.torch'% (opt.dataset_name, x))
		self.dataset_size = len(self.label_paths) 
Example #6
Source File: jnd_dataset.py    From PerceptualSimilarity with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def initialize(self, dataroot, load_size=64):
        self.root = dataroot
        self.load_size = load_size

        self.dir_p0 = os.path.join(self.root, 'p0')
        self.p0_paths = make_dataset(self.dir_p0)
        self.p0_paths = sorted(self.p0_paths)

        self.dir_p1 = os.path.join(self.root, 'p1')
        self.p1_paths = make_dataset(self.dir_p1)
        self.p1_paths = sorted(self.p1_paths)

        transform_list = []
        transform_list.append(transforms.Scale(load_size))
        transform_list += [transforms.ToTensor(),
            transforms.Normalize((0.5, 0.5, 0.5),(0.5, 0.5, 0.5))]

        self.transform = transforms.Compose(transform_list)

        # judgement directory
        self.dir_S = os.path.join(self.root, 'same')
        self.same_paths = make_dataset(self.dir_S,mode='np')
        self.same_paths = sorted(self.same_paths) 
Example #7
Source File: synthesis_dataset.py    From Single-Image-Reflection-Removal-Beyond-Linearity with MIT License 6 votes vote down vote up
def initialize(self, opt):
        self.opt = opt
        self.root = opt.dataroot
        self.loadSize = opt.loadSize
        self.dir_A = os.path.join(opt.dataroot, opt.phase + 'A')
        self.dir_B = os.path.join(opt.dataroot, opt.phase + 'B')

        self.A_paths = make_dataset(self.dir_A)
        self.B_paths = make_dataset(self.dir_B)            

        self.A_paths = sorted(self.A_paths)
        self.B_paths = sorted(self.B_paths)
            
        self.A_size = len(self.A_paths)
        self.B_size = len(self.B_paths)

        if opt.phase == 'train':
            self.dir_C = os.path.join(opt.dataroot, opt.phase + 'C')
            self.C_paths = make_dataset(self.dir_C)
            self.C_paths = sorted(self.C_paths)
            self.C_size = len(self.C_paths) 
Example #8
Source File: removal_dataset.py    From Single-Image-Reflection-Removal-Beyond-Linearity with MIT License 6 votes vote down vote up
def initialize(self, opt):
        self.opt = opt
        self.root = opt.dataroot
        self.phase = opt.phase
        self.dir_C = os.path.join(opt.dataroot, opt.phase + 'C')
        if opt.phase == 'train':
            self.dir_A = os.path.join(opt.dataroot, opt.phase + 'A')
            self.dir_B = os.path.join(opt.dataroot, opt.phase + 'B')
            self.dir_W = os.path.join(opt.dataroot, opt.phase + 'W')

        self.C_paths = make_dataset(self.dir_C)
        if opt.phase == 'train':
            self.A_paths = make_dataset(self.dir_A)
            self.B_paths = make_dataset(self.dir_B)
            self.W_paths = make_dataset(self.dir_W)

        self.C_paths = sorted(self.C_paths)
        if opt.phase == 'train':
            self.A_paths = sorted(self.A_paths)
            self.B_paths = sorted(self.B_paths)
            self.W_paths = sorted(self.W_paths)

        self.C_size = len(self.C_paths) 
Example #9
Source File: unaligned_dataset.py    From Bayesian-CycleGAN with MIT License 5 votes vote down vote up
def initialize(self, opt):
        self.opt = opt
        self.root = opt.dataroot
        self.dir_A = os.path.join(opt.dataroot, opt.phase + 'A')
        self.dir_B = os.path.join(opt.dataroot, opt.phase + 'B')

        self.A_paths = make_dataset(self.dir_A)
        self.B_paths = make_dataset(self.dir_B)

        self.A_paths = sorted(self.A_paths)
        self.B_paths = sorted(self.B_paths)
        self.A_size = len(self.A_paths)
        self.B_size = len(self.B_paths)
        self.transform = get_transform(opt) 
Example #10
Source File: single_dataset.py    From monocularDepth-Inference with MIT License 5 votes vote down vote up
def initialize(self, opt):
        self.opt = opt
        self.root = opt.data_directory
        self.dir_A = os.path.join(opt.data_directory)

        self.A_paths = make_dataset(self.dir_A)

        self.A_paths = sorted(self.A_paths)

        self.transform = get_transform(opt) 
Example #11
Source File: aligned_dataset.py    From deep-learning-for-document-dewarping with MIT License 5 votes vote down vote up
def initialize(self, opt):
        self.opt = opt
        self.root = opt.dataroot    

        ### input A (label maps)
        dir_A = '_A' if self.opt.label_nc == 0 else '_label'
        self.dir_A = os.path.join(opt.dataroot, opt.phase + dir_A)
        self.A_paths = sorted(make_dataset(self.dir_A))

        ### input B (real images)
        if opt.isTrain or opt.use_encoded_image:
            dir_B = '_B' if self.opt.label_nc == 0 else '_img'
            self.dir_B = os.path.join(opt.dataroot, opt.phase + dir_B)  
            self.B_paths = sorted(make_dataset(self.dir_B))

        ### instance maps
        if not opt.no_instance:
            self.dir_inst = os.path.join(opt.dataroot, opt.phase + '_inst')
            self.inst_paths = sorted(make_dataset(self.dir_inst))

        ### load precomputed instance-wise encoded features
        if opt.load_features:                              
            self.dir_feat = os.path.join(opt.dataroot, opt.phase + '_feat')
            print('----------- loading features from %s ----------' % self.dir_feat)
            self.feat_paths = sorted(make_dataset(self.dir_feat))

        self.dataset_size = len(self.A_paths) 
Example #12
Source File: twoafc_dataset.py    From PerceptualSimilarity with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def initialize(self, dataroots, load_size=64):
        if(not isinstance(dataroots,list)):
            dataroots = [dataroots,]
        self.roots = dataroots
        self.load_size = load_size

        # image directory
        self.dir_ref = [os.path.join(root, 'ref') for root in self.roots]
        self.ref_paths = make_dataset(self.dir_ref)
        self.ref_paths = sorted(self.ref_paths)

        self.dir_p0 = [os.path.join(root, 'p0') for root in self.roots]
        self.p0_paths = make_dataset(self.dir_p0)
        self.p0_paths = sorted(self.p0_paths)

        self.dir_p1 = [os.path.join(root, 'p1') for root in self.roots]
        self.p1_paths = make_dataset(self.dir_p1)
        self.p1_paths = sorted(self.p1_paths)

        transform_list = []
        transform_list.append(transforms.Scale(load_size))
        transform_list += [transforms.ToTensor(),
            transforms.Normalize((0.5, 0.5, 0.5),(0.5, 0.5, 0.5))]

        self.transform = transforms.Compose(transform_list)

        # judgement directory
        self.dir_J = [os.path.join(root, 'judge') for root in self.roots]
        self.judge_paths = make_dataset(self.dir_J,mode='np')
        self.judge_paths = sorted(self.judge_paths) 
Example #13
Source File: aligned_dataset.py    From Shift-Net_pytorch with MIT License 5 votes vote down vote up
def initialize(self, opt):
        self.opt = opt
        self.dir_A = opt.dataroot
        self.A_paths = sorted(make_dataset(self.dir_A))
        if self.opt.offline_loading_mask:
            self.mask_folder = self.opt.training_mask_folder if self.opt.isTrain else self.opt.testing_mask_folder
            self.mask_paths = sorted(make_dataset(self.mask_folder))

        assert(opt.resize_or_crop == 'resize_and_crop')

        transform_list = [transforms.ToTensor(),
                          transforms.Normalize((0.5, 0.5, 0.5),
                                               (0.5, 0.5, 0.5))]

        self.transform = transforms.Compose(transform_list) 
Example #14
Source File: aligned_dataset_resized.py    From Shift-Net_pytorch with MIT License 5 votes vote down vote up
def initialize(self, opt):
        self.opt = opt
        self.root = opt.dataroot
        self.dir_A = opt.dataroot # More Flexible for users

        self.A_paths = sorted(make_dataset(self.dir_A))

        assert(opt.resize_or_crop == 'resize_and_crop')

        transform_list = [transforms.ToTensor(),
                          transforms.Normalize((0.5, 0.5, 0.5),
                                               (0.5, 0.5, 0.5))]

        self.transform = transforms.Compose(transform_list) 
Example #15
Source File: single_dataset.py    From Shift-Net_pytorch with MIT License 5 votes vote down vote up
def initialize(self, opt):
        self.opt = opt
        self.root = opt.dataroot
        self.dir_A = os.path.join(opt.dataroot)

        # make_dataset returns paths of all images in one folder
        self.A_paths = make_dataset(self.dir_A)

        self.A_paths = sorted(self.A_paths)

        transform_list = []
        if opt.resize_or_crop == 'resize_and_crop':
            transform_list.append(transforms.Scale(opt.loadSize))

        if opt.isTrain and not opt.no_flip:
            transform_list.append(transforms.RandomHorizontalFlip())

        if opt.resize_or_crop != 'no_resize':
            transform_list.append(transforms.RandomCrop(opt.fineSize))

        # Make it between [-1, 1], beacuse [(0-0.5)/0.5, (1-0.5)/0.5]
        transform_list += [transforms.ToTensor(),
                           transforms.Normalize((0.5, 0.5, 0.5),
                                                (0.5, 0.5, 0.5))]

        self.transform = transforms.Compose(transform_list) 
Example #16
Source File: unaligned_dataset.py    From angularGAN with MIT License 5 votes vote down vote up
def initialize(self, opt):
        self.opt = opt
        self.root = opt.dataroot
        self.dir_A = os.path.join(opt.dataroot, opt.phase + 'A')
        self.dir_B = os.path.join(opt.dataroot, opt.phase + 'B')

        self.A_paths = make_dataset(self.dir_A)
        self.B_paths = make_dataset(self.dir_B)

        self.A_paths = sorted(self.A_paths)
        self.B_paths = sorted(self.B_paths)
        self.A_size = len(self.A_paths)
        self.B_size = len(self.B_paths)
        self.transform = get_transform(opt) 
Example #17
Source File: unaligned_dataset.py    From ToDayGAN with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def __init__(self, opt):
        super(UnalignedDataset, self).__init__()
        self.opt = opt
        self.transform = get_transform(opt)

        datapath = os.path.join(opt.dataroot, opt.phase + '*')
        self.dirs = sorted(glob.glob(datapath))

        self.paths = [sorted(make_dataset(d)) for d in self.dirs]
        self.sizes = [len(p) for p in self.paths] 
Example #18
Source File: aligned_dataset.py    From colorization-pytorch with MIT License 5 votes vote down vote up
def initialize(self, opt):
        self.opt = opt
        self.root = opt.dataroot
        self.dir_AB = os.path.join(opt.dataroot, opt.phase)
        self.AB_paths = sorted(make_dataset(self.dir_AB))
        assert(opt.resize_or_crop == 'resize_and_crop') 
Example #19
Source File: single_dataset.py    From colorization-pytorch with MIT License 5 votes vote down vote up
def initialize(self, opt):
        self.opt = opt
        self.root = opt.dataroot
        self.dir_A = os.path.join(opt.dataroot)

        self.A_paths = make_dataset(self.dir_A)

        self.A_paths = sorted(self.A_paths)

        self.transform = get_transform(opt) 
Example #20
Source File: color_dataset.py    From colorization-pytorch with MIT License 5 votes vote down vote up
def initialize(self, opt):
        self.opt = opt
        self.root = opt.dataroot
        self.dir_A = os.path.join(opt.dataroot)

        self.A_paths = make_dataset(self.dir_A)

        self.A_paths = sorted(self.A_paths)

        self.transform = get_transform(opt) 
Example #21
Source File: unaligned_dataset.py    From ComboGAN with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def __init__(self, opt):
        super(UnalignedDataset, self).__init__()
        self.opt = opt
        self.transform = get_transform(opt)

        datapath = os.path.join(opt.dataroot, opt.phase + '*')
        self.dirs = sorted(glob.glob(datapath))

        self.paths = [sorted(make_dataset(d)) for d in self.dirs]
        self.sizes = [len(p) for p in self.paths] 
Example #22
Source File: segmentation_dataset.py    From neurips18_hierchical_image_manipulation with MIT License 5 votes vote down vote up
def initialize(self, opt): # config=DEFAULT_CONFIG):
        self.opt = opt
        self.root = opt.dataroot
        self.class_of_interest = [] # will define it in child
        self.config = {
            'prob_flip': 0.0 if opt.no_flip else 0.5,
            'prob_bg': opt.prob_bg,
            'fineSize': opt.fineSize,
            'preprocess_option': opt.resize_or_crop,
            'min_box_size': opt.min_box_size,
            'max_box_size': opt.max_box_size,
            'img_to_obj_ratio': opt.contextMargin,
            'patch_to_obj_ratio': 1.2,
            'min_ctx_ratio': 1.2,
            'max_ctx_ratio': 1.5}
        self.check_config(self.config)
        ### input A (label maps)
        dir_A = '_A' if self.opt.label_nc == 0 else '_label'
        self.dir_A = os.path.join(opt.dataroot, opt.phase + dir_A)
        self.A_paths = sorted(make_dataset(self.dir_A))

        ### input B (real images)
        if (opt.isTrain and (not hasattr(self.opt, 'use_bbox'))) or \
                (hasattr(self.opt, 'load_image') and self.opt.load_image):
            dir_B = '_B' if self.opt.label_nc == 0 else '_img'
            self.dir_B = os.path.join(opt.dataroot, opt.phase + dir_B)
            self.B_paths = sorted(make_dataset(self.dir_B))

        ### instance maps
        self.dir_inst = os.path.join(opt.dataroot, opt.phase + '_inst')
        self.inst_paths = sorted(make_dataset(self.dir_inst))
        self.dir_bbox = os.path.join(opt.dataroot, opt.phase + '_bbox')
        self.bbox_paths = sorted(make_dataset(self.dir_bbox))

        self.dataset_size = len(self.A_paths)
        self.use_bbox = hasattr(self.opt, 'use_bbox') and (self.opt.use_bbox)
        self.load_image = hasattr(self.opt, 'load_image') and (self.opt.load_image)
        self.load_raw = hasattr(self.opt, 'load_raw') and (self.opt.load_raw) 
Example #23
Source File: aligned_dataset.py    From angularGAN with MIT License 5 votes vote down vote up
def initialize(self, opt):
        self.opt = opt
        self.root = opt.dataroot
        self.dir_AB = os.path.join(opt.dataroot, opt.phase)
        self.AB_paths = sorted(make_dataset(self.dir_AB))
        assert(opt.resize_or_crop == 'resize_and_crop') 
Example #24
Source File: single_dataset.py    From angularGAN with MIT License 5 votes vote down vote up
def initialize(self, opt):
        self.opt = opt
        self.root = opt.dataroot
        self.dir_A = os.path.join(opt.dataroot)

        self.A_paths = make_dataset(self.dir_A)

        self.A_paths = sorted(self.A_paths)

        self.transform = get_transform(opt) 
Example #25
Source File: aligned_dataset.py    From 2019-CCF-BDCI-OCR-MCZJ-OCR-IdentificationIDElement with MIT License 5 votes vote down vote up
def __init__(self, opt):
        """Initialize this dataset class.

        Parameters:
            opt (Option class) -- stores all the experiment flags; needs to be a subclass of BaseOptions
        """
        BaseDataset.__init__(self, opt)
        self.dir_AB = os.path.join(opt.dataroot, opt.phase)  # get the image directory
        self.AB_paths = sorted(make_dataset(self.dir_AB, opt.max_dataset_size))  # get image paths
        assert(self.opt.load_size >= self.opt.crop_size)   # crop_size should be smaller than the size of loaded image
        self.input_nc = self.opt.output_nc if self.opt.direction == 'BtoA' else self.opt.input_nc
        self.output_nc = self.opt.input_nc if self.opt.direction == 'BtoA' else self.opt.output_nc 
Example #26
Source File: aligned_dataset.py    From everybody_dance_now_pytorch with GNU Affero General Public License v3.0 5 votes vote down vote up
def initialize(self, opt):
        self.opt = opt
        self.root = opt.dataroot    

        ### input A (label maps)
        dir_A = '_A' if self.opt.label_nc == 0 else '_label'
        self.dir_A = os.path.join(opt.dataroot, opt.phase + dir_A)
        self.A_paths = sorted(make_dataset(self.dir_A))

        ### input B (real images)
        if opt.isTrain:
            dir_B = '_B' if self.opt.label_nc == 0 else '_img'
            self.dir_B = os.path.join(opt.dataroot, opt.phase + dir_B)  
            self.B_paths = sorted(make_dataset(self.dir_B))

        ### instance maps
        if not opt.no_instance:
            self.dir_inst = os.path.join(opt.dataroot, opt.phase + '_inst')
            self.inst_paths = sorted(make_dataset(self.dir_inst))

        ### load precomputed instance-wise encoded features
        if opt.load_features:                              
            self.dir_feat = os.path.join(opt.dataroot, opt.phase + '_feat')
            print('----------- loading features from %s ----------' % self.dir_feat)
            self.feat_paths = sorted(make_dataset(self.dir_feat))

        self.dataset_size = len(self.A_paths) 
Example #27
Source File: single_dataset.py    From 2019-CCF-BDCI-OCR-MCZJ-OCR-IdentificationIDElement with MIT License 5 votes vote down vote up
def __init__(self, opt):
        """Initialize this dataset class.

        Parameters:
            opt (Option class) -- stores all the experiment flags; needs to be a subclass of BaseOptions
        """
        BaseDataset.__init__(self, opt)
        self.A_paths = sorted(make_dataset(opt.dataroot, opt.max_dataset_size))
        input_nc = self.opt.output_nc if self.opt.direction == 'BtoA' else self.opt.input_nc
        self.transform = get_transform(opt, grayscale=(input_nc == 1)) 
Example #28
Source File: colorization_dataset.py    From 2019-CCF-BDCI-OCR-MCZJ-OCR-IdentificationIDElement with MIT License 5 votes vote down vote up
def __init__(self, opt):
        """Initialize this dataset class.

        Parameters:
            opt (Option class) -- stores all the experiment flags; needs to be a subclass of BaseOptions
        """
        BaseDataset.__init__(self, opt)
        self.dir = os.path.join(opt.dataroot, opt.phase)
        self.AB_paths = sorted(make_dataset(self.dir, opt.max_dataset_size))
        assert(opt.input_nc == 1 and opt.output_nc == 2 and opt.direction == 'AtoB')
        self.transform = get_transform(self.opt, convert=False) 
Example #29
Source File: unaligned_dataset.py    From Recycle-GAN with MIT License 5 votes vote down vote up
def initialize(self, opt):
        self.opt = opt
        self.root = opt.dataroot
        self.dir_A = os.path.join(opt.dataroot, opt.phase + 'A')
        self.dir_B = os.path.join(opt.dataroot, opt.phase + 'B')

        self.A_paths = make_dataset(self.dir_A)
        self.B_paths = make_dataset(self.dir_B)

        self.A_paths = sorted(self.A_paths)
        self.B_paths = sorted(self.B_paths)
        self.A_size = len(self.A_paths)
        self.B_size = len(self.B_paths)
        self.transform = get_transform(opt) 
Example #30
Source File: single_dataset.py    From EvolutionaryGAN-pytorch with MIT License 5 votes vote down vote up
def __init__(self, opt):
        """Initialize this dataset class.

        Parameters:
            opt (Option class) -- stores all the experiment flags; needs to be a subclass of BaseOptions
        """
        BaseDataset.__init__(self, opt)
        self.A_paths = sorted(make_dataset(opt.dataroot, opt.max_dataset_size))
        self.transform = get_transform(opt, grayscale=(self.opt.input_nc == 1))