MCPcopy Index your code
hub / github.com/apple/ml-pointersect / save_as_npbgpp_input

Method save_as_npbgpp_input

pointersect/inference/structures.py:2711–2818  ·  view source on GitHub ↗

Save as the format used by NPBG++ (https://github.com/rakhimovv/npbgpp). We use the DTU dataset's format: - image: 000000.png ... 000010.png (all images, input and ground truth target) - mask: 000.png ... 010.png (binary masks, 1: object, 0: background)

(
            self,
            output_dirs: T.List[str],
            type: str,  # 'input', 'ground-truth'
            start_idx: int = 0,
            exist_ok: bool = True,
            overwrite: bool = False,
            hit_only: bool = False,
    )

Source from the content-addressed store, hash-verified

2709 )
2710
2711 def save_as_npbgpp_input(
2712 self,
2713 output_dirs: T.List[str],
2714 type: str, # 'input', 'ground-truth'
2715 start_idx: int = 0,
2716 exist_ok: bool = True,
2717 overwrite: bool = False,
2718 hit_only: bool = False,
2719 ):
2720 """
2721 Save as the format used by NPBG++ (https://github.com/rakhimovv/npbgpp).
2722 We use the DTU dataset's format:
2723 - image: 000000.png ... 000010.png (all images, input and ground truth target)
2724 - mask: 000.png ... 010.png (binary masks, 1: object, 0: background)
2725 - mvs_pc.ply: xyz input point cloud (can be without rgb color)
2726 - cameras.npz: world_mat_0 ... world_mat_10 (4x4 Projection matrix from world to image, ie, intrinsics * H_w2c)
2727
2728 image background is white.
2729 reccommend using b==1.
2730
2731 Args:
2732 output_dirs:
2733 (b,) output folders for each b
2734
2735 Returns:
2736 list of output_dir, one per each b
2737 """
2738 background_color = 1.
2739 assert len(output_dirs) == self.rgb.size(0)
2740 for output_dir in output_dirs:
2741 if overwrite:
2742 try:
2743 shutil.rmtree(output_dir)
2744 except:
2745 pass
2746 if os.path.exists(output_dir) and not exist_ok:
2747 raise RuntimeError
2748 os.makedirs(output_dir, exist_ok=True)
2749
2750 if type == 'input':
2751 save_pcd = True
2752 else:
2753 save_pcd = False
2754
2755 if hit_only and self.hit_map is not None:
2756 hit_map = self.hit_map.float() # (b, q, h, w)
2757 else:
2758 hit_map = torch.ones_like(self.depth) # (b, q, h, w)
2759
2760 if self.hit_map is not None:
2761 actual_hit_map = self.hit_map.float() # (b, q, h, w)
2762 else:
2763 actual_hit_map = torch.ones_like(self.depth) # (b, q, h, w)
2764
2765 b, q, h, w, _3 = self.rgb.shape
2766 assert self.camera.width_px == w, f'self.camera.width_px = {self.camera.width_px}, w = {w}'
2767 assert self.camera.height_px == h, f'self.camera.height_px = {self.camera.height_px}, h = {h}'
2768

Callers

nothing calls this directly

Calls 6

get_pcdMethod · 0.95
sizeMethod · 0.80
get_H_w2cMethod · 0.80
loadMethod · 0.80
save_as_npbgppMethod · 0.80
detachMethod · 0.45

Tested by

no test coverage detected