def __getitem__(self, index): data_numpy = self.data[index] label = self.label[index] data_numpy = np.array(data_numpy) C, T, V, M = data_numpy.shape if self.normalization: data_numpy = (data_numpy - self.mean_map) / self.std_map if self.random_shift: data_numpy = tools.random_shift(data_numpy) if self.random_choose: data_numpy = tools.random_choose(data_numpy, self.window_size) elif self.window_size > 0: data_numpy = tools.auto_pading(data_numpy, self.window_size) if self.random_move: data_numpy = tools.random_move(data_numpy) if self.argument: if V == 18: conf = data_numpy[2].reshape(1, -1, V, M) data_numpy = data_numpy[:2] motion = np.concatenate((data_numpy, np.zeros( (C - 1, 1, V, M))), 1) - np.concatenate((np.zeros( (C - 1, 1, V, M)), data_numpy), 1) motion = np.concatenate( (motion[:, 1:-1, :, :], np.zeros((C - 1, 1, V, M))), 1) data_numpy = np.concatenate((data_numpy, motion, conf), 0) else: motion = np.concatenate((data_numpy, np.zeros( (C, 1, V, M))), 1) - np.concatenate((np.zeros( (C, 1, V, M)), data_numpy), 1) motion = np.concatenate( (motion[:, 1:-1, :, :], np.zeros((C, 1, V, M))), 1) data_numpy = np.concatenate((data_numpy, motion), 0) return data_numpy, label, index
def __getitem__(self, index): if "train" in self.data_path and "bone" in self.data_path: train_data_file = train_data_bone_files[index] filename = train_data_file data_numpy = np.load(train_data_bone_path + train_data_file) label = int( filename[filename.index("A") + 1:filename.index("A") + 4]) - 1 elif "test" in self.data_path and "bone" in self.data_path: test_data_file = test_data_bone_files[index] filename = test_data_file data_numpy = np.load(test_data_bone_path + test_data_file) label = int( filename[filename.index("A") + 1:filename.index("A") + 4]) - 1 data_numpy = data_numpy[:, :, :67, :] if self.normalization: data_numpy = (data_numpy - self.mean_map) / self.std_map if self.random_shift: data_numpy = tools.random_shift(data_numpy) if self.random_choose: data_numpy = tools.random_choose(data_numpy, self.window_size) elif self.window_size > 0: data_numpy = tools.auto_pading(data_numpy, self.window_size) if self.random_move: data_numpy = tools.random_move(data_numpy) return data_numpy, label, index
def __getitem__(self, index): data_numpy = self.data[index] label = int(self.label[index]) data_numpy = np.array(data_numpy) if self.normalization: data_numpy = (data_numpy - self.mean_map) / self.std_map if self.random_shift: data_numpy = tools.random_shift(data_numpy) if self.random_choose: data_numpy = tools.random_choose(data_numpy, self.window_size) elif self.window_size > 0: data_numpy = tools.auto_pading(data_numpy, self.window_size) if self.random_move: data_numpy = tools.random_move(data_numpy) # # flipling # if self.flip: # data_numpy = tools.flip(data_numpy) # if self.rescale: # data_numpy = tools.rescale(data_numpy) # if self.rotation: # data_numpy = tools.rotation(data_numpy) # if self.aug: # data_numpy = tools.augmentation(data_numpy) if self.pad: data_numpy = tools.temporal_pad(data_numpy) if self.is_test: return data_numpy, label, index else: return { "batchdata": torch.FloatTensor(data_numpy), "label": torch.LongTensor([label]) }
def __getitem__(self, index): """ self.data is fixed data. each epoch, the sequence of index shuffled. ex) epoch0 --> [ 1 3 2 4 0] ex) epoch1 --> [ 0 3 4 2 1] :param index: :return: """ _data_numpy = self.data[index] # sample index. label = self.label[index] data_numpy = np.array(_data_numpy) # 3, 300, 25, 2 if self.modf == 'knee': data_numpy = self.tmp_noise_knee_test(data_numpy) if self.modf == 'shld': data_numpy = self.tmp_noise_shld_train(data_numpy) if self.modf == 'noise': if self.ttype == 'All': # all data_numpy = self.noise_joint_all(data_numpy) else: # Fixed data_numpy = self.noise_joint_fix(data_numpy) if self.modf == 'mutual': if self.ttype == 'static': __data_numpy = self.noise_joint_static(data_numpy, self.drop_num) else: dynamic_drop_num = np.random.randint(1, self.drop_num + 1) __data_numpy = self.noise_joint_static(data_numpy, dynamic_drop_num) data_numpy = np.array([_data_numpy, __data_numpy]) if self.normalization: data_numpy = (data_numpy - self.mean_map) / self.std_map if self.random_shift: data_numpy = tools.random_shift(data_numpy) if self.random_choose: data_numpy = tools.random_choose(data_numpy, self.window_size) elif self.window_size > 0: data_numpy = tools.auto_pading(data_numpy, self.window_size) if self.random_move: data_numpy = tools.random_move(data_numpy) # print(f'getitem {index} after', data_numpy[:,0,14,0 ]) return data_numpy, label, index
def __getitem__(self, index): # data_numpy = self.data[index] # label = self.label[index] # data_numpy = np.array(data_numpy) ''' if "train" in self.data_path and "joint_motion" in self.data_path: train_data_file = train_data_joint_motion_files[index] filename = train_data_file f = h5py.File(train_data_joint_motion_path + train_data_file, "r") data_numpy = f[list(f.keys())[-1]][:] label =int(filename[filename.index("A") + 1 : filename.index("A") + 4]) - 1 f.close() elif "test" in self.data_path and "joint_motion" in self.data_path: test_data_file = test_data_joint_motion_files[index] filename = test_data_file f = h5py.File(test_data_joint_motion_path + test_data_file, "r") data_numpy = f[list(f.keys())[-1]][:] label = int(filename[filename.index("A") + 1: filename.index("A") + 4]) - 1 f.close() ''' if "train" in self.data_path and "joint_motion" in self.data_path: train_data_file = train_data_joint_motion_files[index] filename = train_data_file data_numpy = np.load(train_data_joint_motion_path + train_data_file) label = int( filename[filename.index("A") + 1:filename.index("A") + 4]) - 1 elif "test" in self.data_path and "joint_motion" in self.data_path: test_data_file = test_data_joint_motion_files[index] filename = test_data_file data_numpy = np.load(test_data_joint_motion_path + test_data_file) label = int( filename[filename.index("A") + 1:filename.index("A") + 4]) - 1 data_numpy = data_numpy[:, :, :67, :] if self.normalization: data_numpy = (data_numpy - self.mean_map) / self.std_map if self.random_shift: data_numpy = tools.random_shift(data_numpy) if self.random_choose: data_numpy = tools.random_choose(data_numpy, self.window_size) elif self.window_size > 0: data_numpy = tools.auto_pading(data_numpy, self.window_size) if self.random_move: data_numpy = tools.random_move(data_numpy) return data_numpy, label, index
def __getitem__(self, index): data_numpy = self.data[index] label = self.label[index] data_numpy = np.array(data_numpy) if self.normalization: data_numpy = (data_numpy - self.mean_map) / self.std_map if self.random_shift: data_numpy = tools.random_shift(data_numpy) if self.random_choose: data_numpy = tools.random_choose(data_numpy, self.window_size) elif self.window_size > 0: data_numpy = tools.auto_pading(data_numpy, self.window_size) if self.random_move: data_numpy = tools.random_move(data_numpy) return data_numpy, label, index
def __getitem__(self, index): data_numpy = self.data[index] label = self.label[index] data_numpy = np.array(data_numpy) if self.random_choose: data_numpy = tools.random_choose(data_numpy, self.window_size) if self.random_mirror: if random.random() > self.random_mirror_p: assert data_numpy.shape[2] == 27 data_numpy = data_numpy[:,:,flip_index,:] if self.is_vector: data_numpy[0,:,:,:] = - data_numpy[0,:,:,:] else: data_numpy[0,:,:,:] = 512 - data_numpy[0,:,:,:] if self.normalization: # data_numpy = (data_numpy - self.mean_map) / self.std_map assert data_numpy.shape[0] == 3 if self.is_vector: data_numpy[0,:,0,:] = data_numpy[0,:,0,:] - data_numpy[0,:,0,0].mean(axis=0) data_numpy[1,:,0,:] = data_numpy[1,:,0,:] - data_numpy[1,:,0,0].mean(axis=0) else: data_numpy[0,:,:,:] = data_numpy[0,:,:,:] - data_numpy[0,:,0,0].mean(axis=0) data_numpy[1,:,:,:] = data_numpy[1,:,:,:] - data_numpy[1,:,0,0].mean(axis=0) if self.random_shift: if self.is_vector: data_numpy[0,:,0,:] += random.random() * 20 - 10.0 data_numpy[1,:,0,:] += random.random() * 20 - 10.0 else: data_numpy[0,:,:,:] += random.random() * 20 - 10.0 data_numpy[1,:,:,:] += random.random() * 20 - 10.0 # if self.random_shift: # data_numpy = tools.random_shift(data_numpy) # elif self.window_size > 0: # data_numpy = tools.auto_pading(data_numpy, self.window_size) if self.random_move: data_numpy = tools.random_move(data_numpy) return data_numpy, label, index
def __getitem__(self, index): data_numpy = self.data[index] label = self.label[index] data_numpy = np.array(data_numpy) info_numpy = np.array(self.sample_name[index]) if self.normalization: data_numpy = (data_numpy - self.mean_map) / self.std_map if self.random_shift: data_numpy = tools.random_shift(data_numpy) if self.random_choose: data_numpy = tools.random_choose(data_numpy, self.window_size) elif self.window_size > 0: data_numpy = tools.auto_pading(data_numpy, self.window_size) if self.random_move: data_numpy = tools.random_move(data_numpy) data_numpy = tools.frame_delay(data_numpy, self.frame_delay) data_numpy = tools.frame_null(data_numpy, self.frame_null) data_numpy = tools.horizontal_flip(data_numpy, self.horizontal_flip) return data_numpy, label, info_numpy
def __getitem__(self, index): data_numpy = self.data[index] label = self.label[index] data_numpy = np.array(data_numpy) if self.normalization: data_numpy = (data_numpy - self.mean_map) / self.std_map if self.random_shift: data_numpy = tools.random_shift(data_numpy) if self.random_choose: data_numpy = tools.random_choose(data_numpy, self.window_size) elif self.window_size > 0: data_numpy = tools.auto_pading(data_numpy, self.window_size) if self.random_move: data_numpy = tools.random_move(data_numpy) disps = displacementVectors(sample=data_numpy) rel_coords = relativeCoordinates(sample=data_numpy) data_numpy = np.concatenate([disps, rel_coords], axis=0) return data_numpy, label, index