def __init__(self, dataset_csv_path, dataset_csv_file, dataset_image_path, dataset_size=0, output_size=(240, 240), transform=None, random_crop=False, random_affine=False): self.random_crop = random_crop if random_affine: self.random_affine = torchvision.transforms.RandomAffine( 40, translate=None, scale=(1, 1.5), shear=40, resample=PIL.Image.BILINEAR) else: self.random_affine = None self.out_h, self.out_w = output_size self.train_data = pd.read_csv( os.path.join(dataset_csv_path, dataset_csv_file)) if dataset_size is not None and dataset_size != 0: dataset_size = min((dataset_size, len(self.train_data))) self.train_data = self.train_data.iloc[0:dataset_size, :] self.img_A_names = self.train_data.iloc[:, 0] self.img_B_names = self.train_data.iloc[:, 1] self.set = self.train_data.iloc[:, 2].to_numpy() self.flip = self.train_data.iloc[:, 3].to_numpy().astype('int') self.dataset_image_path = dataset_image_path self.transform = transform # no cuda as dataset is called from CPU threads in dataloader and produces confilct self.affineTnf = AffineTnf(out_h=self.out_h, out_w=self.out_w, use_cuda=False)
def __init__(self, csv_file, dataset_path, output_size=(240, 240), transform=None, category=None, pck_procedure='pf'): self.category_names = [ 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor' ] self.out_h, self.out_w = output_size self.pairs = pd.read_csv(csv_file) self.category = self.pairs.iloc[:, 2].as_matrix().astype('float') if category is not None: cat_idx = np.nonzero(self.category == category)[0] self.category = self.category[cat_idx] self.pairs = self.pairs.iloc[cat_idx, :] self.img_A_names = self.pairs.iloc[:, 0] self.img_B_names = self.pairs.iloc[:, 1] self.point_A_coords = self.pairs.iloc[:, 3:5] self.point_B_coords = self.pairs.iloc[:, 5:] self.dataset_path = dataset_path self.transform = transform # no cuda as dataset is called from CPU threads in dataloader and produces confilct self.affineTnf = AffineTnf(out_h=self.out_h, out_w=self.out_w, use_cuda=False) self.pck_procedure = pck_procedure
def __init__(self, dataset_csv_path, dataset_csv_file, dataset_image_path, dataset_size=0, output_size=(240, 240), transform=None, random_crop=False): self.random_crop = random_crop self.out_h, self.out_w = output_size self.train_data = pd.read_csv( os.path.join(dataset_csv_path, dataset_csv_file)) if dataset_size is not None and dataset_size != 0: dataset_size = min((dataset_size, len(self.train_data))) self.train_data = self.train_data.iloc[0:dataset_size, :] self.img_A_names = self.train_data.iloc[:, 0] self.img_B_names = self.train_data.iloc[:, 1] self.set = self.train_data.iloc[:, 2].values self.flip = self.train_data.iloc[:, 3].values.astype('int') self.dataset_image_path = dataset_image_path self.transform = transform # no cuda as dataset is called from CPU threads in dataloader and produces confilct self.affineTnf = AffineTnf(out_h=self.out_h, out_w=self.out_w, use_cuda=False)
def __init__( self, csv_file, dataset_path, output_size=(240, 240), transform=None, category=None, pck_procedure="pf", ): self.category_names = [ "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow", "diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor", ] self.out_h, self.out_w = output_size self.pairs = pd.read_csv(csv_file) self.category = np.array(self.pairs.iloc[:, 2]).astype("float") if category is not None: cat_idx = np.nonzero(self.category == category)[0] self.category = self.category[cat_idx] self.pairs = self.pairs.iloc[cat_idx, :] self.img_A_names = self.pairs.iloc[:, 0] self.img_B_names = self.pairs.iloc[:, 1] self.point_A_coords = self.pairs.iloc[:, 3:5] self.point_B_coords = self.pairs.iloc[:, 5:] self.dataset_path = dataset_path self.transform = transform # no cuda as dataset is called from CPU threads in dataloader and produces confilct self.affineTnf = AffineTnf(out_h=self.out_h, out_w=self.out_w, use_cuda=False) self.pck_procedure = pck_procedure