Test that 2D pose estimation runs and produces output.
(test_image_path, test_output_dir)
| 32 | |
| 33 | |
| 34 | def test_2d_pose_estimation(test_image_path, test_output_dir): |
| 35 | """Test that 2D pose estimation runs and produces output.""" |
| 36 | # Import here to avoid import issues at collection time |
| 37 | from fmpose3d.lib.hrnet.gen_kpts import gen_video_kpts as hrnet_pose |
| 38 | from fmpose3d.lib.preprocess import h36m_coco_format, revise_kpts |
| 39 | |
| 40 | # Run 2D pose estimation |
| 41 | keypoints, scores = hrnet_pose(test_image_path, det_dim=416, num_person=1, gen_output=True, type='image') |
| 42 | |
| 43 | # Check output shapes |
| 44 | assert keypoints is not None, "Keypoints should not be None" |
| 45 | assert scores is not None, "Scores should not be None" |
| 46 | assert keypoints.shape[2] == 17, f"Expected 17 joints, got {keypoints.shape[2]}" |
| 47 | assert keypoints.shape[3] == 2, f"Expected 2D coordinates, got shape {keypoints.shape[3]}" |
| 48 | |
| 49 | # Convert to H36M format |
| 50 | keypoints, scores, valid_frames = h36m_coco_format(keypoints, scores) |
| 51 | assert keypoints is not None, "H36M format conversion failed" |
| 52 | |
| 53 | # Save keypoints |
| 54 | output_2d_dir = test_output_dir + 'input_2D/' |
| 55 | os.makedirs(output_2d_dir, exist_ok=True) |
| 56 | np.savez_compressed(output_2d_dir + 'keypoints.npz', reconstruction=keypoints) |
| 57 | |
| 58 | assert os.path.exists(output_2d_dir + 'keypoints.npz'), "Keypoints file should be created" |
| 59 | |
| 60 | |
| 61 | def test_demo_pipeline_runs(test_image_path): |
nothing calls this directly
no test coverage detected