def __getitem__(self, index): index = index % self._size im1_filename = self._image_list[index][0] im2_filename = self._image_list[index][1] # read float32 images and flow im1_np0 = common.read_image_as_byte(im1_filename) im2_np0 = common.read_image_as_byte(im2_filename) # possibly apply photometric transformations im1, im2 = self._photometric_transform(im1_np0, im2_np0) # e.g. "clean/alley_1/" basedir = os.path.splitext( os.path.dirname(im1_filename).replace(self._substract_base, "")[1:])[0] # example filename basename = os.path.splitext(os.path.basename(im1_filename))[0] example_dict = { "input1": im1, "input2": im2, "index": index, "basedir": basedir, "basename": basename } return example_dict
def __getitem__(self, index): index = index % self._size im1_filename = self._image_list[index][0] im2_filename = self._image_list[index][1] flo_filename = self._flow_list[index] # read float32 images and flow im1_np0 = common.read_image_as_byte(im1_filename) im2_np0 = common.read_image_as_byte(im2_filename) flo_np0 = common.read_flo_as_float32(flo_filename) # possibly apply photometric transformations im1, im2 = self._photometric_transform(im1_np0, im2_np0) # convert flow to FloatTensor flo = common.numpy2torch(flo_np0) # target_occ: initialized by zero (not used) target_occ = common.numpy2torch( common.read_occ_image_as_float32(im1_filename)) * 0 # example filename basename = os.path.basename(im1_filename)[:5] example_dict = { "input1": im1, "input2": im2, "target1": flo, "target_occ1": target_occ, "index": index, "basename": basename } return example_dict
def __getitem__(self, index): index = index % self._size im1_filename = self._image_list[index][0] im2_filename = self._image_list[index][1] flo_f_filename = self._flow_list[index][0] # read float32 images and flow im1_np0 = common.read_image_as_byte(im1_filename) im2_np0 = common.read_image_as_byte(im2_filename) flo_f_np0, valid_mask = read_png_flow(flo_f_filename) if self.preprocessing_crop: im1_np0, im2_np0, flo_f_np0, valid_mask = \ kitti_random_crop(im1_np0, im2_np0, flo_f_np0, valid_mask) # possibly apply photometric transformations im1, im2 = self._photometric_transform(im1_np0, im2_np0) # convert flow to FloatTensor flo_f = common.numpy2torch(flo_f_np0) valid_mask_f = common.numpy2torch(valid_mask) # example filename full_basename = os.path.basename(im1_filename).split('.')[0] basename = full_basename[:6] if 'data_scene_flow' in im1_filename: version = '2015' else: version = '2012' example_dict = { "input1": im1, "input2": im2, "target1": flo_f, "target2": flo_f, "index": index, "basename": basename, "input_valid": valid_mask_f, "full_basename": full_basename, "kitti_version": version } if self._args.get_tmp_results: fname = os.path.join(version, full_basename + '.png') file_path = os.path.join(self._args.get_tmp_results, fname) flo_tmp, valid_mask_tmp = read_png_flow(file_path) flo_tmp = common.numpy2torch(flo_tmp) valid_mask_tmp = common.numpy2torch(valid_mask_tmp) example_dict['flo_res'] = flo_tmp example_dict['valid_mask_res'] = valid_mask_tmp return example_dict
def __getitem__(self, index): index = index % self._size im1_filename = self._image_list[index][0] im2_filename = self._image_list[index][1] flo_f_filename = self._flow_list[index][0] flo_b_filename = self._flow_list[index][1] occ1_filename = self._occ_list[index][0] occ2_filename = self._occ_list[index][1] # read float32 images and flow im1_np0 = common.read_image_as_byte(im1_filename) im2_np0 = common.read_image_as_byte(im2_filename) flo_f_np0 = common.read_flo_as_float32(flo_f_filename) flo_b_np0 = common.read_flo_as_float32(flo_b_filename) occ1_np0 = common.read_occ_image_as_float32(occ1_filename) occ2_np0 = common.read_occ_image_as_float32(occ2_filename) # temp - check isnan if np.any(np.isnan(flo_f_np0)): flo_f_np0 = fillingInNaN(flo_f_np0) if np.any(np.isnan(flo_b_np0)): flo_b_np0 = fillingInNaN(flo_b_np0) # possibly apply photometric transformations im1, im2 = self._photometric_transform(im1_np0, im2_np0) # convert flow to FloatTensor flo_f = common.numpy2torch(flo_f_np0) flo_b = common.numpy2torch(flo_b_np0) # convert occ to FloatTensor occ1 = common.numpy2torch(occ1_np0) occ2 = common.numpy2torch(occ2_np0) # example filename basename = os.path.basename(im1_filename)[:5] example_dict = { "input1": im1, "input2": im2, "target1": flo_f, "target2": flo_b, "target_occ1": occ1, "target_occ2": occ2, "index": index, "basename": basename } return example_dict
def __getitem__(self, index): index = index % self._size im1_filename = self._image_list[index][0] im2_filename = self._image_list[index][1] flo_filename = self._flow_list[index] occ_filename = self._occ_list[index] # read float32 images and flow im1_np0 = common.read_image_as_byte(im1_filename) im2_np0 = common.read_image_as_byte(im2_filename) flo_np0 = common.read_flo_as_float32(flo_filename) occ_np0 = common.read_occ_image_as_float32(occ_filename) # possibly apply photometric transformations im1, im2 = self._photometric_transform(im1_np0, im2_np0) flo = common.numpy2torch(flo_np0) occ = common.numpy2torch(occ_np0) # show if transform if requested if self.show_aug: plt.subplot(221) plt.title('1 (Input)') show_image(im1_np0, subplote=True) plt.subplot(222) plt.title('2 (Photometric)') show_image(im1, subplote=True) # e.g. "clean/alley_1/" basedir = os.path.splitext( os.path.dirname(im1_filename).replace(self._substract_base, "")[1:])[0] # example filename basename = os.path.splitext(os.path.basename(im1_filename))[0] example_dict = { "input1": im1, "input2": im2, "index": index, "basedir": basedir, "basename": basename, "target1": flo, "target_occ1": occ } return example_dict
def __getitem__(self, index): index = index % self._size im1_filename = self._image_list[index][0] im2_filename = self._image_list[index][1] # read float32 images and flow im1_np0 = common.read_image_as_byte(im1_filename) im2_np0 = common.read_image_as_byte(im2_filename) # possibly apply photometric transformations im1, im2 = self._photometric_transform(im1_np0, im2_np0) # example filename # basename = os.path.basename(im1_filename)[:9] full_basename = os.path.basename(im1_filename).split('.')[0] basename = full_basename[:9] if 'data_scene_flow' in im1_filename: version = '2015' else: version = '2012' example_dict = { "input1": im1, "input2": im2, "index": index, "basename": basename, "full_basename": full_basename } if self._args.get_tmp_results: fname = os.path.join(full_basename + '.png') file_path = os.path.join(self._args.get_tmp_results, fname) flo_tmp, valid_mask_tmp = read_png_flow(file_path) flo_tmp = common.numpy2torch(flo_tmp) valid_mask_tmp = common.numpy2torch(valid_mask_tmp) example_dict['flo_res'] = flo_tmp example_dict['valid_mask_res'] = valid_mask_tmp return example_dict