ComfyUI custom nodes for SeC (Segment Concept) - State-of-the-art video object segmentation that outperforms SAM 2.1, utilizing the SeC-4B model developed by OpenIXCLab.
⚠️ IMPORTANT BREAKING CHANGE: FP8 support has been removed due to fundamental numerical instability issues. Use FP16 or BF16 models instead.
What Changed:
Full Technical Details: See CHANGELOG.md for comprehensive investigation and FP8 failure analysis.
Download: Single-file models available at https://huggingface.co/VeryAladeen/Sec-4B
SeC (Segment Concept) is a breakthrough in video object segmentation that shifts from simple feature matching to high-level conceptual understanding. Unlike SAM 2.1 which relies primarily on visual similarity, SeC uses a Large Vision-Language Model (LVLM) to understand what an object is conceptually, enabling robust tracking through:
The result? SeC tracks objects more reliably through challenging scenarios like rapid appearance changes, occlusions, and complex multi-object scenes.
https://github.com/user-attachments/assets/5cc6677e-4a9d-4e55-801d-b92305a37725
Example: SeC tracking an object through scene changes and dynamic movement
https://github.com/user-attachments/assets/9e99d55c-ba8e-4041-985e-b95cbd6dd066
Example: SAM fails to track correct dog for some scenes
Install ComfyUI-Manager (if you don't have it already):
Download a model (see Model Download section below)
Install SeC Nodes:
Done! The SeC nodes will appear in the "SeC" category
cd ComfyUI/custom_nodes
git clone https://github.com/9nate-drake/Comfyui-SecNodes
ComfyUI Portable (Windows):
cd ComfyUI/custom_nodes/Comfyui-SecNodes
../../python_embeded/python.exe -m pip install -r requirements.txt
Standard Python Installation (Linux/Mac):
cd ComfyUI/custom_nodes/Comfyui-SecNodes
pip install -r requirements.txt
The nodes will appear in the "SeC" category.
Download ONE of the following model formats:
The SeC Model Loader will automatically detect and let you select which model to use. Download from https://huggingface.co/VeryAladeen/Sec-4B and place in your ComfyUI/models/sams/ folder:
⚠️ FP8 Support Removed (v1.2)
For users who prefer the original OpenIXCLab format:
cd ComfyUI/models/sams
# Download using huggingface-cli (recommended)
huggingface-cli download OpenIXCLab/SeC-4B --local-dir SeC-4B
# Or using git lfs
git lfs clone https://huggingface.co/OpenIXCLab/SeC-4B
Details:
offload_video_to_cpu (~3% speed penalty)Note on CPU Mode:
Flash Attention 2 (Optional):
Minimum: 10GB VRAM
offload_video_to_cpu: True if you experience VRAM issuesRecommended: 16GB+ VRAM
VRAM Management:
offload_video_to_cpu: Primary VRAM control - saves ~2-3GB with only ~3% performance impactmllm_memory_size: Lower values (5-10) for additional VRAM savings if needed (affects semantic quality slightly)use_flash_attn: Enables faster inference (requires RTX 30/40 series or newer)Pro Tips:
Load and configure the SeC model for inference. Automatically detects available models in ComfyUI/models/sams/.
| Parameter | Type | Default | Description |
|---|---|---|---|
| model_file | CHOICE | First available | Select which model to load: • FP32 (Full Precision - ~14.5GB) • FP16 (Half Precision - 7.35GB) - Recommended • BF16 (Brain Float - ~7GB) • SeC-4B (Sharded/Original - ~14GB) Note: Each model uses its native precision automatically. FP8 is no longer supported (v1.2). |
| device | CHOICE | auto | Device selection (dynamically detects available GPUs): • auto: gpu0 if available, else CPU (recommended)• cpu: Force CPU (automatically converts to float32)• gpu0, gpu1, etc.: Specific GPU |
| use_flash_attn | BOOLEAN | True | Enable Flash Attention 2 for faster inference. Note: Automatically disabled for FP32 precision (requires FP16/BF16) |
| allow_mask_overlap | BOOLEAN | True | Allow objects to overlap (disable for strict separation) |
Outputs: model
Notes:
ComfyUI/models/sams/ directory
auto, cpu, gpu0auto, cpu, gpu0, gpu1auto and cpuSegment and track objects across video frames.
| Parameter | Type | Default | Description |
|---|---|---|---|
| model | MODEL | - | SeC model from loader |
| frames | IMAGE | - | Video frames as IMAGE batch |
| positive_points | STRING | "" | JSON: '[{"x": 100, "y": 200}]' |
| negative_points | STRING | "" | JSON: '[{"x": 50, "y": 50}]' |
| bbox | STRING | "" | Bounding box: "x1,y1,x2,y2" |
| input_mask | MASK | - | Binary mask input |
| tracking_direction | CHOICE | forward | forward / backward / bidirectional |
| annotation_frame_idx | INT | 0 | Frame where prompt is applied |
| object_id | INT | 1 | Unique ID for multi-object tracking |
| max_frames_to_track | INT | -1 | Max frames (-1 = all) |
| mllm_memory_size | INT | 12 | Number of keyframes for semantic understanding (affects compute on scene changes, not VRAM). Original paper used 7. |
| offload_video_to_cpu | BOOLEAN | False | Offload video frames to CPU (saves significant GPU memory, ~3% slower) |
| auto_unload_model | BOOLEAN | True | Unload the model from VRAM and RAM after segmentation. Set false if doing multiple segmentations in succession. |
Outputs: masks (MASK), object_ids (INT)
Important Notes:
Input Combination Behavior:
You can combine different input types for powerful segmentation control:
| Input Combination | Behavior |
|---|---|
| Points only | Standard point-based segmentation |
| Bbox only | Segment the most prominent object within bounding box |
| Mask only | Track the masked region |
| Bbox + Points | Two-stage refinement: Bbox establishes initial region, then points refine the segmentation within that region |
| Mask + Positive points | Only positive points inside the mask are used to refine which part of the masked region to segment |
| Mask + Negative points | All negative points are used to exclude regions from the mask |
| Mask + Positive + Negative | Positive points inside mask refine the region, negative points exclude areas |
Example Use Cases:
⚠ Important Note on Negative Points with Masks:
Visualize coordinate points on images for debugging.
| Parameter | Type | Default | Description |
|---|---|---|---|
| coordinates | STRING | '[{"x": 100, "y": 100}]' | JSON coordinates to plot |
| image | IMAGE | - | Optional image (overrides width/height) |
| point_shape | CHOICE | circle | circle / square / triangle |
| point_size | INT | 10 | Point size in pixels (1-100) |
| point_color | STRING | #00FF00 | Hex #FF0000 or RGB 255,0,0 |
| width | INT | 512 | Canvas width if no image |
| height | INT | 512 | Canvas height if no image |
Outputs: image (IMAGE)
| Direction | Best For | Behavior |
|---|---|---|
| forward | Standard videos, object appears at start | Frame N → end |
| backward | Object appears later, reverse analysis | Frame N → start |
| bidirectional | Object clearest in middle, complex scenes | Frame N → both directions |
The mllm_memory_size parameter controls how many historical keyframes SeC's Large Vision-Language Model uses for semantic understanding:
offload_video_to_cpu, ~11-13GB without)Recommended Values:
Why minimal VRAM impact? The parameter stores lightweight frame indices and mask arrays, not full frame tensors. When scene changes occur, frames are loaded from disk on-demand for LVLM processing. The underlying SAM2 architecture supports up to 22 frames.
This node implements the SeC-4B model developed by OpenIXCLab.
Dataset: The original work includes the SeCVOS Benchmark dataset.
Mask-Only Inputs: Using only a mask or bounding box may result in less stable tracking. This is due to how the underlying SAM2 and MLLM components process mask and bbox inputs. For best results, combine masks/bboxes with coordinate points for more precise control.
CUDA out of memory:
offload_video_to_cpu: True (saves ~2-3GB VRAM, only ~3% slower)mllm_memory_size to 5-10 (reduces computation at scene changes)Slow inference:
use_flash_attn in model loader (requires Flash Attention 2)offload_video_to_cpu if you have sufficient VRAMSelf-contained ComfyUI nodes - just install and segment! 🎉
ComfyUI custom nodes for SeC (Segment Concept) - State-of-the-art video object segmentation that outperforms SAM 2.1, utilizing the SeC-4B model developed by OpenIXCLab.
⚠️ IMPORTANT BREAKING CHANGE: FP8 support has been removed due to fundamental numerical instability issues. Use FP16 or BF16 models instead.
What Changed:
Full Technical Details: See CHANGELOG.md for comprehensive investigation and FP8 failure analysis.
Download: Single-file models available at https://huggingface.co/VeryAladeen/Sec-4B
SeC (Segment Concept) is a breakthrough in video object segmentation that shifts from simple feature matching to high-level conceptual understanding. Unlike SAM 2.1 which relies primarily on visual similarity, SeC uses a Large Vision-Language Model (LVLM) to understand what an object is conceptually, enabling robust tracking through:
The result? SeC tracks objects more reliably through challenging scenarios like rapid appearance changes, occlusions, and complex multi-object scenes.
https://github.com/user-attachments/assets/5cc6677e-4a9d-4e55-801d-b92305a37725
Example: SeC tracking an object through scene changes and dynamic movement
https://github.com/user-attachments/assets/9e99d55c-ba8e-4041-985e-b95cbd6dd066
Example: SAM fails to track correct dog for some scenes
Install ComfyUI-Manager (if you don't have it already):
Download a model (see Model Download section below)
Install SeC Nodes:
Done! The SeC nodes will appear in the "SeC" category
cd ComfyUI/custom_nodes
git clone https://github.com/9nate-drake/Comfyui-SecNodes
ComfyUI Portable (Windows):
cd ComfyUI/custom_nodes/Comfyui-SecNodes
../../python_embeded/python.exe -m pip install -r requirements.txt
Standard Python Installation (Linux/Mac):
cd ComfyUI/custom_nodes/Comfyui-SecNodes
pip install -r requirements.txt
The nodes will appear in the "SeC" category.
Download ONE of the following model formats:
The SeC Model Loader will automatically detect and let you select which model to use. Download from https://huggingface.co/VeryAladeen/Sec-4B and place in your ComfyUI/models/sams/ folder:
⚠️ FP8 Support Removed (v1.2)
For users who prefer the original OpenIXCLab format:
cd ComfyUI/models/sams
# Download using huggingface-cli (recommended)
huggingface-cli download OpenIXCLab/SeC-4B --local-dir SeC-4B
# Or using git lfs
git lfs clone https://huggingface.co/OpenIXCLab/SeC-4B
Details:
offload_video_to_cpu (~3% speed penalty)Note on CPU Mode:
Flash Attention 2 (Optional):
Minimum: 10GB VRAM
offload_video_to_cpu: True if you experience VRAM issuesRecommended: 16GB+ VRAM
VRAM Management:
offload_video_to_cpu: Primary VRAM control - saves ~2-3GB with only ~3% performance impactmllm_memory_size: Lower values (5-10) for additional VRAM savings if needed (affects semantic quality slightly)use_flash_attn: Enables faster inference (requires RTX 30/40 series or newer)Pro Tips:
Load and configure the SeC model for inference. Automatically detects available models in ComfyUI/models/sams/.
| Parameter | Type | Default | Description |
|---|---|---|---|
| model_file | CHOICE | First available | Select which model to load: • FP32 (Full Precision - ~14.5GB) • FP16 (Half Precision - 7.35GB) - Recommended • BF16 (Brain Float - ~7GB) • SeC-4B (Sharded/Original - ~14GB) Note: Each model uses its native precision automatically. FP8 is no longer supported (v1.2). |
| device | CHOICE | auto | Device selection (dynamically detects available GPUs): • auto: gpu0 if available, else CPU (recommended)• cpu: Force CPU (automatically converts to float32)• gpu0, gpu1, etc.: Specific GPU |
| use_flash_attn | BOOLEAN | True | Enable Flash Attention 2 for faster inference. Note: Automatically disabled for FP32 precision (requires FP16/BF16) |
| allow_mask_overlap | BOOLEAN | True | Allow objects to overlap (disable for strict separation) |
Outputs: model
Notes:
ComfyUI/models/sams/ directory
auto, cpu, gpu0auto, cpu, gpu0, gpu1auto and cpuSegment and track objects across video frames.
| Parameter | Type | Default | Description |
|---|---|---|---|
| model | MODEL | - | SeC model from loader |
| frames | IMAGE | - | Video frames as IMAGE batch |
| positive_points | STRING | "" | JSON: '[{"x": 100, "y": 200}]' |
| negative_points | STRING | "" | JSON: '[{"x": 50, "y": 50}]' |
| bbox | STRING | "" | Bounding box: "x1,y1,x2,y2" |
| input_mask | MASK | - | Binary mask input |
| tracking_direction | CHOICE | forward | forward / backward / bidirectional |
| annotation_frame_idx | INT | 0 | Frame where prompt is applied |
| object_id | INT | 1 | Unique ID for multi-object tracking |
| max_frames_to_track | INT | -1 | Max frames (-1 = all) |
| mllm_memory_size | INT | 12 | Number of keyframes for semantic understanding (affects compute on scene changes, not VRAM). Original paper used 7. |
| offload_video_to_cpu | BOOLEAN | False | Offload video frames to CPU (saves significant GPU memory, ~3% slower) |
| auto_unload_model | BOOLEAN | True | Unload the model from VRAM and RAM after segmentation. Set false if doing multiple segmentations in succession. |
Outputs: masks (MASK), object_ids (INT)
Important Notes:
Input Combination Behavior:
You can combine different input types for powerful segmentation control:
| Input Combination | Behavior |
|---|---|
| Points only | Standard point-based segmentation |
| Bbox only | Segment the most prominent object within bounding box |
| Mask only | Track the masked region |
| Bbox + Points | Two-stage refinement: Bbox establishes initial region, then points refine the segmentation within that region |
| Mask + Positive points | Only positive points inside the mask are used to refine which part of the masked region to segment |
| Mask + Negative points | All negative points are used to exclude regions from the mask |
| Mask + Positive + Negative | Positive points inside mask refine the region, negative points exclude areas |
Example Use Cases:
⚠ Important Note on Negative Points with Masks:
Visualize coordinate points on images for debugging.
| Parameter | Type | Default | Description |
|---|---|---|---|
| coordinates | STRING | '[{"x": 100, "y": 100}]' | JSON coordinates to plot |
| image | IMAGE | - | Optional image (overrides width/height) |
| point_shape | CHOICE | circle | circle / square / triangle |
| point_size | INT | 10 | Point size in pixels (1-100) |
| point_color | STRING | #00FF00 | Hex #FF0000 or RGB 255,0,0 |
| width | INT | 512 | Canvas width if no image |
| height | INT | 512 | Canvas height if no image |
Outputs: image (IMAGE)
| Direction | Best For | Behavior |
|---|---|---|
| forward | Standard videos, object appears at start | Frame N → end |
| backward | Object appears later, reverse analysis | Frame N → start |
| bidirectional | Object clearest in middle, complex scenes | Frame N → both directions |
The mllm_memory_size parameter controls how many historical keyframes SeC's Large Vision-Language Model uses for semantic understanding:
offload_video_to_cpu, ~11-13GB without)Recommended Values:
Why minimal VRAM impact? The parameter stores lightweight frame indices and mask arrays, not full frame tensors. When scene changes occur, frames are loaded from disk on-demand for LVLM processing. The underlying SAM2 architecture supports up to 22 frames.
This node implements the SeC-4B model developed by OpenIXCLab.
Dataset: The original work includes the SeCVOS Benchmark dataset.
Mask-Only Inputs: Using only a mask or bounding box may result in less stable tracking. This is due to how the underlying SAM2 and MLLM components process mask and bbox inputs. For best results, combine masks/bboxes with coordinate points for more precise control.
CUDA out of memory:
offload_video_to_cpu: True (saves ~2-3GB VRAM, only ~3% slower)mllm_memory_size to 5-10 (reduces computation at scene changes)Slow inference:
use_flash_attn in model loader (requires Flash Attention 2)offload_video_to_cpu if you have sufficient VRAMSelf-contained ComfyUI nodes - just install and segment! 🎉