How wuwukaka/comfyui-bodyratiomapper works
1. What this repo is
- ComfyUI-BodyRatioMapper is a ComfyUI custom node package for transforming pose/keypoint data, not a standalone app.
- Its runtime boundary is the ComfyUI node system: Python nodes consume and emit POSE_KEYPOINT / IMAGE data, and a small JS file supports in-UI preview.
2. Top-level architecture
- The repo splits into three layers:
1. Node wrappers: proportion_transfer_node.py, bone_scale_node.py, render_nodes.py
2. Core pose-processing logic: body_ratio_mapper/core_modules/*
3. UI/debug support: web/js/poseKeypointPreview.js
- nodes.py and body_ratio_mapper/__init__.py are the registration/entry points that expose the nodes to ComfyUI.
3. Primary data flow
- The main pipeline starts with input pose keypoints, usually from SDPose-compatible pose data.
- BodyRatioMapperProportionTransfer aligns the target pose to a reference body shape, rescales proportions, and emits:
- transformed pose keypoints
- anchor keypoints
- an optional first-frame output
- The transformed keypoints can then be sent to rendering, preview, or downstream animation workflows.
4. Core transformation subsystem
- body_ratio_mapper/core_modules/scale_solver.py and matrix_ops.py are the numerical backbone for proportion mapping and coordinate transforms.
- wscs_anchor.py handles anchor selection / stabilization logic used during pose alignment.
- frame_ops.py suggests frame-level pose utilities, likely used when processing sequences rather than isolated poses.
- global_rpca.py indicates robust decomposition/stabilization logic for noisy motion or outlier suppression.
5. Multi-person support
- multi_person_tracker.py is the main boundary for multi-person scenarios.
- The README states identity is preserved through nearest-neighbor tracking plus sliding-window voting, so the architecture is not just per-frame pose editing; it maintains person identity across time.
- This is important for video workflows where keypoint ordering can change frame-to-frame.
6. Node surface exposed to ComfyUI
- BodyRatioMapperProportionTransfer is the orchestration node for alignment and body-ratio transfer.
- BodyRatioMapperSDPoseBoneScale applies per-bone FK-chain scaling to an existing pose.
- BodyRatioMapperSDPoseTranslate applies global XY translation to pose keypoints.
- BodyRatioMapperSDPoseRender converts pose keypoints into a visual skeleton image for inspection.
- PoseJSONToPoseKeypoint and PoseKeypointPreview provide import/export and round-tripping of pose data for debugging.
7. Rendering and inspection path
- The render node is a separate concern from transformation: it turns pose data into an IMAGE for verification.
- This creates a useful architecture boundary:
- processing nodes mutate keypoints
- render/debug nodes visualize keypoints
- That separation matters when drawing the diagram because the image output is not part of the core pose math path.
8. Browser-side support
- web/js/poseKeypointPreview.js is the only frontend asset listed.
- Its role is likely ComfyUI widget integration for the keypoint preview node, enabling text display/copying of pose JSON inside the UI.
- This is a small but distinct UI layer separate from the Python processing pipeline.
9. Workflow and usage boundaries
- example_workflows/ contains ready-made ComfyUI graphs for image and video use cases.
- docs/ and embedded media are documentation assets, not runtime dependencies.
- The repo is meant to be dropped into ComfyUI/custom_nodes, so the integration boundary is the host ComfyUI environment rather than any external service.
10. Architectural constraints implied by the repo
- The core input/output contract is pose keypoint data, especially SDPose-style keypoints.
- The main complexity is in pose normalization across scale, translation, anchor choice, and person identity over time.
- For an architecture diagram, the key boxes are:
- ComfyUI host
- node registration layer
- pose transformation core
- multi-person tracking/stabilization
- visualization/debug UI
- example workflows as integration examples
Main entry points: proportion_transfer_node.py Proportion Transfer · __init__.py BRM Init · bone_scale_node.py Bone Scale · render_nodes.py Pose Render
Components 18
ComfyUI Host
The custom node package runs inside ComfyUI rather than as a standalone application.
- ComfyUI · The host environment that loads and executes custom nodes.
Python Package
Registration layer and node wrappers exposed to ComfyUI.
- Package Init · Top-level package entry used for installation/loading.
__init__.py - Node Registry · Exposes the package nodes to ComfyUI.
nodes.py - BRM Init · Package-level entry point for the body_ratio_mapper module.
body_ratio_mapper/__init__.py - Proportion Transfer · Aligns target pose proportions to a reference body and emits transformed keypoints.
body_ratio_mapper/proportion_transfer_node.py - Bone Scale · Applies per-bone chain scaling to an existing pose.
body_ratio_mapper/bone_scale_node.py - Pose Render · Renders pose keypoints into an image for inspection.
body_ratio_mapper/render_nodes.py - Pose Preview · Imports and round-trips pose keypoint data for inspection.
Pose Core
Numerical pose transformation, alignment, and tracking logic.
- Scale Solver · Computes proportion mapping and scale adjustments.
body_ratio_mapper/core_modules/scale_solver.py - Matrix Ops · Provides matrix and transform utilities for pose manipulation.
body_ratio_mapper/core_modules/matrix_ops.py - Anchor Logic · Selects and stabilizes reference anchors during pose alignment.
body_ratio_mapper/core_modules/wscs_anchor.py - Frame Ops · Frame-level pose helpers for sequence processing.
body_ratio_mapper/core_modules/frame_ops.py - Global RPCA · Robust decomposition or stabilization for noisy motion and outliers.
body_ratio_mapper/core_modules/global_rpca.py - Multi-person Tracker · Preserves person identity across frames with temporal tracking and voting.
body_ratio_mapper/core_modules/multi_person_tracker.py
UI Support
Browser-side preview support for keypoint inspection.
- Preview JS · ComfyUI frontend support for the keypoint preview widget.
web/js/poseKeypointPreview.js
Examples
Ready-made workflows and documentation assets.
- Image Workflow · Example ComfyUI graph for image-based usage.
example_workflows/bodyratiomapper_officail_sdpose_image.json - Video Workflow · Example ComfyUI graph for video-based usage.
example_workflows/bodyratiomapper_officail_sdpose_video.json - Docs Assets · Readme and media assets used to explain and showcase the package.
README.md
Connections 24
- ComfyUI → Package Init: loads · ComfyUI imports the package entry point.
- Package Init → Node Registry: registers · Top-level package exposes the node registry.
- Node Registry → BRM Init: exposes · Registry connects to the package namespace.
- BRM Init → Proportion Transfer: registers · Package exports the main proportion transfer node.
- BRM Init → Bone Scale: registers · Package exports the bone scaling node.
- BRM Init → Pose Render: registers · Package exports the render node.
- BRM Init → Pose Preview: registers · Package exposes the preview/debug node.
- Proportion Transfer → Scale Solver: uses · Main transform orchestration relies on scale solving.
- Proportion Transfer → Matrix Ops: uses · Alignment uses coordinate transform utilities.
- Proportion Transfer → Anchor Logic: uses · Alignment depends on anchor selection/stabilization.
- Proportion Transfer → Global RPCA: uses · Optional robustness/stabilization supports noisy pose data.
- Proportion Transfer → Multi-person Tracker: uses · Multi-person workflows preserve identity across frames.
- Multi-person Tracker → Frame Ops: uses · Tracking is applied across sequences and frames.
- Bone Scale → Matrix Ops: uses · Bone scaling reuses pose coordinate math.
- Bone Scale → Scale Solver: uses · Per-bone scaling is driven by scale computations.
- Pose Render → Matrix Ops: uses · Rendering consumes transformed pose coordinates.
- Pose Preview → Preview JS: supports · The preview node is backed by browser UI integration.
- Image Workflow → Proportion Transfer: demonstrates · Example workflow shows the main image pipeline.
- Video Workflow → Proportion Transfer: demonstrates · Example workflow shows the video pipeline and tracking.
- Docs Assets → Image Workflow: documents · Repository documentation showcases example usage.
- Docs Assets → Video Workflow: documents · Repository documentation showcases example usage.
- Proportion Transfer → Pose Render: feeds · Transformed keypoints can be sent to visualization.
- Proportion Transfer → Pose Preview: feeds · Transformed or imported pose data can be inspected via preview.
- ComfyUI → Preview JS: hosts · ComfyUI loads the frontend asset for widget behavior.