# wuwukaka/comfyui-bodyratiomapper architecture

> Architecture diagram of the GitHub repository wuwukaka/comfyui-bodyratiomapper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wuwukaka/comfyui-bodyratiomapper
- Repository: https://github.com/wuwukaka/comfyui-bodyratiomapper

## Overview

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: [`body_ratio_mapper/proportion_transfer_node.py`](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/proportion_transfer_node.py) (Proportion Transfer), [`body_ratio_mapper/__init__.py`](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/__init__.py) (BRM Init), [`body_ratio_mapper/bone_scale_node.py`](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/bone_scale_node.py) (Bone Scale), [`body_ratio_mapper/render_nodes.py`](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/render_nodes.py) (Pose Render)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["ComfyUI Host"]
  node_comfyui["ComfyUI<br/>host runtime"]
end

subgraph group_pkg["Python Package"]
  node_root_init["Package Init<br/>entrypoint<br/>[__init__.py]"]
  node_nodes_py["Node Registry<br/>registration<br/>[nodes.py]"]
  node_brm_init["BRM Init<br/>package entrypoint<br/>[__init__.py]"]
  node_prop_node["Proportion Transfer<br/>pose transform node"]
  node_bone_node["Bone Scale<br/>fk scaling node<br/>[bone_scale_node.py]"]
  node_render_node["Pose Render<br/>render node<br/>[render_nodes.py]"]
  node_preview_node["Pose Preview<br/>debug node"]
end

subgraph group_core["Pose Core"]
  node_scale_solver["Scale Solver<br/>numerical solver<br/>[scale_solver.py]"]
  node_matrix_ops["Matrix Ops<br/>coordinate math<br/>[matrix_ops.py]"]
  node_anchors["Anchor Logic<br/>stabilization<br/>[wscs_anchor.py]"]
  node_frame_ops["Frame Ops<br/>sequence utilities<br/>[frame_ops.py]"]
  node_rpca["Global RPCA<br/>robust filtering<br/>[global_rpca.py]"]
  node_tracker["Multi-person Tracker<br/>identity tracking"]
end

subgraph group_ui["UI Support"]
  node_preview_js["Preview JS<br/>ui integration"]
end

subgraph group_examples["Examples"]
  node_workflow_img["Image Workflow<br/>example workflow"]
  node_workflow_vid["Video Workflow<br/>example workflow"]
  node_docs["Docs Assets<br/>documentation<br/>[README.md]"]
end

node_comfyui -->|"loads"| node_root_init
node_root_init -->|"registers"| node_nodes_py
node_nodes_py -->|"exposes"| node_brm_init
node_brm_init -->|"registers"| node_prop_node
node_brm_init -->|"registers"| node_bone_node
node_brm_init -->|"registers"| node_render_node
node_brm_init -->|"registers"| node_preview_node
node_prop_node -->|"uses"| node_scale_solver
node_prop_node -->|"uses"| node_matrix_ops
node_prop_node -->|"uses"| node_anchors
node_prop_node -->|"uses"| node_rpca
node_prop_node -->|"uses"| node_tracker
node_tracker -->|"uses"| node_frame_ops
node_bone_node -->|"uses"| node_matrix_ops
node_bone_node -->|"uses"| node_scale_solver
node_render_node -->|"uses"| node_matrix_ops
node_preview_node -->|"supports"| node_preview_js
node_workflow_img -.->|"demonstrates"| node_prop_node
node_workflow_vid -.->|"demonstrates"| node_prop_node
node_docs -.->|"documents"| node_workflow_img
node_docs -.->|"documents"| node_workflow_vid
node_prop_node -->|"feeds"| node_render_node
node_prop_node -->|"feeds"| node_preview_node
node_comfyui -->|"hosts"| node_preview_js

