SAM 3D 人体:从视频提取 3D 人体网格
使用SAM 3D Body从单个视频帧中提取完整的人体3D网格,并通过文本提示词来优化姿态和形状估计。该工作流加载一个视频和一个文本提示词,然后输出一个重建的视频,显示恢复的人体骨骼。非常适合动作捕捉原型设计、生物力学分析和角色动画预可视化。
查看工作流内部
源模板的只读预览。在 Cloud 中打开,即可查看节点并进行修改。
从代码中调用该模型
以下请求使用与体验区相同的预设图和设置。每次提交都可能开始一次付费运行;如果提交结果未知,请勿自动重试。
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({
"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.