Bug description
load_alphapose_wholebody_from_json (and the auto-detecting variant in alphapose.py) iterates over a flat sorted list of all detections across all frames, where each entry represents one person detected in one frame. If a frame contains no detections, it simply does not appear in the AlphaPose JSON output — so the loader silently skips it.
No error is raised, but the resulting Pose will have fewer frames than the source video. This makes the frame count unreliable and breaks any downstream processing that assumes temporal alignment between the Pose and the original video (e.g. subtitle alignment, frame-level annotation, optical flow).
Relevant code
src/python/pose_format/utils/alphapose.py, load_alphapose_wholebody_from_json:
for item in frames:
xy, conf, n_keypoints = parse_keypoints_and_confidence(item["keypoints"])
frames_xy.append(xy)
frames_conf.append(conf)
xy_data = np.stack(frames_xy, axis=0)[:, None, :, :]
If frames 0, 1, 3 have detections but frame 2 does not, the output will have 3 frames with no indication that frame 2 was dropped.
Suggested fix
When the total frame count is known (e.g. passed as a parameter or derived from video metadata), missing frames should be filled with a zeroed, fully-masked row so the output frame count matches the video. This is analogous to what load_openpose does with its num_frames parameter and masked arrays, and how the new mmposewholebody loader handles empty frames.
A lighter-weight fix would be to at least warn the caller when detected frame indices are non-contiguous (i.e. gaps exist in the sorted image_id sequence).
Context
Discovered while implementing the MMPose wholebody loader, which receives one result per video frame from MMPoseInferencer and therefore always knows when a frame is empty.
Bug description
load_alphapose_wholebody_from_json(and the auto-detecting variant inalphapose.py) iterates over a flat sorted list of all detections across all frames, where each entry represents one person detected in one frame. If a frame contains no detections, it simply does not appear in the AlphaPose JSON output — so the loader silently skips it.No error is raised, but the resulting
Posewill have fewer frames than the source video. This makes the frame count unreliable and breaks any downstream processing that assumes temporal alignment between thePoseand the original video (e.g. subtitle alignment, frame-level annotation, optical flow).Relevant code
src/python/pose_format/utils/alphapose.py,load_alphapose_wholebody_from_json:If frames 0, 1, 3 have detections but frame 2 does not, the output will have 3 frames with no indication that frame 2 was dropped.
Suggested fix
When the total frame count is known (e.g. passed as a parameter or derived from video metadata), missing frames should be filled with a zeroed, fully-masked row so the output frame count matches the video. This is analogous to what
load_openposedoes with itsnum_framesparameter and masked arrays, and how the newmmposewholebodyloader handles empty frames.A lighter-weight fix would be to at least warn the caller when detected frame indices are non-contiguous (i.e. gaps exist in the sorted
image_idsequence).Context
Discovered while implementing the MMPose wholebody loader, which receives one result per video frame from
MMPoseInferencerand therefore always knows when a frame is empty.