Пример #1
0
 def _archive(self):
   """The backing npz file contents."""
   if self.__archive is None:
     t = time.time()
     try:
       self.__archive = file_util.read_npz(self.npz_path)
     except:
       raise ValueError('Failed to read %s' % self.npz_path)
     log('Time loading input archive: %0.2f' % (time.time() - t))
   return self.__archive
Пример #2
0
 def testBatchedDodecaDepthToXYZ(self):
     npz_fnames = [
         '53502c15c30d06496e4e9b7d32a4f90d.npz',
         '53a60f2eb6b1a3e9afe717997470b28d.npz'
     ]
     all_depth_ims = []
     for fname in npz_fnames:
         npz_filename = os.path.join(self.test_data_directory, fname)
         all_depth_ims.append(
             file_util.read_npz(npz_filename)['gaps_depth'] / 1000.0)
     depth_ims_tf = tf.stack(all_depth_ims)
     xyz_tf = geom_util.transform_depth_dodeca_to_xyz_dodeca(depth_ims_tf)
     with self.test_session() as session:
         xyz_np = session.run(xyz_tf)
         output_dir = path_util.create_test_output_dir()
         for i in range(len(npz_fnames)):
             np.save(output_dir + '/xyz_im_%i.npy' % i, xyz_np[i, ...])
Пример #3
0
 def testAllToXYZ(self):
     npz_filename = '53a60f2eb6b1a3e9afe717997470b28d.npz'
     npz_filename = os.path.join(self.test_data_directory, npz_filename)
     npz = file_util.read_npz(npz_filename)
     depth_ims = npz['gaps_depth'] / 1000.0
     surface_pts = npz['surface_points']
     depth_ims_tf = tf.reshape(tf.constant(depth_ims, dtype=tf.float32),
                               [1, 20, 224, 224, 1])
     xyz_images = geom_util.transform_depth_dodeca_to_xyz_dodeca(
         depth_ims_tf)
     with self.test_session() as session:
         xyz_np = session.run(xyz_images)
         output_dir = path_util.create_test_output_dir()
         valid_locations = depth_ims != 0.0
         valid_locations = np.reshape(valid_locations, [1, 20, 224, 224])
         filtered_xyz = xyz_np[valid_locations, :]
         xyz_from_depth = np.reshape(filtered_xyz, [-1, 3])
         np.random.shuffle(xyz_from_depth)
         xyz_from_depth = xyz_from_depth[:10000, :]
         np.save(output_dir + '/surface_pts.npy', surface_pts)
         np.save(output_dir + '/depth_xyz.npy', xyz_np)
         np.save(output_dir + '/depth.npy', depth_ims)
         np.save(output_dir + '/filtered_xyz.npy', filtered_xyz)
         np.save(output_dir + '/xyz_from_depth.npy', xyz_from_depth)
Пример #4
0
 def _load_max_depth_normals(self):
   path = self.max_depth_normals_path
   dn = file_util.read_npz(path)['arr_0']
   depth = dn[:, :, :, 0:1]
   normals = dn[:, :, :, 1:]
   return depth, normals
Пример #5
0
 def load_depth_and_normal_npz(self, path):
   depth_normal_arr = file_util.read_npz(path)['arr_0']
   depth = depth_normal_arr[..., 0]  # For backwards compat.
   normals = depth_normal_arr[..., 1:]
   return depth, normals