9.1 KiB
ComfyUI-Impact-Pack
Custom nodes pack for ComfyUI
Features
- MMDetLoader - Load MMDet model
- SAMLoader - Load SAM model
- ONNXLoader - Load ONNX model
- SegmDetectorCombined - Detect segmentation and return mask from input image.
- BboxDetectorCombined - Detect bbox(bounding box) and return mask from input image.
- SamDetectorCombined - Using the technology of SAM, extract the segment at the location indicated by the input SEGS on the input image, and output it as a unified mask.
- BitwiseAndMask - Perform 'bitwise and' operations between 2 masks
- SubtractMask - Perform subtract operations between 2 masks
- SegmDetectorForEach - Detect segmentation and return SEGS from input image.
- BboxDetectorForEach - Detect bbox(bounding box) and return SEGS from input image.
- ONNXDetectorForeach - Using the ONNX model, identify the bbox and retrieve the SEGS from the input image
- DetailerForEach - Refine image rely on SEGS.
- DetailerForEachDebug - Refine image rely on SEGS. Additionally, you can monitor cropped image and refined image of cropped image.
- The 'DetailerForEach' and 'DetailerForEachDebug' now support an 'external_seed' that is obtained from the Seed node on the WAS suite
- To prevent the regeneration caused by the seed that does not change every time when using 'external_seed', please disable the 'seed random generate' option in the 'Detailer...' node
- BitwiseAndMaskForEach - Perform 'bitwise and' operations between 2 SEGS.
- BitwiseAndMaskForEach - Perform subtract operations between 2 SEGS.
- Segs & Masks - Perform a bitwise AND operation on SEGS and MASK.
- MaskToSegs - This node generates SEGS based on the mask.
- ToBinaryMask - This node separates the mask generated with alpha values between 0 and 255 into 0 and 255. The non-zero parts are always set to 255.
- EmptySEGS - This node provides a empty SEGS.
- MaskPainter - This node provides a feature to draw masks.
Installation
- cd custom_nodes
- git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack.git
- cd ComfyUI-Impact-Pack
- (optional) python install.py
- Impact Pack will automatically install its dependencies during its initial launch.
- Restart ComfyUI
- You can use this colab notebook colab notebook to launch it. This notebook automatically downloads the impact pack to the custom_nodes directory, installs the tested dependencies, and runs it.
Package Dependencies (If you need to manual setup.)
-
pip install
- openmim
- segment-anything
- pycocotools
- onnxruntime
-
mim install
- mmcv==2.0.0, mmdet==3.0.0, mmengine==0.7.2
Other Materials (auto-download on initial startup)
- ComfyUI/models/mmdets/bbox <= https://huggingface.co/dustysys/ddetailer/resolve/main/mmdet/bbox/mmdet_anime-face_yolov3.pth
- ComfyUI/models/mmdets/bbox <= https://raw.githubusercontent.com/Bing-su/dddetailer/master/config/mmdet_anime-face_yolov3.py
- ComfyUI/models/sams <= https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth
Troubleshooting page
How to use (DDetailer feature)
1. Basic auto face detection and refine exapmle.
- The face that has been damaged due to low resolution is restored with high resolution by generating and synthesizing it, in order to restore the details.
- The FaceDetailer node is a combination of a Detector node for face detection and a Detailer node for image enhancement. See the Advanced Tutorial for a more detailed explanation.
- Pass the MMDetLoader 's bbox model and the detection model loaded by SAMLoader to FaceDetailer . Since it performs the function of KSampler for image enhancement, it overlaps with KSampler's options.
- The MASK output of FaceDetailer provides a visualization of where the detected and enhanced areas are.
- You can see that the face in the image on the left has increased detail as in the image on the right.
2. 2Pass refine (restore a severely damaged face)
- Although two FaceDetailers can be attached together for a 2-pass configuration, various common inputs used in KSampler can be passed through DETAILER_PIPE, so FaceDetailerPipe can be used to configure easily.
- In 1pass, only rough outline recovery is required, so restore with a reasonable resolution and low options. However, if you increase the dilation at this time, not only the face but also the surrounding parts are included in the recovery range, so it is useful when you need to reshape the face other than the facial part.
- In the first stage, the severely damaged face is restored to some extent, and in the second stage, the details are restored
3. Face Bbox(bounding box) + Person silhouette segmantation (prevent distortion of the background.)
-
Facial synthesis that emphasizes details is delicately aligned with the contours of the face, and it can be observed that it does not affect the image outside of the face.
-
The BBoxDetectorForEach node is used to detect faces, and the SAMDetectorCombined node is used to find the segment related to the detected face. By using the Segs & Mask node with the two masks obtained in this way, an accurate mask that intersects based on segs can be generated. If this generated mask is input to the DetailerForEach node, only the target area can be created in high resolution from the image and then composited.
Mask feature
- SEGS generated by the ...Detector nodes can also be converted to a MASK using nodes such as SegsCombineMask and used accordingly.
SAMDetection Application
-
By using the segmentation feature of SAM, it is possible to automatically generate the optimal mask and apply it to areas other than the face. The image on the left is the original image, the middle image is the result of applying a mask to the alpha channel, and the image on the right is the final result.
-
The "detection_hint" in "SAMDetectorCombined" is a specifier that indicates which points should be included in the segmentation when performing segmentation. "center-1" specifies one point in the center of the mask, "horizontal-2" specifies two points on the center horizontal line, "vertical-2" specifies two points on the center vertical line, "rectangle-4" specifies four points in a rectangular shape inside the mask, and "diamond-4" specifies four points in a diamond shape centered around the center point.
-
Unlike in face detection, for non-rigid objects, the center point may not always be the segmentation area, so be careful not to assume that the center point is always the segmentation area.
Mask Painter
- Click "Edit mask" button
- Don't connect to 'mask_image' input
- You can draw mask on Mask Painter
- Currently, this editor only provides basic functionalities
- When used together, SAMDetector and MaskPainter can be used to enhance specific elements of an image.
Others Tutorials
Credits
ComfyUI/ComfyUI - A powerful and modular stable diffusion GUI.
dustysys/ddetailer - DDetailer for Stable-diffusion-webUI extension.
Bing-su/dddetailer - The anime-face-detector used in ddetailer has been updated to be compatible with mmdet 3.0.0, and we have also applied a patch to the pycocotools dependency for Windows environment in ddetailer.
facebook/segment-anything - Segmentation Anything!
hysts/anime-face-detector - Creator of anime-face_yolov3, which has impressive performance on a variety of art styles.
open-mmlab/mmdetection - Object detection toolset. dd-person_mask2former was trained via transfer learning using their R-50 Mask2Former instance segmentation model as a base.
WASasquatch/was-node-suite-comfyui - A powerful custom node extensions of ComfyUI.


















