poseorbit 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ * text=auto eol=lf
2
+ *.png binary
3
+ *.jpg binary
@@ -0,0 +1,7 @@
1
+ __pycache__/
2
+ *.egg-info/
3
+ .pytest_cache/
4
+ .venv/
5
+ dist/
6
+ build/
7
+ weights/
@@ -0,0 +1,22 @@
1
+ # Changelog
2
+
3
+ ## 0.1.1 (2026-10-06)
4
+
5
+ - Published on PyPI: `pip install poseorbit`. Releases are uploaded from
6
+ GitHub Actions with Trusted Publishing and signed attestations.
7
+ - The README's pictures and links are absolute, so they show on PyPI too.
8
+
9
+ ## 0.1.0 (2026-10-05)
10
+
11
+ First release.
12
+
13
+ - Find people with YOLOX and DWPose (133 whole-body keypoints), left to
14
+ right; choose one, or everyone.
15
+ - Depth for every keypoint from RTMW3D-x on the same boxes; turn the pose
16
+ with an orthographic camera (yaw ±90°, pitch ±45°).
17
+ - Frame the output canvas: zoom ×0.5 to ×6 around any point.
18
+ - Draw `dwpose` (rtmlib's COCO-WholeBody) or `openpose` (thick, body-only, as
19
+ xinsir's SDXL ControlNet was trained) skeletons, letterboxed onto the
20
+ output's size.
21
+ - Library, `python -m poseorbit draw`, and `python -m poseorbit serve`
22
+ (`POST /api/pose`, optional Bearer token).
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
poseorbit-0.1.1/NOTICE ADDED
@@ -0,0 +1,28 @@
1
+ poseorbit
2
+ Copyright 2026 33rd-kk
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
5
+
6
+ It includes or is derived from the following third-party work:
7
+
8
+ - rtmlib (https://github.com/Tau-J/rtmlib), Apache License 2.0.
9
+ poseorbit calls rtmlib to run the detectors and to draw "dwpose" skeletons,
10
+ and uses its COCO-to-OpenPose keypoint conversion.
11
+
12
+ - The "openpose" drawing in poseorbit/draw.py (_draw_openpose_body) follows
13
+ the draw_bodypose function published on the model card of
14
+ xinsir/controlnet-openpose-sdxl-1.0
15
+ (https://huggingface.co/xinsir/controlnet-openpose-sdxl-1.0), Apache License
16
+ 2.0, itself a modification of controlnet_aux's OpenPose drawing
17
+ (https://github.com/huggingface/controlnet_aux), Apache License 2.0.
18
+ The 18-point limb order and colours are OpenPose's conventions as used there.
19
+
20
+ Model files (downloaded at run time, not distributed with poseorbit):
21
+
22
+ - YOLOX-m (HumanArt) person detector and RTMW-DW-x-l whole-body pose model,
23
+ OpenMMLab (https://github.com/open-mmlab/mmpose), Apache License 2.0,
24
+ fetched from rtmlib's mirror https://huggingface.co/Tau-J/RTMPose.
25
+ - RTMW3D-x, OpenMMLab, Apache License 2.0, fetched from
26
+ https://huggingface.co/Soykaf/RTMW3D-x.
27
+ Paper: Jiang et al., "RTMW: Real-Time Multi-Person 2D and 3D Whole-body
28
+ Pose Estimation", arXiv:2407.08634.
@@ -0,0 +1,351 @@
1
+ Metadata-Version: 2.5
2
+ Name: poseorbit
3
+ Version: 0.1.1
4
+ Summary: Find the people in a picture, turn their pose in 3D, and draw the skeleton a pose-conditioned image model follows.
5
+ Project-URL: Homepage, https://github.com/33rd-kk/poseorbit
6
+ Project-URL: Issues, https://github.com/33rd-kk/poseorbit/issues
7
+ Project-URL: Changelog, https://github.com/33rd-kk/poseorbit/blob/main/CHANGELOG.md
8
+ Author: 33rd-kk
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ License-File: NOTICE
12
+ Keywords: 3d,controlnet,dwpose,openpose,pose,rtmlib,skeleton,stable-diffusion
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Multimedia :: Graphics
23
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
24
+ Requires-Python: >=3.10
25
+ Requires-Dist: huggingface-hub>=0.30
26
+ Requires-Dist: numpy>=1.26
27
+ Requires-Dist: onnxruntime>=1.18
28
+ Requires-Dist: pillow>=10
29
+ Requires-Dist: rtmlib>=0.0.16
30
+ Provides-Extra: server
31
+ Requires-Dist: fastapi>=0.115; extra == 'server'
32
+ Requires-Dist: uvicorn>=0.30; extra == 'server'
33
+ Provides-Extra: test
34
+ Requires-Dist: pytest>=8; extra == 'test'
35
+ Description-Content-Type: text/markdown
36
+
37
+ <picture>
38
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/33rd-kk/poseorbit/main/docs/assets/banner-dark.png">
39
+ <img alt="poseorbit: a picture, the skeleton turned 30 degrees and the picture generated from it, then a zoomed skeleton and the close-up generated from it" src="https://raw.githubusercontent.com/33rd-kk/poseorbit/main/docs/assets/banner-light.png">
40
+ </picture>
41
+
42
+ # poseorbit
43
+
44
+ [![PyPI](https://img.shields.io/pypi/v/poseorbit.svg)](https://pypi.org/project/poseorbit/)
45
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://github.com/33rd-kk/poseorbit/blob/main/LICENSE)
46
+ ![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)
47
+ ![CPU only](https://img.shields.io/badge/runs%20on-CPU-555.svg)
48
+ [![Tests](https://github.com/33rd-kk/poseorbit/actions/workflows/test.yml/badge.svg)](https://github.com/33rd-kk/poseorbit/actions/workflows/test.yml)
49
+
50
+ **Take the pose from a picture, pick whose, look at it from another angle or
51
+ closer in, and get the skeleton your image model follows.**
52
+
53
+ poseorbit finds every person in a picture, lets you choose one (or everyone),
54
+ turns the whole-body pose (hands and face included) in 3D, frames it (from a
55
+ face close-up to room around the figure), and draws the skeleton in the style
56
+ a pose-conditioned model was trained on. It is a small Python package: CPU
57
+ only, no torch, usable as a library, a command, or an HTTP server.
58
+
59
+ ```python
60
+ from PIL import Image
61
+ from poseorbit import Camera, Detector, Framing, pose
62
+
63
+ result = pose(Detector(), Image.open("group.png"), size=(832, 1216),
64
+ person=1, camera=Camera(yaw=40, pitch=10),
65
+ framing=Framing(zoom=2, x=0.5, y=0.35), style="openpose")
66
+ result.skeleton.save("skeleton.png") # feed this to your ControlNet or pose adapter
67
+ ```
68
+
69
+ ## Examples
70
+
71
+ One reference, two skeletons, two pictures generated from them:
72
+
73
+ | Reference | Turned: `Camera(yaw=-30)` | Generated | Close-up: `Framing(zoom=5)` on the face | Generated |
74
+ |---|---|---|---|---|
75
+ | <img src="https://raw.githubusercontent.com/33rd-kk/poseorbit/main/docs/assets/examples/reference.jpg" width="150" alt="reference picture: a girl in a grey hoodie waving, legs crossed"> | <img src="https://raw.githubusercontent.com/33rd-kk/poseorbit/main/docs/assets/examples/turn-skeleton.png" width="150" alt="the reference's skeleton turned 30 degrees"> | <img src="https://raw.githubusercontent.com/33rd-kk/poseorbit/main/docs/assets/examples/turn-result.jpg" width="150" alt="picture generated from the turned skeleton"> | <img src="https://raw.githubusercontent.com/33rd-kk/poseorbit/main/docs/assets/examples/closeup-skeleton.png" width="150" alt="the reference's skeleton zoomed five times on the face"> | <img src="https://raw.githubusercontent.com/33rd-kk/poseorbit/main/docs/assets/examples/closeup-result.jpg" width="150" alt="close-up generated from the zoomed skeleton"> |
76
+
77
+ All pictures were generated for this README. The reference: Illustrious XL
78
+ 2.0, "1girl, solo, full body, standing, waving, one hand raised, head tilt,
79
+ grey hoodie, black pants, white sneakers, simple background", seed 13. The
80
+ other two: Anima Base 1.0 with Anima-Control-Pose (`dwpose` style), 832×1216,
81
+ 30 steps, CFG 5, "1girl, solo, short black hair, blue oversized hoodie, loose
82
+ jeans, sneakers, front view, looking at viewer, smile, simple background"
83
+ plus "full body" or "portrait, face focus, close-up", seed 43 each (picked
84
+ from four and three). The skeleton sets the figure, the prompt everything
85
+ else. Note that Anima and Anima-Control-Pose are under CircleStone Labs'
86
+ non-commercial licence (pictures made with them are not restricted);
87
+ poseorbit itself does not use or include them.
88
+
89
+ ## How it works
90
+
91
+ ```mermaid
92
+ flowchart LR
93
+ A[picture] --> B["find people<br/>YOLOX"]
94
+ B --> C["133 keypoints<br/>DWPose"]
95
+ B --> D["depth<br/>RTMW3D"]
96
+ C --> E[choose a person<br/>or everyone]
97
+ D --> E
98
+ E --> F["turn<br/>yaw / pitch"]
99
+ F --> G["fit onto the<br/>output canvas"]
100
+ G --> H["frame<br/>zoom / centre"]
101
+ H --> I["draw<br/>dwpose / openpose"]
102
+ ```
103
+
104
+ One person detector feeds two keypoint models on the same boxes: DWPose gives
105
+ x and y, RTMW3D (only when a turn is asked for) gives depth. The camera is
106
+ orthographic and orbits the middle of the drawn people's hips. The turned
107
+ pose is letterboxed onto the output's canvas, framed like a cropped photo,
108
+ and drawn on black.
109
+
110
+ ## What sets it apart
111
+
112
+ Turning a pose in 3D for ControlNet is not new (see
113
+ [related projects](#related-projects)). poseorbit's choices are different:
114
+
115
+ - **Depth for all 133 whole-body points, from one picture.** x and y come
116
+ from DWPose (RTMW-DW-x-l) and depth from RTMW3D-x, run on the *same*
117
+ person boxes. Hands and face turn with the body instead of staying flat or
118
+ being dropped, and the front view is pixel-identical to plain 2D detection.
119
+ - **Choose a person in a group.** Everyone found comes back left to right
120
+ with a box, so index 1 is the same person on every call. Draw one of them
121
+ or all of them, turned together around a shared centre so the group keeps
122
+ its layout.
123
+ - **Drawn for the model that will read it.** `dwpose` is rtmlib's
124
+ COCO-WholeBody drawing (thin lines, hands and face), the usual input of
125
+ DWPose-trained adapters. `openpose` is the thick, body-only drawing
126
+ xinsir's OpenPose ControlNet for SDXL was trained on, line width growing
127
+ with the canvas as its model card specifies.
128
+ - **Framing, not just turning.** Zoom from ×0.5 to ×6 around any point of
129
+ the output canvas: a face or upper-body close-up from a full-body
130
+ reference, or a smaller figure with room around it. The answer says how
131
+ many body joints are left in the frame, so a client can warn when a
132
+ body-only skeleton has little to follow.
133
+ - **What you preview is what is followed.** The whole mapping (turn,
134
+ letterbox, framing) is specified [below](#coordinates), so a browser
135
+ viewer can show exactly what will be drawn. Latentry's three.js view is
136
+ tested against it to within 0.05 px.
137
+ - **No framework attached.** No ComfyUI or web UI required, no torch, no
138
+ GPU: a library, `python -m poseorbit draw`, or `python -m poseorbit serve`
139
+ answering `POST /api/pose`. A generation server can embed the same handler
140
+ (`poseorbit.api.handle`) so both speak one API.
141
+ - **Guard rails from measurement.** Turning is held to ±90° yaw and ±45°
142
+ pitch, where single-picture depth is still mostly right. Detections with
143
+ fewer than 8 of 17 body joints seen are not offered as people (a blank
144
+ canvas otherwise "finds" one).
145
+
146
+ ## Measured
147
+
148
+ Generated with and without the skeleton, same seed, 832×1216. The score is
149
+ PCK@0.1 of the re-detected output against the skeleton: 1.0 means every
150
+ point landed within 10% of the diagonal of where the skeleton put it.
151
+
152
+ | Model | Pose | Without | With |
153
+ |---|---|---|---|
154
+ | Illustrious XL 2.0 + xinsir OpenPose ControlNet (`openpose`) | walking, front | 0.76 | **0.94** |
155
+ | same | standing, front | 0.47 | **0.76** |
156
+ | same | walking, turned yaw 45° / yaw −60° pitch 15° | — | **0.94 / 0.88** |
157
+ | Anima Base 1.0 + Anima-Control-Pose (`dwpose`) | walking, front | 0.06 | **0.71** |
158
+ | same | walking, turned yaw 45° | — | **0.94** |
159
+
160
+ Framed, scored on the body and face points left in the frame (the prompt
161
+ says "upper body" or "portrait, close-up" in both runs):
162
+
163
+ | Model | Framing | Without | With |
164
+ |---|---|---|---|
165
+ | Illustrious XL 2.0 + xinsir ControlNet | upper body, ×2 | 0.02 | **1.00** |
166
+ | same | face, ×5 (7 body joints left) | 0.48 | **0.99** |
167
+ | Anima Base 1.0 + Anima-Control-Pose | upper body ×2 / face ×5 | 0.93 / 0.97 | 0.93 / 0.99 |
168
+
169
+ Anima already centres a close-up by itself, so its score barely moves; with
170
+ the skeleton the head's tilt and turn follow the reference. Detection takes
171
+ about 0.7 s for one person on a desktop CPU, all three models together.
172
+
173
+ ## Install
174
+
175
+ Python 3.10 or newer.
176
+
177
+ ```sh
178
+ pip install poseorbit
179
+ pip install "poseorbit[server]" # with the HTTP server
180
+ ```
181
+
182
+ The latest `main`, before it is released:
183
+ `pip install "poseorbit @ git+https://github.com/33rd-kk/poseorbit"`.
184
+
185
+ The model files (about 700 MB, all Apache-2.0) download from Hugging Face on
186
+ first use into `~/.cache/poseorbit`, or the `weights_dir` you give `Detector`.
187
+
188
+ ## Use
189
+
190
+ ### From Python
191
+
192
+ ```python
193
+ from pathlib import Path
194
+ from PIL import Image
195
+ from poseorbit import ALL_PEOPLE, Camera, Detector, Framing, pose
196
+
197
+ detector = Detector(weights_dir=Path("weights")) # load once, reuse; thread-safe
198
+ picture = Image.open("reference.png")
199
+
200
+ people = detector.detect(picture) # everyone, left to right
201
+ print([p.bbox for p in people]) # boxes in the picture's pixels
202
+
203
+ result = pose(detector, picture, size=(832, 1216), person=ALL_PEOPLE,
204
+ camera=Camera(yaw=-30), style="dwpose")
205
+ result.skeleton # PIL image, 832x1216, on black
206
+ result.joints_in_frame # body joints left inside the canvas
207
+ ```
208
+
209
+ ### With diffusers
210
+
211
+ ```python
212
+ import torch
213
+ from diffusers import ControlNetModel, StableDiffusionXLControlNetPipeline
214
+
215
+ controlnet = ControlNetModel.from_pretrained("xinsir/controlnet-openpose-sdxl-1.0", torch_dtype=torch.float16)
216
+ pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
217
+ "stabilityai/stable-diffusion-xl-base-1.0", controlnet=controlnet, torch_dtype=torch.float16
218
+ ).to("cuda")
219
+
220
+ skeleton = pose(detector, picture, size=(832, 1216), camera=Camera(yaw=45), style="openpose").skeleton
221
+ image = pipe("1girl, full body", image=skeleton, width=832, height=1216).images[0]
222
+ ```
223
+
224
+ ### From the command line
225
+
226
+ ```sh
227
+ python -m poseorbit draw ref.png skeleton.png --size 832x1216 --person -1 --yaw 40 --style openpose
228
+ python -m poseorbit draw ref.png face.png --size 832x1216 --zoom 5 --centre 0.62,0.2
229
+ ```
230
+
231
+ ### Over HTTP
232
+
233
+ ```sh
234
+ python -m poseorbit serve --port 7870 # set POSEORBIT_TOKEN to require a Bearer token
235
+ ```
236
+
237
+ ```sh
238
+ curl -s localhost:7870/api/pose -H 'Content-Type: application/json' -d '{
239
+ "image_base64": "<base64 PNG or JPEG>", "width": 832, "height": 1216,
240
+ "person": 0, "want_3d": true,
241
+ "camera": { "yaw": 30, "pitch": 10, "framing": { "zoom": 2, "x": 0.5, "y": 0.35 } },
242
+ "style": "openpose" }'
243
+ ```
244
+
245
+ ```json
246
+ { "skeleton_base64": "…png…", "width": 832, "height": 1216, "person": 0,
247
+ "camera": { "yaw": 30, "pitch": 10, "framing": { "zoom": 2, "x": 0.5, "y": 0.35 } },
248
+ "style": "openpose", "limits": { "yaw": 90, "pitch": 45, "zoom": [0.5, 6] },
249
+ "joints_in_frame": 13,
250
+ "people": [ { "bbox": [0.31, 0.2, 0.8, 1.0],
251
+ "points_3d": [[0.61, 0.24, -0.03], "…"], "scores": [0.92, "…"] } ] }
252
+ ```
253
+
254
+ Everything but `image_base64` is optional. `person` is an index into
255
+ `people` (left to right), `-1` for everyone, or absent for the most
256
+ confident. `want_3d` adds each person's 133 points as `[x, y, z]` in units of
257
+ the picture's width, for a 3D viewer. Out-of-range angles and zoom are
258
+ clamped; a picture with nobody in it, or a person index past the end, gets a
259
+ 400 with a `detail` message. Server and API are 127.0.0.1-only by default.
260
+
261
+ ## Reference
262
+
263
+ | Name | What it is |
264
+ |---|---|
265
+ | `Detector(weights_dir=None, device="cpu")` | Loads the models on first use. `detect(image, depth=False) -> list[Person]`, left to right; raises `NoPersonError`. |
266
+ | `pose(detector, image, size, person=None, camera=None, style="dwpose", depth=False, framing=None) -> PoseResult` | Detect, choose, turn, frame and draw in one call. |
267
+ | `Camera(yaw=0, pitch=0)` | Degrees. `+yaw` swings the camera to the viewer's right, `+pitch` raises it. Clamped to `MAX_YAW` (90) / `MAX_PITCH` (45). |
268
+ | `Framing(zoom=1, x=0.5, y=0.5)` | The canvas point `(x, y)` (fractions) goes to the middle, scaled by `zoom` (`MIN_ZOOM` 0.5 to `MAX_ZOOM` 6). |
269
+ | `PoseResult` | `skeleton` (PIL image), `people`, `person`, `camera` and `framing` as used, `joints_in_frame`. |
270
+ | `Person` | `keypoints` (133×2), `scores` (133), `depth` (133 or None), `bbox`, `visible` (body joints seen), `points_3d`. |
271
+ | `render(keypoints, scores, size, style)` | Draw `(N, 133, 2)` keypoints on a black `size` canvas. |
272
+ | `letterbox(skeleton, size)` | Fit a skeleton drawn at another size onto `size`, uniformly scaled and centred. |
273
+ | `poseorbit.api.handle(detector, body, default_style)` | The `/api/pose` handler without a web framework, to embed in another server. |
274
+
275
+ ### Skeleton styles
276
+
277
+ | Style | Drawing | For |
278
+ |---|---|---|
279
+ | `dwpose` | rtmlib's COCO-WholeBody: thin coloured lines, body, feet, hands and face | DWPose-trained adapters, such as Anima-Control-Pose |
280
+ | `openpose` | 18 OpenPose body points, thick translucent limbs scaled with the canvas | OpenPose ControlNets, such as xinsir/controlnet-openpose-sdxl-1.0 |
281
+
282
+ ## Coordinates
283
+
284
+ x right, y down, depth away from the viewer, all in the picture's pixels
285
+ (the API scales them by the picture's width). The camera at (`yaw`, `pitch`)
286
+ stands at `(sin yaw · cos pitch, −sin pitch, −cos yaw · cos pitch)` from the
287
+ centre (the middle of the drawn people's hips). In a y-up, z-toward-viewer
288
+ frame such as three.js that is `(sin yaw · cos pitch, sin pitch, cos yaw ·
289
+ cos pitch)`.
290
+
291
+ The turned picture is letterboxed onto the output canvas, then framed:
292
+ canvas point `(x, y)` (fractions) goes to the middle and everything scales
293
+ by `zoom` around it. Framing never moves the point the camera orbits.
294
+
295
+ ## Limits
296
+
297
+ - Depth is estimated from a single picture: past a side view, which limb is
298
+ in front gets unreliable. That is why the camera is limited.
299
+ - Chosen from a group, a person is drawn where they stand in the picture,
300
+ letterboxed onto the output. A small figure gives a small skeleton, which
301
+ models follow loosely; zoom in on them.
302
+ - Some models do not tell front from back by the skeleton alone. Anima, for
303
+ one, often draws a strongly turned figure from behind. What helps: turn
304
+ away from the side the figure already shows (look at `Person.depth`: the
305
+ nearer shoulder is the smaller value), keep the turn moderate, and put
306
+ "front view" in the prompt and "from behind" in the negative.
307
+ - Animals and non-human figures are not detected.
308
+
309
+ ## Related projects
310
+
311
+ Other ways to get a turned or posed skeleton, each with its own strengths:
312
+
313
+ - [3D Openpose Editor](https://github.com/ZhUyU1997/open-pose-editor): a
314
+ browser 3D mannequin editor for Stable Diffusion web UI, with hand editing
315
+ and depth, normal and canny maps.
316
+ - [ComfyUI-Magos-Nodes](https://github.com/MagosDigitalStudio/ComfyUI-Magos-Nodes):
317
+ a DWPose skeleton editor for ComfyUI with NLF-based 3D, an orbit view and
318
+ animated cameras for video.
319
+ - [ComfyUI-Fisher-Pose](https://github.com/Work-Fisher/ComfyUI-Fisher-Pose):
320
+ a posable MakeHuman mannequin and camera moves for Qwen-Image editing.
321
+ - [RTMW / RTMW3D](https://arxiv.org/abs/2407.08634) and
322
+ [rtmlib](https://github.com/Tau-J/rtmlib): the models and the runtime
323
+ poseorbit is built on.
324
+
325
+ ## Used by
326
+
327
+ Latentry, a local web UI for diffusion backends, uses poseorbit for its pose
328
+ slot and its 3D pose view.
329
+
330
+ ## Development
331
+
332
+ ```sh
333
+ pip install -e ".[test,server]"
334
+ pytest # geometry and API checks; no model download
335
+ python scripts/make_banner.py # redraws docs/assets/banner-*.png
336
+ ```
337
+
338
+ ## Security
339
+
340
+ Report vulnerabilities privately through
341
+ [GitHub's reporting](https://github.com/33rd-kk/poseorbit/security/advisories/new);
342
+ see [SECURITY.md](https://github.com/33rd-kk/poseorbit/blob/main/SECURITY.md).
343
+
344
+ ## License
345
+
346
+ Apache-2.0. See [LICENSE](https://github.com/33rd-kk/poseorbit/blob/main/LICENSE), and [NOTICE](https://github.com/33rd-kk/poseorbit/blob/main/NOTICE) for the third-party
347
+ work poseorbit builds on (rtmlib; the OpenPose drawing from xinsir's model
348
+ card and controlnet_aux). The model files (OpenMMLab's YOLOX, RTMW and
349
+ RTMW3D, Apache-2.0) are downloaded, not shipped. Models you condition with
350
+ the skeletons keep their own licences. The example pictures in
351
+ `docs/assets` were generated by the author for this README.