The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
ComfyUI-BodyDouble: thermal and x-ray looks work on long and large clips
Adarshe5ed1abefc95
diff --git a/comfy-nodes/ComfyUI-BodyDouble/nodes.py b/comfy-nodes/ComfyUI-BodyDouble/nodes.pyindex 5c983cc0..990dd31a 100644--- a/comfy-nodes/ComfyUI-BodyDouble/nodes.py+++ b/comfy-nodes/ComfyUI-BodyDouble/nodes.py@@ -97,12 +97,19 @@ def _turbo(x):return torch.stack([r, g, b], -1).clamp(0, 1)+# torch.quantile takes at most 2**24 values; an even sample of this many gives the same range to well under 1%.+QUANTILE_SAMPLE = 1_000_000++def _nearness(depth, mask):"""MoGe's depth render (near is bright) stretched to 0-1 over the people, with one range for the whole clip."""d = depth[..., 0]inside = d[mask > 0.5]if inside.numel() < 16:return d+ if inside.numel() > QUANTILE_SAMPLE:+ # A long or large clip has more people pixels than quantile takes: an evenly spaced sample over every frame.+ inside = inside[:: -(-inside.numel() // QUANTILE_SAMPLE)]lo, hi = torch.quantile(inside.float(), torch.tensor([0.02, 0.98], device=d.device, dtype=torch.float32))return ((d - lo) / (hi - lo).clamp_min(1e-4)).clamp(0, 1)