Skip to content

fix(vis-grecon): keep SMPL/skeleton actor counters aligned (+3 more) - #51

Draft
andrewwhitecdw wants to merge 1 commit into
NVlabs:mainfrom
andrewwhitecdw:bugfix/vis-grecon-assorted-381317ec
Draft

fix(vis-grecon): keep SMPL/skeleton actor counters aligned (+3 more)#51
andrewwhitecdw wants to merge 1 commit into
NVlabs:mainfrom
andrewwhitecdw:bugfix/vis-grecon-assorted-381317ec

Conversation

@andrewwhitecdw

@andrewwhitecdw andrewwhitecdw commented Jul 27, 2026

Copy link
Copy Markdown

Small fixes in global_recon/vis/vis_grecon.py:

fix: keep SMPL/skeleton actor counters aligned when person is absent

Fix: Replace:

        """ Estimation """     
        if self.show_est_pose:
            i = 0
            j = 0
            for idx, pose_dict in self.scene_dict.items():
                actor = self.smpl_actors[i]
                sk_actor = self.skeleton_actors[j]
                if self.fr in pose_dict['frames']:
                    pind = pose_dict['frame2ind'][self.fr]
                    # smpl actor
                    if self.show_smpl and 'smpl_verts' in pose_dict:
                        if 'exist_frames' in pose_dict and not pose_dict['exist_frames'][self.fr]:
                            actor.set_visibility(False)
                        else:
                            actor.set_visibility(True)
                            verts_i = pose_dict['smpl_verts'][pind]
                            actor.update_verts(verts_i)
                            full_opacity = 0.7 if self.show_skeleton else 1.0
                            opacity = 0.4 if pose_dict['invis_frames'][self.fr] else full_opacity
                            actor.set_opacity(opacity)
                        i += 1
                    # skeleton actor
                    if self.show_skeleton and 'smpl_joints' in pose_dict:
                        sk_actor.set_visibility(True)
                        joints_i = pose_dict['smpl_joints'][pind]
                        sk_actor.update_joints(joints_i)
                        opacity = 0.4 if pose_dict['invis_frames'][self.fr] else 1.0
                        sk_actor.set_opacity(opacity)
                        j += 1
            for k in range(i, self.num_person):
                self.smpl_actors[k].set_visibility(False)
            for k in range(j, self.num_person):
                self.skeleton_actors[k].set_visibility(False)

with:

        """ Estimation """     
        if self.show_est_pose:
            i = 0
            j = 0
            for idx, pose_dict in self.scene_dict.items():
                actor = self.smpl_actors[i]
                sk_actor = self.skeleton_actors[j]
                if self.fr in pose_dict['frames']:
                    pind = pose_dict['frame2ind'][self.fr]
                    if self.show_smpl and 'smpl_verts' in pose_dict:
                        if 'exist_frames' in pose_dict and not pose_dict['exist_frames'][self.fr]:
                            actor.set_visibility(False)
                        else:
                            actor.set_visibility(True)
                            verts_i = pose_dict['smpl_verts'][pind]
                            actor.update_verts(verts_i)
                            full_opacity = 0.7 if self.show_skeleton else 1.0
                            opacity = 0.4 if pose_dict['invis_frames'][self.fr] else full_opacity
                            actor.set_opacity(opacity)
                    elif self.show_smpl:
                        actor.set_visibility(False)
                    if self.show_skeleton and 'smpl_joints' in pose_dict:
                        sk_actor.set_visibility(True)
                        joints_i = pose_dict['smpl_joints'][pind]
                        sk_actor.update_joints(joints_i)
                        opacity = 0.4 if pose_dict['invis_frames'][self.fr] else 1.0
                        sk_actor.set_opacity(opacity)
                    elif self.show_skeleton:
                        sk_actor.set_visibility(False)
                else:
                    if self.show_smpl:
                        actor.set_visibility(False)
                    if self.show_skeleton:
                        sk_actor.set_visibility(False)
                if self.show_smpl:
                    i += 1
                if self.show_skeleton:
                    j += 1
            if self.show_smpl:
                for k in range(i, self.num_person):
                    self.smpl_actors[k].set_visibility(False)
            if self.show_skeleton:
                for k in range(j, self.num_person):
                    self.skeleton_actors[k].set_visibility(False)

fix: copy init_focal_point before mutating in init_camera

Fix: Replace:

            focal_point = self.init_focal_point
            if self.use_y_up_coord:
                focal_point[2] += 3.0
                self.pl.camera.position = (focal_point[0] + self.view_dist, focal_point[1] + 2, focal_point[2])

with:

            focal_point = self.init_focal_point.copy()
            if self.use_y_up_coord:
                focal_point[2] += 3.0
                self.pl.camera.position = (focal_point[0] + self.view_dist, focal_point[1] + 2, focal_point[2])

fix: guard GT pose update when ground-truth dict is empty

Fix: Replace:

        """ GT """
        if self.show_gt_pose:
            for i, actor in enumerate(self.smpl_gt_actors):
                pose_dict = self.gt[i]

with:

        """ GT """
        if self.show_gt_pose and len(self.gt) > 0:
            for i, actor in enumerate(self.smpl_gt_actors):
                pose_dict = self.gt[i]

fix: move SMPL tensors to CPU before calling numpy()

Fix: Apply patch:

--- a/global_recon/vis/vis_grecon.py
+++ b/global_recon/vis/vis_grecon.py
@@ -91,7 +91,7 @@ class GReconVisualizer(Visualizer3D):
                     return_full_pose=True,
                     orig_joints=True
                 )
-            pose_dict['smpl_verts'] = smpl_motion.vertices.numpy()
-            pose_dict['smpl_joints'] = smpl_motion.joints.numpy()
+            pose_dict['smpl_verts'] = smpl_motion.vertices.cpu().numpy()
+            pose_dict['smpl_joints'] = smpl_motion.joints.cpu().numpy()
             if 'fr_start' not in pose_dict:
                 pose_dict['fr_start'] = np.where(pose_dict['visible'])[0][0]
@@ -118,7 +118,7 @@ class GReconVisualizer(Visualizer3D):
                     return_full_pose=True,
                     orig_joints=True
                 )
-                pose_dict['smpl_verts'] = smpl_motion.vertices.numpy()
-                pose_dict['smpl_joints'] = smpl_motion.joints.numpy()
+                pose_dict['smpl_verts'] = smpl_motion.vertices.cpu().numpy()
+                pose_dict['smpl_joints'] = smpl_motion.joints.cpu().numpy()
             if 'smpl_joint_pos' in pose_dict:
                 orient = torch.tensor(pose_dict[f'smpl_orient{suffix}'])
@@ -130,7 +130,7 @@ class GReconVisualizer(Visualizer3D):
                 orient_q = angle_axis_to_quaternion(orient).unsqueeze(-2).expand(joints.shape[:-1] + (4,))
                 joints_world = quat_apply(orient_q, joints) + trans.unsqueeze(-2)
-                pose_dict['smpl_joints'] = joints_world
+                pose_dict['smpl_joints'] = joints_world.cpu().numpy()

Files changed

  • global_recon/vis/vis_grecon.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant