示例#1
0
    def __init__(self,
                 data,
                 dataset,
                 batch_size,
                 shape_rgb,
                 shape_depth,
                 is_flip=False,
                 is_addnoise=False,
                 is_erase=False):
        self.data = data
        self.dataset = dataset
        self.policy = BasicPolicy(color_change_ratio=0.50,
                                  mirror_ratio=0.50,
                                  flip_ratio=0.0 if not is_flip else 0.2,
                                  add_noise_peak=0 if not is_addnoise else 20,
                                  erase_ratio=-1.0 if not is_erase else 0.5)
        self.batch_size = batch_size
        self.shape_rgb = shape_rgb
        self.shape_depth = shape_depth
        self.maxDepth = 1000.0

        from sklearn.utils import shuffle
        self.dataset = shuffle(self.dataset, random_state=0)

        self.N = len(self.dataset)
示例#2
0
 def __init__(self,
              root,
              dataset,
              batch_size,
              shape_rgb,
              shape_depth,
              locations=False,
              is_flip=False,
              is_addnoise=False,
              is_erase=False,
              is_skip_policy=False):
     self.root = root
     self.shape_rgb = [
         (min(shape_rgb), max(shape_rgb)),
         (max(shape_rgb), min(shape_rgb)),
     ]
     self.shape_depth = [
         (min(shape_depth), max(shape_depth)),
         (max(shape_depth), min(shape_depth)),
     ]
     self.dataset = [{
         datum: pickle.load(
             open(os.path.join(dataset, orientation, datum + '_MD.p'),
                  'rb'))
         for datum in ["imgs", "targets"]
     } for orientation in ["landscape", "portrait"]]
     self.policy = BasicPolicy(color_change_ratio=0.50,
                               mirror_ratio=0.50,
                               flip_ratio=0.0 if not is_flip else 0.2,
                               add_noise_peak=0 if not is_addnoise else 20,
                               erase_ratio=-1.0 if not is_erase else 0.5)
     self.batch_size = batch_size
     self.N = [len(dataset["imgs"]) for dataset in self.dataset]
     self.is_skip_policy = is_skip_policy
     self.locations = locations
示例#3
0
    def __init__(self,
                 data,
                 dataset,
                 batch_size,
                 shape_rgb,
                 shape_output,
                 is_flip=False,
                 is_addnoise=False,
                 is_erase=False):
        self.data = data
        self.dataset = dataset
        self.policy = BasicPolicy(color_change_ratio=0.50,
                                  mirror_ratio=0.50,
                                  flip_ratio=0.0 if not is_flip else 0.2,
                                  add_noise_peak=0 if not is_addnoise else 20,
                                  erase_ratio=-1.0 if not is_erase else 0.5)
        self.batch_size = batch_size
        self.shape_rgb = shape_rgb
        self.shape_output = shape_output

        #Shuffling dataset as continous frames can lead to overfitting
        from sklearn.utils import shuffle
        self.dataset = shuffle(self.dataset, random_state=0)

        self.N = len(self.dataset)
示例#4
0
    def __init__(self,
                 data_root,
                 data_paths,
                 batch_size,
                 shape_depth,
                 channels=5,
                 is_flip=False,
                 is_addnoise=False,
                 is_erase=False,
                 dont_interpolate=False):
        self.data_root = data_root
        self.dataset = data_paths
        self.policy = BasicPolicy(color_change_ratio=0.50,
                                  mirror_ratio=0.50,
                                  flip_ratio=0.0 if not is_flip else 0.2,
                                  add_noise_peak=0 if not is_addnoise else 20,
                                  erase_ratio=-1.0 if not is_erase else 0.5)
        self.batch_size = batch_size
        self.channels = channels
        self.shape_rgbd = (batch_size, 480, 640, self.channels)
        self.shape_depth = shape_depth
        self.minDepth = settings.MIN_DEPTH * settings.DEPTH_SCALE  #cm
        self.maxDepth = settings.MAX_DEPTH * settings.DEPTH_SCALE  #cm
        self.dont_interpolate = dont_interpolate

        from sklearn.utils import shuffle
        self.dataset = shuffle(self.dataset, random_state=0)

        self.N = len(self.dataset)
示例#5
0
 def __init__(self, data, dataset, batch_size, shape_rgb, shape_depth, is_flip=False, is_addnoise=False, is_erase=False, is_skip_policy=False):
     self.data = data
     self.dataset = dataset
     self.policy = BasicPolicy( color_change_ratio=0.50, mirror_ratio=0.50, flip_ratio=0.0 if not is_flip else 0.2,
                                 add_noise_peak=0 if not is_addnoise else 20, erase_ratio=-1.0 if not is_erase else 0.5)
     self.batch_size = batch_size
     self.shape_rgb = shape_rgb
     self.shape_depth = shape_depth
     self.maxDepth = 1000.0
     self.N = len(self.dataset)
     self.is_skip_policy = is_skip_policy
示例#6
0
 def __init__(self,
              data_path,
              min_depth,
              max_depth,
              batch_size,
              image_shape,
              depth_shape,
              n_channels,
              is_augment=False,
              shuffle=False,
              mode="train",
              is_flip=False,
              is_addnoise=False,
              is_erase=False,
              is_scale=False,
              is_deconv=False,
              select_label_mode=None,
              scale_value=None):
     self.data_path = data_path
     self.batch_size = batch_size
     self.image_shape = image_shape
     self.depth_shape = depth_shape
     self.n_channels = n_channels
     self.shuffle = shuffle
     self.is_augment = is_augment
     self.min_depth = min_depth
     self.max_depth = max_depth
     self.is_deconv = is_deconv
     self.scale_value = scale_value
     self.select_label_mode = select_label_mode
     self.policy = BasicPolicy(image_shape=image_shape,
                               color_change_ratio=0.50,
                               mirror_ratio=0.50,
                               flip_ratio=0.0 if not is_flip else 0.2,
                               add_noise_peak=0 if not is_addnoise else 20,
                               erase_ratio=-1.0 if not is_erase else 0.5,
                               scale_ratio=-1 if not is_scale else 0.2)
     train_csv_path = os.path.join(self.data_path, "data/nyu2_train.csv")
     valid_csv_path = os.path.join(self.data_path, "data/nyu2_test.csv")
     if mode == "train":
         self.imagePath_labelPath_list = self.read_csv(train_csv_path)
         np.random.shuffle(self.imagePath_labelPath_list)
         self.on_epoch_end()
     else:
         self.imagePath_labelPath_list = self.read_csv(valid_csv_path)