-
Notifications
You must be signed in to change notification settings - Fork 10
[draft] add optional return_2d flag for including 2D results in predict() return
#21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -477,6 +477,8 @@ class Pose3DResult: | |
| ``camera_to_world``). For animal poses this contains the | ||
| limb-regularised output. | ||
| """ | ||
| pose_2d: Pose2DResult | None = None | ||
| """Optional 2D prediction payload from :meth:`FMPose3DInference.predict`.""" | ||
|
|
||
|
|
||
| #: Accepted source types for :meth:`FMPose3DInference.predict`. | ||
|
|
@@ -659,6 +661,7 @@ def predict( | |
| camera_rotation: np.ndarray | None = _DEFAULT_CAM_ROTATION, | ||
| seed: int | None = None, | ||
| progress: ProgressCallback | None = None, | ||
| return_2d: bool = False, | ||
| ) -> Pose3DResult: | ||
| """End-to-end prediction: 2D pose estimation → 3D lifting. | ||
|
|
||
|
|
@@ -683,20 +686,26 @@ def predict( | |
| progress : ProgressCallback or None | ||
| Optional ``(current_step, total_steps)`` callback. Forwarded | ||
| to the :meth:`pose_3d` step (per-frame reporting). | ||
| return_2d : bool | ||
| When ``True``, include the intermediate :class:`Pose2DResult` | ||
| in the returned :class:`Pose3DResult` as ``pose_2d``. | ||
|
|
||
| Returns | ||
| ------- | ||
| Pose3DResult | ||
| Root-relative and world-coordinate 3D poses. | ||
| """ | ||
| result_2d = self.prepare_2d(source) | ||
| return self.pose_3d( | ||
| result_3d = self.pose_3d( | ||
| result_2d.keypoints, | ||
| result_2d.image_size, | ||
| camera_rotation=camera_rotation, | ||
| seed=seed, | ||
| progress=progress, | ||
| ) | ||
| if return_2d: | ||
| result_3d.pose_2d = result_2d | ||
| return result_3d | ||
|
Comment on lines
+706
to
+708
|
||
|
|
||
| @torch.no_grad() | ||
| def prepare_2d( | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pose_3d()explicitly takes only the first person whenkeypoints_2dis 4D (seepose_3dinput handling), but herereturn_2dattaches the fullPose2DResult(potentially containing multiple persons). This makesPose3DResult.pose_2dambiguous/inconsistent with the returned 3D poses. Consider either (a) filteringresult_2ddown to the same person used for lifting before attaching it, or (b) adding/returning an explicitperson_index(and documenting that only that person is lifted).