A ComfyUI extension that allows cutting and dragging multiple parts of an image along specified paths, with advanced masking capabilities.
This node allows you to cut out parts of an image based on masks and then animate them along specified coordinate paths.
Features:
- Cut multiple regions from an image using masks
- Drag these regions along coordinate paths
- Optionally rotate the cut regions during animation
- Background inpainting for removed regions
- Supports custom background images
- Creates a batch of frames showing the animation
Input Format: Coordinate paths should be provided as a JSON array of arrays containing coordinate objects:
[
[{"x": 100, "y": 100}, {"x": 200, "y": 200}, {"x": 300, "y": 100}],
[{"x": 50, "y": 150}, {"x": 40, "y": 200}, {"x": 30, "y": 250}],
]
This node converts RGB images to binary masks using grayscale conversion and thresholding.
Features:
- Batch processing of multiple images
- Automatic handling of different tensor formats and dimensions
- Adjustable threshold for mask creation
- Optional morphological dilation to expand mask areas
This node aligns trajectory paths with mask centroids, allowing for more intuitive animation of segmented objects.
Features:
- Automatically calculates the centroid of each mask
- Translates trajectory paths to align with mask centroids
- Maintains the shape and relative positions within each path
- Handles multi-channel and single-channel masks
- Returns both transformed masks and the translated trajectory JSON
- Open ComfyUI Manager
- Search for "MultiCutAndDrag"
- Click Install
WORKDIR /comfyui/custom_nodes
RUN git clone https://github.com/pablerdo/ComfyUI-MultiCutAndDrag.git --recursive
WORKDIR /comfyui/custom_nodes/ComfyUI-MultiCutAndDrag
RUN git reset --hard (latestcommit hash)
RUN if [ -f requirements.txt ]; then python -m pip install -r requirements.txt; fi
RUN if [ -f install.py ]; then python install.py || echo "install script failed"; fi
- Restart ComfyUI
- Load an image and create masks for the areas you want to animate
- Use BatchImageToMask to convert segmentation images to proper masks if needed
- Define coordinate paths for each mask
- Connect them to MultiCutAndDragOnPath to create an animation sequence
- Alternatively, use MapTrajectoriesToSegmentedMasks to automatically align trajectories with mask centroids
- torch >= 2.0.0
- torchvision >= 0.15.0
- numpy >= 1.20.0
- Pillow >= 9.0.0
- scipy >= 1.8.0
- opencv-python
- Other dependencies as listed in requirements.txt
This project is licensed under the GNU General Public License v3.0