SDPose:影片多人檢測
上傳影片以檢測人體姿態。支援在同一場景中檢測單人和多人。
關於
本工作流程利用 SDPose-OOD 全身模型,對影片進行多人姿勢偵測。流程以 LoadVideo 載入影片,透過 GetVideoComponents 取得畫面尺寸與 FPS,並將每一幀送入 SDPose 子圖(節點 ID 01b6a731-fb78-4070-9a38-c87146da9604)。子圖內,物件偵測器會為每一幀提出人物框,SDPose 全身 checkpoint(sdpose_wholebody_fp16.safetensors)則估算身體、手部與臉部關鍵點。PrimitiveInt 節點控制 max_detections,讓你在擁擠場景中限制每幀處理人數。
流程輸出兩種視覺化結果:DrawBBoxes 畫出邊框,ImageBlend 將姿勢圖層疊加於原始畫面。ResizeImageMaskNode 確保姿勢圖與來源畫面尺寸一致,PreviewImage 可快速檢查結果。最後,CreateVideo 以原始 FPS 組合標註後的幀,SaveVideo 寫出影片。SDPose 邏輯包裝為子圖,可右鍵「解包子圖」以微調內部閾值或路徑,獲得更細緻控制。
您提供的內容
- 正在讀取工作流程
在 ComfyUI 中執行。 此工作流程無法在此頁面上執行。請在已載入所有內容的 Comfy Cloud 中開啟,或下載到您自己的 ComfyUI。
在 Cloud 中試用工作流程內部
節點圖的唯讀預覽。請在 Comfy Cloud 中開啟,或下載後編輯節點。
Loading the graph
Open full-size workflow preview需要自訂節點
- 正在讀取工作流程
從程式碼使用此工作流程
可行時會根據工作流程圖和輸入內容產生;否則會顯示儲存的範例。執行可能產生費用的程式碼前,請檢查認證資訊和端點。
What you need
- Runs on
- Comfy Cloud
- 金鑰
- COMFY_API_KEY
需要付費 Cloud 方案與點數。
# Python 3.10+: pip install comfy-sdk==0.4.0
import os
from comfy_sdk import Comfy
api_key = os.environ.get("COMFY_API_KEY", "").strip()
if not api_key: raise RuntimeError("Set COMFY_API_KEY")
os.environ.setdefault("COMFY_BASE_URL", "https://cloud.comfy.org")
client = Comfy(api_key=api_key)
workflow = client.workflows.from_json({
"682": {
"class_type": "DrawBBoxes",
"inputs": {
"bboxes": [
"675:678",
0
],
"image": [
"687",
0
]
},
"_meta": {
"title": "Draw BBoxes"
}
},
"687": {
"class_type": "ResizeImageMaskNode",
"inputs": {
"input": [
"698",
0
],
"resize_type": "scale longer dimension",
"resize_type.longer_size": [
"688",
0
],
"scale_method": "lanczos"
},
"_meta": {
"title": "Resize Image/Mask"
}
},
"688": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 1024
},
"_meta": {
"title": "Int"
}
},
"690": {
"class_type": "ImageBlend",
"inputs": {
"blend_factor": 0.5,
"blend_mode": "normal",
"image1": [
"682",
0
],
"image2": [
"675:672",
0
]
},
"_meta": {
"title": "Blend Images"
}
},
"694": {
"class_type": "LoadVideo",
"inputs": {
"file": "man_palying_violin.mp4"
},
"_meta": {
"title": "Load Video"
}
},
"695": {
"class_type": "CreateVideo",
"inputs": {
"audio": [
"675:692",
1
],
"bit_depth": "auto",
"codec": "none",
"color_space": "sRGB",
"fps": [
"675:692",
2
],
"images": [
"690",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"697": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/ComfyUI",
"format": "auto",
"format.codec": "auto",
"video": [
"695",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"698": {
"class_type": "GetVideoComponents",
"inputs": {
"video": [
"694",
0
]
},
"_meta": {
"title": "Get Video Components"
}
},
"699": {
"class_type": "PreviewImage",
"inputs": {
"images": [
"675:672",
0
]
},
"_meta": {
"title": "Preview Image"
}
},
"675:671": {
"class_type": "SDPoseKeypointExtractor",
"inputs": {
"batch_size": 16,
"bboxes": [
"675:678",
0
],
"image": [
"675:674",
0
],
"model": [
"675:673",
0
],
"vae": [
"675:673",
2
]
},
"_meta": {
"title": "SDPose Keypoint Extractor"
}
},
"675:672": {
"class_type": "SDPoseDrawKeypoints",
"inputs": {
"draw_body": True,
"draw_face": True,
"draw_feet": True,
"draw_hands": True,
"draw_head": True,
"face_point_size": 2,
"keypoints": [
"675:671",
0
],
"score_threshold": 0.5,
"stick_width": 4
},
"_meta": {
"title": "SDPose Draw Keypoints"
}
},
"675:673": {
"class_type": "CheckpointLoaderSimple",
"inputs": {
"ckpt_name": "sdpose_wholebody_fp16.safetensors"
},
"_meta": {
"title": "Load Checkpoint"
}
},
"675:674": {
"class_type": "ResizeImageMaskNode",
"inputs": {
"input": [
"675:692",
0
],
"resize_type": "scale longer dimension",
"resize_type.longer_size": [
"688",
0
],
"scale_method": "lanczos"
},
"_meta": {
"title": "Resize Image/Mask"
}
},
"675:677": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "rt_detr_v4-x-hgnet_fp16.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"675:678": {
"class_type": "RTDETR_detect",
"inputs": {
"class_name": "person",
"image": [
"675:674",
0
],
"max_detections": 2,
"model": [
"675:677",
0
],
"threshold": 0.5
},
"_meta": {
"title": "Run Real-Time Detection (RT-DETR)"
}
},
"675:692": {
"class_type": "GetVideoComponents",
"inputs": {
"video": [
"694",
0
]
},
"_meta": {
"title": "Get Video Components"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)問答
不會。每一幀都獨立進行多人偵測與姿勢估算,ID 不會跨幀保留。如需追蹤,請在子圖外另加追蹤器。
提高 PrimitiveInt:max_detections,確保輸入解析度足夠,並可解包子圖調高偵測信心值或調整 NMS。解析度與偵測數越高,運算時間越長。
可以。解包子圖或直接將姿勢圖輸出(ImageBlend 前)接到 CreateVideo/SaveVideo。也可改用 SaveImage 節點逐幀存圖。
LoadVideo 與 SaveVideo 依 ComfyUI/FFmpeg 設定而定。常見 MP4/H.264 支援良好。如遇格式問題,請先將輸入轉檔為標準 MP4,並維持 SaveVideo 預設。