Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions prima/utils/evaluate_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ def compute_pck(self, output: Dict, batch: Dict, pck_threshold: Union[List, None
if pck_threshold is not None:
for i in range(len(pck_threshold)):
self.pck_threshold_list.append(torch.tensor([pck_threshold[i]] * len(pred_keypoints_2d), dtype=torch.float32))
if len(self.pck_threshold_list) == 0:
return torch.tensor([], dtype=torch.float32)

pcks = []
# Use mask area if available, otherwise use full image area
Expand All @@ -118,7 +120,7 @@ def compute_pck(self, output: Dict, batch: Dict, pck_threshold: Union[List, None
else:
# Use full image area as fallback
seg_area = torch.tensor([self.image_size * self.image_size] * len(pred_keypoints_2d), dtype=torch.float32).unsqueeze(-1)
total_visible = torch.sum(conf, dim=-1)
total_visible = torch.sum(conf, dim=-1).clamp_min(1e-6)
for th in self.pck_threshold_list:
dist = torch.norm(pred_keypoints_2d - gt_keypoints_2d, dim=-1)

Expand Down Expand Up @@ -147,7 +149,7 @@ def eval_3d(self, output: Dict, batch: Dict):
Returns: evaluate metric
"""
if batch['has_smal_params']["betas"].sum() == 0:
return 0., 0., 0., [0., 0.], 0.
return 0., 0.

pred_keypoints_3d = output["pred_keypoints_3d"].detach()
pred_keypoints_3d = pred_keypoints_3d[:, None, :, :]
Expand Down
5 changes: 3 additions & 2 deletions prima/utils/mesh_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ def __call__(self, vertices, camera_translation, image, focal_length, text=None,
alphaMode='OPAQUE',
baseColorFactor=baseColorFactor)

camera_translation[0] *= -1.
camera_translation_local = camera_translation.copy()
camera_translation_local[0] *= -1.

mesh = trimesh.Trimesh(vertices.copy(), self.faces.copy())
if side_view:
Expand All @@ -248,7 +249,7 @@ def __call__(self, vertices, camera_translation, image, focal_length, text=None,
scene.add(mesh, 'mesh')

camera_pose = np.eye(4)
camera_pose[:3, 3] = camera_translation
camera_pose[:3, 3] = camera_translation_local
camera_center = [image.shape[1] / 2., image.shape[0] / 2.]
camera = pyrender.IntrinsicsCamera(fx=focal_length, fy=focal_length,
cx=camera_center[0], cy=camera_center[1],
Expand Down
11 changes: 5 additions & 6 deletions prima/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ def task_wrapper(task_func: Callable) -> Callable:
"""

def wrap(cfg: DictConfig):

# apply extra utilities
extras(cfg)

# execute the task
start_time = time.time()
try:
start_time = time.time()
# apply extra utilities
extras(cfg)

# execute the task
ret = task_func(cfg=cfg)
except Exception as ex:
log.exception("") # save exception to `.log` file
Expand Down
5 changes: 3 additions & 2 deletions prima/utils/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ def __call__(self,
alphaMode='OPAQUE',
baseColorFactor=(*mesh_base_color, 1.0))

camera_translation[0] *= -1.
camera_translation_local = camera_translation.copy()
camera_translation_local[0] *= -1.

mesh = trimesh.Trimesh(vertices.copy(), self.faces.copy())
if side_view:
Expand All @@ -219,7 +220,7 @@ def __call__(self,
scene.add(mesh, 'mesh')

camera_pose = np.eye(4)
camera_pose[:3, 3] = camera_translation
camera_pose[:3, 3] = camera_translation_local
camera_center = [image.shape[1] / 2., image.shape[0] / 2.]
camera = pyrender.IntrinsicsCamera(fx=focal_length_to_use, fy=focal_length_to_use,
cx=camera_center[0], cy=camera_center[1], zfar=1e12)
Expand Down
Loading