click node_root_init "https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/__init__.py"
click node_nodes_py "https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/nodes.py"
click node_brm_init "https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/__init__.py"
click node_prop_node "https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/proportion_transfer_node.py"
click node_bone_node "https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/bone_scale_node.py"
click node_render_node "https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/render_nodes.py"
click node_scale_solver "https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/core_modules/scale_solver.py"
click node_matrix_ops "https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/core_modules/matrix_ops.py"
click node_anchors "https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/core_modules/wscs_anchor.py"
click node_frame_ops "https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/core_modules/frame_ops.py"
click node_rpca "https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/core_modules/global_rpca.py"
click node_tracker "https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/core_modules/multi_person_tracker.py"
click node_preview_js "https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/web/js/poseKeypointPreview.js"
click node_workflow_img "https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/example_workflows/bodyratiomapper_officail_sdpose_image.json"
click node_workflow_vid "https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/example_workflows/bodyratiomapper_officail_sdpose_video.json"
click node_docs "https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/README.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_comfyui toneBlue
class node_root_init,node_nodes_py,node_brm_init,node_prop_node,node_bone_node,node_render_node,node_preview_node toneAmber
class node_scale_solver,node_matrix_ops,node_anchors,node_frame_ops,node_rpca,node_tracker toneMint
class node_preview_js toneRose
class node_workflow_img,node_workflow_vid,node_docs toneIndigo
```

## Components

### ComfyUI Host

The custom node package runs inside ComfyUI rather than as a standalone application.

- **ComfyUI**: host runtime · The host environment that loads and executes custom nodes.

### Python Package

Registration layer and node wrappers exposed to ComfyUI.

- [Package Init](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/__init__.py): entrypoint · Top-level package entry used for installation/loading. · `__init__.py`
- [Node Registry](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/nodes.py): registration · Exposes the package nodes to ComfyUI. · `nodes.py`
- [BRM Init](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/__init__.py): package entrypoint · Package-level entry point for the body_ratio_mapper module. · `body_ratio_mapper/__init__.py`
- [Proportion Transfer](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/proportion_transfer_node.py): pose transform node · Aligns target pose proportions to a reference body and emits transformed keypoints. · `body_ratio_mapper/proportion_transfer_node.py`
- [Bone Scale](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/bone_scale_node.py): fk scaling node · Applies per-bone chain scaling to an existing pose. · `body_ratio_mapper/bone_scale_node.py`
- [Pose Render](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/render_nodes.py): render node · Renders pose keypoints into an image for inspection. · `body_ratio_mapper/render_nodes.py`
- **Pose Preview**: debug node · Imports and round-trips pose keypoint data for inspection.

### Pose Core

Numerical pose transformation, alignment, and tracking logic.

- [Scale Solver](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/core_modules/scale_solver.py): numerical solver · Computes proportion mapping and scale adjustments. · `body_ratio_mapper/core_modules/scale_solver.py`
- [Matrix Ops](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/core_modules/matrix_ops.py): coordinate math · Provides matrix and transform utilities for pose manipulation. · `body_ratio_mapper/core_modules/matrix_ops.py`
- [Anchor Logic](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/core_modules/wscs_anchor.py): stabilization · Selects and stabilizes reference anchors during pose alignment. · `body_ratio_mapper/core_modules/wscs_anchor.py`
- [Frame Ops](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/core_modules/frame_ops.py): sequence utilities · Frame-level pose helpers for sequence processing. · `body_ratio_mapper/core_modules/frame_ops.py`
- [Global RPCA](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/core_modules/global_rpca.py): robust filtering · Robust decomposition or stabilization for noisy motion and outliers. · `body_ratio_mapper/core_modules/global_rpca.py`
- [Multi-person Tracker](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/body_ratio_mapper/core_modules/multi_person_tracker.py): identity tracking · 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](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/web/js/poseKeypointPreview.js): ui integration · ComfyUI frontend support for the keypoint preview widget. · `web/js/poseKeypointPreview.js`

### Examples

Ready-made workflows and documentation assets.

- [Image Workflow](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/example_workflows/bodyratiomapper_officail_sdpose_image.json): example workflow · Example ComfyUI graph for image-based usage. · `example_workflows/bodyratiomapper_officail_sdpose_image.json`
- [Video Workflow](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/example_workflows/bodyratiomapper_officail_sdpose_video.json): example workflow · Example ComfyUI graph for video-based usage. · `example_workflows/bodyratiomapper_officail_sdpose_video.json`
- [Docs Assets](https://github.com/wuwukaka/comfyui-bodyratiomapper/blob/main/README.md): documentation · Readme and media assets used to explain and showcase the package. · `README.md`

## Connections

- 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.
