SAM 3D 人體:從影片提取 3D 人體網格
使用SAM 3D Body從單一影片幀中擷取完整的人體3D網格,並透過文字提示詞來優化姿態和形狀估計。此工作流程載入一個影片和一個文字提示詞,然後輸出一個重建的影片,顯示恢復的人體骨架。非常適合動作捕捉原型設計、生物力學分析和角色動畫預視覺化。
工作流程內部
來源範本的唯讀預覽。請在 Cloud 中開啟,以探索節點並進行變更。
從您的程式碼呼叫此模型
以下請求使用與 Playground 相同的已準備節點圖和設定。每次提交都可能啟動付費執行;若提交結果不明,請勿自動重試提交。
What you need
- Runs on
- Comfy Cloud
- 金鑰
- COMFY_API_KEY
- 您的檔案
- 由程式碼透過其 URL 上傳
需要付費 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({
"14": {
"class_type": "CheckpointLoaderSimple",
"inputs": {
"ckpt_name": "sam3.1_multiplex_fp16.safetensors"
},
"_meta": {
"title": "Load Checkpoint"
}
},
"15": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"14",
1
],
"text": "person"
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"18": {
"class_type": "SAM3_VideoTrack",
"inputs": {
"conditioning": [
"15",
0
],
"detect_interval": 1,
"detection_threshold": 0.5,
"images": [
"86",
0
],
"max_objects": 4,
"model": [
"14",
0
]
},
"_meta": {
"title": "Run SAM3 Video Track"
}
},
"85": {
"class_type": "LoadVideo",
"inputs": {
"file": "UPLOADED_video_FILENAME"
},
"_meta": {
"title": "Load Video"
}
},
"86": {
"class_type": "GetVideoComponents",
"inputs": {
"video": [
"125",
0
]
},
"_meta": {
"title": "Get Video Components"
}
},
"109": {
"class_type": "RTDETR_detect",
"inputs": {
"class_name": "person",
"image": [
"86",
0
],
"max_detections": 100,
"model": [
"111",
0
],
"threshold": 0.5
},
"_meta": {
"title": "Run Real-Time Detection (RT-DETR)"
}
},
"111": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "rt_detr_v4-x-hgnet_fp32.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"114": {
"class_type": "MoGeInference",
"inputs": {
"apply_mask": True,
"batch_size": 4,
"force_projection": True,
"fov_x_degrees": 0,
"image": [
"86",
0
],
"moge_model": [
"115",
0
],
"refine_steps": 3,
"resolution_level": 9
},
"_meta": {
"title": "Run MoGe Inference"
}
},
"115": {
"class_type": "LoadMoGeModel",
"inputs": {
"model_name": "moge_2_vitl_normal_fp16.safetensors"
},
"_meta": {
"title": "Load MoGe Model"
}
},
"119": {
"class_type": "SAM3DBody_Loader",
"inputs": {
"model_file": "sam_3d_body_dinov3_bf16.safetensors"
},
"_meta": {
"title": "Load SAM3D Body Model"
}
},
"125": {
"class_type": "Video Slice",
"inputs": {
"duration": 5,
"start_time": 0,
"strict_duration": False,
"video": [
"85",
0
]
},
"_meta": {
"title": "Trim Video"
}
},
"126": {
"class_type": "MoGeGeometryToFOV",
"inputs": {
"axis": "vertical",
"moge_geometry": [
"114",
0
],
"unit": "degrees"
},
"_meta": {
"title": "Get FoV from MoGe Geometry"
}
},
"127": {
"class_type": "BuildPoseFile",
"inputs": {
"camera_translation": "off",
"format": "glb",
"format.bone_smooth_window": 0,
"format.mesh_style": "scail",
"format.mesh_style.face_style": "full",
"format.mesh_style.hand_marker_radius_m": 0.005,
"format.mesh_style.hand_stick_radius_m": 0.003,
"format.mesh_style.include_hands": False,
"format.mesh_style.marker_radius_m": 0,
"format.mesh_style.material_roughness": 0.3,
"format.mesh_style.stick_radius_m": 0.022,
"fps": 24,
"pose_data": [
"130",
0
],
"sam3d_body_model": [
"119",
0
],
"track_index": -1
},
"_meta": {
"title": "Create 3D Animation File"
}
},
"128": {
"class_type": "SAM3DBody_FaceExpression",
"inputs": {
"blendshape_smooth_window": 7,
"brow_strength": 2,
"eye_strength": 2,
"image": [
"86",
0
],
"input_threshold": 0.02,
"mhr_pose_data": [
"129",
0
],
"mouth_strength": 1,
"sam3d_body_model": [
"119",
0
],
"strength": 1
},
"_meta": {
"title": "Face Expression to SAM3D Body"
}
},
"129": {
"class_type": "SAM3DBody_Predict",
"inputs": {
"batch_size": 64,
"bboxes": [
"109",
0
],
"fov": [
"126",
0
],
"image": [
"86",
0
],
"run_hand_refinement": True,
"sam3d_body_model": [
"119",
0
],
"track_data": [
"18",
0
]
},
"_meta": {
"title": "Run SAM3D Body Prediction"
}
},
"130": {
"class_type": "SAM3DBody_Smooth",
"inputs": {
"method": "gaussian",
"mhr_pose_data": [
"128",
0
],
"rotation_threshold_degrees": 15,
"strength": 1,
"window": 7
},
"_meta": {
"title": "Smooth SAM3D Body Pose Data"
}
},
"131": {
"class_type": "SAM3DBody_Render",
"inputs": {
"background": [
"86",
0
],
"height": 0,
"pose_data": [
"130",
0
],
"render_style": "mesh",
"render_style.opacity": 1,
"render_style.person_palette_falloff": 0.6,
"render_style.region": "full_body",
"render_style.shader": "default",
"width": 0
},
"_meta": {
"title": "Render 3D Body Pose"
}
},
"134": {
"class_type": "CreateVideo",
"inputs": {
"bit_depth": 8,
"chroma_subsampling": "auto",
"codec": "none",
"color_space": "sRGB",
"fps": [
"86",
2
],
"images": [
"131",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"135": {
"class_type": "SaveVideo",
"inputs": {
"codec": "auto",
"filename_prefix": "video/SAM3D_body",
"format": "auto",
"format.codec": "auto",
"video": [
"134",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"143": {
"class_type": "Save3DAdvanced",
"inputs": {
"filename_prefix": "3d/ComfyUI",
"height": 1024,
"model_3d": [
"127",
0
],
"viewport_state": "",
"width": 1024
},
"_meta": {
"title": "Save 3D (Advanced)"
}
}
})
workflow.set_input("85", "file", client.assets.from_url("https://comfy.org/catalog-media/e1cb8b80-9432-4843-972e-ba32d4b6b78c/0d9e9cc0-4cb8-42ef-a403-62a149b6812e"))
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)
for output in job.get_outputs("135"):
output.to_file(output.name)試試範例
關於此工作流程
This is motion capture without a suit: SAM 3D Body segments the person out of each frame, predicts a parametric body with expression and hand poses, smooths the track and writes a pose file you can bring into a 3D tool — an actor's performance stays as data instead of reference video. The pipeline is layered: SAM 3.1 handles video-object tracking, RT-DETR supplies person boxes, MoGe estimates the field of view so the pose sits in the right perspective, and the SAM 3D Body model predicts the mesh. Hand refinement and face expression are switches on the graph, and the render pass draws the mesh back over the source frame so you can see whether the fit is right.
Graph: LoadVideo -> Video Slice -> GetVideoComponents -> SAM3_VideoTrack + RTDETR_detect + MoGeGeometryToFOV -> SAM3DBody_Predict -> SAM3DBody_FaceExpression -> SAM3DBody_Smooth -> BuildPoseFile (glb) -> Save3DAdvanced; SAM3DBody_Render -> CreateVideo -> SaveVideo.