Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df330c1b06 | ||
|
|
6d438d8b5d | ||
|
|
7d565d1f7a | ||
|
|
27c5368bcc | ||
|
|
705698faf2 | ||
|
|
cf43fc4e3c | ||
|
|
4c292e684e | ||
|
|
65f1363a10 | ||
|
|
f57d309932 | ||
|
|
6ccf9bab68 | ||
|
|
ac3668d946 | ||
|
|
78d3793a77 | ||
|
|
2346b67766 | ||
|
|
025db4b581 | ||
|
|
f8e16df2be | ||
|
|
7df60b2107 | ||
|
|
b394c158ea | ||
|
|
3e3cf3a5b4 | ||
|
|
93fc248503 | ||
|
|
16ffa7d462 | ||
|
|
cd34cfdd63 | ||
|
|
38bb9ffdf6 | ||
|
|
f939e66e1c | ||
|
|
b22aa90cf4 | ||
|
|
d18aaecb93 | ||
|
|
a7840b4fbf | ||
|
|
efa0cb66b2 | ||
|
|
0b94005b1b | ||
|
|
bfcb8674b3 | ||
|
|
839e5a9f90 | ||
|
|
5a2adda580 | ||
|
|
d05882a9e0 | ||
|
|
d900939861 | ||
|
|
cd2696f6fd | ||
|
|
0b1ac0f1c5 | ||
|
|
216d7fd60c | ||
|
|
28cd2f70b2 | ||
|
|
2708eba825 | ||
|
|
c19ab92172 | ||
|
|
6e3d07277b | ||
|
|
782c6f439e | ||
|
|
0e3e6a193a | ||
|
|
798776838e | ||
|
|
66493d8cb4 | ||
|
|
b4fd0834e0 | ||
|
|
808b0dedf0 | ||
|
|
c6056b132d | ||
|
|
1ae7cae2df | ||
|
|
ccb6285548 | ||
|
|
092310bc8f | ||
|
|
5c530eb32e | ||
|
|
e35bc23fd1 | ||
|
|
869ac6fd1f | ||
|
|
cb168d64ab | ||
|
|
a89e9e01a6 | ||
|
|
e70b4df9b5 | ||
|
|
af1ef7e441 | ||
|
|
d8738eee2f | ||
|
|
c397c68ca3 | ||
|
|
0e0722ec08 | ||
|
|
70d0540895 | ||
|
|
7330577a0f | ||
|
|
b1d760291f | ||
|
|
12e838a320 | ||
|
|
8e8621df49 | ||
|
|
cdb7b4d3b0 | ||
|
|
21eecb0c03 | ||
|
|
9402ecf4f9 | ||
|
|
c21b361e2a | ||
|
|
8f04714145 | ||
|
|
a311f9278d | ||
|
|
0ec21f1a4b | ||
|
|
40a3df3acd | ||
|
|
9ba92862c4 | ||
|
|
2c2e148205 | ||
|
|
ff9c30787c | ||
|
|
64f709741a | ||
|
|
455e993354 | ||
|
|
ce23d436fc | ||
|
|
5f630466fb | ||
|
|
81045cc845 | ||
|
|
20f2cac6f0 | ||
|
|
348c3dcb6b | ||
|
|
1ec3037613 | ||
|
|
d4136bc955 | ||
|
|
c9b3aecd1a | ||
|
|
a2bb6f7c91 | ||
|
|
e1e408d8c9 | ||
|
|
f7686845c6 | ||
|
|
37f465d4a9 | ||
|
|
48b4254e81 | ||
|
|
24de5a846b | ||
|
|
6fe85ed6bf | ||
|
|
216f4660e1 | ||
|
|
314b676cc3 | ||
|
|
cd89590a7d | ||
|
|
dc70f40eff | ||
|
|
66bf101341 | ||
|
|
825296c3e0 | ||
|
|
5c0535942a | ||
|
|
bf0e86a10d | ||
|
|
6be257254e | ||
|
|
727295b52e | ||
|
|
6c23f7691d | ||
|
|
6248f31402 | ||
|
|
cb0b652703 | ||
|
|
9c4fa5fb27 | ||
|
|
759b4d0dc9 | ||
|
|
a65fd56b7f | ||
|
|
47d981eca2 | ||
|
|
b2f382776f | ||
|
|
0e4e439d39 | ||
|
|
18d25a29a0 | ||
|
|
2b724e5ed2 | ||
|
|
96cc242f78 |
@@ -7,15 +7,19 @@ on:
|
||||
paths:
|
||||
- "pyproject.toml"
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
|
||||
jobs:
|
||||
publish-node:
|
||||
name: Publish Custom Node to registry
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.repository_owner == 'ltdrdata' }}
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
- name: Publish Custom Node
|
||||
uses: Comfy-Org/publish-node-action@main
|
||||
uses: Comfy-Org/publish-node-action@v1
|
||||
with:
|
||||
## Add your own personal access token to your Github Repository secrets and reference it here.
|
||||
personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
|
||||
personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
|
||||
|
||||
@@ -7,3 +7,5 @@ subpack
|
||||
impact_subpack
|
||||
*.txt
|
||||
*.yaml
|
||||
!requirements.txt
|
||||
!LICENSE.txt
|
||||
@@ -2,11 +2,15 @@
|
||||
|
||||
# ComfyUI-Impact-Pack
|
||||
|
||||
**Custom nodes pack for ComfyUI**
|
||||
This custom node helps to conveniently enhance images through Detector, Detailer, Upscaler, Pipe, and more.
|
||||
**Custom node pack for ComfyUI**
|
||||
This node pack helps to conveniently enhance images through Detector, Detailer, Upscaler, Pipe, and more.
|
||||
|
||||
NOTE: The UltralyticsDetectorProvider node is not part of the ComfyUI-Impact-Pack. To use the UltralyticsDetectorProvider node, please install the ComfyUI-Impact-Subpack separately.
|
||||
|
||||
## NOTICE
|
||||
* V8.19: legacy nodes (mmdet and etc.) are removed
|
||||
* V8.18: Support [facebookresearch/sam2](https://github.com/facebookresearch/sam2) models
|
||||
* V8.0: The `Impact Subpack` is no longer installed automatically. To use `UltralyticsDetectorProvider` nodes, please install the `Impact Subpack` separately.
|
||||
* V7.6: Automatic installation is no longer supported. Please install using ComfyUI-Manager, or manually install requirements.txt and run install.py to complete the installation.
|
||||
* V7.0: Supports Switch based on Execution Model Inversion.
|
||||
* V6.0: Supports FLUX.1 model in Impact KSampler, Detailers, PreviewBridgeLatent
|
||||
@@ -30,12 +34,35 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
* With the addition of wildcard support in FaceDetailer, the structure of DETAILER_PIPE-related nodes and Detailer nodes has changed. There may be malfunctions when using the existing workflow.
|
||||
|
||||
|
||||
## How To Install
|
||||
|
||||
### **Recommended**
|
||||
* Install via [ComfyUI-Manager](https://github.com/ltdrdata/ComfyUI-Manager).
|
||||
|
||||
### **Manual**
|
||||
* Navigate to `ComfyUI/custom_nodes` in your terminal (cmd).
|
||||
* Clone the repository under the `custom_nodes` directory using the following command:
|
||||
```
|
||||
git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack comfyui-impact-pack
|
||||
cd comfyui-impact-pack
|
||||
```
|
||||
* Install dependencies in your Python environment.
|
||||
* For Windows Portable, run the following command inside `ComfyUI\custom_nodes\comfyui-impact-pack`:
|
||||
```
|
||||
..\..\..\python_embeded\python.exe -m pip install -r requirements.txt
|
||||
```
|
||||
* If using venv or conda, activate your Python environment first, then run:
|
||||
```
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
### Companion Pack
|
||||
* If you need the `Ultralytics Detector Provider` to use various YOLO detection models, you should also install [ComfyUI-Impact-Subpack](https://github.com/ltdrdata/ComfyUI-Impact-Subpack).
|
||||
|
||||
|
||||
## Custom Nodes
|
||||
### [Detector nodes](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/detectors.md)
|
||||
* `SAMLoader` - Loads the SAM model.
|
||||
* `UltralyticsDetectorProvider` - Loads the Ultralystics model to provide SEGM_DETECTOR, BBOX_DETECTOR.
|
||||
- Unlike `MMDetDetectorProvider`, for segm models, `BBOX_DETECTOR` is also provided.
|
||||
- The various models available in UltralyticsDetectorProvider can be downloaded through **ComfyUI-Manager**.
|
||||
* `SAMLoader (Impact)` - Loads the SAM model.
|
||||
* `ONNXDetectorProvider` - Loads the ONNX model to provide BBOX_DETECTOR.
|
||||
* `CLIPSegDetectorProvider` - Wrapper for CLIPSeg to provide BBOX_DETECTOR.
|
||||
* You need to install the ComfyUI-CLIPSeg node extension.
|
||||
@@ -46,15 +73,20 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
* As a result, it outputs the `combined_mask`, which is a unified mask, and `batch_masks`, which are multiple masks grouped together in batch form.
|
||||
* While `batch_masks` may not be completely separated, it provides functionality to perform some level of segmentation.
|
||||
* `Simple Detector (SEGS)` - Operating primarily with `BBOX_DETECTOR`, and with the additional provision of `SAM_MODEL` or `SEGM_DETECTOR`, this node internally generates improved SEGS through mask operations on both *bbox* and *silhouette*. It serves as a convenient tool to simplify a somewhat intricate workflow.
|
||||
* `Simple Detector for Video (SEGS)` – Performs detection on videos composed of image frames. Instead of using a single mask, it performs detection individually on each image frame and generates a SEGS object with a batch of masks.
|
||||
* `SAM2 Video Detector (SEGS)` – Similar to `Simple Detector for Video (SEGS)`, but utilizes SAM2’s video tracking technology to generate a SEGS object with a batch of masks.
|
||||
* To use this node, you must select a SAM2 model in the SAMLoader.
|
||||
|
||||
|
||||
### ControlNet, IPAdapter
|
||||
* `ControlNetApply (SEGS)` - To apply ControlNet in SEGS, you need to use the Preprocessor Provider node from the Inspire Pack to utilize this node.
|
||||
* `segs_preprocessor` and `control_image` can be selectively applied. If an `control_image` is given, `segs_preprocessor` will be ignored.
|
||||
* `segs_preprocessor` and `control_image` can be selectively applied. If a `control_image` is given, `segs_preprocessor` will be ignored.
|
||||
* If set to `control_image`, you can preview the cropped cnet image through `SEGSPreview (CNET Image)`. Images generated by `segs_preprocessor` should be verified through the `cnet_images` output of each Detailer.
|
||||
* The `segs_preprocessor` operates by applying preprocessing on-the-fly based on the cropped image during the detailing process, while `control_image` will be cropped and used as input to `ControlNetApply (SEGS)`.
|
||||
* `ControlNetClear (SEGS)` - Clear applied ControlNet in SEGS
|
||||
* `IPAdapterApply (SEGS)` - To apply IPAdapter in SEGS, you need to use the Preprocessor Provider node from the Inspire Pack to utilize this node.
|
||||
|
||||
|
||||
### Mask operation
|
||||
* `Pixelwise(SEGS & SEGS)` - Performs a 'pixelwise and' operation between two SEGS.
|
||||
* `Pixelwise(SEGS - SEGS)` - Subtracts one SEGS from another.
|
||||
@@ -69,13 +101,16 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
* `Dilate Mask` - Dilate Mask.
|
||||
* Support erosion for negative value.
|
||||
* `Gaussian Blur Mask` - Apply Gaussian Blur to Mask. You can utilize this for mask feathering.
|
||||
* `Mask Rect Area` - Create a rectangular mask defined by percentages with preview canvas.
|
||||
* `Mask Rect Area (Advanced)` - Create a rectangular mask defined by pixels and image size.
|
||||
|
||||
|
||||
### [Detailer nodes](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/detailers.md)
|
||||
* `Detailer (SEGS)` - Refines the image based on SEGS.
|
||||
* `DetailerDebug (SEGS)` - Refines the image based on SEGS. Additionally, it provides the ability to monitor the cropped image and the refined image of the cropped image.
|
||||
* To prevent 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.
|
||||
* `MASK to SEGS` - Generates SEGS based on the mask.
|
||||
* `MASK to SEGS For AnimateDiff` - Generates SEGS based on the mask for AnimateDiff.
|
||||
* `MASK to SEGS For Video` - Generates SEGS based on the mask for Video. (Renamed from `MASK to SEGS For AnimateDiff`)
|
||||
* When using a single mask, convert it to SEGS to apply it to the entire frame.
|
||||
* When using a batch mask, the contour fill feature is disabled.
|
||||
* `MediaPipe FaceMesh to SEGS` - Separate each landmark from the mediapipe facemesh image to create labeled SEGS.
|
||||
@@ -92,6 +127,7 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
* `FromDetailer (SDXL/pipe)`, `BasicPipe -> DetailerPipe (SDXL)`, `Edit DetailerPipe (SDXL)` - These are pipe functions used in Detailer for utilizing the refiner model of SDXL.
|
||||
* `Any PIPE -> BasicPipe` - Convert the PIPE Value of other custom nodes that are not BASIC_PIPE but internally have the same structure as BASIC_PIPE to BASIC_PIPE. If an incompatible type is applied, it may cause runtime errors.
|
||||
|
||||
|
||||
### SEGS Manipulation nodes
|
||||
* `SEGSDetailer` - Performs detailed work on SEGS without pasting it back onto the original image.
|
||||
* `SEGSPaste` - Pastes the results of SEGS onto the original image.
|
||||
@@ -106,8 +142,11 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
* `SEGS Filter (label)` - This node filters SEGS based on the label of the detected areas.
|
||||
* `SEGS Filter (ordered)` - This node sorts SEGS based on size and position and retrieves SEGs within a certain range.
|
||||
* `SEGS Filter (range)` - This node retrieves only SEGs from SEGS that have a size and position within a certain range.
|
||||
* `SEGS Filter (non max suppression)` - This node filters SEGS by removing those with high overlap based on the Intersection over Union (IoU) threshold, keeping only the most confident detections.
|
||||
* `SEGS Filter (intersection)` - This node filters segs1, keeping only the SEGS that do not significantly overlap with any SEGS in segs2, based on the Intersection over Area (IoA) threshold.
|
||||
* `SEGS Assign (label)` - Assign labels sequentially to SEGS. This node is useful when used with `[LAB]` of FaceDetailer.
|
||||
* `SEGSConcat` - Concatenate segs1 and segs2. If source shape of segs1 and segs2 are different from segs2 will be ignored.
|
||||
* `SEGS Merge` - SEGS contains multiple SEGs. SEGS Merge integrates several SEGs into a single merged SEG. The label is changed to `merged` and the confidence becomes the minimum confidence. The applied controlnet and cropped_image are removed.
|
||||
* `Picker (SEGS)` - Among the input SEGS, you can select a specific SEG through a dialog. If no SEG is selected, it outputs an empty SEGS. Increasing the batch_size of SEGSDetailer can be used for the purpose of selecting from the candidates.
|
||||
* `Set Default Image For SEGS` - Set a default image for SEGS. SEGS with images set this way do not need to have a fallback image set. When override is set to false, the original image is preserved.
|
||||
* `Remove Image from SEGS` - Remove the image set for the SEGS that has been configured by "Set Default Image for SEGS" or SEGSDetailer. When the image for the SEGS is removed, the Detailer node will operate based on the currently processed image instead of the SEGS.
|
||||
@@ -125,6 +164,7 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
* `From SEG_ELT` crop_region - Extract coordinate from crop_region in SEG_ELT
|
||||
* `Count Elt in SEGS` - Number of Elts ins SEGS
|
||||
|
||||
|
||||
### Pipe nodes
|
||||
* `ToDetailerPipe`, `FromDetailerPipe` - These nodes are used to bundle multiple inputs used in the detailer, such as models and vae, ..., into a single DETAILER_PIPE or extract the elements that are bundled in the DETAILER_PIPE.
|
||||
* `ToBasicPipe`, `FromBasicPipe` - These nodes are used to bundle model, clip, vae, positive conditioning, and negative conditioning into a single BASIC_PIPE, or extract each element from the BASIC_PIPE.
|
||||
@@ -137,6 +177,7 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
* `PixelTiledKSampleUpscalerProvider` - It is similar to `PixelKSampleUpscalerProvider`, but it uses `ComfyUI_TiledKSampler` and Tiled VAE Decoder/Encoder to avoid GPU VRAM issues at high resolutions.
|
||||
* You need to install the [BlenderNeko/ComfyUI_TiledKSampler](https://github.com/BlenderNeko/ComfyUI_TiledKSampler) node extension.
|
||||
|
||||
|
||||
### PK_HOOK
|
||||
* `DenoiseScheduleHookProvider` - IterativeUpscale provides a hook that gradually changes the denoise to target_denoise as the iterative-step progresses.
|
||||
* `CfgScheduleHookProvider` - IterativeUpscale provides a hook that gradually changes the cfg to target_cfg as the iterative-step progresses.
|
||||
@@ -150,6 +191,7 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
* `PixelKSampleHookCombine` - This is used to connect two PK_HOOKs. hook1 is executed first and then hook2 is executed.
|
||||
* If you want to simultaneously change cfg and denoise, you can combine the PK_HOOKs of CfgScheduleHookProvider and PixelKSampleHookCombine.
|
||||
|
||||
|
||||
### DETAILER_HOOK
|
||||
* `NoiseInjectionDetailerHookProvider` - The `detailer_hook` is a hook in the `Detailer` that injects noise during the processing of each SEGS.
|
||||
* `UnsamplerDetailerHookProvider` - Apply Unsampler during each cycle. To use this node, ComfyUI_Noise must be installed.
|
||||
@@ -160,6 +202,11 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
* `PreviewDetailerHook` - Connecting this hook node helps provide assistance for viewing previews whenever SEGS Detailing tasks are completed. When working with a large number of SEGS, such as Make Tile SEGS, it allows for monitoring the situation as improvements progress incrementally.
|
||||
* Since this is the hook applied when pasting onto the original image, it has no effect on nodes like `SEGSDetailer`.
|
||||
* `VariationNoiseDetailerHookProvider` - Apply variation seed to the detailer. It can be applied in multiple stages through combine.
|
||||
* `CustomSamplerDetailerHookProvider` - Apply a hook that allows you to use a custom sampler in the Detailer nodes. When using `DetailerHookCombine`, the sampler from the first hook is applied.
|
||||
* `LamaRemoverDetailerHookProvider` – Applies Lama Remover to the upscaled image during the detailing stage. If `skip_sampling` is set to True, Lama Remover can be used alone without the detailing stage, allowing it to simply remove detected regions.
|
||||
* Not applicable for **AnimateDiff** detailers. When using `DetailerHookCombine`, `skip_sampling` is only applied if it is set to `True` for all hooks.
|
||||
* To use this node, the node pack at [Layer-norm/comfyui-lama-remover](https://github.com/Layer-norm/comfyui-lama-remover) must be installed.
|
||||
|
||||
|
||||
### Iterative Upscale nodes
|
||||
* `Iterative Upscale (Latent/on Pixel Space)` - The upscaler takes the input upscaler and splits the scale_factor into steps, then iteratively performs upscaling.
|
||||
@@ -167,6 +214,7 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
* `Iterative Upscale (Image)` - The upscaler takes the input upscaler and splits the scale_factor into steps, then iteratively performs upscaling. This takes image as input and outputs image as the result.
|
||||
* Internally, this node uses 'Iterative Upscale (Latent)'.
|
||||
|
||||
|
||||
### TwoSamplers nodes
|
||||
* `TwoSamplersForMask` - This node can apply two samplers depending on the mask area. The base_sampler is applied to the area where the mask is 0, while the mask_sampler is applied to the area where the mask is 1.
|
||||
* Note: The latent encoded through VAEEncodeForInpaint cannot be used.
|
||||
@@ -181,6 +229,7 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
* `TwoSamplersForMaskUpscalerProvider` - This is an Upscaler that extends TwoSamplersForMask to be used in Iterative Upscale.
|
||||
* TwoSamplersForMaskUpscalerProviderPipe - pipe version of TwoSamplersForMaskUpscalerProvider.
|
||||
|
||||
|
||||
### Image Utils
|
||||
* `PreviewBridge (image)` - This custom node can be used with a bridge for image when using the MaskEditor feature of Clipspace.
|
||||
* `PreviewBridge (latent)` - This custom node can be used with a bridge for latent image when using the MaskEditor feature of Clipspace.
|
||||
@@ -193,12 +242,14 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
* Furthermore, LatentSender is implemented with PreviewLatent, which stores the latent in payload form within the image thumbnail.
|
||||
* Due to the current structure of ComfyUI, it is unable to distinguish between SDXL latent and SD1.5/SD2.1 latent. Therefore, it generates thumbnails by decoding them using the SD1.5 method.
|
||||
|
||||
|
||||
### Switch nodes
|
||||
* `Switch (image,mask)`, `Switch (latent)`, `Switch (SEGS)` - Among multiple inputs, it selects the input designated by the selector and outputs it. The first input must be provided, while the others are optional. However, if the input specified by the selector is not connected, an error may occur.
|
||||
* `Switch (Any)` - This is a Switch node that takes an arbitrary number of inputs and produces a single output. Its type is determined when connected to any node, and connecting inputs increases the available slots for connections.
|
||||
* `Inversed Switch (Any)` - In contrast to `Switch (Any)`, it takes a single input and outputs one of many.
|
||||
* NOTE: See this [tutorial](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/switch.md)
|
||||
|
||||
|
||||
### [Wildcards](http://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/ImpactWildcard.md) nodes
|
||||
* These are nodes that supports syntax in the form of `__wildcard-name__` and dynamic prompt syntax like `{a|b|c}`.
|
||||
* Wildcard files can be used by placing `.txt` or `.yaml` files under either `ComfyUI-Impact-Pack/wildcards` or `ComfyUI-Impact-Pack/custom_wildcards` paths.
|
||||
@@ -210,6 +261,7 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
* If the `Inspire Pack` is installed, you can use **Lora Block Weight** in the form of `LBW=lbw spec;`
|
||||
* `<lora:chunli:1.0:1.0:LBW=B11:0,0,0,0,0,0,0,0,0,0,A,0,0,0,0,0,0;A=0.;>`, `<lora:chunli:1.0:1.0:LBW=0,0,0,0,0,0,0,0,0,0,A,B,0,0,0,0,0;A=0.5;B=0.2;>`, `<lora:chunli:1.0:1.0:LBW=SD-MIDD;>`
|
||||
|
||||
|
||||
### Regional Sampling
|
||||
* These nodes offer the capability to divide regions and perform partial sampling using a mask. Unlike TwoSamplersForMask, sampling for each region is applied during each step.
|
||||
* `RegionalPrompt` - This node combines a **mask** for specifying regions and the **sampler** to apply to each region to create `REGIONAL_PROMPTS`.
|
||||
@@ -222,7 +274,7 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
|
||||
|
||||
### Impact KSampler
|
||||
* These samplers support basic_pipe and AYS scheduler
|
||||
* These samplers support basic_pipe and AYS/OSS/GITS scheduler
|
||||
* `KSampler (pipe)` - pipe version of KSampler
|
||||
* `KSampler (advanced/pipe)` - pipe version of KSamplerAdvacned
|
||||
* When converting the scheduler widget to input, refer to the `Impact Scheduler Adapter` node to resolve compatibility issues.
|
||||
@@ -239,10 +291,12 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
* `Masks to Mask List`, `Mask List to Masks`, `Make Mask List`, `Make Mask Batch` - It has the same functionality as the nodes above, but uses mask as input instead of image.
|
||||
* `Flatten Mask Batch` - Flattens a Mask Batch into a single Mask. Normal operation is not guaranteed for non-binary masks.
|
||||
* `Make List (Any)` - Create a list with arbitrary values.
|
||||
* `Select Nth Item (Any list)` - Selects the Nth item from a list. If the index is out of range, it returns the last item in the list.
|
||||
|
||||
|
||||
### Logics (experimental)
|
||||
* These nodes are experimental nodes designed to implement the logic for loops and dynamic switching.
|
||||
* `ImpactCompare`, `ImpactConditionalBranch`, `ImpactConditionalBranchSelMode`, `ImpactInt`, `ImpactValueSender`, `ImpactValueReceiver`, `ImpactImageInfo`, `ImpactMinMax`, `ImpactNeg`, `ImpactConditionalStopIteration`
|
||||
* `ImpactCompare`, `ImpactConditionalBranch`, `ImpactConditionalBranchSelMode`, `ImpactInt`, `ImpactBoolean`, `ImpactValueSender`, `ImpactValueReceiver`, `ImpactImageInfo`, `ImpactMinMax`, `ImpactNeg`, `ImpactConditionalStopIteration`
|
||||
* `ImpactIsNotEmptySEGS` - This node returns `true` only if the input SEGS is not empty.
|
||||
* `ImpactIfNone` - Returns `true` if any_input is None, and returns `false` if it is not None.
|
||||
* `Queue Trigger` - When this node is executed, it adds a new queue to assist with repetitive tasks. It will only execute if the signal's status changes.
|
||||
@@ -261,6 +315,7 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
* You can find the `node_id` by checking through [ComfyUI-Manager](https://github.com/ltdrdata/ComfyUI-Manager) using the format `Badge: #ID Nickname`.
|
||||
* Experimental set of nodes for implementing loop functionality (tutorial to be prepared later / [example workflow](test/loop-test.json)).
|
||||
|
||||
|
||||
### HuggingFace nodes
|
||||
* These nodes provide functionalities based on HuggingFace repository models.
|
||||
* The path where the HuggingFace model cache is stored can be changed through the `HF_HOME` environment variable.
|
||||
@@ -273,6 +328,7 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
* For supported labels, please refer to the `config.json` of the respective HuggingFace repository.
|
||||
* `#Female` and `#Male` are symbols that group multiple labels such as `Female, women, woman, ...`, for convenience, rather than being single labels.
|
||||
|
||||
|
||||
### Etc nodes
|
||||
* `Impact Scheduler Adapter` - With the addition of AYS to the scheduler of the Impact Pack and Inspire Pack, there is an issue of incompatibility when the existing scheduler widget is converted to input. The Impact Scheduler Adapter allows for an indirect connection to be possible.
|
||||
* `StringListToString` - Convert String List to String
|
||||
@@ -285,11 +341,7 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
* `Negative Cond Placeholder` - Models like FLUX.1 do not use Negative Conditioning. This is a placeholder node for them. You can use FLUX.1 by replacing the Negative Conditioning used in Impact KSampler, KSampler (Inspire), and Detailer with this node.
|
||||
* `Execution Order Controller` - A helper node that can forcibly control the execution order of nodes.
|
||||
* Connect the output of the node that should be executed first to the signal, and make the input of the node that should be executed later pass through this node.
|
||||
|
||||
|
||||
## MMDet nodes (DEPRECATED) - Don't use these nodes
|
||||
* MMDetDetectorProvider - Loads the MMDet model to provide BBOX_DETECTOR and SEGM_DETECTOR.
|
||||
* To use the existing MMDetDetectorProvider, you need to enable the MMDet usage configuration.
|
||||
* `List Bridge` - When passing the list output through this node, it collects and organizes the data before forwarding it, which ensures that the previous stage's sub-workflow has been completed.
|
||||
|
||||
|
||||
## Feature
|
||||
@@ -297,56 +349,20 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
* Providing a feature to detect errors that occur when mixing models and clips from checkpoints such as `SDXL Base`, `SDXL Refiner`, `SD1.x`, `SD2.x` during sample execution, and reporting appropriate errors.
|
||||
|
||||
|
||||
## Deprecated
|
||||
* The following nodes have been kept only for compatibility with existing workflows, and are no longer supported. Please replace them with new nodes.
|
||||
* ONNX Detector (SEGS) - BBOX Detector (SEGS)
|
||||
* MMDetLoader -> MMDetDetectorProvider
|
||||
* SegsMaskCombine -> SEGS to MASK (combined)
|
||||
* BboxDetectorForEach -> BBOX Detector (SEGS)
|
||||
* SegmDetectorForEach -> SEGM Detector (SEGS)
|
||||
* BboxDetectorCombined -> BBOX Detector (combined)
|
||||
* SegmDetectorCombined -> SEGM Detector (combined)
|
||||
* MaskPainter -> PreviewBridge
|
||||
* To use the existing deprecated legacy nodes, you need to enable the MMDet usage configuration.
|
||||
|
||||
|
||||
## Ultralytics models
|
||||
* When using ultralytics models, save them separately in `models/ultralytics/bbox` and `models/ultralytics/segm` depending on the type of model. Many models can be downloaded by searching for `ultralytics` in the Model Manager of ComfyUI-Manager.
|
||||
* huggingface.co/Bingsu/[adetailer](https://huggingface.co/Bingsu/adetailer/tree/main) - You can download face, people detection models, and clothing detection models.
|
||||
* ultralytics/[assets](https://github.com/ultralytics/assets/releases/) - You can download various types of detection models other than faces or people.
|
||||
* civitai/[adetailer](https://civitai.com/search/models?sortBy=models_v5&query=adetailer) - You can download various types detection models....Many models are associated with NSFW content.
|
||||
|
||||
## How to activate 'MMDet usage' (DEPRECATED)
|
||||
* Upon the initial execution, an `impact-pack.ini` file will be generated in the custom_nodes/ComfyUI-Impact-Pack directory.
|
||||
```
|
||||
[default]
|
||||
dependency_version = 2
|
||||
mmdet_skip = True
|
||||
```
|
||||
* Change `mmdet_skip = True` to `mmdet_skip = False`
|
||||
```
|
||||
[default]
|
||||
dependency_version = 2
|
||||
mmdet_skip = False
|
||||
```
|
||||
* Restart ComfyUI
|
||||
|
||||
|
||||
## Installation
|
||||
## How To Install?
|
||||
|
||||
### Install via ComfyUI-Manager (Recommended)
|
||||
* Search `ComfyUI Impact Pack` in ComfyUI-Manager and click `Install` button.
|
||||
|
||||
### Manual Install (Not Recommended)
|
||||
1. `cd custom_nodes`
|
||||
2. `git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack.git`
|
||||
2. `git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack`
|
||||
3. `cd ComfyUI-Impact-Pack`
|
||||
4. (optional) `git clone https://github.com/ltdrdata/ComfyUI-Impact-Subpack impact_subpack`
|
||||
* Impact Pack will automatically download subpack during its initial launch.
|
||||
5. (optional) `python install.py`
|
||||
* Impact Pack will automatically install its dependencies during its initial launch.
|
||||
* For the portable version, you should execute the command `..\..\..\python_embeded\python.exe install.py` to run the installation script.
|
||||
6. Restart ComfyUI
|
||||
4. `pip install -r requirements.txt`
|
||||
* **IMPORTANT**:
|
||||
* You must install it within the Python environment where ComfyUI is running.
|
||||
* For the portable version, use `<installed path>\python_embeded\python.exe -m pip` instead of `pip`. For a `venv`, activate the `venv` first and then use `pip`.
|
||||
5. Restart ComfyUI
|
||||
|
||||
* NOTE1: If an error occurs during the installation process, please refer to [Troubleshooting Page](troubleshooting/TROUBLESHOOTING.md) for assistance.
|
||||
* NOTE2: You can use this colab notebook [colab notebook](https://colab.research.google.com/github/ltdrdata/ComfyUI-Impact-Pack/blob/Main/notebook/comfyui_colab_impact_pack.ipynb) to launch it. This notebook automatically downloads the impact pack to the custom_nodes directory, installs the tested dependencies, and runs it.
|
||||
@@ -357,11 +373,9 @@ mmdet_skip = False
|
||||
|
||||
* pip install
|
||||
* segment-anything
|
||||
* ultralytics
|
||||
* scikit-image
|
||||
* piexif
|
||||
* opencv-python
|
||||
* GitPython
|
||||
* scipy
|
||||
* numpy<2
|
||||
* dill
|
||||
@@ -370,9 +384,6 @@ mmdet_skip = False
|
||||
* (deprecated) openmim # for mim
|
||||
* (deprecated) pycocotools # for mim
|
||||
|
||||
* mim install (deprecated)
|
||||
* mmcv==2.0.0, mmdet==3.0.0, mmengine==0.7.2
|
||||
|
||||
* linux packages (ubuntu)
|
||||
* libgl1-mesa-glx
|
||||
* libglib2.0-0
|
||||
@@ -381,37 +392,32 @@ mmdet_skip = False
|
||||
## Config example
|
||||
* Once you run the Impact Pack for the first time, an `impact-pack.ini` file will be automatically generated in the Impact Pack directory. You can modify this configuration file to customize the default behavior.
|
||||
* `dependency_version` - don't touch this
|
||||
* `mmdet_skip` - disable MMDet based nodes and legacy nodes if `True`
|
||||
* `sam_editor_cpu` - use cpu for `SAM editor` instead of gpu
|
||||
* sam_editor_model: Specify the SAM model for the SAM editor.
|
||||
* You can download various SAM models using ComfyUI-Manager.
|
||||
* Path to SAM model: `ComfyUI/models/sams`
|
||||
```
|
||||
[default]
|
||||
dependency_version = 9
|
||||
mmdet_skip = True
|
||||
sam_editor_cpu = False
|
||||
sam_editor_model = sam_vit_b_01ec64.pth
|
||||
```
|
||||
|
||||
|
||||
## Other Materials (auto-download on initial startup)
|
||||
## Other Materials (auto-download when installing)
|
||||
|
||||
* 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
|
||||
* [Troubleshooting Page](troubleshooting/TROUBLESHOOTING.md)
|
||||
|
||||
|
||||
## How to use (DDetailer feature)
|
||||
## 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](https://github.com/ltdrdata/ComfyUI-extension-tutorials/raw/Main/ComfyUI-Impact-Pack/tutorial/advanced.md) 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.
|
||||
|
||||
 
|
||||
@@ -503,3 +509,5 @@ BlenderNeok/[ComfyUI_Noise](https://github.com/BlenderNeko/ComfyUI_Noise) - The
|
||||
WASasquatch/[was-node-suite-comfyui](https://github.com/WASasquatch/was-node-suite-comfyui) - A powerful custom node extensions of ComfyUI.
|
||||
|
||||
Trung0246/[ComfyUI-0246](https://github.com/Trung0246/ComfyUI-0246) - Nice bypass hack!
|
||||
|
||||
Layer-norm/[comfyui-lama-remover](https://github.com/Layer-norm/comfyui-lama-remover) - Required for using `LamaRemoverDetailerHook`.
|
||||
|
||||
@@ -5,48 +5,35 @@
|
||||
@description: This extension offers various detector nodes and detailer nodes that allow you to configure a workflow that automatically enhances facial details. And provide iterative upscaler.
|
||||
"""
|
||||
|
||||
import shutil
|
||||
import folder_paths
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
import logging
|
||||
|
||||
comfy_path = os.path.dirname(folder_paths.__file__)
|
||||
impact_path = os.path.join(os.path.dirname(__file__))
|
||||
subpack_path = os.path.join(os.path.dirname(__file__), "impact_subpack")
|
||||
modules_path = os.path.join(os.path.dirname(__file__), "modules")
|
||||
|
||||
sys.path.append(modules_path)
|
||||
|
||||
import impact.config
|
||||
import impact.sample_error_enhancer
|
||||
print(f"### Loading: ComfyUI-Impact-Pack ({impact.config.version})")
|
||||
|
||||
|
||||
sys.path.append(subpack_path)
|
||||
logging.info(f"### Loading: ComfyUI-Impact-Pack ({impact.config.version})")
|
||||
|
||||
# Core
|
||||
# recheck dependencies for colab
|
||||
try:
|
||||
import impact.subpack_nodes # This import must be done before cv2.
|
||||
|
||||
import folder_paths
|
||||
import torch
|
||||
import cv2
|
||||
from cv2 import setNumThreads
|
||||
import numpy as np
|
||||
import torch # noqa: F401
|
||||
import cv2 # noqa: F401
|
||||
from cv2 import setNumThreads # noqa: F401
|
||||
import numpy as np # noqa: F401
|
||||
import comfy.samplers
|
||||
import comfy.sd
|
||||
import warnings
|
||||
from PIL import Image, ImageFilter
|
||||
from skimage.measure import label, regionprops
|
||||
from collections import namedtuple
|
||||
import piexif
|
||||
|
||||
if not impact.config.get_config()['mmdet_skip']:
|
||||
import mmcv
|
||||
from mmdet.apis import (inference_detector, init_detector)
|
||||
from mmdet.evaluation import get_classes
|
||||
import comfy.sd # noqa: F401
|
||||
from PIL import Image, ImageFilter # noqa: F401
|
||||
from skimage.measure import label, regionprops # noqa: F401
|
||||
from collections import namedtuple # noqa: F401
|
||||
import piexif # noqa: F401
|
||||
import nodes
|
||||
except Exception as e:
|
||||
import logging
|
||||
logging.error("[Impact Pack] Failed to import due to several dependencies are missing!!!!")
|
||||
@@ -55,18 +42,18 @@ except Exception as e:
|
||||
|
||||
import impact.impact_server # to load server api
|
||||
|
||||
from .modules.impact.impact_pack import *
|
||||
from .modules.impact.detectors import *
|
||||
from .modules.impact.pipe import *
|
||||
from .modules.impact.logics import *
|
||||
from .modules.impact.util_nodes import *
|
||||
from .modules.impact.segs_nodes import *
|
||||
from .modules.impact.special_samplers import *
|
||||
from .modules.impact.hf_nodes import *
|
||||
from .modules.impact.bridge_nodes import *
|
||||
from .modules.impact.hook_nodes import *
|
||||
from .modules.impact.animatediff_nodes import *
|
||||
from .modules.impact.segs_upscaler import *
|
||||
from .modules.impact.impact_pack import * # noqa: F403
|
||||
from .modules.impact.detectors import * # noqa: F403
|
||||
from .modules.impact.pipe import * # noqa: F403
|
||||
from .modules.impact.logics import * # noqa: F403
|
||||
from .modules.impact.util_nodes import * # noqa: F403
|
||||
from .modules.impact.segs_nodes import * # noqa: F403
|
||||
from .modules.impact.special_samplers import * # noqa: F403
|
||||
from .modules.impact.hf_nodes import * # noqa: F403
|
||||
from .modules.impact.bridge_nodes import * # noqa: F403
|
||||
from .modules.impact.hook_nodes import * # noqa: F403
|
||||
from .modules.impact.animatediff_nodes import * # noqa: F403
|
||||
from .modules.impact.segs_upscaler import * # noqa: F403
|
||||
|
||||
import threading
|
||||
|
||||
@@ -75,223 +62,234 @@ threading.Thread(target=impact.wildcards.wildcard_load).start()
|
||||
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"SAMLoader": SAMLoader,
|
||||
"CLIPSegDetectorProvider": CLIPSegDetectorProvider,
|
||||
"ONNXDetectorProvider": ONNXDetectorProvider,
|
||||
"SAMLoader": SAMLoader, # noqa: F405
|
||||
"CLIPSegDetectorProvider": CLIPSegDetectorProvider, # noqa: F405
|
||||
"ONNXDetectorProvider": ONNXDetectorProvider, # noqa: F405
|
||||
|
||||
"BitwiseAndMaskForEach": BitwiseAndMaskForEach,
|
||||
"SubtractMaskForEach": SubtractMaskForEach,
|
||||
"BitwiseAndMaskForEach": BitwiseAndMaskForEach, # noqa: F405
|
||||
"SubtractMaskForEach": SubtractMaskForEach, # noqa: F405
|
||||
|
||||
"DetailerForEach": DetailerForEach,
|
||||
"DetailerForEachDebug": DetailerForEachTest,
|
||||
"DetailerForEachPipe": DetailerForEachPipe,
|
||||
"DetailerForEachDebugPipe": DetailerForEachTestPipe,
|
||||
"DetailerForEachPipeForAnimateDiff": DetailerForEachPipeForAnimateDiff,
|
||||
"DetailerForEach": DetailerForEach, # noqa: F405
|
||||
"DetailerForEachDebug": DetailerForEachTest, # noqa: F405
|
||||
"DetailerForEachPipe": DetailerForEachPipe, # noqa: F405
|
||||
"DetailerForEachDebugPipe": DetailerForEachTestPipe, # noqa: F405
|
||||
"DetailerForEachPipeForAnimateDiff": DetailerForEachPipeForAnimateDiff, # noqa: F405
|
||||
|
||||
"SAMDetectorCombined": SAMDetectorCombined,
|
||||
"SAMDetectorSegmented": SAMDetectorSegmented,
|
||||
"SAMDetectorCombined": SAMDetectorCombined, # noqa: F405
|
||||
"SAMDetectorSegmented": SAMDetectorSegmented, # noqa: F405
|
||||
|
||||
"FaceDetailer": FaceDetailer,
|
||||
"FaceDetailerPipe": FaceDetailerPipe,
|
||||
"MaskDetailerPipe": MaskDetailerPipe,
|
||||
"FaceDetailer": FaceDetailer, # noqa: F405
|
||||
"FaceDetailerPipe": FaceDetailerPipe, # noqa: F405
|
||||
"MaskDetailerPipe": MaskDetailerPipe, # noqa: F405
|
||||
|
||||
"ToDetailerPipe": ToDetailerPipe,
|
||||
"ToDetailerPipeSDXL": ToDetailerPipeSDXL,
|
||||
"FromDetailerPipe": FromDetailerPipe,
|
||||
"FromDetailerPipe_v2": FromDetailerPipe_v2,
|
||||
"FromDetailerPipeSDXL": FromDetailerPipe_SDXL,
|
||||
"AnyPipeToBasic": AnyPipeToBasic,
|
||||
"ToBasicPipe": ToBasicPipe,
|
||||
"FromBasicPipe": FromBasicPipe,
|
||||
"FromBasicPipe_v2": FromBasicPipe_v2,
|
||||
"BasicPipeToDetailerPipe": BasicPipeToDetailerPipe,
|
||||
"BasicPipeToDetailerPipeSDXL": BasicPipeToDetailerPipeSDXL,
|
||||
"DetailerPipeToBasicPipe": DetailerPipeToBasicPipe,
|
||||
"EditBasicPipe": EditBasicPipe,
|
||||
"EditDetailerPipe": EditDetailerPipe,
|
||||
"EditDetailerPipeSDXL": EditDetailerPipeSDXL,
|
||||
"ToDetailerPipe": ToDetailerPipe, # noqa: F405
|
||||
"ToDetailerPipeSDXL": ToDetailerPipeSDXL, # noqa: F405
|
||||
"FromDetailerPipe": FromDetailerPipe, # noqa: F405
|
||||
"FromDetailerPipe_v2": FromDetailerPipe_v2, # noqa: F405
|
||||
"FromDetailerPipeSDXL": FromDetailerPipe_SDXL, # noqa: F405
|
||||
"AnyPipeToBasic": AnyPipeToBasic, # noqa: F405
|
||||
"ToBasicPipe": ToBasicPipe, # noqa: F405
|
||||
"FromBasicPipe": FromBasicPipe, # noqa: F405
|
||||
"FromBasicPipe_v2": FromBasicPipe_v2, # noqa: F405
|
||||
"BasicPipeToDetailerPipe": BasicPipeToDetailerPipe, # noqa: F405
|
||||
"BasicPipeToDetailerPipeSDXL": BasicPipeToDetailerPipeSDXL, # noqa: F405
|
||||
"DetailerPipeToBasicPipe": DetailerPipeToBasicPipe, # noqa: F405
|
||||
"EditBasicPipe": EditBasicPipe, # noqa: F405
|
||||
"EditDetailerPipe": EditDetailerPipe, # noqa: F405
|
||||
"EditDetailerPipeSDXL": EditDetailerPipeSDXL, # noqa: F405
|
||||
|
||||
"LatentPixelScale": LatentPixelScale,
|
||||
"PixelKSampleUpscalerProvider": PixelKSampleUpscalerProvider,
|
||||
"PixelKSampleUpscalerProviderPipe": PixelKSampleUpscalerProviderPipe,
|
||||
"IterativeLatentUpscale": IterativeLatentUpscale,
|
||||
"IterativeImageUpscale": IterativeImageUpscale,
|
||||
"PixelTiledKSampleUpscalerProvider": PixelTiledKSampleUpscalerProvider,
|
||||
"PixelTiledKSampleUpscalerProviderPipe": PixelTiledKSampleUpscalerProviderPipe,
|
||||
"TwoSamplersForMaskUpscalerProvider": TwoSamplersForMaskUpscalerProvider,
|
||||
"TwoSamplersForMaskUpscalerProviderPipe": TwoSamplersForMaskUpscalerProviderPipe,
|
||||
"LatentPixelScale": LatentPixelScale, # noqa: F405
|
||||
"PixelKSampleUpscalerProvider": PixelKSampleUpscalerProvider, # noqa: F405
|
||||
"PixelKSampleUpscalerProviderPipe": PixelKSampleUpscalerProviderPipe, # noqa: F405
|
||||
"IterativeLatentUpscale": IterativeLatentUpscale, # noqa: F405
|
||||
"IterativeImageUpscale": IterativeImageUpscale, # noqa: F405
|
||||
"PixelTiledKSampleUpscalerProvider": PixelTiledKSampleUpscalerProvider, # noqa: F405
|
||||
"PixelTiledKSampleUpscalerProviderPipe": PixelTiledKSampleUpscalerProviderPipe, # noqa: F405
|
||||
"TwoSamplersForMaskUpscalerProvider": TwoSamplersForMaskUpscalerProvider, # noqa: F405
|
||||
"TwoSamplersForMaskUpscalerProviderPipe": TwoSamplersForMaskUpscalerProviderPipe, # noqa: F405
|
||||
|
||||
"PixelKSampleHookCombine": PixelKSampleHookCombine,
|
||||
"DenoiseScheduleHookProvider": DenoiseScheduleHookProvider,
|
||||
"StepsScheduleHookProvider": StepsScheduleHookProvider,
|
||||
"CfgScheduleHookProvider": CfgScheduleHookProvider,
|
||||
"NoiseInjectionHookProvider": NoiseInjectionHookProvider,
|
||||
"UnsamplerHookProvider": UnsamplerHookProvider,
|
||||
"CoreMLDetailerHookProvider": CoreMLDetailerHookProvider,
|
||||
"PreviewDetailerHookProvider": PreviewDetailerHookProvider,
|
||||
"PixelKSampleHookCombine": PixelKSampleHookCombine, # noqa: F405
|
||||
"DenoiseScheduleHookProvider": DenoiseScheduleHookProvider, # noqa: F405
|
||||
"StepsScheduleHookProvider": StepsScheduleHookProvider, # noqa: F405
|
||||
"CfgScheduleHookProvider": CfgScheduleHookProvider, # noqa: F405
|
||||
"NoiseInjectionHookProvider": NoiseInjectionHookProvider, # noqa: F405
|
||||
"UnsamplerHookProvider": UnsamplerHookProvider, # noqa: F405
|
||||
"CoreMLDetailerHookProvider": CoreMLDetailerHookProvider, # noqa: F405
|
||||
"PreviewDetailerHookProvider": PreviewDetailerHookProvider, # noqa: F405
|
||||
"CustomSamplerDetailerHookProvider": CustomSamplerDetailerHookProvider, # noqa: F405
|
||||
"LamaRemoverDetailerHookProvider": LamaRemoverDetailerHookProvider, # noqa: F405
|
||||
|
||||
"DetailerHookCombine": DetailerHookCombine,
|
||||
"NoiseInjectionDetailerHookProvider": NoiseInjectionDetailerHookProvider,
|
||||
"UnsamplerDetailerHookProvider": UnsamplerDetailerHookProvider,
|
||||
"DenoiseSchedulerDetailerHookProvider": DenoiseSchedulerDetailerHookProvider,
|
||||
"SEGSOrderedFilterDetailerHookProvider": SEGSOrderedFilterDetailerHookProvider,
|
||||
"SEGSRangeFilterDetailerHookProvider": SEGSRangeFilterDetailerHookProvider,
|
||||
"SEGSLabelFilterDetailerHookProvider": SEGSLabelFilterDetailerHookProvider,
|
||||
"VariationNoiseDetailerHookProvider": VariationNoiseDetailerHookProvider,
|
||||
"DetailerHookCombine": DetailerHookCombine, # noqa: F405
|
||||
"NoiseInjectionDetailerHookProvider": NoiseInjectionDetailerHookProvider, # noqa: F405
|
||||
"UnsamplerDetailerHookProvider": UnsamplerDetailerHookProvider, # noqa: F405
|
||||
"DenoiseSchedulerDetailerHookProvider": DenoiseSchedulerDetailerHookProvider, # noqa: F405
|
||||
"SEGSOrderedFilterDetailerHookProvider": SEGSOrderedFilterDetailerHookProvider, # noqa: F405
|
||||
"SEGSRangeFilterDetailerHookProvider": SEGSRangeFilterDetailerHookProvider, # noqa: F405
|
||||
"SEGSLabelFilterDetailerHookProvider": SEGSLabelFilterDetailerHookProvider, # noqa: F405
|
||||
"VariationNoiseDetailerHookProvider": VariationNoiseDetailerHookProvider, # noqa: F405
|
||||
# "CustomNoiseDetailerHookProvider": CustomNoiseDetailerHookProvider,
|
||||
|
||||
"BitwiseAndMask": BitwiseAndMask,
|
||||
"SubtractMask": SubtractMask,
|
||||
"AddMask": AddMask,
|
||||
"ImpactSegsAndMask": SegsBitwiseAndMask,
|
||||
"ImpactSegsAndMaskForEach": SegsBitwiseAndMaskForEach,
|
||||
"EmptySegs": EmptySEGS,
|
||||
"ImpactFlattenMask": FlattenMask,
|
||||
"BitwiseAndMask": BitwiseAndMask, # noqa: F405
|
||||
"SubtractMask": SubtractMask, # noqa: F405
|
||||
"AddMask": AddMask, # noqa: F405
|
||||
"MaskRectArea": MaskRectArea, # noqa: F405
|
||||
"MaskRectAreaAdvanced": MaskRectAreaAdvanced, # noqa: F405
|
||||
"ImpactSegsAndMask": SegsBitwiseAndMask, # noqa: F405
|
||||
"ImpactSegsAndMaskForEach": SegsBitwiseAndMaskForEach, # noqa: F405
|
||||
"EmptySegs": EmptySEGS, # noqa: F405
|
||||
"ImpactFlattenMask": FlattenMask, # noqa: F405
|
||||
|
||||
"MediaPipeFaceMeshToSEGS": MediaPipeFaceMeshToSEGS,
|
||||
"MaskToSEGS": MaskToSEGS,
|
||||
"MaskToSEGS_for_AnimateDiff": MaskToSEGS_for_AnimateDiff,
|
||||
"ToBinaryMask": ToBinaryMask,
|
||||
"MasksToMaskList": MasksToMaskList,
|
||||
"MaskListToMaskBatch": MaskListToMaskBatch,
|
||||
"ImageListToImageBatch": ImageListToImageBatch,
|
||||
"SetDefaultImageForSEGS": DefaultImageForSEGS,
|
||||
"RemoveImageFromSEGS": RemoveImageFromSEGS,
|
||||
"MediaPipeFaceMeshToSEGS": MediaPipeFaceMeshToSEGS, # noqa: F405
|
||||
"MaskToSEGS": MaskToSEGS, # noqa: F405
|
||||
"MaskToSEGS_for_AnimateDiff": MaskToSEGS_for_AnimateDiff, # noqa: F405
|
||||
"ToBinaryMask": ToBinaryMask, # noqa: F405
|
||||
"MasksToMaskList": MasksToMaskList, # noqa: F405
|
||||
"MaskListToMaskBatch": MaskListToMaskBatch, # noqa: F405
|
||||
"ImageListToImageBatch": ImageListToImageBatch, # noqa: F405
|
||||
"SetDefaultImageForSEGS": DefaultImageForSEGS, # noqa: F405
|
||||
"RemoveImageFromSEGS": RemoveImageFromSEGS, # noqa: F405
|
||||
|
||||
"BboxDetectorSEGS": BboxDetectorForEach,
|
||||
"SegmDetectorSEGS": SegmDetectorForEach,
|
||||
"ONNXDetectorSEGS": BboxDetectorForEach,
|
||||
"ImpactSimpleDetectorSEGS_for_AD": SimpleDetectorForAnimateDiff,
|
||||
"ImpactSimpleDetectorSEGS": SimpleDetectorForEach,
|
||||
"ImpactSimpleDetectorSEGSPipe": SimpleDetectorForEachPipe,
|
||||
"ImpactControlNetApplySEGS": ControlNetApplySEGS,
|
||||
"ImpactControlNetApplyAdvancedSEGS": ControlNetApplyAdvancedSEGS,
|
||||
"ImpactControlNetClearSEGS": ControlNetClearSEGS,
|
||||
"ImpactIPAdapterApplySEGS": IPAdapterApplySEGS,
|
||||
"BboxDetectorSEGS": BboxDetectorForEach, # noqa: F405
|
||||
"SegmDetectorSEGS": SegmDetectorForEach, # noqa: F405
|
||||
"ONNXDetectorSEGS": BboxDetectorForEach, # noqa: F405
|
||||
"ImpactSimpleDetectorSEGS_for_AD": SimpleDetectorForAnimateDiff, # noqa: F405
|
||||
"ImpactSAM2VideoDetectorSEGS": SAM2VideoDetectorSEGS, # noqa: F405
|
||||
"ImpactSimpleDetectorSEGS": SimpleDetectorForEach, # noqa: F405
|
||||
"ImpactSimpleDetectorSEGSPipe": SimpleDetectorForEachPipe, # noqa: F405
|
||||
"ImpactControlNetApplySEGS": ControlNetApplySEGS, # noqa: F405
|
||||
"ImpactControlNetApplyAdvancedSEGS": ControlNetApplyAdvancedSEGS, # noqa: F405
|
||||
"ImpactControlNetClearSEGS": ControlNetClearSEGS, # noqa: F405
|
||||
"ImpactIPAdapterApplySEGS": IPAdapterApplySEGS, # noqa: F405
|
||||
|
||||
"ImpactDecomposeSEGS": DecomposeSEGS,
|
||||
"ImpactAssembleSEGS": AssembleSEGS,
|
||||
"ImpactFrom_SEG_ELT": From_SEG_ELT,
|
||||
"ImpactEdit_SEG_ELT": Edit_SEG_ELT,
|
||||
"ImpactDilate_Mask_SEG_ELT": Dilate_SEG_ELT,
|
||||
"ImpactDilateMask": DilateMask,
|
||||
"ImpactGaussianBlurMask": GaussianBlurMask,
|
||||
"ImpactDilateMaskInSEGS": DilateMaskInSEGS,
|
||||
"ImpactGaussianBlurMaskInSEGS": GaussianBlurMaskInSEGS,
|
||||
"ImpactScaleBy_BBOX_SEG_ELT": SEG_ELT_BBOX_ScaleBy,
|
||||
"ImpactFrom_SEG_ELT_bbox": From_SEG_ELT_bbox,
|
||||
"ImpactFrom_SEG_ELT_crop_region": From_SEG_ELT_crop_region,
|
||||
"ImpactCount_Elts_in_SEGS": Count_Elts_in_SEGS,
|
||||
"ImpactDecomposeSEGS": DecomposeSEGS, # noqa: F405
|
||||
"ImpactAssembleSEGS": AssembleSEGS, # noqa: F405
|
||||
"ImpactFrom_SEG_ELT": From_SEG_ELT, # noqa: F405
|
||||
"ImpactEdit_SEG_ELT": Edit_SEG_ELT, # noqa: F405
|
||||
"ImpactDilate_Mask_SEG_ELT": Dilate_SEG_ELT, # noqa: F405
|
||||
"ImpactDilateMask": DilateMask, # noqa: F405
|
||||
"ImpactGaussianBlurMask": GaussianBlurMask, # noqa: F405
|
||||
"ImpactDilateMaskInSEGS": DilateMaskInSEGS, # noqa: F405
|
||||
"ImpactGaussianBlurMaskInSEGS": GaussianBlurMaskInSEGS, # noqa: F405
|
||||
"ImpactScaleBy_BBOX_SEG_ELT": SEG_ELT_BBOX_ScaleBy, # noqa: F405
|
||||
"ImpactFrom_SEG_ELT_bbox": From_SEG_ELT_bbox, # noqa: F405
|
||||
"ImpactFrom_SEG_ELT_crop_region": From_SEG_ELT_crop_region, # noqa: F405
|
||||
"ImpactCount_Elts_in_SEGS": Count_Elts_in_SEGS, # noqa: F405
|
||||
|
||||
"BboxDetectorCombined_v2": BboxDetectorCombined,
|
||||
"SegmDetectorCombined_v2": SegmDetectorCombined,
|
||||
"SegsToCombinedMask": SegsToCombinedMask,
|
||||
"BboxDetectorCombined_v2": BboxDetectorCombined, # noqa: F405
|
||||
"SegmDetectorCombined_v2": SegmDetectorCombined, # noqa: F405
|
||||
"SegsToCombinedMask": SegsToCombinedMask, # noqa: F405
|
||||
|
||||
"KSamplerProvider": KSamplerProvider,
|
||||
"TwoSamplersForMask": TwoSamplersForMask,
|
||||
"TiledKSamplerProvider": TiledKSamplerProvider,
|
||||
"KSamplerProvider": KSamplerProvider, # noqa: F405
|
||||
"TwoSamplersForMask": TwoSamplersForMask, # noqa: F405
|
||||
"TiledKSamplerProvider": TiledKSamplerProvider, # noqa: F405
|
||||
|
||||
"KSamplerAdvancedProvider": KSamplerAdvancedProvider,
|
||||
"TwoAdvancedSamplersForMask": TwoAdvancedSamplersForMask,
|
||||
"KSamplerAdvancedProvider": KSamplerAdvancedProvider, # noqa: F405
|
||||
"TwoAdvancedSamplersForMask": TwoAdvancedSamplersForMask, # noqa: F405
|
||||
|
||||
"ImpactNegativeConditioningPlaceholder": NegativeConditioningPlaceholder,
|
||||
"ImpactNegativeConditioningPlaceholder": NegativeConditioningPlaceholder, # noqa: F405
|
||||
|
||||
"PreviewBridge": PreviewBridge,
|
||||
"PreviewBridgeLatent": PreviewBridgeLatent,
|
||||
"ImageSender": ImageSender,
|
||||
"ImageReceiver": ImageReceiver,
|
||||
"LatentSender": LatentSender,
|
||||
"LatentReceiver": LatentReceiver,
|
||||
"ImageMaskSwitch": ImageMaskSwitch,
|
||||
"LatentSwitch": GeneralSwitch,
|
||||
"SEGSSwitch": GeneralSwitch,
|
||||
"ImpactSwitch": GeneralSwitch,
|
||||
"ImpactInversedSwitch": GeneralInversedSwitch,
|
||||
"PreviewBridge": PreviewBridge, # noqa: F405
|
||||
"PreviewBridgeLatent": PreviewBridgeLatent, # noqa: F405
|
||||
"ImageSender": ImageSender, # noqa: F405
|
||||
"ImageReceiver": ImageReceiver, # noqa: F405
|
||||
"LatentSender": LatentSender, # noqa: F405
|
||||
"LatentReceiver": LatentReceiver, # noqa: F405
|
||||
"ImageMaskSwitch": ImageMaskSwitch, # noqa: F405
|
||||
"LatentSwitch": GeneralSwitch, # noqa: F405
|
||||
"SEGSSwitch": GeneralSwitch, # noqa: F405
|
||||
"ImpactSwitch": GeneralSwitch, # noqa: F405
|
||||
"ImpactInversedSwitch": GeneralInversedSwitch, # noqa: F405
|
||||
|
||||
"ImpactWildcardProcessor": ImpactWildcardProcessor,
|
||||
"ImpactWildcardEncode": ImpactWildcardEncode,
|
||||
"ImpactWildcardProcessor": ImpactWildcardProcessor, # noqa: F405
|
||||
"ImpactWildcardEncode": ImpactWildcardEncode, # noqa: F405
|
||||
|
||||
"SEGSUpscaler": SEGSUpscaler,
|
||||
"SEGSUpscalerPipe": SEGSUpscalerPipe,
|
||||
"SEGSDetailer": SEGSDetailer,
|
||||
"SEGSPaste": SEGSPaste,
|
||||
"SEGSPreview": SEGSPreview,
|
||||
"SEGSPreviewCNet": SEGSPreviewCNet,
|
||||
"SEGSToImageList": SEGSToImageList,
|
||||
"ImpactSEGSToMaskList": SEGSToMaskList,
|
||||
"ImpactSEGSToMaskBatch": SEGSToMaskBatch,
|
||||
"ImpactSEGSConcat": SEGSConcat,
|
||||
"ImpactSEGSPicker": SEGSPicker,
|
||||
"ImpactMakeTileSEGS": MakeTileSEGS,
|
||||
"SEGSUpscaler": SEGSUpscaler, # noqa: F405
|
||||
"SEGSUpscalerPipe": SEGSUpscalerPipe, # noqa: F405
|
||||
"SEGSDetailer": SEGSDetailer, # noqa: F405
|
||||
"SEGSPaste": SEGSPaste, # noqa: F405
|
||||
"SEGSPreview": SEGSPreview, # noqa: F405
|
||||
"SEGSPreviewCNet": SEGSPreviewCNet, # noqa: F405
|
||||
"SEGSToImageList": SEGSToImageList, # noqa: F405
|
||||
"ImpactSEGSToMaskList": SEGSToMaskList, # noqa: F405
|
||||
"ImpactSEGSToMaskBatch": SEGSToMaskBatch, # noqa: F405
|
||||
"ImpactSEGSConcat": SEGSConcat, # noqa: F405
|
||||
"ImpactSEGSPicker": SEGSPicker, # noqa: F405
|
||||
"ImpactMakeTileSEGS": MakeTileSEGS, # noqa: F405
|
||||
"ImpactSEGSMerge": SEGSMerge, # noqa: F405
|
||||
|
||||
"SEGSDetailerForAnimateDiff": SEGSDetailerForAnimateDiff,
|
||||
"SEGSDetailerForAnimateDiff": SEGSDetailerForAnimateDiff, # noqa: F405
|
||||
|
||||
"ImpactKSamplerBasicPipe": KSamplerBasicPipe,
|
||||
"ImpactKSamplerAdvancedBasicPipe": KSamplerAdvancedBasicPipe,
|
||||
"ImpactKSamplerBasicPipe": KSamplerBasicPipe, # noqa: F405
|
||||
"ImpactKSamplerAdvancedBasicPipe": KSamplerAdvancedBasicPipe, # noqa: F405
|
||||
|
||||
"ReencodeLatent": ReencodeLatent,
|
||||
"ReencodeLatentPipe": ReencodeLatentPipe,
|
||||
"ReencodeLatent": ReencodeLatent, # noqa: F405
|
||||
"ReencodeLatentPipe": ReencodeLatentPipe, # noqa: F405
|
||||
|
||||
"ImpactImageBatchToImageList": ImageBatchToImageList,
|
||||
"ImpactMakeImageList": MakeImageList,
|
||||
"ImpactMakeImageBatch": MakeImageBatch,
|
||||
"ImpactMakeAnyList": MakeAnyList,
|
||||
"ImpactMakeMaskList": MakeMaskList,
|
||||
"ImpactMakeMaskBatch": MakeMaskBatch,
|
||||
"ImpactImageBatchToImageList": ImageBatchToImageList, # noqa: F405
|
||||
"ImpactMakeImageList": MakeImageList, # noqa: F405
|
||||
"ImpactMakeImageBatch": MakeImageBatch, # noqa: F405
|
||||
"ImpactMakeAnyList": MakeAnyList, # noqa: F405
|
||||
"ImpactMakeMaskList": MakeMaskList, # noqa: F405
|
||||
"ImpactMakeMaskBatch": MakeMaskBatch, # noqa: F405
|
||||
"ImpactSelectNthItemOfAnyList": NthItemOfAnyList, # noqa: F405
|
||||
|
||||
"RegionalSampler": RegionalSampler,
|
||||
"RegionalSamplerAdvanced": RegionalSamplerAdvanced,
|
||||
"CombineRegionalPrompts": CombineRegionalPrompts,
|
||||
"RegionalPrompt": RegionalPrompt,
|
||||
"RegionalSampler": RegionalSampler, # noqa: F405
|
||||
"RegionalSamplerAdvanced": RegionalSamplerAdvanced, # noqa: F405
|
||||
"CombineRegionalPrompts": CombineRegionalPrompts, # noqa: F405
|
||||
"RegionalPrompt": RegionalPrompt, # noqa: F405
|
||||
|
||||
"ImpactCombineConditionings": CombineConditionings,
|
||||
"ImpactConcatConditionings": ConcatConditionings,
|
||||
"ImpactCombineConditionings": CombineConditionings, # noqa: F405
|
||||
"ImpactConcatConditionings": ConcatConditionings, # noqa: F405
|
||||
|
||||
"ImpactSEGSLabelAssign": SEGSLabelAssign,
|
||||
"ImpactSEGSLabelFilter": SEGSLabelFilter,
|
||||
"ImpactSEGSRangeFilter": SEGSRangeFilter,
|
||||
"ImpactSEGSOrderedFilter": SEGSOrderedFilter,
|
||||
"ImpactSEGSLabelAssign": SEGSLabelAssign, # noqa: F405
|
||||
"ImpactSEGSLabelFilter": SEGSLabelFilter, # noqa: F405
|
||||
"ImpactSEGSRangeFilter": SEGSRangeFilter, # noqa: F405
|
||||
"ImpactSEGSOrderedFilter": SEGSOrderedFilter, # noqa: F405
|
||||
"ImpactSEGSIntersectionFilter": SEGSIntersectionFilter, # noqa: F405
|
||||
"ImpactSEGSNMSFilter": SEGSNMSFilter, # noqa: F405
|
||||
|
||||
"ImpactCompare": ImpactCompare,
|
||||
"ImpactConditionalBranch": ImpactConditionalBranch,
|
||||
"ImpactConditionalBranchSelMode": ImpactConditionalBranchSelMode,
|
||||
"ImpactIfNone": ImpactIfNone,
|
||||
"ImpactConvertDataType": ImpactConvertDataType,
|
||||
"ImpactLogicalOperators": ImpactLogicalOperators,
|
||||
"ImpactInt": ImpactInt,
|
||||
"ImpactFloat": ImpactFloat,
|
||||
"ImpactValueSender": ImpactValueSender,
|
||||
"ImpactValueReceiver": ImpactValueReceiver,
|
||||
"ImpactImageInfo": ImpactImageInfo,
|
||||
"ImpactLatentInfo": ImpactLatentInfo,
|
||||
"ImpactMinMax": ImpactMinMax,
|
||||
"ImpactNeg": ImpactNeg,
|
||||
"ImpactConditionalStopIteration": ImpactConditionalStopIteration,
|
||||
"ImpactStringSelector": StringSelector,
|
||||
"StringListToString": StringListToString,
|
||||
"WildcardPromptFromString": WildcardPromptFromString,
|
||||
"ImpactExecutionOrderController": ImpactExecutionOrderController,
|
||||
"ImpactCompare": ImpactCompare, # noqa: F405
|
||||
"ImpactConditionalBranch": ImpactConditionalBranch, # noqa: F405
|
||||
"ImpactConditionalBranchSelMode": ImpactConditionalBranchSelMode, # noqa: F405
|
||||
"ImpactIfNone": ImpactIfNone, # noqa: F405
|
||||
"ImpactConvertDataType": ImpactConvertDataType, # noqa: F405
|
||||
"ImpactLogicalOperators": ImpactLogicalOperators, # noqa: F405
|
||||
"ImpactInt": ImpactInt, # noqa: F405
|
||||
"ImpactFloat": ImpactFloat, # noqa: F405
|
||||
"ImpactBoolean": ImpactBoolean, # noqa: F405
|
||||
"ImpactValueSender": ImpactValueSender, # noqa: F405
|
||||
"ImpactValueReceiver": ImpactValueReceiver, # noqa: F405
|
||||
"ImpactImageInfo": ImpactImageInfo, # noqa: F405
|
||||
"ImpactLatentInfo": ImpactLatentInfo, # noqa: F405
|
||||
"ImpactMinMax": ImpactMinMax, # noqa: F405
|
||||
"ImpactNeg": ImpactNeg, # noqa: F405
|
||||
"ImpactConditionalStopIteration": ImpactConditionalStopIteration, # noqa: F405
|
||||
"ImpactStringSelector": StringSelector, # noqa: F405
|
||||
"StringListToString": StringListToString, # noqa: F405
|
||||
"WildcardPromptFromString": WildcardPromptFromString, # noqa: F405
|
||||
"ImpactExecutionOrderController": ImpactExecutionOrderController, # noqa: F405
|
||||
"ImpactListBridge": ImpactListBridge, # noqa: F405
|
||||
|
||||
"RemoveNoiseMask": RemoveNoiseMask,
|
||||
"RemoveNoiseMask": RemoveNoiseMask, # noqa: F405
|
||||
|
||||
"ImpactLogger": ImpactLogger,
|
||||
"ImpactDummyInput": ImpactDummyInput,
|
||||
"ImpactLogger": ImpactLogger, # noqa: F405
|
||||
"ImpactDummyInput": ImpactDummyInput, # noqa: F405
|
||||
|
||||
"ImpactQueueTrigger": ImpactQueueTrigger,
|
||||
"ImpactQueueTriggerCountdown": ImpactQueueTriggerCountdown,
|
||||
"ImpactSetWidgetValue": ImpactSetWidgetValue,
|
||||
"ImpactNodeSetMuteState": ImpactNodeSetMuteState,
|
||||
"ImpactControlBridge": ImpactControlBridge,
|
||||
"ImpactIsNotEmptySEGS": ImpactNotEmptySEGS,
|
||||
"ImpactSleep": ImpactSleep,
|
||||
"ImpactRemoteBoolean": ImpactRemoteBoolean,
|
||||
"ImpactRemoteInt": ImpactRemoteInt,
|
||||
"ImpactQueueTrigger": ImpactQueueTrigger, # noqa: F405
|
||||
"ImpactQueueTriggerCountdown": ImpactQueueTriggerCountdown, # noqa: F405
|
||||
"ImpactSetWidgetValue": ImpactSetWidgetValue, # noqa: F405
|
||||
"ImpactNodeSetMuteState": ImpactNodeSetMuteState, # noqa: F405
|
||||
"ImpactControlBridge": ImpactControlBridge, # noqa: F405
|
||||
"ImpactIsNotEmptySEGS": ImpactNotEmptySEGS, # noqa: F405
|
||||
"ImpactSleep": ImpactSleep, # noqa: F405
|
||||
"ImpactRemoteBoolean": ImpactRemoteBoolean, # noqa: F405
|
||||
"ImpactRemoteInt": ImpactRemoteInt, # noqa: F405
|
||||
|
||||
"ImpactHFTransformersClassifierProvider": HF_TransformersClassifierProvider,
|
||||
"ImpactSEGSClassify": SEGS_Classify,
|
||||
"ImpactHFTransformersClassifierProvider": HF_TransformersClassifierProvider, # noqa: F405
|
||||
"ImpactSEGSClassify": SEGS_Classify, # noqa: F405
|
||||
|
||||
"ImpactSchedulerAdapter": ImpactSchedulerAdapter,
|
||||
"GITSSchedulerFuncProvider": GITSSchedulerFuncProvider
|
||||
"ImpactSchedulerAdapter": ImpactSchedulerAdapter, # noqa: F405
|
||||
"GITSSchedulerFuncProvider": GITSSchedulerFuncProvider # noqa: F405
|
||||
}
|
||||
|
||||
|
||||
@@ -301,11 +299,12 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"BboxDetectorSEGS": "BBOX Detector (SEGS)",
|
||||
"SegmDetectorSEGS": "SEGM Detector (SEGS)",
|
||||
"ONNXDetectorSEGS": "ONNX Detector (SEGS/legacy) - use BBOXDetector",
|
||||
"ImpactSimpleDetectorSEGS_for_AD": "Simple Detector for AnimateDiff (SEGS)",
|
||||
"ImpactSimpleDetectorSEGS_for_AD": "Simple Detector for Video (SEGS)",
|
||||
"ImpactSAM2VideoDetectorSEGS": "SAM2 Video Detector (SEGS)",
|
||||
"ImpactSimpleDetectorSEGS": "Simple Detector (SEGS)",
|
||||
"ImpactSimpleDetectorSEGSPipe": "Simple Detector (SEGS/pipe)",
|
||||
"ImpactControlNetApplySEGS": "ControlNetApply (SEGS)",
|
||||
"ImpactControlNetApplyAdvancedSEGS": "ControlNetApplyAdvanced (SEGS)",
|
||||
"ImpactControlNetApplySEGS": "ControlNetApply (SEGS) - DEPRECATED",
|
||||
"ImpactControlNetApplyAdvancedSEGS": "ControlNetApply (SEGS)",
|
||||
"ImpactIPAdapterApplySEGS": "IPAdapterApply (SEGS)",
|
||||
|
||||
"BboxDetectorCombined_v2": "BBOX Detector (combined)",
|
||||
@@ -313,7 +312,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"SegsToCombinedMask": "SEGS to MASK (combined)",
|
||||
"MediaPipeFaceMeshToSEGS": "MediaPipe FaceMesh to SEGS",
|
||||
"MaskToSEGS": "MASK to SEGS",
|
||||
"MaskToSEGS_for_AnimateDiff": "MASK to SEGS for AnimateDiff",
|
||||
"MaskToSEGS_for_AnimateDiff": "MASK to SEGS for Video",
|
||||
"BitwiseAndMaskForEach": "Pixelwise(SEGS & SEGS)",
|
||||
"SubtractMaskForEach": "Pixelwise(SEGS - SEGS)",
|
||||
"ImpactSegsAndMask": "Pixelwise(SEGS & MASK)",
|
||||
@@ -321,13 +320,15 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"BitwiseAndMask": "Pixelwise(MASK & MASK)",
|
||||
"SubtractMask": "Pixelwise(MASK - MASK)",
|
||||
"AddMask": "Pixelwise(MASK + MASK)",
|
||||
"MaskRectArea": "Mask Rect Area",
|
||||
"MaskRectAreaAdvanced": "Mask Rect Area (Advanced)",
|
||||
"ImpactFlattenMask": "Flatten Mask Batch",
|
||||
"DetailerForEach": "Detailer (SEGS)",
|
||||
"DetailerForEachPipe": "Detailer (SEGS/pipe)",
|
||||
"DetailerForEachDebug": "DetailerDebug (SEGS)",
|
||||
"DetailerForEachDebugPipe": "DetailerDebug (SEGS/pipe)",
|
||||
"SEGSDetailerForAnimateDiff": "SEGSDetailer For AnimateDiff (SEGS/pipe)",
|
||||
"DetailerForEachPipeForAnimateDiff": "Detailer For AnimateDiff (SEGS/pipe)",
|
||||
"SEGSDetailerForAnimateDiff": "SEGSDetailer For Video (SEGS/pipe)",
|
||||
"DetailerForEachPipeForAnimateDiff": "Detailer For Video (SEGS/pipe)",
|
||||
"SEGSUpscaler": "Upscaler (SEGS)",
|
||||
"SEGSUpscalerPipe": "Upscaler (SEGS/pipe)",
|
||||
|
||||
@@ -362,11 +363,14 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"ImpactSEGSLabelFilter": "SEGS Filter (label)",
|
||||
"ImpactSEGSRangeFilter": "SEGS Filter (range)",
|
||||
"ImpactSEGSOrderedFilter": "SEGS Filter (ordered)",
|
||||
"ImpactSEGSIntersectionFilter": "SEGS Filter (intersection)",
|
||||
"ImpactSEGSNMSFilter": "SEGS Filter (non max suppression)",
|
||||
"ImpactSEGSConcat": "SEGS Concat",
|
||||
"ImpactSEGSToMaskList": "SEGS to Mask List",
|
||||
"ImpactSEGSToMaskBatch": "SEGS to Mask Batch",
|
||||
"ImpactSEGSPicker": "Picker (SEGS)",
|
||||
"ImpactMakeTileSEGS": "Make Tile SEGS",
|
||||
"ImpactSEGSMerge": "SEGS Merge",
|
||||
|
||||
"ImpactDecomposeSEGS": "Decompose (SEGS)",
|
||||
"ImpactAssembleSEGS": "Assemble (SEGS)",
|
||||
@@ -390,6 +394,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"ImpactSwitch": "Switch (Any)",
|
||||
"ImpactInversedSwitch": "Inversed Switch (Any)",
|
||||
"ImpactExecutionOrderController": "Execution Order Controller",
|
||||
"ImpactListBridge": "List Bridge",
|
||||
|
||||
"MasksToMaskList": "Mask Batch to Mask List",
|
||||
"MaskListToMaskBatch": "Mask List to Mask Batch",
|
||||
@@ -401,6 +406,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"ImpactMakeMaskList": "Make Mask List",
|
||||
"ImpactMakeMaskBatch": "Make Mask Batch",
|
||||
"ImpactMakeAnyList": "Make List (Any)",
|
||||
"ImpactSelectNthItemOfAnyList": "Select Nth Item (Any list)",
|
||||
|
||||
"ImpactStringSelector": "String Selector",
|
||||
"StringListToString": "String List to String",
|
||||
@@ -436,43 +442,6 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"ImpactNegativeConditioningPlaceholder": "Negative Cond Placeholder"
|
||||
}
|
||||
|
||||
if not impact.config.get_config()['mmdet_skip']:
|
||||
from impact.mmdet_nodes import *
|
||||
import impact.legacy_nodes
|
||||
NODE_CLASS_MAPPINGS.update({
|
||||
"MMDetDetectorProvider": MMDetDetectorProvider,
|
||||
"MMDetLoader": impact.legacy_nodes.MMDetLoader,
|
||||
"MaskPainter": impact.legacy_nodes.MaskPainter,
|
||||
"SegsMaskCombine": impact.legacy_nodes.SegsMaskCombine,
|
||||
"BboxDetectorForEach": impact.legacy_nodes.BboxDetectorForEach,
|
||||
"SegmDetectorForEach": impact.legacy_nodes.SegmDetectorForEach,
|
||||
"BboxDetectorCombined": impact.legacy_nodes.BboxDetectorCombined,
|
||||
"SegmDetectorCombined": impact.legacy_nodes.SegmDetectorCombined,
|
||||
})
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update({
|
||||
"MaskPainter": "MaskPainter (Deprecated)",
|
||||
"MMDetLoader": "MMDetLoader (Legacy)",
|
||||
"SegsMaskCombine": "SegsMaskCombine (Legacy)",
|
||||
"BboxDetectorForEach": "BboxDetectorForEach (Legacy)",
|
||||
"SegmDetectorForEach": "SegmDetectorForEach (Legacy)",
|
||||
"BboxDetectorCombined": "BboxDetectorCombined (Legacy)",
|
||||
"SegmDetectorCombined": "SegmDetectorCombined (Legacy)",
|
||||
})
|
||||
|
||||
try:
|
||||
import impact.subpack_nodes
|
||||
|
||||
NODE_CLASS_MAPPINGS.update(impact.subpack_nodes.NODE_CLASS_MAPPINGS)
|
||||
NODE_DISPLAY_NAME_MAPPINGS.update(impact.subpack_nodes.NODE_DISPLAY_NAME_MAPPINGS)
|
||||
except Exception as e:
|
||||
print("### ComfyUI-Impact-Pack: (IMPORT FAILED) Subpack\n")
|
||||
print(" The module at the `custom_nodes/ComfyUI-Impact-Pack/impact_subpack` path appears to be incomplete.")
|
||||
print(" Recommended to delete the path and restart ComfyUI.")
|
||||
print(" If the issue persists, please report it to https://github.com/ltdrdata/ComfyUI-Impact-Pack/issues.")
|
||||
print("\n---------------------------------")
|
||||
traceback.print_exc()
|
||||
print("---------------------------------\n")
|
||||
|
||||
# NOTE: Inject directly into EXTENSION_WEB_DIRS instead of WEB_DIRECTORY
|
||||
# Provide the js path fixed as ComfyUI-Impact-Pack instead of the path name, making it available for external use
|
||||
@@ -482,14 +451,3 @@ nodes.EXTENSION_WEB_DIRS["ComfyUI-Impact-Pack"] = os.path.join(os.path.dirname(o
|
||||
|
||||
|
||||
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']
|
||||
|
||||
|
||||
try:
|
||||
import cm_global
|
||||
cm_global.register_extension('ComfyUI-Impact-Pack',
|
||||
{'version': config.version_code,
|
||||
'name': 'Impact Pack',
|
||||
'nodes': set(NODE_CLASS_MAPPINGS.keys()),
|
||||
'description': 'This extension provides inpainting functionality based on the detector and detailer, along with convenient workflow features like wildcards and logics.', })
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import platform
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
comfy_path = '../..'
|
||||
|
||||
def rmtree(path):
|
||||
retry_count = 3
|
||||
|
||||
while True:
|
||||
try:
|
||||
retry_count -= 1
|
||||
|
||||
if platform.system() == "Windows":
|
||||
subprocess.check_call(['attrib', '-R', path + '\\*', '/S'])
|
||||
|
||||
shutil.rmtree(path)
|
||||
|
||||
return True
|
||||
|
||||
except Exception as ex:
|
||||
print(f"ex: {ex}")
|
||||
time.sleep(3)
|
||||
|
||||
if retry_count < 0:
|
||||
raise ex
|
||||
|
||||
print(f"Uninstall retry({retry_count})")
|
||||
|
||||
js_dest_path = os.path.join(comfy_path, "web", "extensions", "impact-pack")
|
||||
|
||||
if os.path.exists(js_dest_path):
|
||||
rmtree(js_dest_path)
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 112 KiB |
@@ -0,0 +1,596 @@
|
||||
{
|
||||
"last_node_id": 5,
|
||||
"last_link_id": 5,
|
||||
"nodes": [
|
||||
{
|
||||
"id": 1,
|
||||
"type": "LoadImage",
|
||||
"pos": [
|
||||
30,
|
||||
210
|
||||
],
|
||||
"size": [
|
||||
390,
|
||||
320
|
||||
],
|
||||
"flags": {},
|
||||
"order": 0,
|
||||
"mode": 0,
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "IMAGE",
|
||||
"type": "IMAGE",
|
||||
"shape": 3,
|
||||
"links": [
|
||||
1
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MASK",
|
||||
"type": "MASK",
|
||||
"shape": 3,
|
||||
"links": [
|
||||
2
|
||||
]
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "LoadImage"
|
||||
},
|
||||
"widgets_values": [
|
||||
"clipspace/clipspace-mask-609196.2000000011.png [input]",
|
||||
"image"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"type": "PreviewImage",
|
||||
"pos": [
|
||||
1230,
|
||||
210
|
||||
],
|
||||
"size": [
|
||||
210,
|
||||
246
|
||||
],
|
||||
"flags": {},
|
||||
"order": 3,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "images",
|
||||
"type": "IMAGE",
|
||||
"link": 5
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"properties": {
|
||||
"Node name for S&R": "PreviewImage"
|
||||
},
|
||||
"widgets_values": []
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"type": "workflow>Impact::MAKE_BASIC_PIPE",
|
||||
"pos": [
|
||||
20,
|
||||
620
|
||||
],
|
||||
"size": [
|
||||
400,
|
||||
200
|
||||
],
|
||||
"flags": {},
|
||||
"order": 1,
|
||||
"mode": 0,
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "basic_pipe",
|
||||
"type": "BASIC_PIPE",
|
||||
"shape": 3,
|
||||
"links": [
|
||||
3
|
||||
]
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "workflow/Impact::MAKE_BASIC_PIPE"
|
||||
},
|
||||
"widgets_values": [
|
||||
"SD1.5/realcartoon3d_v13.safetensors",
|
||||
"(best quality:1.4), fox girl",
|
||||
"(worst quality:1.4), nsfw"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"type": "MaskDetailerPipe",
|
||||
"pos": [
|
||||
530,
|
||||
210
|
||||
],
|
||||
"size": [
|
||||
569.4000244140625,
|
||||
850
|
||||
],
|
||||
"flags": {},
|
||||
"order": 2,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "image",
|
||||
"type": "IMAGE",
|
||||
"link": 1
|
||||
},
|
||||
{
|
||||
"name": "mask",
|
||||
"type": "MASK",
|
||||
"link": 2
|
||||
},
|
||||
{
|
||||
"name": "basic_pipe",
|
||||
"type": "BASIC_PIPE",
|
||||
"link": 3,
|
||||
"slot_index": 2
|
||||
},
|
||||
{
|
||||
"name": "refiner_basic_pipe_opt",
|
||||
"type": "BASIC_PIPE",
|
||||
"shape": 7,
|
||||
"link": null
|
||||
},
|
||||
{
|
||||
"name": "detailer_hook",
|
||||
"type": "DETAILER_HOOK",
|
||||
"shape": 7,
|
||||
"link": null
|
||||
},
|
||||
{
|
||||
"name": "scheduler_func_opt",
|
||||
"type": "SCHEDULER_FUNC",
|
||||
"shape": 7,
|
||||
"link": null
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "image",
|
||||
"type": "IMAGE",
|
||||
"shape": 3,
|
||||
"links": [
|
||||
5
|
||||
],
|
||||
"slot_index": 0
|
||||
},
|
||||
{
|
||||
"name": "cropped_refined",
|
||||
"type": "IMAGE",
|
||||
"shape": 6,
|
||||
"links": null
|
||||
},
|
||||
{
|
||||
"name": "cropped_enhanced_alpha",
|
||||
"type": "IMAGE",
|
||||
"shape": 6,
|
||||
"links": [
|
||||
4
|
||||
],
|
||||
"slot_index": 2
|
||||
},
|
||||
{
|
||||
"name": "basic_pipe",
|
||||
"type": "BASIC_PIPE",
|
||||
"shape": 3,
|
||||
"links": null
|
||||
},
|
||||
{
|
||||
"name": "refiner_basic_pipe_opt",
|
||||
"type": "BASIC_PIPE",
|
||||
"shape": 3,
|
||||
"links": null
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "MaskDetailerPipe"
|
||||
},
|
||||
"widgets_values": [
|
||||
512,
|
||||
true,
|
||||
1024,
|
||||
true,
|
||||
1003,
|
||||
"fixed",
|
||||
20,
|
||||
8,
|
||||
"euler",
|
||||
"normal",
|
||||
0.75,
|
||||
5,
|
||||
3,
|
||||
10,
|
||||
0.2,
|
||||
1,
|
||||
1,
|
||||
false,
|
||||
20,
|
||||
false,
|
||||
false
|
||||
],
|
||||
"color": "#322",
|
||||
"bgcolor": "#533"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"type": "PreviewImage",
|
||||
"pos": [
|
||||
1230,
|
||||
560
|
||||
],
|
||||
"size": [
|
||||
210,
|
||||
246
|
||||
],
|
||||
"flags": {},
|
||||
"order": 4,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "images",
|
||||
"type": "IMAGE",
|
||||
"link": 4
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"properties": {
|
||||
"Node name for S&R": "PreviewImage"
|
||||
},
|
||||
"widgets_values": []
|
||||
}
|
||||
],
|
||||
"links": [
|
||||
[
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
"IMAGE"
|
||||
],
|
||||
[
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
"MASK"
|
||||
],
|
||||
[
|
||||
3,
|
||||
3,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
"BASIC_PIPE"
|
||||
],
|
||||
[
|
||||
4,
|
||||
2,
|
||||
2,
|
||||
4,
|
||||
0,
|
||||
"IMAGE"
|
||||
],
|
||||
[
|
||||
5,
|
||||
2,
|
||||
0,
|
||||
5,
|
||||
0,
|
||||
"IMAGE"
|
||||
]
|
||||
],
|
||||
"groups": [],
|
||||
"config": {},
|
||||
"extra": {
|
||||
"ds": {
|
||||
"scale": 1,
|
||||
"offset": [
|
||||
80,
|
||||
-110
|
||||
]
|
||||
},
|
||||
"groupNodes": {
|
||||
"Impact::MAKE_BASIC_PIPE": {
|
||||
"author": "Dr.Lt.Data",
|
||||
"category": "",
|
||||
"config": {
|
||||
"1": {
|
||||
"input": {
|
||||
"text": {
|
||||
"name": "Positive prompt"
|
||||
}
|
||||
}
|
||||
},
|
||||
"2": {
|
||||
"input": {
|
||||
"text": {
|
||||
"name": "Negative prompt"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"datetime": 1708272471445,
|
||||
"external": [],
|
||||
"links": [
|
||||
[
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
"CLIP"
|
||||
],
|
||||
[
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
"CLIP"
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
3,
|
||||
0,
|
||||
1,
|
||||
"MODEL"
|
||||
],
|
||||
[
|
||||
0,
|
||||
1,
|
||||
3,
|
||||
1,
|
||||
1,
|
||||
"CLIP"
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
3,
|
||||
2,
|
||||
1,
|
||||
"VAE"
|
||||
],
|
||||
[
|
||||
1,
|
||||
0,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
"CONDITIONING"
|
||||
],
|
||||
[
|
||||
2,
|
||||
0,
|
||||
3,
|
||||
4,
|
||||
4,
|
||||
"CONDITIONING"
|
||||
]
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"flags": {},
|
||||
"index": 0,
|
||||
"mode": 0,
|
||||
"order": 0,
|
||||
"outputs": [
|
||||
{
|
||||
"links": [],
|
||||
"name": "MODEL",
|
||||
"shape": 3,
|
||||
"slot_index": 0,
|
||||
"type": "MODEL",
|
||||
"localized_name": "MODEL"
|
||||
},
|
||||
{
|
||||
"links": [],
|
||||
"name": "CLIP",
|
||||
"shape": 3,
|
||||
"slot_index": 1,
|
||||
"type": "CLIP",
|
||||
"localized_name": "CLIP"
|
||||
},
|
||||
{
|
||||
"links": [],
|
||||
"name": "VAE",
|
||||
"shape": 3,
|
||||
"slot_index": 2,
|
||||
"type": "VAE",
|
||||
"localized_name": "VAE"
|
||||
}
|
||||
],
|
||||
"pos": [
|
||||
550,
|
||||
360
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "CheckpointLoaderSimple"
|
||||
},
|
||||
"size": {
|
||||
"0": 315,
|
||||
"1": 98
|
||||
},
|
||||
"type": "CheckpointLoaderSimple",
|
||||
"widgets_values": [
|
||||
"SDXL/sd_xl_base_1.0_0.9vae.safetensors"
|
||||
],
|
||||
"inputs": []
|
||||
},
|
||||
{
|
||||
"flags": {},
|
||||
"index": 1,
|
||||
"inputs": [
|
||||
{
|
||||
"link": null,
|
||||
"name": "clip",
|
||||
"type": "CLIP",
|
||||
"localized_name": "clip"
|
||||
}
|
||||
],
|
||||
"mode": 0,
|
||||
"order": 1,
|
||||
"outputs": [
|
||||
{
|
||||
"links": [],
|
||||
"name": "CONDITIONING",
|
||||
"shape": 3,
|
||||
"slot_index": 0,
|
||||
"type": "CONDITIONING",
|
||||
"localized_name": "CONDITIONING"
|
||||
}
|
||||
],
|
||||
"pos": [
|
||||
940,
|
||||
480
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "CLIPTextEncode"
|
||||
},
|
||||
"size": {
|
||||
"0": 263,
|
||||
"1": 99
|
||||
},
|
||||
"title": "Positive",
|
||||
"type": "CLIPTextEncode",
|
||||
"widgets_values": [
|
||||
""
|
||||
]
|
||||
},
|
||||
{
|
||||
"flags": {},
|
||||
"index": 2,
|
||||
"inputs": [
|
||||
{
|
||||
"link": null,
|
||||
"name": "clip",
|
||||
"type": "CLIP",
|
||||
"localized_name": "clip"
|
||||
}
|
||||
],
|
||||
"mode": 0,
|
||||
"order": 2,
|
||||
"outputs": [
|
||||
{
|
||||
"links": [],
|
||||
"name": "CONDITIONING",
|
||||
"shape": 3,
|
||||
"slot_index": 0,
|
||||
"type": "CONDITIONING",
|
||||
"localized_name": "CONDITIONING"
|
||||
}
|
||||
],
|
||||
"pos": [
|
||||
940,
|
||||
640
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "CLIPTextEncode"
|
||||
},
|
||||
"size": {
|
||||
"0": 263,
|
||||
"1": 99
|
||||
},
|
||||
"title": "Negative",
|
||||
"type": "CLIPTextEncode",
|
||||
"widgets_values": [
|
||||
""
|
||||
]
|
||||
},
|
||||
{
|
||||
"flags": {},
|
||||
"index": 3,
|
||||
"inputs": [
|
||||
{
|
||||
"link": null,
|
||||
"name": "model",
|
||||
"type": "MODEL",
|
||||
"localized_name": "model"
|
||||
},
|
||||
{
|
||||
"link": null,
|
||||
"name": "clip",
|
||||
"type": "CLIP",
|
||||
"localized_name": "clip"
|
||||
},
|
||||
{
|
||||
"link": null,
|
||||
"name": "vae",
|
||||
"type": "VAE",
|
||||
"localized_name": "vae"
|
||||
},
|
||||
{
|
||||
"link": null,
|
||||
"name": "positive",
|
||||
"type": "CONDITIONING",
|
||||
"localized_name": "positive"
|
||||
},
|
||||
{
|
||||
"link": null,
|
||||
"name": "negative",
|
||||
"type": "CONDITIONING",
|
||||
"localized_name": "negative"
|
||||
}
|
||||
],
|
||||
"mode": 0,
|
||||
"order": 3,
|
||||
"outputs": [
|
||||
{
|
||||
"links": null,
|
||||
"name": "basic_pipe",
|
||||
"shape": 3,
|
||||
"slot_index": 0,
|
||||
"type": "BASIC_PIPE",
|
||||
"localized_name": "basic_pipe"
|
||||
}
|
||||
],
|
||||
"pos": [
|
||||
1320,
|
||||
360
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "ToBasicPipe"
|
||||
},
|
||||
"size": {
|
||||
"0": 241.79998779296875,
|
||||
"1": 106
|
||||
},
|
||||
"type": "ToBasicPipe"
|
||||
}
|
||||
],
|
||||
"packname": "Impact",
|
||||
"version": "1.0"
|
||||
}
|
||||
},
|
||||
"controller_panel": {
|
||||
"controllers": {},
|
||||
"hidden": true,
|
||||
"highlight": true,
|
||||
"version": 2,
|
||||
"default_order": []
|
||||
},
|
||||
"node_versions": {
|
||||
"comfy-core": "0.3.14",
|
||||
"comfyui-impact-pack": "1ae7cae2df8cca06027edfa3a24512671239d6c4"
|
||||
},
|
||||
"ue_links": [],
|
||||
"VHS_latentpreview": false,
|
||||
"VHS_latentpreviewrate": 0,
|
||||
"VHS_MetadataImage": true,
|
||||
"VHS_KeepIntermediate": true
|
||||
},
|
||||
"version": 0.4
|
||||
}
|
||||
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 106 KiB |
|
After Width: | Height: | Size: 67 KiB |
|
After Width: | Height: | Size: 128 KiB |
|
After Width: | Height: | Size: 526 KiB |
@@ -12,13 +12,11 @@ if sys.argv[0] == 'install.py':
|
||||
|
||||
|
||||
impact_path = os.path.join(os.path.dirname(__file__), "modules")
|
||||
subpack_path = os.path.join(os.path.dirname(__file__), "impact_subpack")
|
||||
subpack_repo = "https://github.com/ltdrdata/ComfyUI-Impact-Subpack"
|
||||
|
||||
|
||||
comfy_path = os.environ.get('COMFYUI_PATH')
|
||||
if comfy_path is None:
|
||||
print(f"\n[bold yellow]WARN: The `COMFYUI_PATH` environment variable is not set. Assuming `{os.path.dirname(__file__)}/../../` as the ComfyUI path.[/bold yellow]", file=sys.stderr)
|
||||
print(f"\nWARN: The `COMFYUI_PATH` environment variable is not set. Assuming `{os.path.dirname(__file__)}/../../` as the ComfyUI path.", file=sys.stderr)
|
||||
comfy_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||
|
||||
model_path = os.environ.get('COMFYUI_MODEL_PATH')
|
||||
@@ -31,7 +29,7 @@ if model_path is None:
|
||||
|
||||
if model_path is None:
|
||||
model_path = os.path.abspath(os.path.join(comfy_path, 'models'))
|
||||
print(f"\n[bold yellow]WARN: The `COMFYUI_MODEL_PATH` environment variable is not set. Assuming `{model_path}` as the ComfyUI path.[/bold yellow]", file=sys.stderr)
|
||||
print(f"\nWARN: The `COMFYUI_MODEL_PATH` environment variable is not set. Assuming `{model_path}` as the ComfyUI path.", file=sys.stderr)
|
||||
|
||||
|
||||
sys.path.append(impact_path)
|
||||
@@ -70,63 +68,26 @@ def process_wrap(cmd_str, cwd=None, handler=None, env=None):
|
||||
|
||||
|
||||
try:
|
||||
import platform
|
||||
import folder_paths
|
||||
from torchvision.datasets.utils import download_url
|
||||
import impact.config
|
||||
|
||||
print("### ComfyUI-Impact-Pack: Check dependencies")
|
||||
def ensure_subpack():
|
||||
import git
|
||||
if os.path.exists(subpack_path):
|
||||
try:
|
||||
repo = git.Repo(subpack_path)
|
||||
repo.remotes.origin.pull()
|
||||
except:
|
||||
traceback.print_exc()
|
||||
if platform.system() == 'Windows':
|
||||
print(f"[ComfyUI-Impact-Pack] Please turn off ComfyUI and remove '{subpack_path}' and restart ComfyUI.")
|
||||
else:
|
||||
shutil.rmtree(subpack_path)
|
||||
git.Repo.clone_from(subpack_repo, subpack_path)
|
||||
else:
|
||||
git.Repo.clone_from(subpack_repo, subpack_path)
|
||||
|
||||
|
||||
def install():
|
||||
subpack_install_script = os.path.join(subpack_path, "install.py")
|
||||
|
||||
print(f"### ComfyUI-Impact-Pack: Updating subpack")
|
||||
ensure_subpack() # The installation of the subpack must take place before ensure_pip. cv2 triggers a permission error.
|
||||
|
||||
new_env = os.environ.copy()
|
||||
new_env["COMFYUI_PATH"] = comfy_path
|
||||
new_env["COMFYUI_MODEL_PATH"] = model_path
|
||||
|
||||
if os.path.exists(subpack_install_script):
|
||||
process_wrap([sys.executable, 'install.py'], cwd=subpack_path, env=new_env)
|
||||
else:
|
||||
print(f"### ComfyUI-Impact-Pack: (Install Failed) Subpack\nFile not found: `{subpack_install_script}`")
|
||||
|
||||
# Download model
|
||||
print("### ComfyUI-Impact-Pack: Check basic models")
|
||||
sam_path = os.path.join(model_path, "sams")
|
||||
onnx_path = os.path.join(model_path, "onnx")
|
||||
|
||||
if not os.path.exists(os.path.join(os.path.dirname(__file__), '..', 'skip_download_model')):
|
||||
if not impact.config.get_config()['mmdet_skip']:
|
||||
bbox_path = os.path.join(model_path, "mmdets", "bbox")
|
||||
if not os.path.exists(bbox_path):
|
||||
os.makedirs(bbox_path)
|
||||
|
||||
if not os.path.exists(os.path.join(bbox_path, "mmdet_anime-face_yolov3.pth")):
|
||||
download_url("https://huggingface.co/dustysys/ddetailer/resolve/main/mmdet/bbox/mmdet_anime-face_yolov3.pth", bbox_path)
|
||||
|
||||
if not os.path.exists(os.path.join(bbox_path, "mmdet_anime-face_yolov3.py")):
|
||||
download_url("https://raw.githubusercontent.com/Bing-su/dddetailer/master/config/mmdet_anime-face_yolov3.py", bbox_path)
|
||||
|
||||
if not os.path.exists(os.path.join(sam_path, "sam_vit_b_01ec64.pth")):
|
||||
download_url("https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth", sam_path)
|
||||
try:
|
||||
if not os.path.exists(os.path.join(sam_path, "sam_vit_b_01ec64.pth")):
|
||||
download_url("https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth", sam_path)
|
||||
except:
|
||||
print("[Impact Pack] Failed to auto-download model files. Please download them manually.")
|
||||
|
||||
if not os.path.exists(onnx_path):
|
||||
print(f"### ComfyUI-Impact-Pack: onnx model directory created ({onnx_path})")
|
||||
@@ -134,8 +95,22 @@ try:
|
||||
|
||||
impact.config.write_config()
|
||||
|
||||
# Remove legacy subpack
|
||||
try:
|
||||
subpack_path = os.path.join(os.path.dirname(__file__), 'impact_subpack')
|
||||
if os.path.exists(subpack_path):
|
||||
shutil.rmtree(subpack_path)
|
||||
print(f"Legacy subpack is detected. '{subpack_path}' is removed.")
|
||||
|
||||
subpack_path = os.path.join(os.path.dirname(__file__), 'subpack')
|
||||
if os.path.exists(subpack_path):
|
||||
shutil.rmtree(subpack_path)
|
||||
print(f"Legacy subpack is detected. '{subpack_path}' is removed.")
|
||||
except:
|
||||
print(f"ERROT: Failed to delete legacy subpack '{subpack_path}'\nPlease delete the folder after terminate ComfyUI.")
|
||||
|
||||
install()
|
||||
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
print("[ERROR] ComfyUI-Impact-Pack: Dependency installation has failed. Please install manually.")
|
||||
traceback.print_exc()
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import { ComfyApp, app } from "../../scripts/app.js";
|
||||
|
||||
let conflict_check = undefined;
|
||||
|
||||
app.registerExtension({
|
||||
name: "Comfy.impact.comboBoolMigration",
|
||||
|
||||
nodeCreated(node, app) {
|
||||
for(let i in node.widgets) {
|
||||
let widget = node.widgets[i];
|
||||
|
||||
if(conflict_check == undefined) {
|
||||
conflict_check = !!app.extensions.find((ext) => ext.name === "Comfy.comboBoolMigration");
|
||||
}
|
||||
|
||||
if(conflict_check)
|
||||
return;
|
||||
|
||||
if(widget.type == "toggle") {
|
||||
let value = widget.value;
|
||||
|
||||
var v = Object.getOwnPropertyDescriptor(widget, 'value');
|
||||
if(!v) {
|
||||
Object.defineProperty(widget, "value", {
|
||||
set: (value) => {
|
||||
delete widget.value;
|
||||
widget.value = value == true || value == widget.options.on;
|
||||
},
|
||||
get: () => { return value; }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -3,6 +3,48 @@ import { app } from "../../scripts/app.js";
|
||||
|
||||
let original_show = app.ui.dialog.show;
|
||||
|
||||
export function customAlert(message) {
|
||||
try {
|
||||
app.extensionManager.toast.addAlert(message);
|
||||
}
|
||||
catch {
|
||||
alert(message);
|
||||
}
|
||||
}
|
||||
|
||||
export function isBeforeFrontendVersion(compareVersion) {
|
||||
try {
|
||||
const frontendVersion = window['__COMFYUI_FRONTEND_VERSION__'];
|
||||
if (typeof frontendVersion !== 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
function parseVersion(versionString) {
|
||||
const parts = versionString.split('.').map(Number);
|
||||
return parts.length === 3 && parts.every(part => !isNaN(part)) ? parts : null;
|
||||
}
|
||||
|
||||
const currentVersion = parseVersion(frontendVersion);
|
||||
const comparisonVersion = parseVersion(compareVersion);
|
||||
|
||||
if (!currentVersion || !comparisonVersion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < 3; i++) {
|
||||
if (currentVersion[i] > comparisonVersion[i]) {
|
||||
return false;
|
||||
} else if (currentVersion[i] < comparisonVersion[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function dialog_show_wrapper(html) {
|
||||
if (typeof html === "string") {
|
||||
if(html.includes("IMPACT-PACK-SIGNAL: STOP CONTROL BRIDGE")) {
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import { ComfyApp, app } from "../../scripts/app.js";
|
||||
import { ComfyDialog, $el } from "../../scripts/ui.js";
|
||||
import { api } from "../../scripts/api.js";
|
||||
import { customAlert, isBeforeFrontendVersion } from "./common.js";
|
||||
|
||||
const is_legacy_front = () => isBeforeFrontendVersion('1.16.9');
|
||||
|
||||
if(is_legacy_front()) {
|
||||
customAlert("An outdated version(<1.16.9) of the `comfyui-frontend-package` is installed. It is not compatible with the current version of the Impact Pack.");
|
||||
}
|
||||
|
||||
let wildcards_list = [];
|
||||
async function load_wildcards() {
|
||||
@@ -93,7 +100,7 @@ const input_dirty = {};
|
||||
const output_tracking = {};
|
||||
|
||||
function progressExecuteHandler(event) {
|
||||
if(event.detail.output.aux){
|
||||
if(event.detail?.output?.aux){
|
||||
const id = event.detail.node;
|
||||
if(input_tracking.hasOwnProperty(id)) {
|
||||
if(input_tracking.hasOwnProperty(id) && input_tracking[id][0] != event.detail.output.aux[0]) {
|
||||
@@ -222,6 +229,31 @@ api.addEventListener("executed", progressExecuteHandler);
|
||||
|
||||
app.registerExtension({
|
||||
name: "Comfy.Impack",
|
||||
|
||||
commands: [
|
||||
{
|
||||
id: 'refresh-impact-wildcard',
|
||||
label: 'Impact: Refresh Wildcard',
|
||||
function: async () => {
|
||||
await api.fetchApi('/impact/wildcards/refresh');
|
||||
await load_wildcards();
|
||||
app.extensionManager.toast.add({
|
||||
severity: 'info',
|
||||
summary: 'Refreshed!',
|
||||
detail: 'Impact Wildcard List is refreshed!!',
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
menuCommands: [
|
||||
{
|
||||
path: ['Edit'],
|
||||
commands: ['refresh-impact-wildcard']
|
||||
}
|
||||
],
|
||||
|
||||
loadedGraphNode(node, app) {
|
||||
if (node.comfyClass == "MaskPainter") {
|
||||
input_dirty[node.id + ""] = true;
|
||||
@@ -248,7 +280,7 @@ app.registerExtension({
|
||||
}
|
||||
else {
|
||||
const node = app.graph.getNodeById(link_info.origin_id);
|
||||
slot_type = node.outputs[link_info.origin_slot].type;
|
||||
slot_type = node.outputs[link_info.origin_slot]?.type;
|
||||
}
|
||||
|
||||
this.inputs[0].type = slot_type;
|
||||
@@ -299,6 +331,32 @@ app.registerExtension({
|
||||
}
|
||||
}
|
||||
|
||||
if(nodeData.name == "ImpactSelectNthItemOfAnyList") {
|
||||
const onConnectionsChange = nodeType.prototype.onConnectionsChange;
|
||||
nodeType.prototype.onConnectionsChange = function (type, index, connected, link_info) {
|
||||
if(!link_info || this.inputs[0].type != '*')
|
||||
return;
|
||||
|
||||
if(index >= 2)
|
||||
return;
|
||||
|
||||
// assign type
|
||||
let slot_type = '*';
|
||||
|
||||
if(type == 2) {
|
||||
slot_type = link_info.type;
|
||||
}
|
||||
else {
|
||||
const node = app.graph.getNodeById(link_info.origin_id);
|
||||
slot_type = node.outputs[link_info.origin_slot].type;
|
||||
}
|
||||
|
||||
this.inputs[0].type = slot_type;
|
||||
this.outputs[0].type = slot_type;
|
||||
this.outputs[0].label = slot_type;
|
||||
}
|
||||
}
|
||||
|
||||
if(nodeData.name === 'ImpactInversedSwitch') {
|
||||
nodeData.output = ['*'];
|
||||
nodeData.output_is_list = [false];
|
||||
@@ -312,12 +370,12 @@ app.registerExtension({
|
||||
if(type == 2) {
|
||||
// connect output
|
||||
if(connected){
|
||||
if(app.graph._nodes_by_id[link_info.target_id].type == 'Reroute') {
|
||||
if(app.graph._nodes_by_id[link_info.target_id]?.type == 'Reroute') {
|
||||
app.graph._nodes_by_id[link_info.target_id].disconnectInput(link_info.target_slot);
|
||||
}
|
||||
|
||||
if(this.outputs[0].type == '*'){
|
||||
if(link_info.type == '*') {
|
||||
if(link_info.type == '*' && app.graph.getNodeById(link_info.target_id).slots[link_info.target_slot].type != '*') {
|
||||
app.graph._nodes_by_id[link_info.target_id].disconnectInput(link_info.target_slot);
|
||||
}
|
||||
else {
|
||||
@@ -334,15 +392,19 @@ app.registerExtension({
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(app.graph._nodes_by_id[link_info.origin_id].type == 'Reroute')
|
||||
if(app.graph._nodes_by_id[link_info.origin_id]?.type == 'Reroute')
|
||||
this.disconnectInput(link_info.target_slot);
|
||||
|
||||
// connect input
|
||||
if(this.inputs[0].type == '*'){
|
||||
const node = app.graph.getNodeById(link_info.origin_id);
|
||||
let origin_type = node.outputs[link_info.origin_slot].type;
|
||||
let origin_type = node.outputs[link_info.origin_slot]?.type;
|
||||
|
||||
if(origin_type == '*') {
|
||||
if(origin_type==undefined) {
|
||||
return; // fallback
|
||||
}
|
||||
|
||||
if(origin_type == '*' && app.graph.getNodeById(link_info.origin_id).slots[link_info.origin_slot].type != '*') {
|
||||
this.disconnectInput(link_info.target_slot);
|
||||
return;
|
||||
}
|
||||
@@ -353,7 +415,7 @@ app.registerExtension({
|
||||
}
|
||||
|
||||
this.outputs[0].type = origin_type;
|
||||
this.outputs[0].name = origin_type;
|
||||
this.outputs[0].name = 'output1';
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -366,20 +428,27 @@ app.registerExtension({
|
||||
!stackTrace.includes('LGraphNode.prototype.connect') && // for touch device
|
||||
!stackTrace.includes('LGraphNode.connect') && // for mouse device
|
||||
!stackTrace.includes('loadGraphData')) {
|
||||
if(this.outputs[link_info.origin_slot].links.length == 0)
|
||||
if(this.outputs[link_info.origin_slot].links.length == 0) {
|
||||
this.removeOutput(link_info.origin_slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let slot_i = 1;
|
||||
for (let i = 0; i < this.outputs.length; i++) {
|
||||
this.outputs[i].name = `output${slot_i}`
|
||||
if (this.outputs[i].slot_index === undefined) {
|
||||
this.outputs[i].slot_index = i;
|
||||
}
|
||||
slot_i++;
|
||||
}
|
||||
|
||||
let last_slot = this.outputs[this.outputs.length - 1];
|
||||
if (last_slot.slot_index == link_info.origin_slot) {
|
||||
this.addOutput(`output${slot_i}`, this.outputs[0].type);
|
||||
if(connected) {
|
||||
// NOTE: node.slot_index is different with link_info.origin_slot
|
||||
let last_slot_index = this.outputs.length - 1;
|
||||
if (last_slot_index == link_info.origin_slot) {
|
||||
this.addOutput(`output${slot_i}`, this.outputs[0].type);
|
||||
}
|
||||
}
|
||||
|
||||
let select_slot = this.inputs.find(x => x.name == "select");
|
||||
@@ -442,6 +511,23 @@ app.registerExtension({
|
||||
|
||||
const onConnectionsChange = nodeType.prototype.onConnectionsChange;
|
||||
nodeType.prototype.onConnectionsChange = function (type, index, connected, link_info) {
|
||||
const stackTrace = new Error().stack;
|
||||
if(stackTrace.includes('loadGraphData')) {
|
||||
if(this.widgets?.[0]) {
|
||||
this.widgets[0].options.max = this.inputs.length-3;
|
||||
this.widgets[0].value = Math.min(this.widgets[0].value, this.widgets[0].options.max);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(stackTrace.includes('pasteFromClipboard')) {
|
||||
if(this.widgets?.[0]) {
|
||||
this.widgets[0].options.max = this.inputs.length-3;
|
||||
this.widgets[0].value = Math.min(this.widgets[0].value, this.widgets[0].options.max);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(!link_info)
|
||||
return;
|
||||
|
||||
@@ -453,7 +539,7 @@ app.registerExtension({
|
||||
}
|
||||
|
||||
if(this.outputs[0].type == '*'){
|
||||
if(link_info.type == '*') {
|
||||
if(link_info.type == '*' && app.graph.getNodeById(link_info.target_id).slots[link_info.target_slot].type != '*') {
|
||||
app.graph._nodes_by_id[link_info.target_id].disconnectInput(link_info.target_slot);
|
||||
}
|
||||
else {
|
||||
@@ -483,9 +569,13 @@ app.registerExtension({
|
||||
|
||||
if(this.inputs[0].type == '*'){
|
||||
const node = app.graph.getNodeById(link_info.origin_id);
|
||||
let origin_type = node.outputs[link_info.origin_slot].type;
|
||||
|
||||
if(origin_type == '*') {
|
||||
let origin_type = node.outputs[link_info.origin_slot]?.type;
|
||||
if(link_info.target_slot == 0 && this.inputs.length > 3) { // NOTE: widgets are regarded as input since new front
|
||||
origin_type = this.inputs[1].type;
|
||||
node.connect(link_info.origin_slot, node.id, 'input1');
|
||||
}
|
||||
|
||||
if(origin_type == '*' && app.graph.getNodeById(link_info.origin_id).slots[link_info.origin_slot].type != '*') {
|
||||
this.disconnectInput(link_info.target_slot);
|
||||
return;
|
||||
}
|
||||
@@ -503,15 +593,8 @@ app.registerExtension({
|
||||
}
|
||||
|
||||
let select_slot = this.inputs.find(x => x.name == "select");
|
||||
let mode_slot = this.inputs.find(x => x.name == "sel_mode");
|
||||
|
||||
let converted_count = 0;
|
||||
converted_count += select_slot?1:0;
|
||||
converted_count += mode_slot?1:0;
|
||||
|
||||
if (!connected && (this.inputs.length > 1+converted_count)) {
|
||||
const stackTrace = new Error().stack;
|
||||
|
||||
if (!connected && (this.inputs.length > 3)) {
|
||||
if(
|
||||
!stackTrace.includes('LGraphNode.prototype.connect') && // for touch device
|
||||
!stackTrace.includes('LGraphNode.connect') && // for mouse device
|
||||
@@ -521,6 +604,7 @@ app.registerExtension({
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let slot_i = 1;
|
||||
for (let i = 0; i < this.inputs.length; i++) {
|
||||
let input_i = this.inputs[i];
|
||||
@@ -530,18 +614,13 @@ app.registerExtension({
|
||||
}
|
||||
}
|
||||
|
||||
let last_slot = this.inputs[this.inputs.length - 1];
|
||||
if (
|
||||
(last_slot.name == 'select' && last_slot.name != 'sel_mode' && this.inputs[this.inputs.length - 2].link != undefined)
|
||||
|| (last_slot.name != 'select' && last_slot.name != 'sel_mode' && last_slot.link != undefined)) {
|
||||
this.addInput(`${input_name}${slot_i}`, this.outputs[0].type);
|
||||
if(connected) {
|
||||
this.addInput(`${input_name}${slot_i}`, this.outputs[0].type);
|
||||
}
|
||||
|
||||
if(this.widgets?.length) {
|
||||
this.widgets[0].options.max = select_slot?this.inputs.length-1:this.inputs.length;
|
||||
if(this.widgets?.[0]) {
|
||||
this.widgets[0].options.max = this.inputs.length-3;
|
||||
this.widgets[0].value = Math.min(this.widgets[0].value, this.widgets[0].options.max);
|
||||
if(this.widgets[0].options.max > 0 && this.widgets[0].value == 0)
|
||||
this.widgets[0].value = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -583,17 +662,19 @@ app.registerExtension({
|
||||
}
|
||||
|
||||
if(node.comfyClass == "ImpactSEGSLabelFilter" || node.comfyClass == "SEGSLabelFilterDetailerHookProvider") {
|
||||
node.widgets[0].callback = (value, canvas, node, pos, e) => {
|
||||
if(node) {
|
||||
if(node.widgets[1].value.trim() != "" && !node.widgets[1].value.trim().endsWith(","))
|
||||
node.widgets[1].value += ", "
|
||||
|
||||
node.widgets[1].value += value;
|
||||
if(node.widgets_values)
|
||||
node.widgets_values[1] = node.widgets[1].value;
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(node.widgets[0], "value", {
|
||||
set: (value) => {
|
||||
const stackTrace = new Error().stack;
|
||||
if(stackTrace.includes('inner_value_change')) {
|
||||
if(node.widgets[1].value.trim() != "" && !node.widgets[1].value.trim().endsWith(","))
|
||||
node.widgets[1].value += ", "
|
||||
|
||||
node.widgets[1].value += value;
|
||||
node.widgets_values[1] = node.widgets[1].value;
|
||||
}
|
||||
|
||||
node._value = value;
|
||||
},
|
||||
get: () => {
|
||||
@@ -663,18 +744,20 @@ app.registerExtension({
|
||||
break;
|
||||
}
|
||||
|
||||
node.widgets[combo_id+1].callback = (value, canvas, node, pos, e) => {
|
||||
if(node) {
|
||||
if(node.widgets[tbox_id].value != '')
|
||||
node.widgets[tbox_id].value += ', '
|
||||
|
||||
node.widgets[tbox_id].value += node._wildcard_value;
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(node.widgets[combo_id+1], "value", {
|
||||
set: (value) => {
|
||||
const stackTrace = new Error().stack;
|
||||
if(stackTrace.includes('inner_value_change')) {
|
||||
if(value != "Select the Wildcard to add to the text") {
|
||||
if(node.widgets[tbox_id].value != '')
|
||||
node.widgets[tbox_id].value += ', '
|
||||
|
||||
node.widgets[tbox_id].value += value;
|
||||
}
|
||||
}
|
||||
},
|
||||
if (value !== "Select the Wildcard to add to the text")
|
||||
node._wildcard_value = value;
|
||||
},
|
||||
get: () => { return "Select the Wildcard to add to the text"; }
|
||||
});
|
||||
|
||||
@@ -686,24 +769,24 @@ app.registerExtension({
|
||||
});
|
||||
|
||||
if(has_lora) {
|
||||
node.widgets[combo_id].callback = (value, canvas, node, pos, e) => {
|
||||
if(node) {
|
||||
let lora_name = node._value;
|
||||
if(lora_name.endsWith('.safetensors')) {
|
||||
lora_name = lora_name.slice(0, -12);
|
||||
}
|
||||
|
||||
node.widgets[tbox_id].value += `<lora:${lora_name}>`;
|
||||
if(node.widgets_values) {
|
||||
node.widgets_values[tbox_id] = node.widgets[tbox_id].value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(node.widgets[combo_id], "value", {
|
||||
set: (value) => {
|
||||
const stackTrace = new Error().stack;
|
||||
if(stackTrace.includes('inner_value_change')) {
|
||||
if(value != "Select the LoRA to add to the text") {
|
||||
let lora_name = value;
|
||||
if (lora_name.endsWith('.safetensors')) {
|
||||
lora_name = lora_name.slice(0, -12);
|
||||
}
|
||||
|
||||
node.widgets[tbox_id].value += `<lora:${lora_name}>`;
|
||||
if(node.widgets_values) {
|
||||
node.widgets_values[tbox_id] = node.widgets[tbox_id].value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
node._value = value;
|
||||
if (value !== "Select the LoRA to add to the text")
|
||||
node._value = value;
|
||||
},
|
||||
|
||||
get: () => { return "Select the LoRA to add to the text"; }
|
||||
@@ -728,14 +811,20 @@ app.registerExtension({
|
||||
// mode combo
|
||||
Object.defineProperty(mode_widget, "value", {
|
||||
set: (value) => {
|
||||
node._mode_value = value == true || value == "Populate";
|
||||
populated_text_widget.inputEl.disabled = value == true || value == "Populate";
|
||||
if(value == true)
|
||||
node._mode_value = "populate";
|
||||
else if(value == false)
|
||||
node._mode_value = "fixed";
|
||||
else
|
||||
node._mode_value = value; // combo value
|
||||
|
||||
populated_text_widget.inputEl.disabled = node._mode_value == 'populate';
|
||||
},
|
||||
get: () => {
|
||||
if(node._mode_value != undefined)
|
||||
return node._mode_value;
|
||||
else
|
||||
return true;
|
||||
return 'populate';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ class ImpactSamEditorDialog extends ComfyDialog {
|
||||
const pointsCanvas = document.createElement('canvas');
|
||||
|
||||
imgCanvas.id = "imageCanvas";
|
||||
maskCanvas.id = "maskCanvas";
|
||||
maskCanvas.id = "samEditorMaskCanvas";
|
||||
pointsCanvas.id = "pointsCanvas";
|
||||
|
||||
this.setlayout(imgCanvas, maskCanvas, pointsCanvas);
|
||||
@@ -353,13 +353,16 @@ class ImpactSamEditorDialog extends ComfyDialog {
|
||||
imgCtx.drawImage(orig_image, 0, 0, drawWidth, drawHeight);
|
||||
|
||||
// update mask
|
||||
pointsCanvas.width = drawWidth;
|
||||
pointsCanvas.height = drawHeight;
|
||||
let w = (drawWidth * imgCanvas.clientWidth/imgCanvas.width) + "px";
|
||||
let h = (drawHeight * imgCanvas.clientHeight/imgCanvas.height) + "px";
|
||||
|
||||
pointsCanvas.width = drawWidth * imgCanvas.clientWidth/imgCanvas.width;
|
||||
pointsCanvas.height = drawHeight * imgCanvas.clientHeight/imgCanvas.height;
|
||||
pointsCanvas.style.top = imgCanvas.offsetTop + "px";
|
||||
pointsCanvas.style.left = imgCanvas.offsetLeft + "px";
|
||||
|
||||
maskCanvas.width = drawWidth;
|
||||
maskCanvas.height = drawHeight;
|
||||
maskCanvas.width = pointsCanvas.width;
|
||||
maskCanvas.height = pointsCanvas.height;
|
||||
maskCanvas.style.top = imgCanvas.offsetTop + "px";
|
||||
maskCanvas.style.left = imgCanvas.offsetLeft + "px";
|
||||
|
||||
@@ -473,8 +476,9 @@ class ImpactSamEditorDialog extends ComfyDialog {
|
||||
for(const i in self.prompt_points) {
|
||||
const [is_positive, x, y] = self.prompt_points[i];
|
||||
const point = [x,y];
|
||||
if(is_positive)
|
||||
if(is_positive) {
|
||||
positive_points.push(point);
|
||||
}
|
||||
else
|
||||
negative_points.push(point);
|
||||
}
|
||||
@@ -508,8 +512,8 @@ class ImpactSamEditorDialog extends ComfyDialog {
|
||||
const x = event.offsetX || event.targetTouches[0].clientX - maskRect.left;
|
||||
const y = event.offsetY || event.targetTouches[0].clientY - maskRect.top;
|
||||
|
||||
const originalX = x * self.image.width / self.pointsCanvas.width;
|
||||
const originalY = y * self.image.height / self.pointsCanvas.height;
|
||||
const originalX = x * self.image.width / self.pointsCanvas.clientWidth;
|
||||
const originalY = y * self.image.height / self.pointsCanvas.clientHeight;
|
||||
|
||||
var point = null;
|
||||
if (event.button == 0) {
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import { ComfyApp, app } from "../../scripts/app.js";
|
||||
import { api } from "../../scripts/api.js";
|
||||
|
||||
let refresh_btn = document.getElementById('comfy-refresh-button');
|
||||
let refresh_btn2 = document.querySelector('button[title="Refresh widgets in nodes to find new models or files"]');
|
||||
|
||||
let orig = refresh_btn.onclick;
|
||||
|
||||
if(refresh_btn) {
|
||||
refresh_btn.onclick = function() {
|
||||
orig();
|
||||
api.fetchApi('/impact/wildcards/refresh');
|
||||
};
|
||||
}
|
||||
|
||||
if(refresh_btn2) {
|
||||
refresh_btn2?.addEventListener('click', function() {
|
||||
api.fetchApi('/impact/wildcards/refresh');
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,381 @@
|
||||
import { app } from "/scripts/app.js";
|
||||
function showPreviewCanvas(node, app) {
|
||||
|
||||
const widget = {
|
||||
type: "customCanvas",
|
||||
name: "mask-rect-area-canvas",
|
||||
get value() {
|
||||
return this.canvas.value;
|
||||
},
|
||||
set value(x) {
|
||||
this.canvas.value = x;
|
||||
},
|
||||
draw: function (ctx, node, widgetWidth, widgetY) {
|
||||
|
||||
// If we are initially offscreen when created we wont have received a resize event
|
||||
// Calculate it here instead
|
||||
if (!node.canvasHeight) {
|
||||
computeCanvasSize(node, node.size);
|
||||
}
|
||||
|
||||
const visible = true;
|
||||
const t = ctx.getTransform();
|
||||
const margin = 12;
|
||||
const border = 2;
|
||||
const widgetHeight = node.canvasHeight;
|
||||
const width = Math.round(node.properties["width"]);
|
||||
const height = Math.round(node.properties["height"]);
|
||||
const scale = Math.min((widgetWidth - margin * 3) / width, (widgetHeight - margin * 3) / height);
|
||||
const blurRadius = node.properties["blur_radius"] || 0;
|
||||
const index = 0;
|
||||
|
||||
Object.assign(this.canvas.style, {
|
||||
left: `${t.e}px`,
|
||||
top: `${t.f + (widgetY * t.d)}px`,
|
||||
width: `${widgetWidth * t.a}px`,
|
||||
height: `${widgetHeight * t.d}px`,
|
||||
position: "absolute",
|
||||
zIndex: 1,
|
||||
fontSize: `${t.d * 10.0}px`,
|
||||
pointerEvents: "none"
|
||||
});
|
||||
|
||||
this.canvas.hidden = !visible;
|
||||
|
||||
let backgroundWidth = width * scale;
|
||||
let backgroundHeight = height * scale;
|
||||
|
||||
let xOffset = margin;
|
||||
if (backgroundWidth < widgetWidth) {
|
||||
xOffset += (widgetWidth - backgroundWidth) / 2 - margin;
|
||||
}
|
||||
let yOffset = (margin / 2);
|
||||
if (backgroundHeight < widgetHeight) {
|
||||
yOffset += (widgetHeight - backgroundHeight) / 2 - margin;
|
||||
}
|
||||
|
||||
let widgetX = xOffset;
|
||||
widgetY = widgetY + yOffset;
|
||||
|
||||
// Draw the background border
|
||||
ctx.fillStyle = globalThis.LiteGraph.WIDGET_OUTLINE_COLOR;
|
||||
ctx.fillRect(widgetX - border, widgetY - border, backgroundWidth + border * 2, backgroundHeight + border * 2)
|
||||
|
||||
// Draw the main background area
|
||||
ctx.fillStyle = globalThis.LiteGraph.WIDGET_BGCOLOR;
|
||||
ctx.fillRect(widgetX, widgetY, backgroundWidth, backgroundHeight);
|
||||
|
||||
// Draw the conditioning zone
|
||||
let [x, y, w, h] = getDrawArea(node, backgroundWidth, backgroundHeight);
|
||||
|
||||
ctx.fillStyle = getDrawColor(0, "80");
|
||||
ctx.fillRect(widgetX + x, widgetY + y, w, h);
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth = 1;
|
||||
|
||||
// Draw grid lines
|
||||
for (let x = 0; x <= width / 64; x += 1) {
|
||||
ctx.moveTo(widgetX + x * 64 * scale, widgetY);
|
||||
ctx.lineTo(widgetX + x * 64 * scale, widgetY + backgroundHeight);
|
||||
}
|
||||
|
||||
for (let y = 0; y <= height / 64; y += 1) {
|
||||
ctx.moveTo(widgetX, widgetY + y * 64 * scale);
|
||||
ctx.lineTo(widgetX + backgroundWidth, widgetY + y * 64 * scale);
|
||||
}
|
||||
|
||||
ctx.strokeStyle = "#66666650";
|
||||
ctx.stroke();
|
||||
ctx.closePath();
|
||||
|
||||
// Draw current zone
|
||||
let [sx, sy, sw, sh] = getDrawArea(node, backgroundWidth, backgroundHeight);
|
||||
|
||||
ctx.fillStyle = getDrawColor(0, "80");
|
||||
ctx.fillRect(widgetX + sx, widgetY + sy, sw, sh);
|
||||
|
||||
ctx.fillStyle = getDrawColor(0, "40");
|
||||
ctx.fillRect(widgetX + sx + border, widgetY + sy + border, sw - border * 2, sh - border * 2);
|
||||
|
||||
// Draw white border around the current zone
|
||||
ctx.strokeStyle = globalThis.LiteGraph.NODE_SELECTED_TITLE_COLOR;
|
||||
ctx.lineWidth = 2;
|
||||
ctx.strokeRect(widgetX + sx, widgetY + sy, sw, sh);
|
||||
|
||||
// Display
|
||||
ctx.beginPath();
|
||||
|
||||
ctx.arc(LiteGraph.NODE_SLOT_HEIGHT * 0.5, LiteGraph.NODE_SLOT_HEIGHT * (index + 0.5) + 4, 4, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
|
||||
ctx.lineWidth = 1;
|
||||
ctx.strokeStyle = "white";
|
||||
ctx.stroke();
|
||||
|
||||
ctx.lineWidth = 1;
|
||||
ctx.closePath();
|
||||
|
||||
// Draw progress bar canvas
|
||||
if (backgroundWidth < widgetWidth) {
|
||||
xOffset += (widgetWidth - backgroundWidth) / 2 - margin;
|
||||
}
|
||||
|
||||
// Ajustar las coordenadas X e Y
|
||||
const barHeight = 8;
|
||||
let widgetYBar = widgetY + backgroundHeight + margin;
|
||||
|
||||
// Dibujar el borde negro alrededor de la barra
|
||||
ctx.fillStyle = globalThis.LiteGraph.WIDGET_OUTLINE_COLOR;
|
||||
ctx.fillRect(
|
||||
widgetX - border,
|
||||
widgetYBar - border,
|
||||
backgroundWidth + border * 2,
|
||||
barHeight + border * 2
|
||||
);
|
||||
|
||||
// Dibujar el área principal de la barra (fondo)
|
||||
ctx.fillStyle = globalThis.LiteGraph.WIDGET_BGCOLOR; // Mismo color de fondo que el canvas
|
||||
ctx.fillRect(
|
||||
widgetX,
|
||||
widgetYBar,
|
||||
backgroundWidth,
|
||||
barHeight
|
||||
);
|
||||
|
||||
|
||||
// Draw progress bar grid
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth = 1;
|
||||
ctx.strokeStyle = "#66666650";
|
||||
|
||||
// Calcular el número de líneas en función del tamaño de la barra
|
||||
const numLines = Math.floor(backgroundWidth / 64);
|
||||
|
||||
// Dibujar líneas del grid
|
||||
for (let x = 0; x <= width / 64; x += 1) {
|
||||
ctx.moveTo(widgetX + x * 64 * scale, widgetYBar);
|
||||
ctx.lineTo(widgetX + x * 64 * scale, widgetYBar + barHeight);
|
||||
}
|
||||
ctx.stroke();
|
||||
ctx.closePath();
|
||||
|
||||
// Dibujar progreso (basado en blur_radius)
|
||||
const progress = Math.min(blurRadius / 255, 1);
|
||||
ctx.fillStyle = "rgba(0, 120, 255, 0.5)";
|
||||
|
||||
ctx.fillRect(
|
||||
widgetX,
|
||||
widgetYBar,
|
||||
backgroundWidth * progress,
|
||||
barHeight
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
widget.canvas = document.createElement("canvas");
|
||||
widget.canvas.className = "mask-rect-area-canvas";
|
||||
widget.parent = node;
|
||||
|
||||
document.body.appendChild(widget.canvas);
|
||||
node.addCustomWidget(widget);
|
||||
|
||||
app.canvas.onDrawBackground = function () {
|
||||
// Draw node isnt fired once the node is off the screen
|
||||
// if it goes off screen quickly, the input may not be removed
|
||||
// this shifts it off screen so it can be moved back if the node is visible.
|
||||
for (let n in app.graph._nodes) {
|
||||
n = app.graph._nodes[n];
|
||||
for (let w in n.widgets) {
|
||||
let wid = n.widgets[w];
|
||||
if (Object.hasOwn(wid, "canvas")) {
|
||||
wid.canvas.style.left = -8000 + "px";
|
||||
wid.canvas.style.position = "absolute";
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
node.onResize = function (size) {
|
||||
computeCanvasSize(node, size);
|
||||
};
|
||||
|
||||
return {minWidth: 200, minHeight: 200, widget};
|
||||
}
|
||||
|
||||
app.registerExtension({
|
||||
name: 'drltdata.MaskRectAreaAdvanced',
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||
if (nodeData.name === "MaskRectAreaAdvanced") {
|
||||
const onNodeCreated = nodeType.prototype.onNodeCreated;
|
||||
nodeType.prototype.onNodeCreated = function () {
|
||||
const r = onNodeCreated ? onNodeCreated.apply(this, arguments) : undefined;
|
||||
|
||||
this.setProperty("width", 512);
|
||||
this.setProperty("height", 512);
|
||||
this.setProperty("x", 0);
|
||||
this.setProperty("y", 0);
|
||||
this.setProperty("w", 256);
|
||||
this.setProperty("h", 256);
|
||||
this.setProperty("blur_radius", 0);
|
||||
|
||||
this.selected = false;
|
||||
this.index = 3;
|
||||
this.serialize_widgets = true;
|
||||
|
||||
CUSTOM_INT(this, "x", 0, function (v, _, node) {
|
||||
const s = this.options.step / 10;
|
||||
this.value = Math.round(v / s) * s;
|
||||
node.properties["x"] = this.value;
|
||||
});
|
||||
CUSTOM_INT(this, "y", 0, function (v, _, node) {
|
||||
const s = this.options.step / 10;
|
||||
this.value = Math.round(v / s) * s;
|
||||
node.properties["y"] = this.value;
|
||||
});
|
||||
CUSTOM_INT(this, "width", 256, function (v, _, node) {
|
||||
const s = this.options.step / 10;
|
||||
this.value = Math.round(v / s) * s;
|
||||
node.properties["w"] = this.value;
|
||||
});
|
||||
CUSTOM_INT(this, "height", 256, function (v, _, node) {
|
||||
const s = this.options.step / 10;
|
||||
this.value = Math.round(v / s) * s;
|
||||
node.properties["h"] = this.value;
|
||||
});
|
||||
CUSTOM_INT(this, "image_width", 512, function (v, _, node) {
|
||||
const s = this.options.step / 10;
|
||||
this.value = Math.round(v / s) * s;
|
||||
node.properties["width"] = this.value;
|
||||
});
|
||||
CUSTOM_INT(this, "image_height", 512, function (v, _, node) {
|
||||
const s = this.options.step / 10;
|
||||
this.value = Math.round(v / s) * s;
|
||||
node.properties["height"] = this.value;
|
||||
});
|
||||
CUSTOM_INT(this, "blur_radius", 0, function (v, _, node) {
|
||||
this.value = Math.round(v) || 0;
|
||||
node.properties["blur_radius"] = this.value;
|
||||
},
|
||||
{"min": 0, "max": 255, "step": 10}
|
||||
);
|
||||
|
||||
showPreviewCanvas(this, app);
|
||||
|
||||
this.onSelected = function () {
|
||||
this.selected = true;
|
||||
};
|
||||
this.onDeselected = function () {
|
||||
this.selected = false;
|
||||
};
|
||||
|
||||
return r;
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Calculate the drawing area using individual properties.
|
||||
function getDrawArea(node, backgroundWidth, backgroundHeight) {
|
||||
let x = node.properties["x"] * backgroundWidth / node.properties["width"];
|
||||
let y = node.properties["y"] * backgroundHeight / node.properties["height"];
|
||||
let w = node.properties["w"] * backgroundWidth / node.properties["width"];
|
||||
let h = node.properties["h"] * backgroundHeight / node.properties["height"];
|
||||
|
||||
if (x > backgroundWidth) {
|
||||
x = backgroundWidth;
|
||||
}
|
||||
if (y > backgroundHeight) {
|
||||
y = backgroundHeight;
|
||||
}
|
||||
|
||||
if (x + w > backgroundWidth) {
|
||||
w = Math.max(0, backgroundWidth - x);
|
||||
}
|
||||
|
||||
if (y + h > backgroundHeight) {
|
||||
h = Math.max(0, backgroundHeight - y);
|
||||
}
|
||||
|
||||
return [x, y, w, h];
|
||||
}
|
||||
|
||||
function CUSTOM_INT(node, inputName, val, func, config = {}) {
|
||||
return {
|
||||
widget: node.addWidget(
|
||||
"number",
|
||||
inputName,
|
||||
val,
|
||||
func,
|
||||
Object.assign({}, {min: 0, max: 4096, step: 640, precision: 0}, config)
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
function getDrawColor(percent, alpha) {
|
||||
let h = 360 * percent;
|
||||
let s = 50;
|
||||
let l = 50;
|
||||
l /= 100;
|
||||
const a = s * Math.min(l, 1 - l) / 100;
|
||||
const f = n => {
|
||||
const k = (n + h / 30) % 12;
|
||||
const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
||||
return Math.round(255 * color).toString(16).padStart(2, '0'); // convert to Hex and prefix "0" if needed
|
||||
};
|
||||
return `#${f(0)}${f(8)}${f(4)}${alpha}`;
|
||||
}
|
||||
|
||||
function computeCanvasSize(node, size) {
|
||||
if (node.widgets[0].last_y == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const MIN_HEIGHT = 220;
|
||||
const MIN_WIDTH = 240;
|
||||
|
||||
let y = LiteGraph.NODE_WIDGET_HEIGHT * Math.max(node.inputs.length, node.outputs.length) + 5;
|
||||
let freeSpace = size[1] - y;
|
||||
|
||||
// Compute the height of all non-customCanvas widgets
|
||||
let widgetHeight = 0;
|
||||
for (let i = 0; i < node.widgets.length; i++) {
|
||||
const w = node.widgets[i];
|
||||
if (w.type !== "customCanvas") {
|
||||
if (w.computeSize) {
|
||||
widgetHeight += w.computeSize()[1] + 4;
|
||||
} else {
|
||||
widgetHeight += LiteGraph.NODE_WIDGET_HEIGHT + 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure there is enough vertical space
|
||||
freeSpace -= widgetHeight;
|
||||
|
||||
// Adjust the height of the node if needed
|
||||
if (freeSpace < MIN_HEIGHT) {
|
||||
freeSpace = MIN_HEIGHT;
|
||||
node.size[1] = y + widgetHeight + freeSpace;
|
||||
node.graph.setDirtyCanvas(true);
|
||||
}
|
||||
|
||||
// Ensure the node width meets the minimum width requirement
|
||||
if (node.size[0] < MIN_WIDTH) {
|
||||
node.size[0] = MIN_WIDTH;
|
||||
node.graph.setDirtyCanvas(true);
|
||||
}
|
||||
|
||||
// Position each of the widgets
|
||||
for (const w of node.widgets) {
|
||||
w.y = y;
|
||||
if (w.type === "customCanvas") {
|
||||
y += freeSpace;
|
||||
} else if (w.computeSize) {
|
||||
y += w.computeSize()[1] + 4;
|
||||
} else {
|
||||
y += LiteGraph.NODE_WIDGET_HEIGHT + 4;
|
||||
}
|
||||
}
|
||||
|
||||
node.canvasHeight = freeSpace;
|
||||
}
|
||||
@@ -0,0 +1,366 @@
|
||||
import { app } from "/scripts/app.js";
|
||||
function showPreviewCanvas(node, app) {
|
||||
|
||||
const widget = {
|
||||
type: "customCanvas",
|
||||
name: "mask-rect-area-canvas",
|
||||
get value() {
|
||||
return this.canvas.value;
|
||||
},
|
||||
set value(x) {
|
||||
this.canvas.value = x;
|
||||
},
|
||||
draw: function (ctx, node, widgetWidth, widgetY) {
|
||||
|
||||
// If we are initially offscreen when created we wont have received a resize event
|
||||
// Calculate it here instead
|
||||
if (!node.canvasHeight) {
|
||||
computeCanvasSize(node, node.size);
|
||||
}
|
||||
|
||||
const visible = true;
|
||||
const t = ctx.getTransform();
|
||||
const margin = 12;
|
||||
const border = 2;
|
||||
const widgetHeight = node.canvasHeight;
|
||||
const width = 512;
|
||||
const height = 512;
|
||||
const scale = Math.min((widgetWidth - margin * 3) / width, (widgetHeight - margin * 3) / height);
|
||||
const blurRadius = node.properties["blur_radius"] || 0;
|
||||
const index = 0;
|
||||
|
||||
Object.assign(this.canvas.style, {
|
||||
left: `${t.e}px`,
|
||||
top: `${t.f + (widgetY * t.d)}px`,
|
||||
width: `${widgetWidth * t.a}px`,
|
||||
height: `${widgetHeight * t.d}px`,
|
||||
position: "absolute",
|
||||
zIndex: 1,
|
||||
fontSize: `${t.d * 10.0}px`,
|
||||
pointerEvents: "none"
|
||||
});
|
||||
|
||||
this.canvas.hidden = !visible;
|
||||
|
||||
let backgroundWidth = width * scale;
|
||||
let backgroundHeight = height * scale;
|
||||
let xOffset = margin;
|
||||
if (backgroundWidth < widgetWidth) {
|
||||
xOffset += (widgetWidth - backgroundWidth) / 2 - margin;
|
||||
}
|
||||
let yOffset = (margin / 2);
|
||||
if (backgroundHeight < widgetHeight) {
|
||||
yOffset += (widgetHeight - backgroundHeight) / 2 - margin;
|
||||
}
|
||||
|
||||
let widgetX = xOffset;
|
||||
widgetY = widgetY + yOffset;
|
||||
|
||||
// Draw the background border
|
||||
ctx.fillStyle = globalThis.LiteGraph.WIDGET_OUTLINE_COLOR;
|
||||
ctx.fillRect(widgetX - border, widgetY - border, backgroundWidth + border * 2, backgroundHeight + border * 2);
|
||||
|
||||
// Draw the main background area
|
||||
ctx.fillStyle = globalThis.LiteGraph.WIDGET_BGCOLOR;
|
||||
ctx.fillRect(widgetX, widgetY, backgroundWidth, backgroundHeight);
|
||||
|
||||
// Draw the conditioning zone
|
||||
let [x, y, w, h] = getDrawArea(node, backgroundWidth, backgroundHeight);
|
||||
|
||||
ctx.fillStyle = getDrawColor(0, "80");
|
||||
ctx.fillRect(widgetX + x, widgetY + y, w, h);
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth = 1;
|
||||
|
||||
// Draw grid lines
|
||||
for (let x = 0; x <= width / 64; x += 1) {
|
||||
ctx.moveTo(widgetX + x * 64 * scale, widgetY);
|
||||
ctx.lineTo(widgetX + x * 64 * scale, widgetY + backgroundHeight);
|
||||
}
|
||||
|
||||
for (let y = 0; y <= height / 64; y += 1) {
|
||||
ctx.moveTo(widgetX, widgetY + y * 64 * scale);
|
||||
ctx.lineTo(widgetX + backgroundWidth, widgetY + y * 64 * scale);
|
||||
}
|
||||
|
||||
ctx.strokeStyle = "#66666650";
|
||||
ctx.stroke();
|
||||
ctx.closePath();
|
||||
|
||||
// Draw current zone
|
||||
let [sx, sy, sw, sh] = getDrawArea(node, backgroundWidth, backgroundHeight);
|
||||
|
||||
ctx.fillStyle = getDrawColor(0, "80");
|
||||
ctx.fillRect(widgetX + sx, widgetY + sy, sw, sh);
|
||||
|
||||
ctx.fillStyle = getDrawColor(0, "40");
|
||||
ctx.fillRect(widgetX + sx + border, widgetY + sy + border, sw - border * 2, sh - border * 2);
|
||||
|
||||
// Draw white border around the current zone
|
||||
ctx.strokeStyle = globalThis.LiteGraph.NODE_SELECTED_TITLE_COLOR;
|
||||
ctx.lineWidth = 2;
|
||||
ctx.strokeRect(widgetX + sx, widgetY + sy, sw, sh);
|
||||
//ctx.strokeRect(finalSX, finalSY, finalSW, finalSH);
|
||||
|
||||
// Display
|
||||
ctx.beginPath();
|
||||
|
||||
ctx.arc(LiteGraph.NODE_SLOT_HEIGHT * 0.5, LiteGraph.NODE_SLOT_HEIGHT * (index + 0.5) + 4, 4, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
|
||||
ctx.lineWidth = 1;
|
||||
ctx.strokeStyle = "white";
|
||||
ctx.stroke();
|
||||
ctx.lineWidth = 1;
|
||||
ctx.closePath();
|
||||
|
||||
// Draw progress bar canvas
|
||||
if (backgroundWidth < widgetWidth) {
|
||||
xOffset += (widgetWidth - backgroundWidth) / 2 - margin;
|
||||
}
|
||||
|
||||
const barHeight = 8;
|
||||
let widgetYBar = widgetY + backgroundHeight + margin;
|
||||
|
||||
// Draw progress bar border
|
||||
ctx.fillStyle = globalThis.LiteGraph.WIDGET_OUTLINE_COLOR;
|
||||
ctx.fillRect(
|
||||
widgetX - border,
|
||||
widgetYBar - border,
|
||||
backgroundWidth + border * 2,
|
||||
barHeight + border * 2
|
||||
);
|
||||
|
||||
// Draw progress bar area
|
||||
ctx.fillStyle = globalThis.LiteGraph.WIDGET_BGCOLOR; // Mismo color de fondo que el canvas
|
||||
ctx.fillRect(
|
||||
widgetX,
|
||||
widgetYBar,
|
||||
backgroundWidth,
|
||||
barHeight
|
||||
);
|
||||
|
||||
// Draw progress bar grid
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth = 1;
|
||||
ctx.strokeStyle = "#66666650";
|
||||
|
||||
// Determine max lines
|
||||
const numLines = Math.floor(backgroundWidth / 64);
|
||||
|
||||
// Draw progress bar grid
|
||||
for (let x = 0; x <= width / 64; x += 1) {
|
||||
ctx.moveTo(widgetX + x * 64 * scale, widgetYBar);
|
||||
ctx.lineTo(widgetX + x * 64 * scale, widgetYBar + barHeight);
|
||||
}
|
||||
ctx.stroke();
|
||||
ctx.closePath();
|
||||
|
||||
// Draw progress bar
|
||||
const progress = Math.min(blurRadius / 255, 1);
|
||||
ctx.fillStyle = "rgba(0, 120, 255, 0.5)";
|
||||
|
||||
ctx.fillRect(
|
||||
widgetX,
|
||||
widgetYBar,
|
||||
backgroundWidth * progress,
|
||||
barHeight
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
widget.canvas = document.createElement("canvas");
|
||||
widget.canvas.className = "mask-rect-area-canvas";
|
||||
widget.parent = node;
|
||||
|
||||
document.body.appendChild(widget.canvas);
|
||||
node.addCustomWidget(widget);
|
||||
|
||||
app.canvas.onDrawBackground = function () {
|
||||
// Draw node isnt fired once the node is off the screen
|
||||
// if it goes off screen quickly, the input may not be removed
|
||||
// this shifts it off screen so it can be moved back if the node is visible.
|
||||
for (let n in app.graph._nodes) {
|
||||
n = app.graph._nodes[n];
|
||||
for (let w in n.widgets) {
|
||||
let wid = n.widgets[w];
|
||||
if (Object.hasOwn(wid, "canvas")) {
|
||||
wid.canvas.style.left = -8000 + "px";
|
||||
wid.canvas.style.position = "absolute";
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
node.onResize = function (size) {
|
||||
computeCanvasSize(node, size);
|
||||
};
|
||||
|
||||
return {minWidth: 200, minHeight: 200, widget};
|
||||
}
|
||||
|
||||
app.registerExtension({
|
||||
name: 'drltdata.MaskRectArea',
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||
if (nodeData.name === "MaskRectArea") {
|
||||
const onNodeCreated = nodeType.prototype.onNodeCreated;
|
||||
nodeType.prototype.onNodeCreated = function () {
|
||||
const r = onNodeCreated ? onNodeCreated.apply(this, arguments) : undefined;
|
||||
|
||||
this.setProperty("width", 512);
|
||||
this.setProperty("height", 512);
|
||||
this.setProperty("x", 0);
|
||||
this.setProperty("y", 0);
|
||||
this.setProperty("w", 50);
|
||||
this.setProperty("h", 50);
|
||||
this.setProperty("blur_radius", 0);
|
||||
|
||||
this.selected = false;
|
||||
this.index = 3;
|
||||
this.serialize_widgets = true;
|
||||
|
||||
CUSTOM_INT(this, "x", 0, function (v, _, node) {
|
||||
this.value = Math.max(0, Math.min(100, Math.round(v))); // Limitar entre 0 y 100
|
||||
node.properties["x"] = this.value;
|
||||
});
|
||||
CUSTOM_INT(this, "y", 0, function (v, _, node) {
|
||||
this.value = Math.max(0, Math.min(100, Math.round(v)));
|
||||
node.properties["y"] = this.value;
|
||||
});
|
||||
CUSTOM_INT(this, "w", 50, function (v, _, node) {
|
||||
this.value = Math.max(0, Math.min(100, Math.round(v)));
|
||||
node.properties["w"] = this.value;
|
||||
});
|
||||
CUSTOM_INT(this, "h", 50, function (v, _, node) {
|
||||
this.value = Math.max(0, Math.min(100, Math.round(v)));
|
||||
node.properties["h"] = this.value;
|
||||
});
|
||||
CUSTOM_INT(this, "blur_radius", 0, function (v, _, node) {
|
||||
this.value = Math.round(v) || 0;
|
||||
node.properties["blur_radius"] = this.value;
|
||||
},
|
||||
{"min": 0, "max": 255, "step": 10}
|
||||
);
|
||||
|
||||
showPreviewCanvas(this, app);
|
||||
|
||||
this.onSelected = function () {
|
||||
this.selected = true;
|
||||
};
|
||||
this.onDeselected = function () {
|
||||
this.selected = false;
|
||||
};
|
||||
|
||||
return r;
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Calculate the drawing area using percentage-based properties.
|
||||
function getDrawArea(node, backgroundWidth, backgroundHeight) {
|
||||
// Convert percentages to actual pixel values based on the background dimensions
|
||||
let x = (node.properties["x"] / 100) * backgroundWidth;
|
||||
let y = (node.properties["y"] / 100) * backgroundHeight;
|
||||
let w = (node.properties["w"] / 100) * backgroundWidth;
|
||||
let h = (node.properties["h"] / 100) * backgroundHeight;
|
||||
|
||||
// Ensure the values do not exceed the background boundaries
|
||||
if (x > backgroundWidth) {
|
||||
x = backgroundWidth;
|
||||
}
|
||||
if (y > backgroundHeight) {
|
||||
y = backgroundHeight;
|
||||
}
|
||||
|
||||
// Adjust width and height to fit within the background dimensions
|
||||
if (x + w > backgroundWidth) {
|
||||
w = Math.max(0, backgroundWidth - x);
|
||||
}
|
||||
if (y + h > backgroundHeight) {
|
||||
h = Math.max(0, backgroundHeight - y);
|
||||
}
|
||||
|
||||
return [x, y, w, h];
|
||||
}
|
||||
|
||||
function CUSTOM_INT(node, inputName, val, func, config = {}) {
|
||||
return {
|
||||
widget: node.addWidget(
|
||||
"number",
|
||||
inputName,
|
||||
val,
|
||||
func,
|
||||
Object.assign({}, {min: 0, max: 100, step: 10, precision: 0}, config)
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
function getDrawColor(percent, alpha) {
|
||||
let h = 360 * percent;
|
||||
let s = 50;
|
||||
let l = 50;
|
||||
l /= 100;
|
||||
const a = s * Math.min(l, 1 - l) / 100;
|
||||
const f = n => {
|
||||
const k = (n + h / 30) % 12;
|
||||
const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
||||
return Math.round(255 * color).toString(16).padStart(2, '0'); // convert to Hex and prefix "0" if needed
|
||||
};
|
||||
return `#${f(0)}${f(8)}${f(4)}${alpha}`;
|
||||
}
|
||||
|
||||
function computeCanvasSize(node, size) {
|
||||
if (node.widgets[0].last_y == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const MIN_HEIGHT = 200;
|
||||
const MIN_WIDTH = 200;
|
||||
|
||||
let y = LiteGraph.NODE_WIDGET_HEIGHT * Math.max(node.inputs.length, node.outputs.length) + 5;
|
||||
let freeSpace = size[1] - y;
|
||||
|
||||
// Compute the height of all non-customCanvas widgets
|
||||
let widgetHeight = 0;
|
||||
for (let i = 0; i < node.widgets.length; i++) {
|
||||
const w = node.widgets[i];
|
||||
if (w.type !== "customCanvas") {
|
||||
if (w.computeSize) {
|
||||
widgetHeight += w.computeSize()[1] + 4;
|
||||
} else {
|
||||
widgetHeight += LiteGraph.NODE_WIDGET_HEIGHT + 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure there is enough vertical space
|
||||
freeSpace -= widgetHeight;
|
||||
|
||||
// Adjust the height of the node if needed
|
||||
if (freeSpace < MIN_HEIGHT) {
|
||||
freeSpace = MIN_HEIGHT;
|
||||
node.size[1] = y + widgetHeight + freeSpace;
|
||||
node.graph.setDirtyCanvas(true);
|
||||
}
|
||||
|
||||
// Ensure the node width meets the minimum width requirement
|
||||
if (node.size[0] < MIN_WIDTH) {
|
||||
node.size[0] = MIN_WIDTH;
|
||||
node.graph.setDirtyCanvas(true);
|
||||
}
|
||||
|
||||
// Position each of the widgets
|
||||
for (const w of node.widgets) {
|
||||
w.y = y;
|
||||
if (w.type === "customCanvas") {
|
||||
y += freeSpace;
|
||||
} else if (w.computeSize) {
|
||||
y += w.computeSize()[1] + 4;
|
||||
} else {
|
||||
y += LiteGraph.NODE_WIDGET_HEIGHT + 4;
|
||||
}
|
||||
}
|
||||
|
||||
node.canvasHeight = freeSpace;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import subprocess
|
||||
|
||||
def ensure_onnx_package():
|
||||
try:
|
||||
import onnxruntime
|
||||
import onnxruntime # noqa: F401
|
||||
except Exception:
|
||||
if "python_embeded" in sys.executable or "python_embedded" in sys.executable:
|
||||
subprocess.check_call([sys.executable, '-s', '-m', 'pip', 'install', 'onnxruntime'])
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
from nodes import MAX_RESOLUTION
|
||||
from impact.utils import *
|
||||
import impact.core as core
|
||||
from impact.core import SEG
|
||||
from impact.segs_nodes import SEGSPaste
|
||||
|
||||
import comfy
|
||||
from impact import utils
|
||||
import torch
|
||||
import nodes
|
||||
import logging
|
||||
|
||||
try:
|
||||
from comfy_extras import nodes_differential_diffusion
|
||||
except Exception:
|
||||
print(f"\n#############################################\n[Impact Pack] ComfyUI is an outdated version.\n#############################################\n")
|
||||
logging.warning("\n#############################################\n[Impact Pack] ComfyUI is an outdated version.\n#############################################\n")
|
||||
raise Exception("[Impact Pack] ComfyUI is an outdated version.")
|
||||
|
||||
|
||||
@@ -27,7 +30,7 @@ class SEGSDetailerForAnimateDiff:
|
||||
"sampler_name": (comfy.samplers.KSampler.SAMPLERS,),
|
||||
"scheduler": (core.SCHEDULERS,),
|
||||
"denoise": ("FLOAT", {"default": 0.5, "min": 0.0001, "max": 1.0, "step": 0.01}),
|
||||
"basic_pipe": ("BASIC_PIPE",),
|
||||
"basic_pipe": ("BASIC_PIPE", {"tooltip": "If the `ImpactDummyInput` is connected to the model in the basic_pipe, the inference stage is skipped."}),
|
||||
"refiner_ratio": ("FLOAT", {"default": 0.2, "min": 0.0, "max": 1.0}),
|
||||
},
|
||||
"optional": {
|
||||
@@ -45,6 +48,8 @@ class SEGSDetailerForAnimateDiff:
|
||||
|
||||
CATEGORY = "ImpactPack/Detailer"
|
||||
|
||||
DESCRIPTION = "This node enhances details by inpainting each region within the detected area bundle (SEGS) after enlarging them based on the guide size.\nThis node is applied specifically to SEGS rather than the entire image. To apply it to the entire image, use the 'SEGS Paste' node.\nAs a specialized detailer node for improving video details, such as in AnimateDiff, this node can handle cases where the masks contained in SEGS serve as batch masks spanning multiple frames."
|
||||
|
||||
@staticmethod
|
||||
def do_detail(image_frames, segs, guide_size, guide_size_for, max_size, seed, steps, cfg, sampler_name, scheduler,
|
||||
denoise, basic_pipe, refiner_ratio=None, refiner_basic_pipe_opt=None, noise_mask_feather=0, scheduler_func_opt=None):
|
||||
@@ -60,7 +65,7 @@ class SEGSDetailerForAnimateDiff:
|
||||
new_segs = []
|
||||
cnet_image_list = []
|
||||
|
||||
if noise_mask_feather > 0 and 'denoise_mask_function' not in model.model_options:
|
||||
if not (isinstance(model, str) and model == "DUMMY") and noise_mask_feather > 0 and 'denoise_mask_function' not in model.model_options:
|
||||
model = nodes_differential_diffusion.DifferentialDiffusion().apply(model)[0]
|
||||
|
||||
for seg in segs[1]:
|
||||
@@ -68,8 +73,8 @@ class SEGSDetailerForAnimateDiff:
|
||||
|
||||
for image in image_frames:
|
||||
image = image.unsqueeze(0)
|
||||
cropped_image = seg.cropped_image if seg.cropped_image is not None else crop_tensor4(image, seg.crop_region)
|
||||
cropped_image = to_tensor(cropped_image)
|
||||
cropped_image = seg.cropped_image if seg.cropped_image is not None else utils.crop_tensor4(image, seg.crop_region)
|
||||
cropped_image = utils.to_tensor(cropped_image)
|
||||
if cropped_image_frames is None:
|
||||
cropped_image_frames = cropped_image
|
||||
else:
|
||||
@@ -94,13 +99,18 @@ class SEGSDetailerForAnimateDiff:
|
||||
for condition, details in negative
|
||||
]
|
||||
|
||||
enhanced_image_tensor, cnet_images = core.enhance_detail_for_animatediff(cropped_image_frames, model, clip, vae, guide_size, guide_size_for, max_size,
|
||||
seg.bbox, seed, steps, cfg, sampler_name, scheduler,
|
||||
cropped_positive, cropped_negative, denoise, seg.cropped_mask,
|
||||
refiner_ratio=refiner_ratio, refiner_model=refiner_model,
|
||||
refiner_clip=refiner_clip, refiner_positive=refiner_positive,
|
||||
refiner_negative=refiner_negative, control_net_wrapper=seg.control_net_wrapper,
|
||||
noise_mask_feather=noise_mask_feather, scheduler_func=scheduler_func_opt)
|
||||
if not (isinstance(model, str) and model == "DUMMY"):
|
||||
enhanced_image_tensor, cnet_images = core.enhance_detail_for_animatediff(cropped_image_frames, model, clip, vae, guide_size, guide_size_for, max_size,
|
||||
seg.bbox, seed, steps, cfg, sampler_name, scheduler,
|
||||
cropped_positive, cropped_negative, denoise, seg.cropped_mask,
|
||||
refiner_ratio=refiner_ratio, refiner_model=refiner_model,
|
||||
refiner_clip=refiner_clip, refiner_positive=refiner_positive,
|
||||
refiner_negative=refiner_negative, control_net_wrapper=seg.control_net_wrapper,
|
||||
noise_mask_feather=noise_mask_feather, scheduler_func=scheduler_func_opt)
|
||||
else:
|
||||
enhanced_image_tensor = cropped_image_frames
|
||||
cnet_images = None
|
||||
|
||||
if cnet_images is not None:
|
||||
cnet_image_list.extend(cnet_images)
|
||||
|
||||
@@ -122,7 +132,7 @@ class SEGSDetailerForAnimateDiff:
|
||||
noise_mask_feather=noise_mask_feather, scheduler_func_opt=scheduler_func_opt)
|
||||
|
||||
if len(cnet_images) == 0:
|
||||
cnet_images = [empty_pil_tensor()]
|
||||
cnet_images = [utils.empty_pil_tensor()]
|
||||
|
||||
return (segs, cnet_images)
|
||||
|
||||
@@ -143,7 +153,7 @@ class DetailerForEachPipeForAnimateDiff:
|
||||
"scheduler": (core.SCHEDULERS,),
|
||||
"denoise": ("FLOAT", {"default": 0.5, "min": 0.0001, "max": 1.0, "step": 0.01}),
|
||||
"feather": ("INT", {"default": 5, "min": 0, "max": 100, "step": 1}),
|
||||
"basic_pipe": ("BASIC_PIPE", ),
|
||||
"basic_pipe": ("BASIC_PIPE", {"tooltip": "If the `ImpactDummyInput` is connected to the model in the basic_pipe, the inference stage is skipped."}),
|
||||
"refiner_ratio": ("FLOAT", {"default": 0.2, "min": 0.0, "max": 1.0}),
|
||||
},
|
||||
"optional": {
|
||||
@@ -161,6 +171,8 @@ class DetailerForEachPipeForAnimateDiff:
|
||||
|
||||
CATEGORY = "ImpactPack/Detailer"
|
||||
|
||||
DESCRIPTION = "This node enhances details by inpainting each region within the detected area bundle (SEGS) after enlarging them based on the guide size.\nThis node is a specialized detailer node for enhancing video details, such as in AnimateDiff. It can handle cases where the masks contained in SEGS serve as batch masks spanning multiple frames."
|
||||
|
||||
@staticmethod
|
||||
def doit(image_frames, segs, guide_size, guide_size_for, max_size, seed, steps, cfg, sampler_name, scheduler,
|
||||
denoise, feather, basic_pipe, refiner_ratio=None, detailer_hook=None, refiner_basic_pipe_opt=None,
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import os
|
||||
from PIL import ImageOps
|
||||
from impact.utils import *
|
||||
import latent_preview
|
||||
|
||||
import logging
|
||||
import folder_paths
|
||||
import torch
|
||||
import nodes
|
||||
from PIL import Image
|
||||
import numpy as np
|
||||
from impact import utils
|
||||
|
||||
# NOTE: this should not be `from . import core`.
|
||||
# I don't know why but... 'from .' and 'from impact' refer to different core modules.
|
||||
@@ -20,7 +24,8 @@ class PreviewBridge:
|
||||
"image": ("STRING", {"default": ""}),
|
||||
},
|
||||
"optional": {
|
||||
"block": ("BOOLEAN", {"default": False, "label_on": "if_empty_mask", "label_off": "never", "tooltip": "is_empty_mask: If the mask is empty, the execution is stopped.\nnever: The execution is never stopped."})
|
||||
"block": ("BOOLEAN", {"default": False, "label_on": "if_empty_mask", "label_off": "never", "tooltip": "is_empty_mask: If the mask is empty, the execution is stopped.\nnever: The execution is never stopped."}),
|
||||
"restore_mask": (["never", "always", "if_same_size"], {"tooltip": "if_same_size: If the changed input image is the same size as the previous image, restore using the last saved mask\nalways: Whenever the input image changes, always restore using the last saved mask\nnever: Do not restore the mask.\n`restore_mask` has higher priority than `block`"}),
|
||||
},
|
||||
"hidden": {"unique_id": "UNIQUE_ID", "extra_pnginfo": "EXTRA_PNGINFO"},
|
||||
}
|
||||
@@ -65,7 +70,7 @@ class PreviewBridge:
|
||||
else:
|
||||
mask = torch.zeros((64, 64), dtype=torch.float32, device="cpu")
|
||||
else:
|
||||
image = empty_pil_tensor()
|
||||
image = utils.empty_pil_tensor()
|
||||
mask = torch.zeros((64, 64), dtype=torch.float32, device="cpu")
|
||||
ui_item = {
|
||||
"filename": 'empty.png',
|
||||
@@ -75,7 +80,7 @@ class PreviewBridge:
|
||||
|
||||
return image, mask.unsqueeze(0), ui_item
|
||||
|
||||
def doit(self, images, image, unique_id, block=False, prompt=None, extra_pnginfo=None):
|
||||
def doit(self, images, image, unique_id, block=False, restore_mask="never", prompt=None, extra_pnginfo=None):
|
||||
need_refresh = False
|
||||
|
||||
if unique_id not in core.preview_bridge_cache:
|
||||
@@ -88,10 +93,25 @@ class PreviewBridge:
|
||||
pixels, mask, path_item = PreviewBridge.load_image(image)
|
||||
image = [path_item]
|
||||
else:
|
||||
res = nodes.PreviewImage().save_images(images, filename_prefix="PreviewBridge/PB-", prompt=prompt, extra_pnginfo=extra_pnginfo)
|
||||
if restore_mask != "never":
|
||||
mask = core.preview_bridge_last_mask_cache.get(unique_id)
|
||||
if mask is None or (restore_mask != "always" and mask.shape[1:] != images.shape[1:3]):
|
||||
mask = None
|
||||
else:
|
||||
mask = None
|
||||
|
||||
if mask is None:
|
||||
mask = torch.zeros((64, 64), dtype=torch.float32, device="cpu")
|
||||
res = nodes.PreviewImage().save_images(images, filename_prefix="PreviewBridge/PB-", prompt=prompt, extra_pnginfo=extra_pnginfo)
|
||||
else:
|
||||
masked_images = utils.tensor_convert_rgba(images)
|
||||
resized_mask = utils.resize_mask(mask, (images.shape[1], images.shape[2])).unsqueeze(3)
|
||||
resized_mask = 1 - resized_mask
|
||||
utils.tensor_putalpha(masked_images, resized_mask)
|
||||
res = nodes.PreviewImage().save_images(masked_images, filename_prefix="PreviewBridge/PB-", prompt=prompt, extra_pnginfo=extra_pnginfo)
|
||||
|
||||
image2 = res['ui']['images']
|
||||
pixels = images
|
||||
mask = torch.zeros((64, 64), dtype=torch.float32, device="cpu")
|
||||
|
||||
path = os.path.join(folder_paths.get_temp_directory(), 'PreviewBridge', image2[0]['filename'])
|
||||
core.set_previewbridge_image(unique_id, path, image2[0])
|
||||
@@ -103,15 +123,18 @@ class PreviewBridge:
|
||||
|
||||
is_empty_mask = torch.all(mask == 0)
|
||||
|
||||
if block and is_empty_mask and core.is_execution_model_version_supported:
|
||||
if block and is_empty_mask and core.is_execution_model_version_supported():
|
||||
from comfy_execution.graph import ExecutionBlocker
|
||||
result = ExecutionBlocker(None), ExecutionBlocker(None)
|
||||
elif block and is_empty_mask:
|
||||
print(f"[Impact Pack] PreviewBridge: ComfyUI is outdated - blocking feature is disabled.")
|
||||
logging.warning("[Impact Pack] PreviewBridge: ComfyUI is outdated - blocking feature is disabled.")
|
||||
result = pixels, mask
|
||||
else:
|
||||
result = pixels, mask
|
||||
|
||||
if not is_empty_mask:
|
||||
core.preview_bridge_last_mask_cache[unique_id] = mask
|
||||
|
||||
return {
|
||||
"ui": {"images": image},
|
||||
"result": result,
|
||||
@@ -167,8 +190,11 @@ def decode_latent(latent, preview_method, vae_opt=None):
|
||||
elif preview_method == "Latent2RGB-FLUX.1":
|
||||
latent_format = latent_formats.Flux()
|
||||
method = LatentPreviewMethod.Latent2RGB
|
||||
elif preview_method == "Latent2RGB-LTXV":
|
||||
latent_format = latent_formats.LTXV()
|
||||
method = LatentPreviewMethod.Latent2RGB
|
||||
else:
|
||||
print(f"[Impact Pack] PreviewBridgeLatent: '{preview_method}' is unsupported preview method.")
|
||||
logging.warning(f"[Impact Pack] PreviewBridgeLatent: '{preview_method}' is unsupported preview method.")
|
||||
latent_format = latent_formats.SD15()
|
||||
method = LatentPreviewMethod.Latent2RGB
|
||||
|
||||
@@ -177,9 +203,9 @@ def decode_latent(latent, preview_method, vae_opt=None):
|
||||
|
||||
pil_image = previewer.decode_latent_to_preview(samples)
|
||||
pixels_size = pil_image.size[0]*8, pil_image.size[1]*8
|
||||
resized_image = pil_image.resize(pixels_size, resample=LANCZOS)
|
||||
resized_image = pil_image.resize(pixels_size, resample=utils.LANCZOS)
|
||||
|
||||
return to_tensor(resized_image).unsqueeze(0)
|
||||
return utils.to_tensor(resized_image).unsqueeze(0)
|
||||
|
||||
|
||||
class PreviewBridgeLatent:
|
||||
@@ -192,11 +218,13 @@ class PreviewBridgeLatent:
|
||||
"Latent2RGB-SDXL", "Latent2RGB-SD15", "Latent2RGB-SD3",
|
||||
"Latent2RGB-SD-X4", "Latent2RGB-Playground-2.5",
|
||||
"Latent2RGB-SC-Prior", "Latent2RGB-SC-B",
|
||||
"Latent2RGB-LTXV",
|
||||
"TAEF1", "TAESDXL", "TAESD15", "TAESD3"],),
|
||||
},
|
||||
"optional": {
|
||||
"vae_opt": ("VAE", ),
|
||||
"block": ("BOOLEAN", {"default": False, "label_on": "if_empty_mask", "label_off": "never", "tooltip": "is_empty_mask: If the mask is empty, the execution is stopped.\nnever: The execution is never stopped. Instead, it returns a white mask."})
|
||||
"block": ("BOOLEAN", {"default": False, "label_on": "if_empty_mask", "label_off": "never", "tooltip": "is_empty_mask: If the mask is empty, the execution is stopped.\nnever: The execution is never stopped. Instead, it returns a white mask."}),
|
||||
"restore_mask": (["never", "always", "if_same_size"], {"tooltip": "if_same_size: If the changed input latent is the same size as the previous latent, restore using the last saved mask\nalways: Whenever the input latent changes, always restore using the last saved mask\nnever: Do not restore the mask.\n`restore_mask` has higher priority than `block`\nIf the input latent already has a mask, do not restore mask."}),
|
||||
},
|
||||
"hidden": {"unique_id": "UNIQUE_ID", "prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"},
|
||||
}
|
||||
@@ -242,7 +270,7 @@ class PreviewBridgeLatent:
|
||||
else:
|
||||
mask = None
|
||||
else:
|
||||
image = empty_pil_tensor()
|
||||
image = utils.empty_pil_tensor()
|
||||
mask = None
|
||||
ui_item = {
|
||||
"filename": 'empty.png',
|
||||
@@ -252,12 +280,18 @@ class PreviewBridgeLatent:
|
||||
|
||||
return image, mask, ui_item
|
||||
|
||||
def doit(self, latent, image, preview_method, vae_opt=None, block=False, unique_id=None, prompt=None, extra_pnginfo=None):
|
||||
def doit(self, latent, image, preview_method, vae_opt=None, block=False, unique_id=None, restore_mask='never', prompt=None, extra_pnginfo=None):
|
||||
latent_channels = latent['samples'].shape[1]
|
||||
preview_method_channels = 16 if 'SD3' in preview_method or 'SC-Prior' in preview_method or 'FLUX.1' in preview_method or 'TAEF1' == preview_method else 4
|
||||
|
||||
if 'SD3' in preview_method or 'SC-Prior' in preview_method or 'FLUX.1' in preview_method or 'TAEF1' == preview_method:
|
||||
preview_method_channels = 16
|
||||
elif 'LTXV' in preview_method:
|
||||
preview_method_channels = 128
|
||||
else:
|
||||
preview_method_channels = 4
|
||||
|
||||
if vae_opt is None and latent_channels != preview_method_channels:
|
||||
print(f"[PreviewBridgeLatent] The version of latent is not compatible with preview_method.\nSD3, SD1/SD2, SDXL, SC-Prior, SC-B and FLUX.1 are not compatible with each other.")
|
||||
logging.warning("[PreviewBridgeLatent] The version of latent is not compatible with preview_method.\nSD3, SD1/SD2, SDXL, SC-Prior, SC-B and FLUX.1 are not compatible with each other.")
|
||||
raise Exception("The version of latent is not compatible with preview_method.<BR>SD3, SD1/SD2, SDXL, SC-Prior, SC-B and FLUX.1 are not compatible with each other.")
|
||||
|
||||
need_refresh = False
|
||||
@@ -296,11 +330,11 @@ class PreviewBridgeLatent:
|
||||
if 'noise_mask' in latent:
|
||||
mask = latent['noise_mask'].squeeze(0) # 4D mask -> 3D mask
|
||||
|
||||
decoded_pil = to_pil(decoded_image)
|
||||
decoded_pil = utils.to_pil(decoded_image)
|
||||
|
||||
inverted_mask = 1 - mask # invert
|
||||
resized_mask = resize_mask(inverted_mask, (decoded_image.shape[1], decoded_image.shape[2]))
|
||||
result_pil = apply_mask_alpha_to_pil(decoded_pil, resized_mask)
|
||||
resized_mask = utils.resize_mask(inverted_mask, (decoded_image.shape[1], decoded_image.shape[2]))
|
||||
result_pil = utils.apply_mask_alpha_to_pil(decoded_pil, resized_mask)
|
||||
|
||||
full_output_folder, filename, counter, _, _ = folder_paths.get_save_image_path("PreviewBridge/PBL-"+self.prefix_append, folder_paths.get_temp_directory(), result_pil.size[0], result_pil.size[1])
|
||||
file = f"{filename}_{counter}.png"
|
||||
@@ -311,13 +345,28 @@ class PreviewBridgeLatent:
|
||||
'type': 'temp',
|
||||
}]
|
||||
|
||||
is_empty_mask = torch.all(mask == 1)
|
||||
is_empty_mask = False
|
||||
else:
|
||||
mask = torch.ones(latent['samples'].shape[2:], dtype=torch.float32, device="cpu").unsqueeze(0)
|
||||
res = nodes.PreviewImage().save_images(decoded_image, filename_prefix="PreviewBridge/PBL-", prompt=prompt, extra_pnginfo=extra_pnginfo)
|
||||
if restore_mask != "never":
|
||||
mask = core.preview_bridge_last_mask_cache.get(unique_id)
|
||||
if mask is None or (restore_mask != "always" and mask.shape[1:] != decoded_image.shape[1:3]):
|
||||
mask = None
|
||||
else:
|
||||
mask = None
|
||||
|
||||
if mask is None:
|
||||
mask = torch.ones(latent['samples'].shape[2:], dtype=torch.float32, device="cpu").unsqueeze(0)
|
||||
res = nodes.PreviewImage().save_images(decoded_image, filename_prefix="PreviewBridge/PBL-", prompt=prompt, extra_pnginfo=extra_pnginfo)
|
||||
else:
|
||||
masked_images = utils.tensor_convert_rgba(decoded_image)
|
||||
resized_mask = utils.resize_mask(mask, (decoded_image.shape[1], decoded_image.shape[2])).unsqueeze(3)
|
||||
resized_mask = 1 - resized_mask
|
||||
utils.tensor_putalpha(masked_images, resized_mask)
|
||||
res = nodes.PreviewImage().save_images(masked_images, filename_prefix="PreviewBridge/PBL-", prompt=prompt, extra_pnginfo=extra_pnginfo)
|
||||
|
||||
res_image = res['ui']['images']
|
||||
|
||||
is_empty_mask = True
|
||||
is_empty_mask = torch.all(mask == 1)
|
||||
|
||||
path = os.path.join(folder_paths.get_temp_directory(), 'PreviewBridge', res_image[0]['filename'])
|
||||
core.set_previewbridge_image(unique_id, path, res_image[0])
|
||||
@@ -327,15 +376,18 @@ class PreviewBridgeLatent:
|
||||
|
||||
res_latent = latent
|
||||
|
||||
if block and is_empty_mask and core.is_execution_model_version_supported:
|
||||
if block and is_empty_mask and core.is_execution_model_version_supported():
|
||||
from comfy_execution.graph import ExecutionBlocker
|
||||
result = ExecutionBlocker(None), ExecutionBlocker(None)
|
||||
elif block and is_empty_mask:
|
||||
print(f"[Impact Pack] PreviewBridgeLatent: ComfyUI is outdated - blocking feature is disabled.")
|
||||
logging.warning("[Impact Pack] PreviewBridgeLatent: ComfyUI is outdated - blocking feature is disabled.")
|
||||
result = res_latent, mask
|
||||
else:
|
||||
result = res_latent, mask
|
||||
|
||||
if not is_empty_mask:
|
||||
core.preview_bridge_last_mask_cache[unique_id] = mask
|
||||
|
||||
return {
|
||||
"ui": {"images": res_image},
|
||||
"result": result,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import configparser
|
||||
import os
|
||||
import logging
|
||||
|
||||
version_code = [7, 7, 1]
|
||||
|
||||
version_code = [8, 19, 1]
|
||||
version = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')
|
||||
|
||||
dependency_version = 22
|
||||
|
||||
my_path = os.path.dirname(__file__)
|
||||
old_config_path = os.path.join(my_path, "impact-pack.ini")
|
||||
config_path = os.path.join(my_path, "..", "..", "impact-pack.ini")
|
||||
@@ -15,8 +15,6 @@ latent_letter_path = os.path.join(my_path, "..", "..", "latent.png")
|
||||
def write_config():
|
||||
config = configparser.ConfigParser()
|
||||
config['default'] = {
|
||||
'dependency_version': str(dependency_version),
|
||||
'mmdet_skip': str(get_config()['mmdet_skip']),
|
||||
'sam_editor_cpu': str(get_config()['sam_editor_cpu']),
|
||||
'sam_editor_model': get_config()['sam_editor_model'],
|
||||
'custom_wildcards': get_config()['custom_wildcards'],
|
||||
@@ -33,12 +31,10 @@ def read_config():
|
||||
default_conf = config['default']
|
||||
|
||||
if not os.path.exists(default_conf['custom_wildcards']):
|
||||
print(f"[WARN] ComfyUI-Impact-Pack: custom_wildcards path not found: {default_conf['custom_wildcards']}. Using default path.")
|
||||
logging.warning(f"[Impact Pack] custom_wildcards path not found: {default_conf['custom_wildcards']}. Using default path.")
|
||||
default_conf['custom_wildcards'] = os.path.join(my_path, "..", "..", "custom_wildcards")
|
||||
|
||||
return {
|
||||
'dependency_version': int(default_conf['dependency_version']),
|
||||
'mmdet_skip': default_conf['mmdet_skip'].lower() == 'true' if 'mmdet_skip' in default_conf else True,
|
||||
'sam_editor_cpu': default_conf['sam_editor_cpu'].lower() == 'true' if 'sam_editor_cpu' in default_conf else False,
|
||||
'sam_editor_model': default_conf['sam_editor_model'].lower() if 'sam_editor_model' else 'sam_vit_b_01ec64.pth',
|
||||
'custom_wildcards': default_conf['custom_wildcards'] if 'custom_wildcards' in default_conf else os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "custom_wildcards")),
|
||||
@@ -47,8 +43,6 @@ def read_config():
|
||||
|
||||
except Exception:
|
||||
return {
|
||||
'dependency_version': 0,
|
||||
'mmdet_skip': True,
|
||||
'sam_editor_cpu': False,
|
||||
'sam_editor_model': 'sam_vit_b_01ec64.pth',
|
||||
'custom_wildcards': os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "custom_wildcards")),
|
||||
|
||||
@@ -14,4 +14,4 @@ detection_labels = [
|
||||
"tv", "laptop", "mouse", "remote", "keyboard", "cell phone", "microwave", "oven",
|
||||
"toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors", "teddy bear",
|
||||
"hair drier", "toothbrush"
|
||||
]
|
||||
]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import logging
|
||||
|
||||
import impact.core as core
|
||||
from nodes import MAX_RESOLUTION
|
||||
import impact.segs_nodes as segs_nodes
|
||||
@@ -163,7 +165,7 @@ class SegmDetectorCombined:
|
||||
mask = segm_detector.detect_combined(image, threshold, dilation)
|
||||
|
||||
if mask is None:
|
||||
mask = torch.zeros((image.shape[2], image.shape[1]), dtype=torch.float32, device="cpu")
|
||||
mask = torch.zeros((image.shape[1], image.shape[2]), dtype=torch.float32, device="cpu")
|
||||
|
||||
return (mask.unsqueeze(0),)
|
||||
|
||||
@@ -183,7 +185,7 @@ class BboxDetectorCombined(SegmDetectorCombined):
|
||||
mask = bbox_detector.detect_combined(image, threshold, dilation)
|
||||
|
||||
if mask is None:
|
||||
mask = torch.zeros((image.shape[2], image.shape[1]), dtype=torch.float32, device="cpu")
|
||||
mask = torch.zeros((image.shape[1], image.shape[2]), dtype=torch.float32, device="cpu")
|
||||
|
||||
return (mask.unsqueeze(0),)
|
||||
|
||||
@@ -298,6 +300,68 @@ class SimpleDetectorForEachPipe:
|
||||
sam_mask_hint_threshold, post_dilation=post_dilation, sam_model_opt=sam_model_opt, segm_detector_opt=segm_detector_opt,
|
||||
detailer_hook=detailer_hook)
|
||||
|
||||
class SAM2VideoDetectorSEGS:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"image_frames": ("IMAGE", ),
|
||||
|
||||
"bbox_detector": ("BBOX_DETECTOR", ),
|
||||
"sam2_model": ("SAM_MODEL", ),
|
||||
|
||||
"bbox_threshold": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"sam2_threshold": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
|
||||
"crop_factor": ("FLOAT", {"default": 3.0, "min": 1.0, "max": 100, "step": 0.1}),
|
||||
"drop_size": ("INT", {"min": 1, "max": MAX_RESOLUTION, "step": 1, "default": 10}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("SEGS", )
|
||||
FUNCTION = "doit"
|
||||
|
||||
CATEGORY = "ImpactPack/Detector"
|
||||
|
||||
@staticmethod
|
||||
def doit(bbox_detector, sam2_model, image_frames, bbox_threshold, sam2_threshold, crop_factor, drop_size):
|
||||
if not isinstance(sam2_model, core.SAM2Wrapper):
|
||||
logging.error("[Impact Pack] To use the SAM2VideoDetectorSEGS node, a SAM2 model must be provided as input to `sam2_model`.")
|
||||
raise Exception("To use the SAM2VideoDetectorSEGS node, a SAM2 model must be provided as input to `sam2_model`.")
|
||||
|
||||
segs = bbox_detector.detect(image_frames[0].unsqueeze(0), bbox_threshold, 0, 0, drop_size)
|
||||
segs_masks = sam2_model.predict_video_segs(image_frames, segs)
|
||||
|
||||
def get_whole_merged_mask(all_masks):
|
||||
merged_mask = (all_masks[0] * 255).to(torch.uint8)
|
||||
for mask in all_masks[1:]:
|
||||
merged_mask |= (mask * 255).to(torch.uint8)
|
||||
|
||||
merged_mask = (merged_mask / 255.0).to(torch.float32)
|
||||
merged_mask = utils.to_binary_mask(merged_mask, 0.1)[0]
|
||||
return merged_mask
|
||||
|
||||
new_segs = []
|
||||
for k, v in segs_masks.items():
|
||||
v = v.squeeze(3)
|
||||
m = get_whole_merged_mask(v)
|
||||
seg = segs_nodes.MaskToSEGS.doit(m, False, crop_factor, False, drop_size, contour_fill=True)[0][1]
|
||||
|
||||
if len(seg) == 0:
|
||||
continue
|
||||
|
||||
seg = seg[0]
|
||||
|
||||
x1, y1, x2, y2 = seg.crop_region
|
||||
masks = []
|
||||
for mask in v:
|
||||
masks.append(mask[y1:y2, x1:x2])
|
||||
cropped_mask = torch.stack(masks)
|
||||
cropped_mask = (cropped_mask >= (sam2_threshold*100-50)).to(torch.uint8).cpu()
|
||||
new_seg = SEG(seg.cropped_image, cropped_mask, seg.confidence, seg.crop_region, seg.bbox, seg.label, seg.control_net_wrapper)
|
||||
new_segs.append(new_seg)
|
||||
|
||||
return ((segs[0], new_segs), )
|
||||
|
||||
|
||||
class SimpleDetectorForAnimateDiff:
|
||||
@classmethod
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import comfy
|
||||
import re
|
||||
from impact.utils import *
|
||||
from impact import utils
|
||||
|
||||
|
||||
hf_transformer_model_urls = [
|
||||
"rizvandwiki/gender-classification-2",
|
||||
@@ -138,10 +139,10 @@ class SEGS_Classify:
|
||||
cropped_image = seg.cropped_image
|
||||
elif ref_image_opt is not None:
|
||||
# take from original image
|
||||
cropped_image = crop_image(ref_image_opt, seg.crop_region)
|
||||
cropped_image = utils.crop_image(ref_image_opt, seg.crop_region)
|
||||
|
||||
if cropped_image is not None:
|
||||
cropped_image = to_pil(cropped_image)
|
||||
cropped_image = utils.to_pil(cropped_image)
|
||||
res = classifier(cropped_image)
|
||||
classified.append((seg, res))
|
||||
|
||||
|
||||
@@ -83,3 +83,24 @@ class PreviewDetailerHookProvider:
|
||||
def doit(self, quality, unique_id):
|
||||
hook = hooks.PreviewDetailerHook(unique_id, quality)
|
||||
return hook, hook
|
||||
|
||||
|
||||
class LamaRemoverDetailerHookProvider:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"mask_threshold":("INT", {"default": 250, "min": 0, "max": 255, "step": 1, "display": "slider"}),
|
||||
"gaussblur_radius": ("INT", {"default": 8, "min": 0, "max": 20, "step": 1, "display": "slider"}),
|
||||
"skip_sampling": ("BOOLEAN", {"default": True}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("DETAILER_HOOK", )
|
||||
FUNCTION = "doit"
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
def doit(self, mask_threshold, gaussblur_radius, skip_sampling):
|
||||
hook = hooks.LamaRemoverDetailerHook(mask_threshold, gaussblur_radius, skip_sampling)
|
||||
return (hook, )
|
||||
|
||||
@@ -10,6 +10,7 @@ import folder_paths
|
||||
import os
|
||||
from comfy_extras import nodes_custom_sampler
|
||||
import math
|
||||
import logging
|
||||
|
||||
|
||||
class PixelKSampleHook:
|
||||
@@ -25,7 +26,7 @@ class PixelKSampleHook:
|
||||
def post_decode(self, pixels):
|
||||
return pixels
|
||||
|
||||
def post_upscale(self, pixels):
|
||||
def post_upscale(self, pixels, mask=None):
|
||||
return pixels
|
||||
|
||||
def post_encode(self, samples):
|
||||
@@ -64,8 +65,8 @@ class PixelKSampleHookCombine(PixelKSampleHook):
|
||||
def post_decode(self, pixels):
|
||||
return self.hook2.post_decode(self.hook1.post_decode(pixels))
|
||||
|
||||
def post_upscale(self, pixels):
|
||||
return self.hook2.post_upscale(self.hook1.post_upscale(pixels))
|
||||
def post_upscale(self, pixels, mask=None):
|
||||
return self.hook2.post_upscale(self.hook1.post_upscale(pixels, mask), mask)
|
||||
|
||||
def post_encode(self, samples):
|
||||
return self.hook2.post_encode(self.hook1.post_encode(samples))
|
||||
@@ -109,6 +110,15 @@ class DetailerHookCombine(PixelKSampleHookCombine):
|
||||
noise_2nd, is_touched = self.hook2.get_custom_noise(seed, noise, is_touched)
|
||||
return noise, is_touched
|
||||
|
||||
def get_custom_sampler(self):
|
||||
if self.hook1.get_custom_sampler() is not None:
|
||||
return self.hook1.get_custom_sampler()
|
||||
else:
|
||||
return self.hook2.get_custom_sampler()
|
||||
|
||||
def get_skip_sampling(self):
|
||||
return self.hook1.get_skip_sampling() and self.hook2.get_skip_sampling()
|
||||
|
||||
|
||||
class SimpleCfgScheduleHook(PixelKSampleHook):
|
||||
target_cfg = 0
|
||||
@@ -173,6 +183,21 @@ class DetailerHook(PixelKSampleHook):
|
||||
def get_custom_noise(self, seed, noise, is_touched):
|
||||
return noise, is_touched
|
||||
|
||||
def get_custom_sampler(self):
|
||||
return None
|
||||
|
||||
def get_skip_sampling(self):
|
||||
return False
|
||||
|
||||
|
||||
class CustomSamplerDetailerHookProvider(DetailerHook):
|
||||
def __init__(self, sampler):
|
||||
super().__init__()
|
||||
self.sampler = sampler
|
||||
|
||||
def get_custom_sampler(self):
|
||||
return self.sampler
|
||||
|
||||
|
||||
# class CustomNoiseDetailerHookProvider(DetailerHook):
|
||||
# def __init__(self, noise):
|
||||
@@ -315,7 +340,7 @@ class InjectNoiseHook(PixelKSampleHook):
|
||||
|
||||
strength = self.start_strength + (self.end_strength - self.start_strength) * cur_step / self.total_step
|
||||
samples = InjectNoise().inject_noise(samples, strength, noise, mask)[0]
|
||||
print(f"[Impact Pack] InjectNoiseHook: strength = {strength}")
|
||||
logging.info(f"[Impact Pack] InjectNoiseHook: strength = {strength}")
|
||||
|
||||
if mask is not None:
|
||||
samples['noise_mask'] = mask
|
||||
@@ -346,7 +371,7 @@ class UnsamplerHook(PixelKSampleHook):
|
||||
end_at_step = self.start_end_at_step + (self.end_end_at_step - self.start_end_at_step) * cur_step / self.total_step
|
||||
end_at_step = int(end_at_step)
|
||||
|
||||
print(f"[Impact Pack] UnsamplerHook: end_at_step = {end_at_step}")
|
||||
logging.info(f"[Impact Pack] UnsamplerHook: end_at_step = {end_at_step}")
|
||||
|
||||
# inj noise
|
||||
mask = None
|
||||
@@ -486,6 +511,27 @@ class SEGSLabelFilterDetailerHook(DetailerHook):
|
||||
return segs_nodes.SEGSLabelFilter().doit(segs, "", self.labels)[0]
|
||||
|
||||
|
||||
class LamaRemoverDetailerHook(DetailerHook):
|
||||
def __init__(self, mask_threshold, gaussblur_radius, skip_sampling):
|
||||
super().__init__()
|
||||
self.mask_threshold = mask_threshold
|
||||
self.gaussblur_radius = gaussblur_radius
|
||||
self.skip_sampling = skip_sampling
|
||||
|
||||
def post_upscale(self, img, mask=None):
|
||||
if "LamaRemover" in nodes.NODE_CLASS_MAPPINGS:
|
||||
lama_remover_obj = nodes.NODE_CLASS_MAPPINGS['LamaRemover']()
|
||||
else:
|
||||
utils.try_install_custom_node('https://github.com/Layer-norm/comfyui-lama-remover',
|
||||
"To use 'LAMARemoverDetailerHookProvider', 'comfyui-lama-remover' nodepack is required.")
|
||||
raise Exception("'LamaRemover' node is not installed.")
|
||||
|
||||
return lama_remover_obj.lama_remover(img, masks=mask, mask_threshold=self.mask_threshold, gaussblur_radius=self.gaussblur_radius, invert_mask=False)[0]
|
||||
|
||||
def get_skip_sampling(self):
|
||||
return self.skip_sampling
|
||||
|
||||
|
||||
class PreviewDetailerHook(DetailerHook):
|
||||
def __init__(self, node_id, quality):
|
||||
super().__init__()
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import impact.additional_dependencies
|
||||
from impact.utils import *
|
||||
import numpy as np
|
||||
from impact import utils
|
||||
import logging
|
||||
|
||||
impact.additional_dependencies.ensure_onnx_package()
|
||||
|
||||
@@ -8,7 +10,7 @@ try:
|
||||
|
||||
def onnx_inference(image, onnx_model):
|
||||
# prepare image
|
||||
pil = tensor2pil(image)
|
||||
pil = utils.tensor2pil(image)
|
||||
image = np.ascontiguousarray(pil)
|
||||
image = image[:, :, ::-1] # to BGR image
|
||||
image = image.astype(np.float32)
|
||||
@@ -33,6 +35,5 @@ try:
|
||||
boxes = boxes[0][:idx].astype(np.uint32)
|
||||
|
||||
return labels, scores, boxes
|
||||
except Exception as e:
|
||||
print("[ERROR] ComfyUI-Impact-Pack: 'onnxruntime' package doesn't support 'python 3.11', yet.")
|
||||
print(f"\t{e}")
|
||||
except Exception:
|
||||
logging.error("[Impact Pack] ComfyUI-Impact-Pack: 'onnxruntime' package doesn't support 'python 3.11', yet.\t{e}")
|
||||
@@ -1,3 +1,5 @@
|
||||
import logging
|
||||
|
||||
import nodes
|
||||
from comfy.k_diffusion import sampling as k_diffusion_sampling
|
||||
from comfy import samplers
|
||||
@@ -12,8 +14,8 @@ import comfy.model_management as mm
|
||||
try:
|
||||
from comfy_extras.nodes_custom_sampler import Noise_EmptyNoise, Noise_RandomNoise
|
||||
import node_helpers
|
||||
except:
|
||||
print(f"\n#############################################\n[Impact Pack] ComfyUI is an outdated version.\n#############################################\n")
|
||||
except Exception:
|
||||
logging.warning("\n#############################################\n[Impact Pack] ComfyUI is an outdated version.\n#############################################\n")
|
||||
raise Exception("[Impact Pack] ComfyUI is an outdated version.")
|
||||
|
||||
|
||||
@@ -27,6 +29,10 @@ def calculate_sigmas(model, sampler, scheduler, steps):
|
||||
sigmas = nodes.NODE_CLASS_MAPPINGS['AlignYourStepsScheduler']().get_sigmas(scheduler[4:], steps, denoise=1.0)[0]
|
||||
elif scheduler.startswith('GITS[coeff='):
|
||||
sigmas = nodes.NODE_CLASS_MAPPINGS['GITSScheduler']().get_sigmas(float(scheduler[11:-1]), steps, denoise=1.0)[0]
|
||||
elif scheduler == 'LTXV[default]':
|
||||
sigmas = nodes.NODE_CLASS_MAPPINGS['LTXVScheduler']().get_sigmas(20, 2.05, 0.95, True, 0.1)[0]
|
||||
elif scheduler.startswith('OSS'):
|
||||
sigmas = nodes.NODE_CLASS_MAPPINGS['OptimalStepsScheduler']().get_sigmas(scheduler[4:], steps, denoise=1.0)[0]
|
||||
else:
|
||||
sigmas = samplers.calculate_sigmas(model.get_model_object("model_sampling"), scheduler, steps)
|
||||
|
||||
@@ -44,65 +50,27 @@ def get_noise_sampler(x, cpu, total_sigmas, **kwargs):
|
||||
|
||||
|
||||
def ksampler(sampler_name, total_sigmas, extra_options={}, inpaint_options={}):
|
||||
if sampler_name == "dpmpp_sde":
|
||||
def sample_dpmpp_sde(model, x, sigmas, **kwargs):
|
||||
noise_sampler = get_noise_sampler(x, True, total_sigmas, **kwargs)
|
||||
if noise_sampler is not None:
|
||||
kwargs['noise_sampler'] = noise_sampler
|
||||
if sampler_name in ["dpmpp_sde", "dpmpp_sde_gpu", "dpmpp_2m_sde", "dpmpp_2m_sde_gpu", "dpmpp_3m_sde", "dpmpp_3m_sde_gpu"]:
|
||||
if sampler_name == "dpmpp_sde":
|
||||
orig_sampler_function = k_diffusion_sampling.sample_dpmpp_sde
|
||||
elif sampler_name == "dpmpp_sde_gpu":
|
||||
orig_sampler_function = k_diffusion_sampling.sample_dpmpp_sde_gpu
|
||||
elif sampler_name == "dpmpp_2m_sde":
|
||||
orig_sampler_function = k_diffusion_sampling.sample_dpmpp_2m_sde
|
||||
elif sampler_name == "dpmpp_2m_sde_gpu":
|
||||
orig_sampler_function = k_diffusion_sampling.sample_dpmpp_2m_sde_gpu
|
||||
elif sampler_name == "dpmpp_3m_sde":
|
||||
orig_sampler_function = k_diffusion_sampling.sample_dpmpp_3m_sde
|
||||
elif sampler_name == "dpmpp_3m_sde_gpu":
|
||||
orig_sampler_function = k_diffusion_sampling.sample_dpmpp_3m_sde_gpu
|
||||
|
||||
return k_diffusion_sampling.sample_dpmpp_sde(model, x, sigmas, **kwargs)
|
||||
def sampler_function_wrapper(model, x, sigmas, **kwargs):
|
||||
if 'noise_sampler' not in kwargs:
|
||||
kwargs['noise_sampler'] = get_noise_sampler(x, 'gpu' not in sampler_name, total_sigmas, **kwargs)
|
||||
|
||||
sampler_function = sample_dpmpp_sde
|
||||
return orig_sampler_function(model, x, sigmas, **kwargs)
|
||||
|
||||
elif sampler_name == "dpmpp_sde_gpu":
|
||||
def sample_dpmpp_sde(model, x, sigmas, **kwargs):
|
||||
noise_sampler = get_noise_sampler(x, False, total_sigmas, **kwargs)
|
||||
if noise_sampler is not None:
|
||||
kwargs['noise_sampler'] = noise_sampler
|
||||
|
||||
return k_diffusion_sampling.sample_dpmpp_sde_gpu(model, x, sigmas, **kwargs)
|
||||
|
||||
sampler_function = sample_dpmpp_sde
|
||||
|
||||
elif sampler_name == "dpmpp_2m_sde":
|
||||
def sample_dpmpp_sde(model, x, sigmas, **kwargs):
|
||||
noise_sampler = get_noise_sampler(x, True, total_sigmas, **kwargs)
|
||||
if noise_sampler is not None:
|
||||
kwargs['noise_sampler'] = noise_sampler
|
||||
|
||||
return k_diffusion_sampling.sample_dpmpp_2m_sde(model, x, sigmas, **kwargs)
|
||||
|
||||
sampler_function = sample_dpmpp_sde
|
||||
|
||||
elif sampler_name == "dpmpp_2m_sde_gpu":
|
||||
def sample_dpmpp_sde(model, x, sigmas, **kwargs):
|
||||
noise_sampler = get_noise_sampler(x, False, total_sigmas, **kwargs)
|
||||
if noise_sampler is not None:
|
||||
kwargs['noise_sampler'] = noise_sampler
|
||||
|
||||
return k_diffusion_sampling.sample_dpmpp_2m_sde_gpu(model, x, sigmas, **kwargs)
|
||||
|
||||
sampler_function = sample_dpmpp_sde
|
||||
|
||||
elif sampler_name == "dpmpp_3m_sde":
|
||||
def sample_dpmpp_sde(model, x, sigmas, **kwargs):
|
||||
noise_sampler = get_noise_sampler(x, True, total_sigmas, **kwargs)
|
||||
if noise_sampler is not None:
|
||||
kwargs['noise_sampler'] = noise_sampler
|
||||
|
||||
return k_diffusion_sampling.sample_dpmpp_3m_sde(model, x, sigmas, **kwargs)
|
||||
|
||||
sampler_function = sample_dpmpp_sde
|
||||
|
||||
elif sampler_name == "dpmpp_3m_sde_gpu":
|
||||
def sample_dpmpp_sde(model, x, sigmas, **kwargs):
|
||||
noise_sampler = get_noise_sampler(x, False, total_sigmas, **kwargs)
|
||||
if noise_sampler is not None:
|
||||
kwargs['noise_sampler'] = noise_sampler
|
||||
|
||||
return k_diffusion_sampling.sample_dpmpp_3m_sde_gpu(model, x, sigmas, **kwargs)
|
||||
|
||||
sampler_function = sample_dpmpp_sde
|
||||
sampler_function = sampler_function_wrapper
|
||||
|
||||
else:
|
||||
return comfy.samplers.sampler_object(sampler_name)
|
||||
@@ -210,7 +178,7 @@ def separated_sample(model, add_noise, seed, steps, cfg, sampler_name, scheduler
|
||||
|
||||
if len(sigmas) == 0 or (len(sigmas) == 1 and sigmas[0] == 0):
|
||||
return latent_image
|
||||
|
||||
|
||||
res = sample_with_custom_noise(model, add_noise, seed, cfg, positive, negative, impact_sampler, sigmas, latent_image, noise=noise, callback=callback)
|
||||
|
||||
if return_with_leftover_noise:
|
||||
@@ -228,7 +196,7 @@ def impact_sample(model, seed, steps, cfg, sampler_name, scheduler, positive, ne
|
||||
|
||||
|
||||
def ksampler_wrapper(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise,
|
||||
refiner_ratio=None, refiner_model=None, refiner_clip=None, refiner_positive=None, refiner_negative=None, sigma_factor=1.0, noise=None, scheduler_func=None):
|
||||
refiner_ratio=None, refiner_model=None, refiner_clip=None, refiner_positive=None, refiner_negative=None, sigma_factor=1.0, noise=None, scheduler_func=None, sampler_opt=None):
|
||||
|
||||
if refiner_ratio is None or refiner_model is None or refiner_clip is None or refiner_positive is None or refiner_negative is None:
|
||||
# Use separated_sample instead of KSampler for `AYS scheduler`
|
||||
@@ -240,7 +208,7 @@ def ksampler_wrapper(model, seed, steps, cfg, sampler_name, scheduler, positive,
|
||||
|
||||
refined_latent = separated_sample(model, True, seed, advanced_steps, cfg, sampler_name, scheduler,
|
||||
positive, negative, latent_image, start_at_step, end_at_step, False,
|
||||
sigma_ratio=sigma_factor, noise=noise, scheduler_func=scheduler_func)
|
||||
sigma_ratio=sigma_factor, sampler_opt=sampler_opt, noise=noise, scheduler_func=scheduler_func)
|
||||
else:
|
||||
advanced_steps = math.floor(steps / denoise)
|
||||
start_at_step = advanced_steps - steps
|
||||
@@ -249,7 +217,7 @@ def ksampler_wrapper(model, seed, steps, cfg, sampler_name, scheduler, positive,
|
||||
# print(f"pre: {start_at_step} .. {end_at_step} / {advanced_steps}")
|
||||
temp_latent = separated_sample(model, True, seed, advanced_steps, cfg, sampler_name, scheduler,
|
||||
positive, negative, latent_image, start_at_step, end_at_step, True,
|
||||
sigma_ratio=sigma_factor, noise=noise, scheduler_func=scheduler_func)
|
||||
sigma_ratio=sigma_factor, sampler_opt=sampler_opt, noise=noise, scheduler_func=scheduler_func)
|
||||
|
||||
if 'noise_mask' in latent_image:
|
||||
# noise_latent = \
|
||||
@@ -263,7 +231,7 @@ def ksampler_wrapper(model, seed, steps, cfg, sampler_name, scheduler, positive,
|
||||
# print(f"post: {end_at_step} .. {advanced_steps + 1} / {advanced_steps}")
|
||||
refined_latent = separated_sample(refiner_model, False, seed, advanced_steps, cfg, sampler_name, scheduler,
|
||||
refiner_positive, refiner_negative, temp_latent, end_at_step, advanced_steps + 1, False,
|
||||
sigma_ratio=sigma_factor, scheduler_func=scheduler_func)
|
||||
sigma_ratio=sigma_factor, sampler_opt=sampler_opt, scheduler_func=scheduler_func)
|
||||
|
||||
return refined_latent
|
||||
|
||||
@@ -309,7 +277,7 @@ class KSamplerAdvancedWrapper:
|
||||
sampler_opt=self.sampler_opt, noise=noise, scheduler_func=self.scheduler_func)
|
||||
except ValueError as e:
|
||||
if str(e) == 'sigma_min and sigma_max must not be 0':
|
||||
print(f"\nWARN: sampling skipped - sigma_min and sigma_max are 0")
|
||||
logging.warning("\nWARN: sampling skipped - sigma_min and sigma_max are 0")
|
||||
return latent_image
|
||||
|
||||
if (recovery_sigma_ratio > 0 and recovery_mode != 'DISABLE' and
|
||||
@@ -333,7 +301,7 @@ class KSamplerAdvancedWrapper:
|
||||
sigma_ratio=recovery_sigma_ratio * sigma_factor, sampler_opt=self.sampler_opt, scheduler_func=self.scheduler_func)
|
||||
except ValueError as e:
|
||||
if str(e) == 'sigma_min and sigma_max must not be 0':
|
||||
print(f"\nWARN: sampling skipped - sigma_min and sigma_max are 0")
|
||||
logging.warning("\nWARN: sampling skipped - sigma_min and sigma_max are 0")
|
||||
|
||||
return latent_image
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@ import numpy as np
|
||||
import nodes
|
||||
from PIL import Image
|
||||
import io
|
||||
import impact.wildcards as wildcards
|
||||
import comfy
|
||||
from io import BytesIO
|
||||
import random
|
||||
from server import PromptServer
|
||||
import logging
|
||||
|
||||
|
||||
sam_predictor = None
|
||||
@@ -77,9 +77,13 @@ async def sam_prepare(request):
|
||||
if data['sam_model_name'] == 'auto':
|
||||
model_name = impact.config.get_config()['sam_editor_model']
|
||||
|
||||
model_name = os.path.join(impact_pack.model_path, "sams", model_name)
|
||||
model_path = folder_paths.get_full_path("sams", model_name)
|
||||
|
||||
print(f"[INFO] ComfyUI-Impact-Pack: Loading SAM model '{impact_pack.model_path}'")
|
||||
if model_path is None:
|
||||
logging.error(f"[Impact Pack] The '{model_name}' model file cannot be found in any sams model path.")
|
||||
return web.Response(status=400)
|
||||
|
||||
logging.info(f"[Impact Pack] Loading SAM model '{model_path}'")
|
||||
|
||||
filename, image_dir = folder_paths.annotated_filepath(data["filename"])
|
||||
|
||||
@@ -92,10 +96,10 @@ async def sam_prepare(request):
|
||||
if image_dir is None:
|
||||
return web.Response(status=400)
|
||||
|
||||
thread = threading.Thread(target=async_prepare_sam, args=(image_dir, model_name, filename,))
|
||||
thread = threading.Thread(target=async_prepare_sam, args=(image_dir, model_path, filename,))
|
||||
thread.start()
|
||||
|
||||
print(f"[INFO] ComfyUI-Impact-Pack: SAM model loaded. ")
|
||||
logging.info("[Impact Pack] SAM model loaded. ")
|
||||
return web.Response(status=200)
|
||||
|
||||
|
||||
@@ -104,10 +108,11 @@ async def release_sam(request):
|
||||
global sam_predictor
|
||||
|
||||
with sam_lock:
|
||||
del sam_predictor
|
||||
temp = sam_predictor
|
||||
del temp
|
||||
sam_predictor = None
|
||||
|
||||
print(f"[INFO] ComfyUI-Impact-Pack: unloading SAM model")
|
||||
logging.info("[Impact Pack]: unloading SAM model")
|
||||
|
||||
|
||||
@PromptServer.instance.routes.post("/sam/detect")
|
||||
@@ -178,7 +183,7 @@ async def wildcards_list(request):
|
||||
@PromptServer.instance.routes.post("/impact/wildcards")
|
||||
async def populate_wildcards(request):
|
||||
data = await request.json()
|
||||
populated = wildcards.process(data['text'], data.get('seed', None))
|
||||
populated = impact.wildcards.process(data['text'], data.get('seed', None))
|
||||
return web.json_response({"text": populated})
|
||||
|
||||
|
||||
@@ -234,7 +239,7 @@ async def view_validate(request):
|
||||
|
||||
|
||||
@PromptServer.instance.routes.get("/impact/validate/pb_id_image")
|
||||
async def view_validate(request):
|
||||
async def view_pb_id_image(request):
|
||||
if "id" in request.rel_url.query:
|
||||
pb_id = request.rel_url.query["id"]
|
||||
|
||||
@@ -304,7 +309,7 @@ async def view_previewbridge_image(request):
|
||||
if pb_id in core.preview_bridge_image_id_map:
|
||||
file = core.preview_bridge_image_id_map[pb_id]
|
||||
|
||||
with Image.open(file) as img:
|
||||
with Image.open(file):
|
||||
filename = os.path.basename(file)
|
||||
return web.FileResponse(file, headers={"Content-Disposition": f"filename=\"{filename}\""})
|
||||
|
||||
@@ -315,6 +320,8 @@ def onprompt_for_switch(json_data):
|
||||
inversed_switch_info = {}
|
||||
onprompt_switch_info = {}
|
||||
onprompt_cond_branch_info = {}
|
||||
disabled_switch = set()
|
||||
|
||||
|
||||
for k, v in json_data['prompt'].items():
|
||||
if 'class_type' not in v:
|
||||
@@ -322,20 +329,24 @@ def onprompt_for_switch(json_data):
|
||||
|
||||
cls = v['class_type']
|
||||
if cls == 'ImpactInversedSwitch':
|
||||
# if 'sel_mode' is 'select_on_prompt'
|
||||
if 'sel_mode' in v['inputs'] and v['inputs']['sel_mode'] and 'select' in v['inputs']:
|
||||
select_input = v['inputs']['select']
|
||||
# if 'select' is converted input
|
||||
if isinstance(select_input, list) and len(select_input) == 2:
|
||||
input_node = json_data['prompt'][select_input[0]]
|
||||
if input_node['class_type'] == 'ImpactInt' and 'inputs' in input_node and 'value' in input_node['inputs']:
|
||||
inversed_switch_info[k] = input_node['inputs']['value']
|
||||
else:
|
||||
print(f"\n##### ##### #####\n[WARN] {cls}: For the 'select' operation, only 'select_index' of the 'ImpactInversedSwitch', which is not an input, or 'ImpactInt' and 'Primitive' are allowed as inputs if 'select_on_prompt' is selected.\n##### ##### #####\n")
|
||||
logging.warning(f"\n##### ##### #####\n[Impact Pack] {cls}: For the 'select' operation, only 'select_index' of the 'ImpactInversedSwitch', which is not an input, or 'ImpactInt' and 'Primitive' are allowed as inputs if 'select_on_prompt' is selected.\n##### ##### #####\n")
|
||||
else:
|
||||
inversed_switch_info[k] = select_input
|
||||
|
||||
elif cls in ['ImpactSwitch', 'LatentSwitch', 'SEGSSwitch', 'ImpactMakeImageList']:
|
||||
# if 'sel_mode' is 'select_on_prompt'
|
||||
if 'sel_mode' in v['inputs'] and v['inputs']['sel_mode'] and 'select' in v['inputs']:
|
||||
select_input = v['inputs']['select']
|
||||
# if 'select' is converted input
|
||||
if isinstance(select_input, list) and len(select_input) == 2:
|
||||
input_node = json_data['prompt'][select_input[0]]
|
||||
if input_node['class_type'] == 'ImpactInt' and 'inputs' in input_node and 'value' in input_node['inputs']:
|
||||
@@ -344,10 +355,14 @@ def onprompt_for_switch(json_data):
|
||||
if isinstance(input_node['inputs']['select'], int):
|
||||
onprompt_switch_info[k] = input_node['inputs']['select']
|
||||
else:
|
||||
print(f"\n##### ##### #####\n[WARN] {cls}: For the 'select' operation, only 'select_index' of the 'ImpactSwitch', which is not an input, or 'ImpactInt' and 'Primitive' are allowed as inputs if 'select_on_prompt' is selected.\n##### ##### #####\n")
|
||||
logging.warning(f"\n##### ##### #####\n[Impact Pack] {cls}: For the 'select' operation, only 'select_index' of the 'ImpactSwitch', which is not an input, or 'ImpactInt' and 'Primitive' are allowed as inputs if 'select_on_prompt' is selected.\n##### ##### #####\n")
|
||||
else:
|
||||
onprompt_switch_info[k] = select_input
|
||||
|
||||
if k in onprompt_switch_info and f'input{onprompt_switch_info[k]}' not in v['inputs']:
|
||||
# disconnect output
|
||||
disabled_switch.add(k)
|
||||
|
||||
elif cls == 'ImpactConditionalBranchSelMode':
|
||||
if 'sel_mode' in v['inputs'] and v['inputs']['sel_mode'] and 'cond' in v['inputs']:
|
||||
cond_input = v['inputs']['cond']
|
||||
@@ -358,7 +373,7 @@ def onprompt_for_switch(json_data):
|
||||
if 'BOOLEAN' == input_node['inputs']['typ']:
|
||||
try:
|
||||
onprompt_cond_branch_info[k] = input_node['inputs']['value'].lower() == "true"
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
onprompt_cond_branch_info[k] = cond_input
|
||||
@@ -371,6 +386,11 @@ def onprompt_for_switch(json_data):
|
||||
if vv[0] in inversed_switch_info:
|
||||
if vv[1] + 1 != inversed_switch_info[vv[0]]:
|
||||
disable_targets.add(kk)
|
||||
else:
|
||||
del inversed_switch_info[k]
|
||||
|
||||
if vv[0] in disabled_switch:
|
||||
disable_targets.add(kk)
|
||||
|
||||
if k in onprompt_switch_info:
|
||||
selected_slot_name = f"input{onprompt_switch_info[k]}"
|
||||
@@ -387,6 +407,11 @@ def onprompt_for_switch(json_data):
|
||||
for kk in disable_targets:
|
||||
del v['inputs'][kk]
|
||||
|
||||
# inversed_switch - select out of range
|
||||
for target in inversed_switch_info.keys():
|
||||
del json_data['prompt'][target]['inputs']['input']
|
||||
|
||||
|
||||
def onprompt_for_pickers(json_data):
|
||||
detected_pickers = set()
|
||||
|
||||
@@ -409,9 +434,14 @@ def gc_preview_bridge_cache(json_data):
|
||||
|
||||
for key in list(core.preview_bridge_cache.keys()):
|
||||
if key not in prompt_keys:
|
||||
print(f"key deleted: {key}")
|
||||
# print(f"key deleted [PB]: {key}")
|
||||
del core.preview_bridge_cache[key]
|
||||
|
||||
for key in list(core.preview_bridge_last_mask_cache.keys()):
|
||||
if key not in prompt_keys:
|
||||
# print(f"key deleted [PB_last_mask]: {key}")
|
||||
del core.preview_bridge_last_mask_cache[key]
|
||||
|
||||
|
||||
def workflow_imagereceiver_update(json_data):
|
||||
prompt = json_data['prompt']
|
||||
@@ -452,7 +482,17 @@ def onprompt_populate_wildcards(json_data):
|
||||
for k, v in prompt.items():
|
||||
if 'class_type' in v and (v['class_type'] == 'ImpactWildcardEncode' or v['class_type'] == 'ImpactWildcardProcessor'):
|
||||
inputs = v['inputs']
|
||||
if inputs['mode'] and isinstance(inputs['populated_text'], str):
|
||||
|
||||
# legacy adapter
|
||||
if isinstance(inputs['mode'], bool):
|
||||
if inputs['mode']:
|
||||
new_mode = 'populate'
|
||||
else:
|
||||
new_mode = 'fixed'
|
||||
|
||||
inputs['mode'] = new_mode
|
||||
|
||||
if inputs['mode'] == 'populate' and isinstance(inputs['populated_text'], str):
|
||||
if isinstance(inputs['seed'], list):
|
||||
try:
|
||||
input_node = prompt[inputs['seed'][0]]
|
||||
@@ -465,25 +505,30 @@ def onprompt_populate_wildcards(json_data):
|
||||
if not isinstance(input_seed, int):
|
||||
continue
|
||||
else:
|
||||
print(f"[Impact Pack] Only `ImpactInt`, `Seed (rgthree)` and `Primitive` Node are allowed as the seed for '{v['class_type']}'. It will be ignored. ")
|
||||
logging.info(f"[Impact Pack] Only `ImpactInt`, `Seed (rgthree)` and `Primitive` Node are allowed as the seed for '{v['class_type']}'. It will be ignored. ")
|
||||
continue
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
else:
|
||||
input_seed = int(inputs['seed'])
|
||||
|
||||
inputs['populated_text'] = wildcards.process(inputs['wildcard_text'], input_seed)
|
||||
inputs['mode'] = False
|
||||
inputs['populated_text'] = impact.wildcards.process(inputs['wildcard_text'], input_seed)
|
||||
inputs['mode'] = 'reproduce'
|
||||
|
||||
PromptServer.instance.send_sync("impact-node-feedback", {"node_id": k, "widget_name": "populated_text", "type": "STRING", "value": inputs['populated_text']})
|
||||
updated_widget_values[k] = inputs['populated_text']
|
||||
|
||||
if inputs['mode'] == 'reproduce':
|
||||
PromptServer.instance.send_sync("impact-node-feedback", {"node_id": k, "widget_name": "mode", "type": "STRING", "value": 'populate'})
|
||||
|
||||
|
||||
|
||||
if 'extra_data' in json_data and 'extra_pnginfo' in json_data['extra_data']:
|
||||
for node in json_data['extra_data']['extra_pnginfo']['workflow']['nodes']:
|
||||
key = str(node['id'])
|
||||
if key in updated_widget_values:
|
||||
node['widgets_values'][1] = updated_widget_values[key]
|
||||
node['widgets_values'][2] = False
|
||||
node['widgets_values'][2] = 'reproduce'
|
||||
|
||||
|
||||
def onprompt_for_remote(json_data):
|
||||
@@ -528,7 +573,7 @@ def onprompt(json_data):
|
||||
regional_sampler_seed_update(json_data)
|
||||
core.current_prompt = json_data
|
||||
except Exception as e:
|
||||
print(f"[WARN] ComfyUI-Impact-Pack: Error on prompt - several features will not work.\n{e}")
|
||||
logging.warning(f"[Impact Pack] ComfyUI-Impact-Pack: Error on prompt - several features will not work.\n{e}")
|
||||
|
||||
return json_data
|
||||
|
||||
|
||||
@@ -1,285 +0,0 @@
|
||||
import folder_paths
|
||||
|
||||
import impact.mmdet_nodes as mmdet_nodes
|
||||
from impact.utils import *
|
||||
from impact.core import SEG
|
||||
import impact.core as core
|
||||
import nodes
|
||||
|
||||
class NO_BBOX_MODEL:
|
||||
pass
|
||||
|
||||
|
||||
class NO_SEGM_MODEL:
|
||||
pass
|
||||
|
||||
|
||||
class MMDetLoader:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
bboxs = ["bbox/"+x for x in folder_paths.get_filename_list("mmdets_bbox")]
|
||||
segms = ["segm/"+x for x in folder_paths.get_filename_list("mmdets_segm")]
|
||||
return {"required": {"model_name": (bboxs + segms, )}}
|
||||
RETURN_TYPES = ("BBOX_MODEL", "SEGM_MODEL")
|
||||
FUNCTION = "load_mmdet"
|
||||
|
||||
CATEGORY = "ImpactPack/Legacy"
|
||||
|
||||
DEPRECATED = True
|
||||
|
||||
def load_mmdet(self, model_name):
|
||||
mmdet_path = folder_paths.get_full_path("mmdets", model_name)
|
||||
model = mmdet_nodes.load_mmdet(mmdet_path)
|
||||
|
||||
if model_name.startswith("bbox"):
|
||||
return model, NO_SEGM_MODEL()
|
||||
else:
|
||||
return NO_BBOX_MODEL(), model
|
||||
|
||||
|
||||
class BboxDetectorForEach:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"bbox_model": ("BBOX_MODEL", ),
|
||||
"image": ("IMAGE", ),
|
||||
"threshold": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"dilation": ("INT", {"default": 10, "min": 0, "max": 255, "step": 1}),
|
||||
"crop_factor": ("FLOAT", {"default": 3.0, "min": 1.0, "max": 100, "step": 0.1}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("SEGS", )
|
||||
FUNCTION = "doit"
|
||||
|
||||
CATEGORY = "ImpactPack/Legacy"
|
||||
|
||||
DEPRECATED = True
|
||||
|
||||
@staticmethod
|
||||
def detect(bbox_model, image, threshold, dilation, crop_factor, drop_size=1, detailer_hook=None):
|
||||
mmdet_results = mmdet_nodes.inference_bbox(bbox_model, image, threshold)
|
||||
segmasks = core.create_segmasks(mmdet_results)
|
||||
|
||||
if dilation > 0:
|
||||
segmasks = dilate_masks(segmasks, dilation)
|
||||
|
||||
items = []
|
||||
h = image.shape[1]
|
||||
w = image.shape[2]
|
||||
for x in segmasks:
|
||||
item_bbox = x[0]
|
||||
item_mask = x[1]
|
||||
|
||||
y1, x1, y2, x2 = item_bbox
|
||||
|
||||
if x2 - x1 > drop_size and y2 - y1 > drop_size:
|
||||
crop_region = make_crop_region(w, h, item_bbox, crop_factor)
|
||||
cropped_image = crop_image(image, crop_region)
|
||||
cropped_mask = crop_ndarray2(item_mask, crop_region)
|
||||
confidence = x[2]
|
||||
# bbox_size = (item_bbox[2]-item_bbox[0],item_bbox[3]-item_bbox[1]) # (w,h)
|
||||
|
||||
item = SEG(cropped_image, cropped_mask, confidence, crop_region, item_bbox, None, None)
|
||||
items.append(item)
|
||||
|
||||
shape = h, w
|
||||
return shape, items
|
||||
|
||||
def doit(self, bbox_model, image, threshold, dilation, crop_factor):
|
||||
return (BboxDetectorForEach.detect(bbox_model, image, threshold, dilation, crop_factor), )
|
||||
|
||||
|
||||
class SegmDetectorCombined:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"segm_model": ("SEGM_MODEL", ),
|
||||
"image": ("IMAGE", ),
|
||||
"threshold": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"dilation": ("INT", {"default": 0, "min": 0, "max": 255, "step": 1}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("MASK",)
|
||||
FUNCTION = "doit"
|
||||
|
||||
CATEGORY = "ImpactPack/Legacy"
|
||||
|
||||
DEPRECATED = True
|
||||
|
||||
def doit(self, segm_model, image, threshold, dilation):
|
||||
mmdet_results = mmdet_nodes.inference_segm(image, segm_model, threshold)
|
||||
segmasks = core.create_segmasks(mmdet_results)
|
||||
if dilation > 0:
|
||||
segmasks = dilate_masks(segmasks, dilation)
|
||||
|
||||
mask = combine_masks(segmasks)
|
||||
return (mask,)
|
||||
|
||||
|
||||
class BboxDetectorCombined(SegmDetectorCombined):
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"bbox_model": ("BBOX_MODEL", ),
|
||||
"image": ("IMAGE", ),
|
||||
"threshold": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"dilation": ("INT", {"default": 4, "min": 0, "max": 255, "step": 1}),
|
||||
}
|
||||
}
|
||||
|
||||
def doit(self, bbox_model, image, threshold, dilation):
|
||||
mmdet_results = mmdet_nodes.inference_bbox(bbox_model, image, threshold)
|
||||
segmasks = core.create_segmasks(mmdet_results)
|
||||
if dilation > 0:
|
||||
segmasks = dilate_masks(segmasks, dilation)
|
||||
|
||||
mask = combine_masks(segmasks)
|
||||
return (mask,)
|
||||
|
||||
|
||||
class SegmDetectorForEach:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"segm_model": ("SEGM_MODEL", ),
|
||||
"image": ("IMAGE", ),
|
||||
"threshold": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
"dilation": ("INT", {"default": 10, "min": 0, "max": 255, "step": 1}),
|
||||
"crop_factor": ("FLOAT", {"default": 3.0, "min": 1.0, "max": 100, "step": 0.1}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("SEGS", )
|
||||
FUNCTION = "doit"
|
||||
|
||||
CATEGORY = "ImpactPack/Legacy"
|
||||
|
||||
DEPRECATED = True
|
||||
|
||||
def doit(self, segm_model, image, threshold, dilation, crop_factor):
|
||||
mmdet_results = mmdet_nodes.inference_segm(image, segm_model, threshold)
|
||||
segmasks = core.create_segmasks(mmdet_results)
|
||||
|
||||
if dilation > 0:
|
||||
segmasks = dilate_masks(segmasks, dilation)
|
||||
|
||||
items = []
|
||||
h = image.shape[1]
|
||||
w = image.shape[2]
|
||||
for x in segmasks:
|
||||
item_bbox = x[0]
|
||||
item_mask = x[1]
|
||||
|
||||
crop_region = make_crop_region(w, h, item_bbox, crop_factor)
|
||||
cropped_image = crop_image(image, crop_region)
|
||||
cropped_mask = crop_ndarray2(item_mask, crop_region)
|
||||
confidence = x[2]
|
||||
|
||||
item = SEG(cropped_image, cropped_mask, confidence, crop_region, item_bbox, None, None)
|
||||
items.append(item)
|
||||
|
||||
shape = h,w
|
||||
return ((shape, items), )
|
||||
|
||||
|
||||
class SegsMaskCombine:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"segs": ("SEGS", ),
|
||||
"image": ("IMAGE", ),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("MASK",)
|
||||
FUNCTION = "doit"
|
||||
|
||||
CATEGORY = "ImpactPack/Legacy"
|
||||
|
||||
DEPRECATED = True
|
||||
|
||||
@staticmethod
|
||||
def combine(segs, image):
|
||||
h = image.shape[1]
|
||||
w = image.shape[2]
|
||||
|
||||
mask = np.zeros((h, w), dtype=np.uint8)
|
||||
|
||||
for seg in segs[1]:
|
||||
cropped_mask = seg.cropped_mask
|
||||
crop_region = seg.crop_region
|
||||
mask[crop_region[1]:crop_region[3], crop_region[0]:crop_region[2]] |= (cropped_mask * 255).astype(np.uint8)
|
||||
|
||||
return torch.from_numpy(mask.astype(np.float32) / 255.0)
|
||||
|
||||
def doit(self, segs, image):
|
||||
return (SegsMaskCombine.combine(segs, image), )
|
||||
|
||||
|
||||
class MaskPainter(nodes.PreviewImage):
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {"images": ("IMAGE",), },
|
||||
"hidden": {
|
||||
"prompt": "PROMPT",
|
||||
"extra_pnginfo": "EXTRA_PNGINFO",
|
||||
},
|
||||
"optional": {"mask_image": ("IMAGE_PATH",), },
|
||||
"optional": {"image": (["#placeholder"], )},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("MASK",)
|
||||
|
||||
FUNCTION = "save_painted_images"
|
||||
|
||||
CATEGORY = "ImpactPack/Legacy"
|
||||
|
||||
DEPRECATED = True
|
||||
|
||||
def save_painted_images(self, images, filename_prefix="impact-mask",
|
||||
prompt=None, extra_pnginfo=None, mask_image=None, image=None):
|
||||
if image == "#placeholder" or image['image_hash'] != id(images):
|
||||
# new input image
|
||||
res = self.save_images(images, filename_prefix, prompt, extra_pnginfo)
|
||||
|
||||
item = res['ui']['images'][0]
|
||||
|
||||
if not item['filename'].endswith(']'):
|
||||
filepath = f"{item['filename']} [{item['type']}]"
|
||||
else:
|
||||
filepath = item['filename']
|
||||
|
||||
_, mask = nodes.LoadImage().load_image(filepath)
|
||||
|
||||
res['ui']['aux'] = [id(images), res['ui']['images']]
|
||||
res['result'] = (mask, )
|
||||
|
||||
return res
|
||||
|
||||
else:
|
||||
# new mask
|
||||
if '0' in image: # fallback
|
||||
image = image['0']
|
||||
|
||||
forward = {'filename': image['forward_filename'],
|
||||
'subfolder': image['forward_subfolder'],
|
||||
'type': image['forward_type'], }
|
||||
|
||||
res = {'ui': {'images': [forward]}}
|
||||
|
||||
imgpath = ""
|
||||
if 'subfolder' in image and image['subfolder'] != "":
|
||||
imgpath = image['subfolder'] + "/"
|
||||
|
||||
imgpath += f"{image['filename']}"
|
||||
|
||||
if 'type' in image and image['type'] != "":
|
||||
imgpath += f" [{image['type']}]"
|
||||
|
||||
res['ui']['aux'] = [id(images), [forward]]
|
||||
_, mask = nodes.LoadImage().load_image(imgpath)
|
||||
res['result'] = (mask, )
|
||||
|
||||
return res
|
||||
@@ -8,7 +8,8 @@ from impact.utils import any_typ
|
||||
import impact.core as core
|
||||
import re
|
||||
import nodes
|
||||
import traceback
|
||||
import logging
|
||||
|
||||
|
||||
class ImpactCompare:
|
||||
@classmethod
|
||||
@@ -115,7 +116,6 @@ class ImpactConditionalBranchSelMode:
|
||||
RETURN_TYPES = (any_typ, )
|
||||
|
||||
def doit(self, cond, tt_value=None, ff_value=None, **kwargs):
|
||||
print(f'tt={tt_value is None}\nff={ff_value is None}')
|
||||
if cond:
|
||||
return (tt_value,)
|
||||
else:
|
||||
@@ -272,6 +272,24 @@ class ImpactFloat:
|
||||
return (value, )
|
||||
|
||||
|
||||
class ImpactBoolean:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"value": ("BOOLEAN", {"default": False}),
|
||||
},
|
||||
}
|
||||
|
||||
FUNCTION = "doit"
|
||||
CATEGORY = "ImpactPack/Logic"
|
||||
|
||||
RETURN_TYPES = ("BOOLEAN", )
|
||||
|
||||
def doit(self, value):
|
||||
return (value, )
|
||||
|
||||
|
||||
class ImpactValueSender:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
@@ -556,27 +574,6 @@ class ImpactSleep:
|
||||
return (signal,)
|
||||
|
||||
|
||||
error_skip_flag = False
|
||||
try:
|
||||
import cm_global
|
||||
def filter_message(str):
|
||||
global error_skip_flag
|
||||
|
||||
if "IMPACT-PACK-SIGNAL: STOP CONTROL BRIDGE" in str:
|
||||
return True
|
||||
elif error_skip_flag and "ERROR:root:!!! Exception during processing !!!\n" == str:
|
||||
error_skip_flag = False
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
cm_global.try_call(api='cm.register_message_collapse', f=filter_message)
|
||||
|
||||
except Exception as e:
|
||||
print(f"[WARN] ComfyUI-Impact-Pack: `ComfyUI` or `ComfyUI-Manager` is an outdated version.")
|
||||
pass
|
||||
|
||||
|
||||
def workflow_to_map(workflow):
|
||||
nodes = {}
|
||||
links = {}
|
||||
@@ -657,8 +654,8 @@ class ImpactControlBridge:
|
||||
# so extra_pnginfo is useless in here
|
||||
try:
|
||||
workflow = core.current_prompt['extra_data']['extra_pnginfo']['workflow']
|
||||
except:
|
||||
print(f"[Impact Pack] core.current_prompt['extra_data']['extra_pnginfo']['workflow']")
|
||||
except Exception:
|
||||
logging.info("[Impact Pack] core.current_prompt['extra_data']['extra_pnginfo']['workflow']")
|
||||
return 0
|
||||
|
||||
nodes, links = workflow_to_map(workflow)
|
||||
@@ -673,16 +670,19 @@ class ImpactControlBridge:
|
||||
def doit(self, value, mode, behavior="Stop", unique_id=None, prompt=None, extra_pnginfo=None):
|
||||
global error_skip_flag
|
||||
|
||||
if core.is_execution_model_version_supported:
|
||||
if core.is_execution_model_version_supported():
|
||||
from comfy_execution.graph import ExecutionBlocker
|
||||
else:
|
||||
print("[Impact Pack] ImpactControlBridge: ComfyUI is outdated. The 'Stop' behavior cannot function properly.")
|
||||
logging.info("[Impact Pack] ImpactControlBridge: ComfyUI is outdated. The 'Stop' behavior cannot function properly.")
|
||||
|
||||
if behavior == "Stop":
|
||||
if mode:
|
||||
return (value, )
|
||||
else:
|
||||
return (ExecutionBlocker(None), )
|
||||
elif extra_pnginfo is None:
|
||||
logging.warning(f"[Impact Pack] limitation: '{behavior}' behavior cannot be used in API execution.")
|
||||
return (value,)
|
||||
else:
|
||||
workflow_nodes, links = workflow_to_map(extra_pnginfo['workflow'])
|
||||
|
||||
@@ -713,7 +713,7 @@ class ImpactControlBridge:
|
||||
PromptServer.instance.send_sync("impact-bridge-continue", {"node_id": unique_id, 'actives': list(should_be_active_nodes)})
|
||||
nodes.interrupt_processing()
|
||||
|
||||
elif behavior == "Mute" or behavior == True:
|
||||
elif behavior == "Mute" or behavior == True: # noqa: E712
|
||||
# mute
|
||||
should_be_mute_nodes = active_nodes + bypass_nodes
|
||||
if len(should_be_mute_nodes) > 0:
|
||||
@@ -748,6 +748,29 @@ class ImpactExecutionOrderController:
|
||||
return signal, value
|
||||
|
||||
|
||||
class ImpactListBridge:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {"required": {
|
||||
"list_input": (any_typ,),
|
||||
}}
|
||||
|
||||
FUNCTION = "doit"
|
||||
|
||||
DESCRIPTION = "When passing the list output through this node, it collects and organizes the data before forwarding it, which ensures that the previous stage's sub-workflow has been completed."
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
RETURN_TYPES = (any_typ, )
|
||||
RETURN_NAMES = ("list_output", )
|
||||
|
||||
INPUT_IS_LIST = True
|
||||
OUTPUT_IS_LIST = (True, )
|
||||
|
||||
@staticmethod
|
||||
def doit(list_input):
|
||||
return (list_input,)
|
||||
|
||||
|
||||
original_handle_execution = execution.PromptExecutor.handle_execution_error
|
||||
|
||||
|
||||
|
||||
@@ -1,219 +0,0 @@
|
||||
import folder_paths
|
||||
from impact.core import *
|
||||
import os
|
||||
|
||||
import mmcv
|
||||
from mmdet.apis import (inference_detector, init_detector)
|
||||
from mmdet.evaluation import get_classes
|
||||
|
||||
|
||||
def load_mmdet(model_path):
|
||||
model_config = os.path.splitext(model_path)[0] + ".py"
|
||||
model = init_detector(model_config, model_path, device="cpu")
|
||||
return model
|
||||
|
||||
|
||||
def inference_segm_old(model, image, conf_threshold):
|
||||
image = image.numpy()[0] * 255
|
||||
mmdet_results = inference_detector(model, image)
|
||||
|
||||
bbox_results, segm_results = mmdet_results
|
||||
label = "A"
|
||||
|
||||
classes = get_classes("coco")
|
||||
labels = [
|
||||
np.full(bbox.shape[0], i, dtype=np.int32)
|
||||
for i, bbox in enumerate(bbox_results)
|
||||
]
|
||||
n, m = bbox_results[0].shape
|
||||
if n == 0:
|
||||
return [[], [], []]
|
||||
labels = np.concatenate(labels)
|
||||
bboxes = np.vstack(bbox_results)
|
||||
segms = mmcv.concat_list(segm_results)
|
||||
filter_idxs = np.where(bboxes[:, -1] > conf_threshold)[0]
|
||||
results = [[], [], []]
|
||||
for i in filter_idxs:
|
||||
results[0].append(label + "-" + classes[labels[i]])
|
||||
results[1].append(bboxes[i])
|
||||
results[2].append(segms[i])
|
||||
|
||||
return results
|
||||
|
||||
|
||||
def inference_segm(image, modelname, conf_thres, lab="A"):
|
||||
image = image.numpy()[0] * 255
|
||||
mmdet_results = inference_detector(modelname, image).pred_instances
|
||||
bboxes = mmdet_results.bboxes.numpy()
|
||||
segms = mmdet_results.masks.numpy()
|
||||
scores = mmdet_results.scores.numpy()
|
||||
|
||||
classes = get_classes("coco")
|
||||
|
||||
n, m = bboxes.shape
|
||||
if n == 0:
|
||||
return [[], [], [], []]
|
||||
labels = mmdet_results.labels
|
||||
filter_inds = np.where(mmdet_results.scores > conf_thres)[0]
|
||||
results = [[], [], [], []]
|
||||
for i in filter_inds:
|
||||
results[0].append(lab + "-" + classes[labels[i]])
|
||||
results[1].append(bboxes[i])
|
||||
results[2].append(segms[i])
|
||||
results[3].append(scores[i])
|
||||
|
||||
return results
|
||||
|
||||
|
||||
def inference_bbox(modelname, image, conf_threshold):
|
||||
image = image.numpy()[0] * 255
|
||||
label = "A"
|
||||
output = inference_detector(modelname, image).pred_instances
|
||||
cv2_image = np.array(image)
|
||||
cv2_image = cv2_image[:, :, ::-1].copy()
|
||||
cv2_gray = cv2.cvtColor(cv2_image, cv2.COLOR_BGR2GRAY)
|
||||
|
||||
segms = []
|
||||
for x0, y0, x1, y1 in output.bboxes:
|
||||
cv2_mask = np.zeros(cv2_gray.shape, np.uint8)
|
||||
cv2.rectangle(cv2_mask, (int(x0), int(y0)), (int(x1), int(y1)), 255, -1)
|
||||
cv2_mask_bool = cv2_mask.astype(bool)
|
||||
segms.append(cv2_mask_bool)
|
||||
|
||||
n, m = output.bboxes.shape
|
||||
if n == 0:
|
||||
return [[], [], [], []]
|
||||
|
||||
bboxes = output.bboxes.numpy()
|
||||
scores = output.scores.numpy()
|
||||
filter_idxs = np.where(scores > conf_threshold)[0]
|
||||
results = [[], [], [], []]
|
||||
for i in filter_idxs:
|
||||
results[0].append(label)
|
||||
results[1].append(bboxes[i])
|
||||
results[2].append(segms[i])
|
||||
results[3].append(scores[i])
|
||||
|
||||
return results
|
||||
|
||||
|
||||
class BBoxDetector:
|
||||
bbox_model = None
|
||||
|
||||
def __init__(self, bbox_model):
|
||||
self.bbox_model = bbox_model
|
||||
|
||||
def detect(self, image, threshold, dilation, crop_factor, drop_size=1, detailer_hook=None):
|
||||
drop_size = max(drop_size, 1)
|
||||
mmdet_results = inference_bbox(self.bbox_model, image, threshold)
|
||||
segmasks = create_segmasks(mmdet_results)
|
||||
|
||||
if dilation > 0:
|
||||
segmasks = dilate_masks(segmasks, dilation)
|
||||
|
||||
items = []
|
||||
h = image.shape[1]
|
||||
w = image.shape[2]
|
||||
|
||||
for x in segmasks:
|
||||
item_bbox = x[0]
|
||||
item_mask = x[1]
|
||||
|
||||
y1, x1, y2, x2 = item_bbox
|
||||
|
||||
if x2 - x1 > drop_size and y2 - y1 > drop_size: # minimum dimension must be (2,2) to avoid squeeze issue
|
||||
crop_region = make_crop_region(w, h, item_bbox, crop_factor)
|
||||
cropped_image = crop_image(image, crop_region)
|
||||
cropped_mask = crop_ndarray2(item_mask, crop_region)
|
||||
confidence = x[2]
|
||||
# bbox_size = (item_bbox[2]-item_bbox[0],item_bbox[3]-item_bbox[1]) # (w,h)
|
||||
|
||||
item = SEG(cropped_image, cropped_mask, confidence, crop_region, item_bbox, None, None)
|
||||
|
||||
items.append(item)
|
||||
|
||||
shape = image.shape[1], image.shape[2]
|
||||
return shape, items
|
||||
|
||||
def detect_combined(self, image, threshold, dilation):
|
||||
mmdet_results = inference_bbox(self.bbox_model, image, threshold)
|
||||
segmasks = create_segmasks(mmdet_results)
|
||||
if dilation > 0:
|
||||
segmasks = dilate_masks(segmasks, dilation)
|
||||
|
||||
return combine_masks(segmasks)
|
||||
|
||||
def setAux(self, x):
|
||||
pass
|
||||
|
||||
|
||||
class SegmDetector(BBoxDetector):
|
||||
segm_model = None
|
||||
|
||||
def __init__(self, segm_model):
|
||||
self.segm_model = segm_model
|
||||
|
||||
def detect(self, image, threshold, dilation, crop_factor, drop_size=1, detailer_hook=None):
|
||||
drop_size = max(drop_size, 1)
|
||||
mmdet_results = inference_segm(image, self.segm_model, threshold)
|
||||
segmasks = create_segmasks(mmdet_results)
|
||||
|
||||
if dilation > 0:
|
||||
segmasks = dilate_masks(segmasks, dilation)
|
||||
|
||||
items = []
|
||||
h = image.shape[1]
|
||||
w = image.shape[2]
|
||||
for x in segmasks:
|
||||
item_bbox = x[0]
|
||||
item_mask = x[1]
|
||||
|
||||
y1, x1, y2, x2 = item_bbox
|
||||
|
||||
if x2 - x1 > drop_size and y2 - y1 > drop_size: # minimum dimension must be (2,2) to avoid squeeze issue
|
||||
crop_region = make_crop_region(w, h, item_bbox, crop_factor)
|
||||
cropped_image = crop_image(image, crop_region)
|
||||
cropped_mask = crop_ndarray2(item_mask, crop_region)
|
||||
confidence = x[2]
|
||||
|
||||
item = SEG(cropped_image, cropped_mask, confidence, crop_region, item_bbox, None, None)
|
||||
items.append(item)
|
||||
|
||||
segs = image.shape, items
|
||||
|
||||
if detailer_hook is not None and hasattr(detailer_hook, "post_detection"):
|
||||
segs = detailer_hook.post_detection(segs)
|
||||
|
||||
return segs
|
||||
|
||||
def detect_combined(self, image, threshold, dilation):
|
||||
mmdet_results = inference_bbox(self.bbox_model, image, threshold)
|
||||
segmasks = create_segmasks(mmdet_results)
|
||||
if dilation > 0:
|
||||
segmasks = dilate_masks(segmasks, dilation)
|
||||
|
||||
return combine_masks(segmasks)
|
||||
|
||||
def setAux(self, x):
|
||||
pass
|
||||
|
||||
|
||||
class MMDetDetectorProvider:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
bboxs = ["bbox/"+x for x in folder_paths.get_filename_list("mmdets_bbox")]
|
||||
segms = ["segm/"+x for x in folder_paths.get_filename_list("mmdets_segm")]
|
||||
return {"required": {"model_name": (bboxs + segms, )}}
|
||||
RETURN_TYPES = ("BBOX_DETECTOR", "SEGM_DETECTOR")
|
||||
FUNCTION = "load_mmdet"
|
||||
|
||||
CATEGORY = "ImpactPack"
|
||||
|
||||
def load_mmdet(self, model_name):
|
||||
mmdet_path = folder_paths.get_full_path("mmdets", model_name)
|
||||
model = load_mmdet(mmdet_path)
|
||||
|
||||
if model_name.startswith("bbox"):
|
||||
return BBoxDetector(model), NO_SEGM_DETECTOR()
|
||||
else:
|
||||
return NO_BBOX_DETECTOR(), model
|
||||
@@ -1,5 +1,4 @@
|
||||
import folder_paths
|
||||
import impact.wildcards
|
||||
from impact.utils import any_typ
|
||||
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
import comfy.sample
|
||||
import traceback
|
||||
|
||||
original_sample = comfy.sample.sample
|
||||
|
||||
|
||||
def informative_sample(*args, **kwargs):
|
||||
try:
|
||||
return original_sample(*args, **kwargs) # This code helps interpret error messages that occur within exceptions but does not have any impact on other operations.
|
||||
except RuntimeError as e:
|
||||
is_model_mix_issue = False
|
||||
try:
|
||||
if 'mat1 and mat2 shapes cannot be multiplied' in e.args[0]:
|
||||
if 'torch.nn.functional.linear' in traceback.format_exc().strip().split('\n')[-3]:
|
||||
is_model_mix_issue = True
|
||||
except:
|
||||
pass
|
||||
|
||||
if is_model_mix_issue:
|
||||
raise RuntimeError("\n\n#### It seems that models and clips are mixed and interconnected between SDXL Base, SDXL Refiner, SD1.x, and SD2.x. Please verify. ####\n\n")
|
||||
else:
|
||||
raise e
|
||||
|
||||
|
||||
comfy.sample.sample = informative_sample
|
||||
@@ -4,7 +4,6 @@ import sys
|
||||
import impact.impact_server
|
||||
from nodes import MAX_RESOLUTION
|
||||
|
||||
from impact.utils import *
|
||||
from . import core
|
||||
from .core import SEG
|
||||
import impact.utils as utils
|
||||
@@ -12,12 +11,20 @@ from . import defs
|
||||
from . import segs_upscaler
|
||||
from comfy.cli_args import args
|
||||
import math
|
||||
from PIL import Image
|
||||
import comfy
|
||||
import numpy as np
|
||||
import torch
|
||||
import folder_paths
|
||||
import logging
|
||||
|
||||
|
||||
from typing import Callable, Union
|
||||
|
||||
try:
|
||||
from comfy_extras import nodes_differential_diffusion
|
||||
except Exception:
|
||||
print(f"\n#############################################\n[Impact Pack] ComfyUI is an outdated version.\n#############################################\n")
|
||||
logging.info("\n#############################################\n[Impact Pack] ComfyUI is an outdated version.\n#############################################\n")
|
||||
raise Exception("[Impact Pack] ComfyUI is an outdated version.")
|
||||
|
||||
|
||||
@@ -38,7 +45,7 @@ class SEGSDetailer:
|
||||
"denoise": ("FLOAT", {"default": 0.5, "min": 0.0001, "max": 1.0, "step": 0.01}),
|
||||
"noise_mask": ("BOOLEAN", {"default": True, "label_on": "enabled", "label_off": "disabled"}),
|
||||
"force_inpaint": ("BOOLEAN", {"default": True, "label_on": "enabled", "label_off": "disabled"}),
|
||||
"basic_pipe": ("BASIC_PIPE",),
|
||||
"basic_pipe": ("BASIC_PIPE", {"tooltip": "If the `ImpactDummyInput` is connected to the model in the basic_pipe, the inference stage is skipped."}),
|
||||
"refiner_ratio": ("FLOAT", {"default": 0.2, "min": 0.0, "max": 1.0}),
|
||||
"batch_size": ("INT", {"default": 1, "min": 1, "max": 100}),
|
||||
|
||||
@@ -60,6 +67,8 @@ class SEGSDetailer:
|
||||
|
||||
CATEGORY = "ImpactPack/Detailer"
|
||||
|
||||
DESCRIPTION = "This node enhances details by inpainting each region within the detected area bundle (SEGS) after enlarging them based on the guide size.\nThis node is applied specifically to SEGS rather than the entire image. To apply it to the entire image, use the 'SEGS Paste' node."
|
||||
|
||||
@staticmethod
|
||||
def do_detail(image, segs, guide_size, guide_size_for, max_size, seed, steps, cfg, sampler_name, scheduler,
|
||||
denoise, noise_mask, force_inpaint, basic_pipe, refiner_ratio=None, batch_size=1, cycle=1,
|
||||
@@ -76,19 +85,19 @@ class SEGSDetailer:
|
||||
new_segs = []
|
||||
cnet_pil_list = []
|
||||
|
||||
if noise_mask_feather > 0 and 'denoise_mask_function' not in model.model_options:
|
||||
if not (isinstance(model, str) and model == "DUMMY") and noise_mask_feather > 0 and 'denoise_mask_function' not in model.model_options:
|
||||
model = nodes_differential_diffusion.DifferentialDiffusion().apply(model)[0]
|
||||
|
||||
for i in range(batch_size):
|
||||
seed += 1
|
||||
for seg in segs[1]:
|
||||
cropped_image = seg.cropped_image if seg.cropped_image is not None \
|
||||
else crop_ndarray4(image.numpy(), seg.crop_region)
|
||||
cropped_image = to_tensor(cropped_image)
|
||||
else utils.crop_ndarray4(image.numpy(), seg.crop_region)
|
||||
cropped_image = utils.to_tensor(cropped_image)
|
||||
|
||||
is_mask_all_zeros = (seg.cropped_mask == 0).all().item()
|
||||
if is_mask_all_zeros:
|
||||
print(f"Detailer: segment skip [empty mask]")
|
||||
logging.info("Detailer: segment skip [empty mask]")
|
||||
new_segs.append(seg)
|
||||
continue
|
||||
|
||||
@@ -113,13 +122,17 @@ class SEGSDetailer:
|
||||
for condition, details in negative
|
||||
]
|
||||
|
||||
enhanced_image, cnet_pils = core.enhance_detail(cropped_image, model, clip, vae, guide_size, guide_size_for, max_size,
|
||||
seg.bbox, seed, steps, cfg, sampler_name, scheduler,
|
||||
cropped_positive, cropped_negative, denoise, cropped_mask, force_inpaint,
|
||||
refiner_ratio=refiner_ratio, refiner_model=refiner_model,
|
||||
refiner_clip=refiner_clip, refiner_positive=refiner_positive, refiner_negative=refiner_negative,
|
||||
control_net_wrapper=seg.control_net_wrapper, cycle=cycle,
|
||||
inpaint_model=inpaint_model, noise_mask_feather=noise_mask_feather, scheduler_func=scheduler_func_opt)
|
||||
if not (isinstance(model, str) and model == "DUMMY"):
|
||||
enhanced_image, cnet_pils = core.enhance_detail(cropped_image, model, clip, vae, guide_size, guide_size_for, max_size,
|
||||
seg.bbox, seed, steps, cfg, sampler_name, scheduler,
|
||||
cropped_positive, cropped_negative, denoise, cropped_mask, force_inpaint,
|
||||
refiner_ratio=refiner_ratio, refiner_model=refiner_model,
|
||||
refiner_clip=refiner_clip, refiner_positive=refiner_positive, refiner_negative=refiner_negative,
|
||||
control_net_wrapper=seg.control_net_wrapper, cycle=cycle,
|
||||
inpaint_model=inpaint_model, noise_mask_feather=noise_mask_feather, scheduler_func=scheduler_func_opt)
|
||||
else:
|
||||
enhanced_image = cropped_image
|
||||
cnet_pils = None
|
||||
|
||||
if cnet_pils is not None:
|
||||
cnet_pil_list.extend(cnet_pils)
|
||||
@@ -129,7 +142,7 @@ class SEGSDetailer:
|
||||
else:
|
||||
new_cropped_image = enhanced_image
|
||||
|
||||
new_seg = SEG(to_numpy(new_cropped_image), seg.cropped_mask, seg.confidence, seg.crop_region, seg.bbox, seg.label, None)
|
||||
new_seg = SEG(utils.to_numpy(new_cropped_image), seg.cropped_mask, seg.confidence, seg.crop_region, seg.bbox, seg.label, None)
|
||||
new_segs.append(new_seg)
|
||||
|
||||
return (segs[0], new_segs), cnet_pil_list
|
||||
@@ -148,7 +161,7 @@ class SEGSDetailer:
|
||||
|
||||
# set fallback image
|
||||
if len(cnet_pil_list) == 0:
|
||||
cnet_pil_list = [empty_pil_tensor()]
|
||||
cnet_pil_list = [utils.empty_pil_tensor()]
|
||||
|
||||
return segs, cnet_pil_list
|
||||
|
||||
@@ -170,6 +183,8 @@ class SEGSPaste:
|
||||
|
||||
CATEGORY = "ImpactPack/Detailer"
|
||||
|
||||
DESCRIPTION = "This node provides a function to paste the enhanced SEGS, improved through the SEGS detailer, back onto the original image."
|
||||
|
||||
@staticmethod
|
||||
def doit(image, segs, feather, alpha=255, ref_image_opt=None):
|
||||
|
||||
@@ -188,12 +203,12 @@ class SEGSPaste:
|
||||
ref_image = cropped_image[i].unsqueeze(0)
|
||||
elif ref_image_opt is not None:
|
||||
ref_tensor = ref_image_opt[i].unsqueeze(0)
|
||||
ref_image = crop_image(ref_tensor, seg.crop_region)
|
||||
ref_image = utils.crop_image(ref_tensor, seg.crop_region)
|
||||
if ref_image is not None:
|
||||
if seg.cropped_mask.ndim == 3 and len(seg.cropped_mask) == len(image):
|
||||
mask = seg.cropped_mask[i]
|
||||
elif seg.cropped_mask.ndim == 3 and len(seg.cropped_mask) > 1:
|
||||
print(f"[Impact Pack] WARN: SEGSPaste - The number of the mask batch({len(seg.cropped_mask)}) and the image batch({len(image)}) are different. Combine the mask frames and apply.")
|
||||
logging.warning(f"[Impact Pack] SEGSPaste: The number of the mask batch({len(seg.cropped_mask)}) and the image batch({len(image)}) are different. Combine the mask frames and apply.")
|
||||
combined_mask = (seg.cropped_mask[0] * 255).to(torch.uint8)
|
||||
|
||||
for frame_mask in seg.cropped_mask[1:]:
|
||||
@@ -204,14 +219,14 @@ class SEGSPaste:
|
||||
else: # ndim == 2
|
||||
mask = seg.cropped_mask
|
||||
|
||||
mask = tensor_gaussian_blur_mask(mask, feather) * (alpha/255)
|
||||
mask = utils.tensor_gaussian_blur_mask(mask, feather) * (alpha/255)
|
||||
x, y, *_ = seg.crop_region
|
||||
|
||||
# ensure same device
|
||||
mask = mask.to(image_i.device)
|
||||
ref_image = ref_image.to(image_i.device)
|
||||
|
||||
tensor_paste(image_i, ref_image, (x, y), mask)
|
||||
utils.tensor_paste(image_i, ref_image, (x, y), mask)
|
||||
|
||||
if result is None:
|
||||
result = image_i
|
||||
@@ -255,7 +270,7 @@ class SEGSPreviewCNet:
|
||||
cnet_image = seg.control_net_wrapper.control_image
|
||||
result_image_list.append(cnet_image)
|
||||
else:
|
||||
cnet_image = empty_pil_tensor(64, 64)
|
||||
cnet_image = utils.empty_pil_tensor(64, 64)
|
||||
|
||||
cnet_pil = utils.tensor2pil(cnet_image)
|
||||
cnet_pil.save(os.path.join(full_output_folder, file))
|
||||
@@ -363,14 +378,14 @@ class SEGSPreview:
|
||||
elif fallback_image_opt is not None:
|
||||
# take from original image
|
||||
ref_image = fallback_image_opt[i].unsqueeze(0)
|
||||
cropped_image = crop_image(ref_image, seg.crop_region)
|
||||
cropped_image = utils.crop_image(ref_image, seg.crop_region)
|
||||
|
||||
if cropped_image is not None:
|
||||
if isinstance(cropped_image, np.ndarray):
|
||||
cropped_image = torch.from_numpy(cropped_image)
|
||||
|
||||
cropped_image = cropped_image.clone()
|
||||
cropped_pil = to_pil(cropped_image)
|
||||
cropped_pil = utils.to_pil(cropped_image)
|
||||
|
||||
if alpha_mode:
|
||||
if isinstance(seg.cropped_mask, np.ndarray):
|
||||
@@ -473,7 +488,7 @@ class SEGSLabelAssign:
|
||||
labels = [label.strip() for label in labels]
|
||||
|
||||
if len(labels) != len(segs[1]):
|
||||
print(f'Warning (SEGSLabelAssign): length of labels ({len(labels)}) != length of segs ({len(segs[1])})')
|
||||
logging.warning(f'[Impact Pack] SEGSLabelAssign: length of labels ({len(labels)}) != length of segs ({len(segs[1])})')
|
||||
|
||||
labeled_segs = []
|
||||
|
||||
@@ -496,7 +511,7 @@ class SEGSOrderedFilter:
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"segs": ("SEGS", ),
|
||||
"target": (["area(=w*h)", "width", "height", "x1", "y1", "x2", "y2", "confidence"],),
|
||||
"target": (["area(=w*h)", "width", "height", "x1", "y1", "x2", "y2", "confidence", "none"],),
|
||||
"order": ("BOOLEAN", {"default": True, "label_on": "descending", "label_off": "ascending"}),
|
||||
"take_start": ("INT", {"default": 0, "min": 0, "max": sys.maxsize, "step": 1}),
|
||||
"take_count": ("INT", {"default": 1, "min": 0, "max": sys.maxsize, "step": 1}),
|
||||
@@ -509,51 +524,35 @@ class SEGSOrderedFilter:
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
@staticmethod
|
||||
def get_sort_key_fn(target: str) -> Union[Callable, None]:
|
||||
if target == "none":
|
||||
return None
|
||||
|
||||
def sort_key_fn(seg):
|
||||
x1, y1, x2, y2 = seg.crop_region
|
||||
if target == "confidence": return seg.confidence
|
||||
if target == "area(=w*h)": return (x2 - x1) * (y2 - y1)
|
||||
if target == "width": return x2 - x1
|
||||
if target == "height": return y2 - y1
|
||||
if target == "x1": return x1
|
||||
if target == "y1": return y1
|
||||
if target == "x2": return x2
|
||||
if target == "y2": return y2
|
||||
raise Exception(f"[Impact Pack] SEGSOrderedFilter - Unexpected target '{target}'")
|
||||
|
||||
return sort_key_fn
|
||||
|
||||
def doit(self, segs, target, order, take_start, take_count):
|
||||
segs_with_order = []
|
||||
sort_key_fn = SEGSOrderedFilter.get_sort_key_fn(target)
|
||||
|
||||
for seg in segs[1]:
|
||||
x1 = seg.crop_region[0]
|
||||
y1 = seg.crop_region[1]
|
||||
x2 = seg.crop_region[2]
|
||||
y2 = seg.crop_region[3]
|
||||
sorted_list = list(segs[1]) # make a shallow copy, so it does not mutate the original list when sort
|
||||
if sort_key_fn is not None:
|
||||
sorted_list.sort(key=sort_key_fn, reverse=order)
|
||||
|
||||
if target == "area(=w*h)":
|
||||
value = (y2 - y1) * (x2 - x1)
|
||||
elif target == "width":
|
||||
value = x2 - x1
|
||||
elif target == "height":
|
||||
value = y2 - y1
|
||||
elif target == "x1":
|
||||
value = x1
|
||||
elif target == "x2":
|
||||
value = x2
|
||||
elif target == "y1":
|
||||
value = y1
|
||||
elif target == "y2":
|
||||
value = y2
|
||||
elif target == "confidence":
|
||||
value = seg.confidence
|
||||
else:
|
||||
raise Exception(f"[Impact Pack] SEGSOrderedFilter - Unexpected target '{target}'")
|
||||
|
||||
segs_with_order.append((value, seg))
|
||||
|
||||
if order:
|
||||
sorted_list = sorted(segs_with_order, key=lambda x: x[0], reverse=True)
|
||||
else:
|
||||
sorted_list = sorted(segs_with_order, key=lambda x: x[0], reverse=False)
|
||||
|
||||
result_list = []
|
||||
remained_list = []
|
||||
|
||||
for i, item in enumerate(sorted_list):
|
||||
if take_start <= i < take_start + take_count:
|
||||
result_list.append(item[1])
|
||||
else:
|
||||
remained_list.append(item[1])
|
||||
|
||||
return (segs[0], result_list), (segs[0], remained_list),
|
||||
take_stop = take_start + take_count
|
||||
return (segs[0], sorted_list[take_start:take_stop]), \
|
||||
(segs[0], sorted_list[:take_start] + sorted_list[take_stop:]),
|
||||
|
||||
|
||||
class SEGSRangeFilter:
|
||||
@@ -590,7 +589,6 @@ class SEGSRangeFilter:
|
||||
h = y2 - y1
|
||||
w = x2 - x1
|
||||
value = max(h/w, w/h)*100
|
||||
print(f"value={value}")
|
||||
elif target == "width":
|
||||
value = x2 - x1
|
||||
elif target == "height":
|
||||
@@ -609,18 +607,123 @@ class SEGSRangeFilter:
|
||||
raise Exception(f"[Impact Pack] SEGSRangeFilter - Unexpected target '{target}'")
|
||||
|
||||
if mode and min_value <= value <= max_value:
|
||||
print(f"[in] value={value} / {mode}, {min_value}, {max_value}")
|
||||
logging.info(f"[in] value={value} / {mode}, {min_value}, {max_value}")
|
||||
new_segs.append(seg)
|
||||
elif not mode and (value < min_value or value > max_value):
|
||||
print(f"[out] value={value} / {mode}, {min_value}, {max_value}")
|
||||
logging.info(f"[out] value={value} / {mode}, {min_value}, {max_value}")
|
||||
new_segs.append(seg)
|
||||
else:
|
||||
remained_segs.append(seg)
|
||||
print(f"[filter] value={value} / {mode}, {min_value}, {max_value}")
|
||||
logging.info(f"[filter] value={value} / {mode}, {min_value}, {max_value}")
|
||||
|
||||
return (segs[0], new_segs), (segs[0], remained_segs),
|
||||
|
||||
|
||||
class SEGSIntersectionFilter:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"segs1": ("SEGS", ),
|
||||
"segs2": ("SEGS", ),
|
||||
"ioa_threshold": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("SEGS",)
|
||||
RETURN_NAMES = ("filtered_SEGS",)
|
||||
FUNCTION = "doit"
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
def compute_ioa(self, mask1, mask2):
|
||||
"""Compute Intersection over Area (IoA) between two boxes."""
|
||||
inter_mask = utils.bitwise_and_masks(mask1, mask2)
|
||||
|
||||
inter_area = (inter_mask > 0).sum()
|
||||
area1 = (mask1 > 0).sum()
|
||||
|
||||
return inter_area / area1 if area1 > 0 else 0
|
||||
|
||||
def doit(self, segs1, segs2, ioa_threshold):
|
||||
"""Remove segments from segs1 if their IoA with any segment in segs2 exceeds the threshold."""
|
||||
# Extract bounding boxes for all segments in segs1 and segs2
|
||||
keep = []
|
||||
|
||||
# Iterate over all segments in segs1
|
||||
for idx1, seg1 in enumerate(segs1[1]):
|
||||
keep_segment = True # Assume the segment should be kept
|
||||
mask1 = core.segs_to_combined_mask((segs1[0], [seg1]))
|
||||
|
||||
# Compare with every segment in segs2
|
||||
for seg2 in segs2[1]:
|
||||
mask2 = core.segs_to_combined_mask((segs2[0], [seg2]))
|
||||
ioa = self.compute_ioa(mask1, mask2) # IoA between segment 1 and segment 2
|
||||
|
||||
if ioa > ioa_threshold: # If IoA exceeds the threshold, mark the segment for removal
|
||||
keep_segment = False
|
||||
break # If one overlap exceeds threshold, break early and mark for removal
|
||||
|
||||
# Keep the segment if it did not exceed the threshold with any other segment
|
||||
if keep_segment:
|
||||
keep.append(segs1[1][idx1])
|
||||
|
||||
return (segs1[0], keep), # Return the updated SEGS
|
||||
|
||||
|
||||
class SEGSNMSFilter:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"segs": ("SEGS",),
|
||||
"iou_threshold": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("SEGS",)
|
||||
RETURN_NAMES = ("filtered_SEGS",)
|
||||
FUNCTION = "doit"
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
def compute_iou(self, mask1, mask2):
|
||||
"""Compute IoU between two bounding boxes (x1, y1, x2, y2)."""
|
||||
inter_mask = utils.bitwise_and_masks(mask1, mask2)
|
||||
union_mask = utils.add_masks(mask1, mask2)
|
||||
|
||||
inter_area = (inter_mask > 0).sum()
|
||||
union_area = (union_mask > 0).sum()
|
||||
|
||||
return inter_area / union_area if union_area > 0 else 0
|
||||
|
||||
def doit(self, segs, iou_threshold):
|
||||
"""Perform NMS to filter overlapping segments."""
|
||||
confidences = np.ndarray.flatten(np.array([seg.confidence for seg in segs[1]]))
|
||||
|
||||
# Sort boxes by confidence (high to low)
|
||||
sorted_indices = np.argsort(confidences)[::-1].tolist()
|
||||
keep = []
|
||||
|
||||
while len(sorted_indices) > 0:
|
||||
idx = sorted_indices[0]
|
||||
mask1 = core.segs_to_combined_mask((segs[0], [segs[1][idx]]))
|
||||
keep.append(idx)
|
||||
sorted_indices = sorted_indices[1:]
|
||||
|
||||
# Filter indices only contain the indices where the bbox does not intersect
|
||||
filtered_indices = []
|
||||
for i in sorted_indices:
|
||||
mask2 = core.segs_to_combined_mask((segs[0], [segs[1][i]]))
|
||||
iou = self.compute_iou(mask1, mask2)
|
||||
if iou < iou_threshold:
|
||||
filtered_indices.append(i)
|
||||
|
||||
sorted_indices = np.array(filtered_indices)
|
||||
|
||||
filtered_segs = [segs[1][i] for i in keep]
|
||||
return (segs[0], filtered_segs),
|
||||
|
||||
|
||||
class SEGSToImageList:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
@@ -646,17 +749,17 @@ class SEGSToImageList:
|
||||
|
||||
for seg in segs[1]:
|
||||
if seg.cropped_image is not None:
|
||||
cropped_image = to_tensor(seg.cropped_image)
|
||||
cropped_image = utils.to_tensor(seg.cropped_image)
|
||||
elif fallback_image_opt is not None:
|
||||
# take from original image
|
||||
cropped_image = to_tensor(crop_image(fallback_image_opt, seg.crop_region))
|
||||
cropped_image = utils.to_tensor(utils.crop_image(fallback_image_opt, seg.crop_region))
|
||||
else:
|
||||
cropped_image = empty_pil_tensor()
|
||||
cropped_image = utils.empty_pil_tensor()
|
||||
|
||||
results.append(cropped_image)
|
||||
|
||||
if len(results) == 0:
|
||||
results.append(empty_pil_tensor())
|
||||
results.append(utils.empty_pil_tensor())
|
||||
|
||||
return (results,)
|
||||
|
||||
@@ -704,6 +807,68 @@ class SEGSToMaskBatch:
|
||||
return (mask_batch,)
|
||||
|
||||
|
||||
class SEGSMerge:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"segs": ("SEGS", ),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("SEGS",)
|
||||
FUNCTION = "doit"
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
DESCRIPTION = "SEGS contains multiple SEGs. SEGS Merge integrates several SEGs into a single merged SEG. The label is changed to `merged` and the confidence becomes the minimum confidence. The applied controlnet and cropped_image are removed."
|
||||
|
||||
def doit(self, segs):
|
||||
crop_left = sys.maxsize
|
||||
crop_right = 0
|
||||
crop_top = sys.maxsize
|
||||
crop_bottom = 0
|
||||
|
||||
bbox_left = sys.maxsize
|
||||
bbox_right = 0
|
||||
bbox_top = sys.maxsize
|
||||
bbox_bottom = 0
|
||||
|
||||
min_confidence = 1.0
|
||||
|
||||
for seg in segs[1]:
|
||||
cx1 = seg.crop_region[0]
|
||||
cy1 = seg.crop_region[1]
|
||||
cx2 = seg.crop_region[2]
|
||||
cy2 = seg.crop_region[3]
|
||||
|
||||
bx1 = seg.bbox[0]
|
||||
by1 = seg.bbox[1]
|
||||
bx2 = seg.bbox[2]
|
||||
by2 = seg.bbox[3]
|
||||
|
||||
crop_left = min(crop_left, cx1)
|
||||
crop_top = min(crop_top, cy1)
|
||||
crop_right = max(crop_right, cx2)
|
||||
crop_bottom = max(crop_bottom, cy2)
|
||||
|
||||
bbox_left = min(bbox_left, bx1)
|
||||
bbox_top = min(bbox_top, by1)
|
||||
bbox_right = max(bbox_right, bx2)
|
||||
bbox_bottom = max(bbox_bottom, by2)
|
||||
|
||||
min_confidence = min(min_confidence, seg.confidence)
|
||||
|
||||
combined_mask = core.segs_to_combined_mask(segs)
|
||||
cropped_mask = combined_mask[crop_top:crop_bottom, crop_left:crop_right]
|
||||
cropped_mask = cropped_mask.unsqueeze(0)
|
||||
|
||||
crop_region = [crop_left, crop_top, crop_right, crop_bottom]
|
||||
bbox = [bbox_left, bbox_top, bbox_right, bbox_bottom]
|
||||
|
||||
seg = SEG(None, cropped_mask, min_confidence, crop_region, bbox, 'merged', None)
|
||||
return ((segs[0], [seg]),)
|
||||
|
||||
|
||||
class SEGSConcat:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
@@ -732,7 +897,7 @@ class SEGSConcat:
|
||||
if v[0] == dim:
|
||||
res = res + v[1]
|
||||
else:
|
||||
print(f"ERROR: source shape of 'segs1'{dim} and '{k}'{v[0]} are different. '{k}' will be ignored")
|
||||
logging.error(f"[Impact Pack] source shape of 'segs1'{dim} and '{k}'{v[0]} are different. '{k}' will be ignored")
|
||||
|
||||
if dim is None:
|
||||
empty_segs = ((0, 0), [])
|
||||
@@ -814,8 +979,8 @@ class From_SEG_ELT:
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
def doit(self, seg_elt):
|
||||
cropped_image = to_tensor(seg_elt.cropped_image) if seg_elt.cropped_image is not None else None
|
||||
return (seg_elt, cropped_image, to_tensor(seg_elt.cropped_mask), seg_elt.crop_region, seg_elt.bbox, seg_elt.control_net_wrapper, seg_elt.confidence, seg_elt.label,)
|
||||
cropped_image = utils.to_tensor(seg_elt.cropped_image) if seg_elt.cropped_image is not None else None
|
||||
return (seg_elt, cropped_image, utils.to_tensor(seg_elt.cropped_mask), seg_elt.crop_region, seg_elt.bbox, seg_elt.control_net_wrapper, seg_elt.confidence, seg_elt.label,)
|
||||
|
||||
|
||||
class From_SEG_ELT_bbox:
|
||||
@@ -834,7 +999,7 @@ class From_SEG_ELT_bbox:
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
def doit(self, bbox):
|
||||
return bbox
|
||||
return [int(c) for c in bbox]
|
||||
|
||||
|
||||
class From_SEG_ELT_crop_region:
|
||||
@@ -918,7 +1083,7 @@ class DilateMask:
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
def doit(self, mask, dilation):
|
||||
mask = core.dilate_mask(mask.numpy(), dilation)
|
||||
mask = utils.dilate_mask(mask.numpy(), dilation)
|
||||
mask = torch.from_numpy(mask)
|
||||
mask = utils.make_3d_mask(mask)
|
||||
return (mask, )
|
||||
@@ -941,7 +1106,7 @@ class GaussianBlurMask:
|
||||
|
||||
def doit(self, mask, kernel_size, sigma):
|
||||
# Some custom nodes use abnormal 4-dimensional masks in the format of b, c, h, w. In the impact pack, internal 4-dimensional masks are required in the format of b, h, w, c. Therefore, normalization is performed using the normal mask format, which is 3-dimensional, before proceeding with the operation.
|
||||
mask = make_3d_mask(mask)
|
||||
mask = utils.make_3d_mask(mask)
|
||||
mask = torch.unsqueeze(mask, dim=-1)
|
||||
mask = utils.tensor_gaussian_blur_mask(mask, kernel_size, sigma)
|
||||
mask = torch.squeeze(mask, dim=-1)
|
||||
@@ -965,7 +1130,7 @@ class DilateMaskInSEGS:
|
||||
def doit(self, segs, dilation):
|
||||
new_segs = []
|
||||
for seg in segs[1]:
|
||||
mask = core.dilate_mask(seg.cropped_mask, dilation)
|
||||
mask = utils.dilate_mask(seg.cropped_mask, dilation)
|
||||
seg = SEG(seg.cropped_image, mask, seg.confidence, seg.crop_region, seg.bbox, seg.label, seg.control_net_wrapper)
|
||||
new_segs.append(seg)
|
||||
|
||||
@@ -1013,7 +1178,7 @@ class Dilate_SEG_ELT:
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
def doit(self, seg, dilation):
|
||||
mask = core.dilate_mask(seg.cropped_mask, dilation)
|
||||
mask = utils.dilate_mask(seg.cropped_mask, dilation)
|
||||
seg = SEG(seg.cropped_image, mask, seg.confidence, seg.crop_region, seg.bbox, seg.label, seg.control_net_wrapper)
|
||||
return (seg,)
|
||||
|
||||
@@ -1039,10 +1204,10 @@ class SEG_ELT_BBOX_ScaleBy:
|
||||
x1, y1, x2, y2 = x1-cx1, y1-cy1, x2-cx1, y2-cy1
|
||||
h, w = mask.shape
|
||||
|
||||
x1 = min(w-1, max(0, x1))
|
||||
x2 = min(w-1, max(0, x2))
|
||||
y1 = min(h-1, max(0, y1))
|
||||
y2 = min(h-1, max(0, y2))
|
||||
x1 = int(min(w-1, max(0, x1)))
|
||||
x2 = int(min(w-1, max(0, x2)))
|
||||
y1 = int(min(h-1, max(0, y1)))
|
||||
y2 = int(min(h-1, max(0, y2)))
|
||||
|
||||
mask_cropped = mask.copy()
|
||||
mask_cropped[:, :x1] = 0 # zero fill left side
|
||||
@@ -1182,7 +1347,7 @@ class MaskToSEGS:
|
||||
|
||||
@staticmethod
|
||||
def doit(mask, combined, crop_factor, bbox_fill, drop_size, contour_fill=False):
|
||||
mask = make_2d_mask(mask)
|
||||
mask = utils.make_2d_mask(mask)
|
||||
result = core.mask_to_segs(mask, combined, crop_factor, bbox_fill, drop_size, is_contour=contour_fill)
|
||||
|
||||
return (result, )
|
||||
@@ -1209,13 +1374,13 @@ class MaskToSEGS_for_AnimateDiff:
|
||||
@staticmethod
|
||||
def doit(mask, combined, crop_factor, bbox_fill, drop_size, contour_fill=False):
|
||||
if (len(mask.shape) == 4 and mask.shape[1] > 1) or (len(mask.shape) == 3 and mask.shape[0] > 1):
|
||||
mask = make_3d_mask(mask)
|
||||
mask = utils.make_3d_mask(mask)
|
||||
if contour_fill:
|
||||
print(f"[Impact Pack] MaskToSEGS_for_AnimateDiff: 'contour_fill' is ignored because batch mask 'contour_fill' is not supported.")
|
||||
logging.info("[Impact Pack] MaskToSEGS_for_AnimateDiff: 'contour_fill' is ignored because batch mask 'contour_fill' is not supported.")
|
||||
result = core.batch_mask_to_segs(mask, combined, crop_factor, bbox_fill, drop_size)
|
||||
return (result, )
|
||||
|
||||
mask = make_2d_mask(mask)
|
||||
mask = utils.make_2d_mask(mask)
|
||||
segs = core.mask_to_segs(mask, combined, crop_factor, bbox_fill, drop_size, is_contour=contour_fill)
|
||||
all_masks = SEGSToMaskList().doit(segs)[0]
|
||||
|
||||
@@ -1261,7 +1426,7 @@ class IPAdapterApplySEGS:
|
||||
def doit(segs, ipadapter_pipe, weight, noise, weight_type, start_at, end_at, unfold_batch, faceid_v2, weight_v2, context_crop_factor, reference_image, combine_embeds="concat", neg_image=None):
|
||||
|
||||
if len(ipadapter_pipe) == 4:
|
||||
print(f"[Impact Pack] IPAdapterApplySEGS: Installed Inspire Pack is outdated.")
|
||||
logging.info("[Impact Pack] IPAdapterApplySEGS: Installed Inspire Pack is outdated.")
|
||||
raise Exception("Inspire Pack is outdated.")
|
||||
|
||||
new_segs = []
|
||||
@@ -1269,12 +1434,12 @@ class IPAdapterApplySEGS:
|
||||
h, w = segs[0]
|
||||
|
||||
if reference_image.shape[2] != w or reference_image.shape[1] != h:
|
||||
reference_image = tensor_resize(reference_image, w, h)
|
||||
|
||||
reference_image = utils.tensor_resize(reference_image, w, h)
|
||||
|
||||
for seg in segs[1]:
|
||||
# The context_crop_region sets how much wider the IPAdapter context will reflect compared to the crop_region, not the bbox
|
||||
context_crop_region = make_crop_region(w, h, seg.crop_region, context_crop_factor)
|
||||
cropped_image = crop_image(reference_image, context_crop_region)
|
||||
context_crop_region = utils.make_crop_region(w, h, seg.crop_region, context_crop_factor)
|
||||
cropped_image = utils.crop_image(reference_image, context_crop_region)
|
||||
|
||||
control_net_wrapper = core.IPAdapterWrapper(ipadapter_pipe, weight, noise, weight_type, start_at, end_at, unfold_batch, weight_v2, cropped_image, neg_image=neg_image, prev_control_net=seg.control_net_wrapper, combine_embeds=combine_embeds)
|
||||
new_seg = SEG(seg.cropped_image, seg.cropped_mask, seg.confidence, seg.crop_region, seg.bbox, seg.label, control_net_wrapper)
|
||||
@@ -1300,6 +1465,8 @@ class ControlNetApplySEGS:
|
||||
RETURN_TYPES = ("SEGS",)
|
||||
FUNCTION = "doit"
|
||||
|
||||
DEPRECATED = True
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
@staticmethod
|
||||
@@ -1327,7 +1494,8 @@ class ControlNetApplyAdvancedSEGS:
|
||||
},
|
||||
"optional": {
|
||||
"segs_preprocessor": ("SEGS_PREPROCESSOR",),
|
||||
"control_image": ("IMAGE",)
|
||||
"control_image": ("IMAGE",),
|
||||
"vae": ("VAE",)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1337,13 +1505,13 @@ class ControlNetApplyAdvancedSEGS:
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
@staticmethod
|
||||
def doit(segs, control_net, strength, start_percent, end_percent, segs_preprocessor=None, control_image=None):
|
||||
def doit(segs, control_net, strength, start_percent, end_percent, segs_preprocessor=None, control_image=None, vae=None):
|
||||
new_segs = []
|
||||
|
||||
for seg in segs[1]:
|
||||
control_net_wrapper = core.ControlNetAdvancedWrapper(control_net, strength, start_percent, end_percent, segs_preprocessor,
|
||||
seg.control_net_wrapper, original_size=segs[0], crop_region=seg.crop_region,
|
||||
control_image=control_image)
|
||||
control_image=control_image, vae=vae)
|
||||
new_seg = SEG(seg.cropped_image, seg.cropped_mask, seg.confidence, seg.crop_region, seg.bbox, seg.label, control_net_wrapper)
|
||||
new_segs.append(new_seg)
|
||||
|
||||
@@ -1394,7 +1562,7 @@ class SEGSSwitch:
|
||||
if input_name in kwargs:
|
||||
return (kwargs[input_name],)
|
||||
else:
|
||||
print(f"SEGSSwitch: invalid select index ('segs1' is selected)")
|
||||
logging.info("SEGSSwitch: invalid select index ('segs1' is selected)")
|
||||
return (kwargs['segs1'],)
|
||||
|
||||
|
||||
@@ -1417,6 +1585,8 @@ class SEGSPicker:
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
DESCRIPTION = "This node provides a function to select only the chosen SEGS from the input SEGS."
|
||||
|
||||
@staticmethod
|
||||
def doit(picks, segs, fallback_image_opt=None, unique_id=None):
|
||||
if fallback_image_opt is not None:
|
||||
@@ -1429,9 +1599,9 @@ class SEGSPicker:
|
||||
cropped_image = seg.cropped_image
|
||||
elif fallback_image_opt is not None:
|
||||
# take from original image
|
||||
cropped_image = crop_image(fallback_image_opt, seg.crop_region)
|
||||
cropped_image = utils.crop_image(fallback_image_opt, seg.crop_region)
|
||||
else:
|
||||
cropped_image = empty_pil_tensor()
|
||||
cropped_image = utils.empty_pil_tensor()
|
||||
|
||||
mask_array = seg.cropped_mask.copy()
|
||||
mask_array[mask_array < 0.3] = 0.3
|
||||
@@ -1473,6 +1643,8 @@ class DefaultImageForSEGS:
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
DESCRIPTION = "If the SEGS have not passed through the detailer, they contain only detection area information without an image. This node sets a default image for the SEGS."
|
||||
|
||||
@staticmethod
|
||||
def doit(segs, image, override):
|
||||
results = []
|
||||
@@ -1493,7 +1665,7 @@ class DefaultImageForSEGS:
|
||||
for i in range(0, batch_count):
|
||||
# take from original image
|
||||
ref_image = image[i].unsqueeze(0)
|
||||
cropped_image2 = crop_image(ref_image, seg.crop_region)
|
||||
cropped_image2 = utils.crop_image(ref_image, seg.crop_region)
|
||||
|
||||
if cropped_image is None:
|
||||
cropped_image = cropped_image2
|
||||
@@ -1560,7 +1732,7 @@ class MakeTileSEGS:
|
||||
def doit(images, bbox_size, crop_factor, min_overlap, filter_segs_dilation, mask_irregularity=0, irregular_mask_mode="Reuse fast", filter_in_segs_opt=None, filter_out_segs_opt=None):
|
||||
if bbox_size <= 2*min_overlap:
|
||||
new_min_overlap = bbox_size / 2
|
||||
print(f"[MakeTileSEGS] min_overlap should be greater than bbox_size. (value changed: {min_overlap} => {new_min_overlap})")
|
||||
logging.info(f"[MakeTileSEGS] min_overlap should be greater than bbox_size. (value changed: {min_overlap} => {new_min_overlap})")
|
||||
min_overlap = new_min_overlap
|
||||
|
||||
_, ih, iw, _ = images.size()
|
||||
@@ -1590,7 +1762,7 @@ class MakeTileSEGS:
|
||||
exclusion_mask = core.segs_to_combined_mask(filter_out_segs_opt)
|
||||
exclusion_mask = utils.make_3d_mask(exclusion_mask)
|
||||
exclusion_mask = utils.resize_mask(exclusion_mask, (ih, iw))
|
||||
exclusion_mask = dilate_mask(exclusion_mask.cpu().numpy(), filter_segs_dilation)
|
||||
exclusion_mask = utils.dilate_mask(exclusion_mask.cpu().numpy(), filter_segs_dilation)
|
||||
else:
|
||||
exclusion_mask = None
|
||||
|
||||
@@ -1598,7 +1770,7 @@ class MakeTileSEGS:
|
||||
and_mask = core.segs_to_combined_mask(filter_in_segs_opt)
|
||||
and_mask = utils.make_3d_mask(and_mask)
|
||||
and_mask = utils.resize_mask(and_mask, (ih, iw))
|
||||
and_mask = dilate_mask(and_mask.cpu().numpy(), filter_segs_dilation)
|
||||
and_mask = utils.dilate_mask(and_mask.cpu().numpy(), filter_segs_dilation)
|
||||
|
||||
a, b = core.mask_to_segs(and_mask, True, 1.0, False, 0)
|
||||
if len(b) == 0:
|
||||
@@ -1616,7 +1788,7 @@ class MakeTileSEGS:
|
||||
# calculate tile factors
|
||||
if bbox_size > h or bbox_size > w:
|
||||
new_bbox_size = min(bbox_size, min(w, h))
|
||||
print(f"[MaskTileSEGS] bbox_size is greater than resolution (value changed: {bbox_size} => {new_bbox_size}")
|
||||
logging.info(f"[MaskTileSEGS] bbox_size is greater than resolution (value changed: {bbox_size} => {new_bbox_size}")
|
||||
bbox_size = new_bbox_size
|
||||
|
||||
n_horizontal = math.ceil(w / (bbox_size - min_overlap))
|
||||
@@ -1664,7 +1836,7 @@ class MakeTileSEGS:
|
||||
y1 = ih-bbox_size
|
||||
|
||||
bbox = x1, y1, x2, y2
|
||||
crop_region = make_crop_region(iw, ih, bbox, crop_factor)
|
||||
crop_region = utils.make_crop_region(iw, ih, bbox, crop_factor)
|
||||
cx1, cy1, cx2, cy2 = crop_region
|
||||
|
||||
mask = np.zeros((cy2 - cy1, cx2 - cx1)).astype(np.float32)
|
||||
@@ -1773,14 +1945,14 @@ class SEGSUpscaler:
|
||||
ordered_segs = segs[1]
|
||||
|
||||
for i, seg in enumerate(ordered_segs):
|
||||
cropped_image = crop_ndarray4(new_image.numpy(), seg.crop_region)
|
||||
cropped_image = to_tensor(cropped_image)
|
||||
mask = to_tensor(seg.cropped_mask)
|
||||
mask = tensor_gaussian_blur_mask(mask, feather)
|
||||
cropped_image = utils.crop_ndarray4(new_image.numpy(), seg.crop_region)
|
||||
cropped_image = utils.to_tensor(cropped_image)
|
||||
mask = utils.to_tensor(seg.cropped_mask)
|
||||
mask = utils.tensor_gaussian_blur_mask(mask, feather)
|
||||
|
||||
is_mask_all_zeros = (seg.cropped_mask == 0).all().item()
|
||||
if is_mask_all_zeros:
|
||||
print(f"SEGSUpscaler: segment skip [empty mask]")
|
||||
logging.info("SEGSUpscaler: segment skip [empty mask]")
|
||||
continue
|
||||
|
||||
cropped_mask = seg.cropped_mask
|
||||
@@ -1791,17 +1963,17 @@ class SEGSUpscaler:
|
||||
positive, negative, denoise,
|
||||
noise_mask=cropped_mask, control_net_wrapper=seg.control_net_wrapper,
|
||||
inpaint_model=inpaint_model, noise_mask_feather=noise_mask_feather, scheduler_func_opt=scheduler_func_opt)
|
||||
if not (enhanced_image is None):
|
||||
if enhanced_image is not None:
|
||||
new_image = new_image.cpu()
|
||||
enhanced_image = enhanced_image.cpu()
|
||||
left = seg.crop_region[0]
|
||||
top = seg.crop_region[1]
|
||||
tensor_paste(new_image, enhanced_image, (left, top), mask)
|
||||
utils.tensor_paste(new_image, enhanced_image, (left, top), mask)
|
||||
|
||||
if upscaler_hook_opt is not None:
|
||||
new_image = upscaler_hook_opt.post_paste(new_image)
|
||||
|
||||
enhanced_img = tensor_convert_rgb(new_image)
|
||||
enhanced_img = utils.tensor_convert_rgb(new_image)
|
||||
|
||||
return (enhanced_img,)
|
||||
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
from impact.utils import *
|
||||
from impact import impact_sampling
|
||||
from comfy import model_management
|
||||
from comfy.cli_args import args
|
||||
from impact import utils
|
||||
from PIL import Image
|
||||
import nodes
|
||||
import torch
|
||||
import inspect
|
||||
import logging
|
||||
import comfy
|
||||
|
||||
try:
|
||||
from comfy_extras import nodes_differential_diffusion
|
||||
except Exception:
|
||||
print(f"[Impact Pack] ComfyUI is an outdated version. The DifferentialDiffusion feature will be disabled.")
|
||||
logging.info("[Impact Pack] ComfyUI is an outdated version. The DifferentialDiffusion feature will be disabled.")
|
||||
|
||||
|
||||
# Implementation based on `https://github.com/lingondricka2/Upscaler-Detailer`
|
||||
@@ -19,7 +23,6 @@ def upscale_with_model(upscale_model, image):
|
||||
device = model_management.get_torch_device()
|
||||
upscale_model.to(device)
|
||||
in_img = image.movedim(-1, -3).to(device)
|
||||
free_memory = model_management.get_free_memory(device)
|
||||
|
||||
tile = 512
|
||||
overlap = 32
|
||||
@@ -72,9 +75,9 @@ def upscaler(image, upscale_model, rescale_factor, resampling_method, supersampl
|
||||
else:
|
||||
up_image = image
|
||||
|
||||
pil_img = tensor2pil(image)
|
||||
pil_img = utils.tensor2pil(image)
|
||||
original_width, original_height = pil_img.size
|
||||
scaled_image = pil2tensor(apply_resize_image(tensor2pil(up_image), original_width, original_height, rounding_modulus, 'rescale',
|
||||
scaled_image = utils.pil2tensor(apply_resize_image(utils.tensor2pil(up_image), original_width, original_height, rounding_modulus, 'rescale',
|
||||
supersample, rescale_factor, 1024, resampling_method))
|
||||
return scaled_image
|
||||
|
||||
@@ -92,10 +95,10 @@ def img2img_segs(image, model, clip, vae, seed, steps, cfg, sampler_name, schedu
|
||||
scale = 8/min(original_image_size[0], original_image_size[1]) + 1
|
||||
w = int(original_image_size[1] * scale)
|
||||
h = int(original_image_size[0] * scale)
|
||||
image = tensor_resize(image, w, h)
|
||||
image = utils.tensor_resize(image, w, h)
|
||||
|
||||
if noise_mask is not None:
|
||||
noise_mask = tensor_gaussian_blur_mask(noise_mask, noise_mask_feather)
|
||||
noise_mask = utils.tensor_gaussian_blur_mask(noise_mask, noise_mask_feather)
|
||||
noise_mask = noise_mask.squeeze(3)
|
||||
|
||||
if noise_mask_feather > 0 and 'denoise_mask_function' not in model.model_options:
|
||||
@@ -106,9 +109,14 @@ def img2img_segs(image, model, clip, vae, seed, steps, cfg, sampler_name, schedu
|
||||
|
||||
# prepare mask
|
||||
if noise_mask is not None and inpaint_model:
|
||||
positive, negative, latent_image = nodes.InpaintModelConditioning().encode(positive, negative, image, vae, noise_mask)
|
||||
imc_encode = nodes.InpaintModelConditioning().encode
|
||||
if 'noise_mask' in inspect.signature(imc_encode).parameters:
|
||||
positive, negative, latent_image = imc_encode(positive, negative, image, vae, mask=noise_mask, noise_mask=True)
|
||||
else:
|
||||
logging.info("[Impact Pack] ComfyUI is an outdated version.")
|
||||
positive, negative, latent_image = imc_encode(positive, negative, image, vae, noise_mask)
|
||||
else:
|
||||
latent_image = to_latent_image(image, vae)
|
||||
latent_image = utils.to_latent_image(image, vae)
|
||||
if noise_mask is not None:
|
||||
latent_image['noise_mask'] = noise_mask
|
||||
|
||||
@@ -125,7 +133,7 @@ def img2img_segs(image, model, clip, vae, seed, steps, cfg, sampler_name, schedu
|
||||
|
||||
# Match to original image size
|
||||
if refined_image.shape[1:3] != original_image_size:
|
||||
refined_image = tensor_resize(refined_image, original_image_size[1], original_image_size[0])
|
||||
refined_image = utils.tensor_resize(refined_image, original_image_size[1], original_image_size[0])
|
||||
|
||||
# don't convert to latent - latent break image
|
||||
# preserving pil is much better
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import math
|
||||
import impact.core as core
|
||||
from comfy_extras.nodes_custom_sampler import Noise_RandomNoise
|
||||
from impact.utils import *
|
||||
from nodes import MAX_RESOLUTION
|
||||
import nodes
|
||||
from impact.impact_sampling import KSamplerWrapper, KSamplerAdvancedWrapper, separated_sample, impact_sample
|
||||
import comfy
|
||||
import torch
|
||||
import numpy as np
|
||||
import logging
|
||||
|
||||
|
||||
class TiledKSamplerProvider:
|
||||
@classmethod
|
||||
@@ -239,7 +242,7 @@ class CombineConditionings:
|
||||
res += v
|
||||
|
||||
return (res, )
|
||||
|
||||
|
||||
|
||||
class ConcatConditionings:
|
||||
@classmethod
|
||||
@@ -263,7 +266,7 @@ class ConcatConditionings:
|
||||
for k, conditioning_from in list(kwargs.items())[1:]:
|
||||
out = []
|
||||
if len(conditioning_from) > 1:
|
||||
print("Warning: ConcatConditionings {k} contains more than 1 cond, only the first one will actually be applied to conditioning1.")
|
||||
logging.warning("Warning: ConcatConditionings {k} contains more than 1 cond, only the first one will actually be applied to conditioning1.")
|
||||
|
||||
cond_from = conditioning_from[0][0]
|
||||
|
||||
@@ -276,8 +279,8 @@ class ConcatConditionings:
|
||||
conditioning_to = out
|
||||
|
||||
return (out, )
|
||||
|
||||
|
||||
|
||||
|
||||
class RegionalSampler:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
@@ -425,7 +428,7 @@ class RegionalSampler:
|
||||
add_noise = False
|
||||
|
||||
# finalize
|
||||
core.update_node_status(unique_id, f"finalize")
|
||||
core.update_node_status(unique_id, "finalize")
|
||||
if base_latent_image is not None:
|
||||
new_latent_image = base_latent_image
|
||||
else:
|
||||
@@ -546,7 +549,7 @@ class RegionalSamplerAdvanced:
|
||||
j += 1
|
||||
|
||||
# finalize
|
||||
core.update_node_status(unique_id, f"finalize")
|
||||
core.update_node_status(unique_id, "finalize")
|
||||
if base_latent_image is not None:
|
||||
new_latent_image = base_latent_image
|
||||
else:
|
||||
|
||||
@@ -9,6 +9,7 @@ import re
|
||||
import impact.core as core
|
||||
from server import PromptServer
|
||||
import inspect
|
||||
import logging
|
||||
|
||||
|
||||
class GeneralSwitch:
|
||||
@@ -17,9 +18,16 @@ class GeneralSwitch:
|
||||
dyn_inputs = {"input1": (any_typ, {"lazy": True, "tooltip": "Any input. When connected, one more input slot is added."}), }
|
||||
if core.is_execution_model_version_supported():
|
||||
stack = inspect.stack()
|
||||
if stack[2].function == 'get_input_info' and stack[3].function == 'add_node':
|
||||
for x in range(2, 200):
|
||||
dyn_inputs[f"input{x}"] = (any_typ, {"lazy": True})
|
||||
if stack[2].function == 'get_input_info':
|
||||
# bypass validation
|
||||
class AllContainer:
|
||||
def __contains__(self, item):
|
||||
return True
|
||||
|
||||
def __getitem__(self, key):
|
||||
return any_typ, {"lazy": True}
|
||||
|
||||
dyn_inputs = AllContainer()
|
||||
|
||||
inputs = {"required": {
|
||||
"select": ("INT", {"default": 1, "min": 1, "max": 999999, "step": 1, "tooltip": "The input number you want to output among the inputs"}),
|
||||
@@ -43,9 +51,12 @@ class GeneralSwitch:
|
||||
selected_index = int(kwargs['select'])
|
||||
input_name = f"input{selected_index}"
|
||||
|
||||
print(f"SELECTED: {input_name}")
|
||||
logging.info(f"SELECTED: {input_name}")
|
||||
|
||||
return [input_name]
|
||||
if input_name in kwargs:
|
||||
return [input_name]
|
||||
else:
|
||||
return []
|
||||
|
||||
@staticmethod
|
||||
def doit(*args, **kwargs):
|
||||
@@ -67,12 +78,12 @@ class GeneralSwitch:
|
||||
|
||||
break
|
||||
else:
|
||||
print(f"[Impact-Pack] The switch node does not guarantee proper functioning in API mode.")
|
||||
logging.info("[Impact-Pack] The switch node does not guarantee proper functioning in API mode.")
|
||||
|
||||
if input_name in kwargs:
|
||||
return kwargs[input_name], selected_label, selected_index
|
||||
else:
|
||||
print(f"ImpactSwitch: invalid select index (ignored)")
|
||||
logging.info("ImpactSwitch: invalid select index (ignored)")
|
||||
return None, "", selected_index
|
||||
|
||||
class LatentSwitch:
|
||||
@@ -98,7 +109,7 @@ class LatentSwitch:
|
||||
if input_name in kwargs:
|
||||
return (kwargs[input_name],)
|
||||
else:
|
||||
print(f"LatentSwitch: invalid select index ('latent1' is selected)")
|
||||
logging.info("LatentSwitch: invalid select index ('latent1' is selected)")
|
||||
return (kwargs['latent1'],)
|
||||
|
||||
|
||||
@@ -163,10 +174,10 @@ class GeneralInversedSwitch:
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
def doit(self, select, prompt, unique_id, input, **kwargs):
|
||||
if core.is_execution_model_version_supported:
|
||||
if core.is_execution_model_version_supported():
|
||||
from comfy_execution.graph import ExecutionBlocker
|
||||
else:
|
||||
print("[Impact Pack] InversedSwitch: ComfyUI is outdated. The 'select_on_execution' mode cannot function properly.")
|
||||
logging.warning("[Impact Pack] InversedSwitch: ComfyUI is outdated. The 'select_on_execution' mode cannot function properly.")
|
||||
|
||||
res = []
|
||||
|
||||
@@ -181,7 +192,7 @@ class GeneralInversedSwitch:
|
||||
for i in range(0, cnt + 1):
|
||||
if select == i+1:
|
||||
res.append(input)
|
||||
elif core.is_execution_model_version_supported:
|
||||
elif core.is_execution_model_version_supported():
|
||||
res.append(ExecutionBlocker(None))
|
||||
else:
|
||||
res.append(None)
|
||||
@@ -254,9 +265,9 @@ class ImpactLogger:
|
||||
if hasattr(data, "shape"):
|
||||
shape = f"{data.shape} / "
|
||||
|
||||
print(f"[IMPACT LOGGER]: {shape}{data}")
|
||||
logging.info(f"[IMPACT LOGGER]: {shape}{data}")
|
||||
|
||||
print(f" PROMPT: {prompt}")
|
||||
logging.info(f" PROMPT: {prompt}")
|
||||
|
||||
# for x in prompt:
|
||||
# if 'inputs' in x and 'populated_text' in x['inputs']:
|
||||
@@ -308,8 +319,6 @@ class MasksToMaskList:
|
||||
for mask in masks:
|
||||
res.append(mask)
|
||||
|
||||
print(f"mask len: {len(res)}")
|
||||
|
||||
res = [make_3d_mask(x) for x in res]
|
||||
|
||||
return (res, )
|
||||
@@ -366,7 +375,7 @@ class ImageListToImageBatch:
|
||||
|
||||
def doit(self, images):
|
||||
if len(images) <= 1:
|
||||
return (images,)
|
||||
return (images[0],)
|
||||
else:
|
||||
image1 = images[0]
|
||||
for image2 in images[1:]:
|
||||
@@ -436,6 +445,31 @@ class MakeMaskList:
|
||||
return (masks, )
|
||||
|
||||
|
||||
class NthItemOfAnyList:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required": {
|
||||
"any_list": (any_typ,),
|
||||
"index": ("INT", {"default": 0, "min": 0, "max": sys.maxsize, "step": 1, "tooltip": "The index of the item you want to select from the list."}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = (any_typ,)
|
||||
INPUT_IS_LIST = True
|
||||
FUNCTION = "doit"
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
DESCRIPTION = "Selects the Nth item from a list. If the index is out of range, it returns the last item in the list."
|
||||
|
||||
def doit(self, any_list, index):
|
||||
i = index[0]
|
||||
if i >= len(any_list):
|
||||
return (any_list[-1],)
|
||||
else:
|
||||
return (any_list[i],)
|
||||
|
||||
|
||||
class MakeImageList:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
@@ -494,7 +528,7 @@ class MakeMaskBatch:
|
||||
def doit(self, **kwargs):
|
||||
mask1 = kwargs['mask1']
|
||||
del kwargs['mask1']
|
||||
masks = [utils.make_3d_mask(value) for value in kwargs.values()]
|
||||
masks = [make_3d_mask(value) for value in kwargs.values()]
|
||||
|
||||
if len(masks) == 0:
|
||||
return (mask1,)
|
||||
@@ -516,6 +550,9 @@ class ReencodeLatent:
|
||||
"output_vae": ("VAE", ),
|
||||
"tile_size": ("INT", {"default": 512, "min": 320, "max": 4096, "step": 64}),
|
||||
},
|
||||
"optional": {
|
||||
"overlap": ("INT", {"default": 64, "min": 0, "max": 4096, "step": 32, "tooltip": "This setting applies when 'tile_mode' is enabled."}),
|
||||
}
|
||||
}
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
@@ -523,14 +560,22 @@ class ReencodeLatent:
|
||||
RETURN_TYPES = ("LATENT", )
|
||||
FUNCTION = "doit"
|
||||
|
||||
def doit(self, samples, tile_mode, input_vae, output_vae, tile_size=512):
|
||||
def doit(self, samples, tile_mode, input_vae, output_vae, tile_size=512, overlap=64):
|
||||
if tile_mode in ["Both", "Decode(input) only"]:
|
||||
pixels = nodes.VAEDecodeTiled().decode(input_vae, samples, tile_size)[0]
|
||||
decoder = nodes.VAEDecodeTiled()
|
||||
if 'overlap' in inspect.signature(decoder.decode).parameters:
|
||||
pixels = decoder.decode(input_vae, samples, tile_size, overlap=overlap)[0]
|
||||
else:
|
||||
pixels = decoder.decode(input_vae, samples, tile_size, overlap=overlap)[0]
|
||||
else:
|
||||
pixels = nodes.VAEDecode().decode(input_vae, samples)[0]
|
||||
|
||||
if tile_mode in ["Both", "Encode(output) only"]:
|
||||
return nodes.VAEEncodeTiled().encode(output_vae, pixels, tile_size)
|
||||
encoder = nodes.VAEEncodeTiled()
|
||||
if 'overlap' in inspect.signature(encoder.encode).parameters:
|
||||
return encoder.encode(output_vae, pixels, tile_size, overlap=overlap)
|
||||
else:
|
||||
return encoder.encode(output_vae, pixels, tile_size)
|
||||
else:
|
||||
return nodes.VAEEncode().encode(output_vae, pixels)
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ import nodes
|
||||
from . import config
|
||||
from PIL import Image
|
||||
import comfy
|
||||
import time
|
||||
import logging
|
||||
|
||||
|
||||
class TensorBatchBuilder:
|
||||
@@ -66,6 +68,54 @@ def tensor_convert_rgb(image, prefer_copy=True):
|
||||
raise ValueError(f"illegal conversion (channels: {n_channel} -> 3)")
|
||||
|
||||
|
||||
def resize_with_padding(image, target_w: int, target_h: int):
|
||||
_tensor_check_image(image)
|
||||
b, h, w, c = image.shape
|
||||
image = image.permute(0, 3, 1, 2) # B, C, H, W
|
||||
|
||||
scale = min(target_w / w, target_h / h)
|
||||
new_w, new_h = int(w * scale), int(h * scale)
|
||||
|
||||
image = F.interpolate(image, size=(new_h, new_w), mode="bilinear", align_corners=False)
|
||||
|
||||
pad_left = (target_w - new_w) // 2
|
||||
pad_right = target_w - new_w - pad_left
|
||||
pad_top = (target_h - new_h) // 2
|
||||
pad_bottom = target_h - new_h - pad_top
|
||||
|
||||
image = F.pad(image, (pad_left, pad_right, pad_top, pad_bottom), mode='constant', value=0)
|
||||
|
||||
image = image.permute(0, 2, 3, 1) # B, H, W, C
|
||||
return image, (pad_top, pad_bottom, pad_left, pad_right)
|
||||
|
||||
|
||||
def remove_padding(image, padding):
|
||||
pad_top, pad_bottom, pad_left, pad_right = padding
|
||||
return image[:, pad_top:image.shape[1] - pad_bottom, pad_left:image.shape[2] - pad_right, :]
|
||||
|
||||
|
||||
def adjust_bbox_after_resize(bbox, original_size, target_size, padding):
|
||||
"""
|
||||
bbox: (x1, y1, x2, y2) in original image
|
||||
original_size: (original_h, original_w)
|
||||
target_size: (target_h, target_w)
|
||||
padding: (pad_top, pad_bottom, pad_left, pad_right)
|
||||
"""
|
||||
orig_h, orig_w = original_size
|
||||
target_h, target_w = target_size
|
||||
pad_top, pad_bottom, pad_left, pad_right = padding
|
||||
|
||||
scale = min(target_w / orig_w, target_h / orig_h)
|
||||
|
||||
# Apply scale
|
||||
x1 = int(bbox[0] * scale + pad_left)
|
||||
y1 = int(bbox[1] * scale + pad_top)
|
||||
x2 = int(bbox[2] * scale + pad_left)
|
||||
y2 = int(bbox[3] * scale + pad_top)
|
||||
|
||||
return x1, y1, x2, y2
|
||||
|
||||
|
||||
def general_tensor_resize(image, w: int, h: int):
|
||||
_tensor_check_image(image)
|
||||
image = image.permute(0, 3, 1, 2)
|
||||
@@ -141,8 +191,6 @@ def to_numpy(image):
|
||||
if isinstance(image, np.ndarray):
|
||||
return image
|
||||
raise ValueError(f"Cannot convert {type(image)} to numpy.ndarray")
|
||||
|
||||
|
||||
|
||||
def tensor_putalpha(image, mask):
|
||||
_tensor_check_image(image)
|
||||
@@ -177,19 +225,22 @@ def tensor2numpy(image):
|
||||
|
||||
|
||||
def tensor_paste(image1, image2, left_top, mask):
|
||||
"""Mask and image2 has to be the same size"""
|
||||
"""
|
||||
Pastes image2 onto image1 at position left_top using mask.
|
||||
Supports both RGB and RGBA images.
|
||||
"""
|
||||
_tensor_check_image(image1)
|
||||
_tensor_check_image(image2)
|
||||
_tensor_check_mask(mask)
|
||||
|
||||
if image2.shape[1:3] != mask.shape[1:3]:
|
||||
mask = resize_mask(mask.squeeze(dim=3), image2.shape[1:3]).unsqueeze(dim=3)
|
||||
# raise ValueError(f"Inconsistent size: Image ({image2.shape[1:3]}) != Mask ({mask.shape[1:3]})")
|
||||
|
||||
x, y = left_top
|
||||
_, h1, w1, _ = image1.shape
|
||||
_, h2, w2, _ = image2.shape
|
||||
_, h1, w1, c1 = image1.shape
|
||||
_, h2, w2, c2 = image2.shape
|
||||
|
||||
# calculate image patch size
|
||||
# Calculate image patch size
|
||||
w = min(w1, x + w2) - x
|
||||
h = min(h1, y + h2) - y
|
||||
|
||||
@@ -198,10 +249,47 @@ def tensor_paste(image1, image2, left_top, mask):
|
||||
return
|
||||
|
||||
mask = mask[:, :h, :w, :]
|
||||
image1[:, y:y+h, x:x+w, :] = (
|
||||
(1 - mask) * image1[:, y:y+h, x:x+w, :] +
|
||||
mask * image2[:, :h, :w, :]
|
||||
)
|
||||
|
||||
# Get the region to be modified
|
||||
region1 = image1[:, y:y+h, x:x+w, :]
|
||||
region2 = image2[:, :h, :w, :]
|
||||
|
||||
# Handle RGB and RGBA cases
|
||||
if c1 == 3 and c2 == 3:
|
||||
# Both RGB - simple case
|
||||
image1[:, y:y+h, x:x+w, :] = (1 - mask) * region1 + mask * region2
|
||||
|
||||
elif c1 == 4 and c2 == 4:
|
||||
# Both RGBA - need to handle alpha channel separately
|
||||
# RGB channels
|
||||
image1[:, y:y+h, x:x+w, :3] = (
|
||||
(1 - mask) * region1[:, :, :, :3] +
|
||||
mask * region2[:, :, :, :3]
|
||||
)
|
||||
|
||||
# Alpha channel - use "over" composition
|
||||
a1 = region1[:, :, :, 3:4]
|
||||
a2 = region2[:, :, :, 3:4] * mask
|
||||
new_alpha = a1 + a2 * (1 - a1)
|
||||
image1[:, y:y+h, x:x+w, 3:4] = new_alpha
|
||||
|
||||
elif c1 == 4 and c2 == 3:
|
||||
# Target is RGBA, source is RGB - assume source is fully opaque
|
||||
image1[:, y:y+h, x:x+w, :3] = (
|
||||
(1 - mask) * region1[:, :, :, :3] +
|
||||
mask * region2
|
||||
)
|
||||
# Alpha channel - reduce alpha where mask is applied
|
||||
image1[:, y:y+h, x:x+w, 3:4] = region1[:, :, :, 3:4] * (1 - mask) + mask
|
||||
|
||||
elif c1 == 3 and c2 == 4:
|
||||
# Target is RGB, source is RGBA - apply source alpha to mask
|
||||
effective_mask = mask * region2[:, :, :, 3:4]
|
||||
image1[:, y:y+h, x:x+w, :] = (
|
||||
(1 - effective_mask) * region1 +
|
||||
effective_mask * region2[:, :, :, :3]
|
||||
)
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -501,15 +589,21 @@ def crop_image(image, crop_region):
|
||||
return crop_tensor4(image, crop_region)
|
||||
|
||||
|
||||
def to_latent_image(pixels, vae):
|
||||
def to_latent_image(pixels, vae, vae_tiled_encode=False):
|
||||
x = pixels.shape[1]
|
||||
y = pixels.shape[2]
|
||||
if pixels.shape[1] != x or pixels.shape[2] != y:
|
||||
pixels = pixels[:, :x, :y, :]
|
||||
|
||||
vae_encode = nodes.VAEEncode()
|
||||
start = time.time()
|
||||
if vae_tiled_encode:
|
||||
encoded = nodes.VAEEncodeTiled().encode(vae, pixels, 512, overlap=64)[0] # using default settings
|
||||
logging.info(f"[Impact Pack] vae encoded (tiled) in {time.time() - start:.1f}s")
|
||||
else:
|
||||
encoded = nodes.VAEEncode().encode(vae, pixels)[0]
|
||||
logging.info(f"[Impact Pack] vae encoded in {time.time() - start:.1f}s")
|
||||
|
||||
return vae_encode.encode(vae, pixels)[0]
|
||||
return encoded
|
||||
|
||||
|
||||
def empty_pil_tensor(w=64, h=64):
|
||||
@@ -592,8 +686,8 @@ def try_install_custom_node(custom_node_url, msg):
|
||||
cm_global.try_call(api='cm.try-install-custom-node',
|
||||
sender="Impact Pack", custom_node_url=custom_node_url, msg=msg)
|
||||
except Exception:
|
||||
print(msg)
|
||||
print(f"[Impact Pack] ComfyUI-Manager is outdated. The custom node installation feature is not available.")
|
||||
logging.info(msg)
|
||||
logging.info("[Impact Pack] ComfyUI-Manager is outdated. The custom node installation feature is not available.")
|
||||
|
||||
|
||||
# author: Trung0246 --->
|
||||
|
||||
@@ -8,6 +8,7 @@ import numpy as np
|
||||
import threading
|
||||
from impact import utils
|
||||
from impact import config
|
||||
import logging
|
||||
|
||||
|
||||
wildcards_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "wildcards"))
|
||||
@@ -44,7 +45,9 @@ def read_wildcard(k, v):
|
||||
elif isinstance(v, str):
|
||||
k = wildcard_normalize(k)
|
||||
wildcard_dict[k] = [v]
|
||||
|
||||
elif isinstance(v, (int, float)):
|
||||
k = wildcard_normalize(k)
|
||||
wildcard_dict[k] = [str(v)]
|
||||
|
||||
def read_wildcard_dict(wildcard_path):
|
||||
global wildcard_dict
|
||||
@@ -58,18 +61,18 @@ def read_wildcard_dict(wildcard_path):
|
||||
try:
|
||||
with open(file_path, 'r', encoding="ISO-8859-1") as f:
|
||||
lines = f.read().splitlines()
|
||||
wildcard_dict[key] = lines
|
||||
wildcard_dict[key] = [x for x in lines if not x.strip().startswith('#')]
|
||||
except yaml.reader.ReaderError:
|
||||
with open(file_path, 'r', encoding="UTF-8", errors="ignore") as f:
|
||||
lines = f.read().splitlines()
|
||||
wildcard_dict[key] = lines
|
||||
elif file.endswith('.yaml'):
|
||||
wildcard_dict[key] = [x for x in lines if not x.strip().startswith('#')]
|
||||
elif file.endswith('.yaml') or file.endswith('.yml'):
|
||||
file_path = os.path.join(root, file)
|
||||
|
||||
try:
|
||||
with open(file_path, 'r', encoding="ISO-8859-1") as f:
|
||||
yaml_data = yaml.load(f, Loader=yaml.FullLoader)
|
||||
except yaml.reader.ReaderError as e:
|
||||
except yaml.reader.ReaderError:
|
||||
with open(file_path, 'r', encoding="UTF-8", errors="ignore") as f:
|
||||
yaml_data = yaml.load(f, Loader=yaml.FullLoader)
|
||||
|
||||
@@ -135,7 +138,9 @@ def process(text, seed=None):
|
||||
b = r.group(3)
|
||||
if b is not None:
|
||||
b = b.strip()
|
||||
|
||||
else:
|
||||
b = "-1"
|
||||
|
||||
if r is not None:
|
||||
if b is not None and is_numeric_string(a) and is_numeric_string(b):
|
||||
# PATTERN: num1-num2
|
||||
@@ -145,26 +150,32 @@ def process(text, seed=None):
|
||||
x = int(a)
|
||||
select_range = (x, x)
|
||||
|
||||
# Expand wildcard path or return the string after $$
|
||||
def expand_wildcard_or_return_string(options, pattern, wildcard_pattern):
|
||||
matches = re.findall(wildcard_pattern, pattern)
|
||||
if len(options) == 1 and matches:
|
||||
# $$<single wildcard>
|
||||
return get_wildcard_options(pattern)
|
||||
else:
|
||||
# $$opt1|opt2|...
|
||||
options[0] = pattern
|
||||
return options
|
||||
|
||||
if select_range is not None and len(multi_select_pattern) == 2:
|
||||
# PATTERN: count$$
|
||||
matches = re.findall(wildcard_pattern, multi_select_pattern[1])
|
||||
if len(options) == 1 and matches:
|
||||
# count$$<single wildcard>
|
||||
options = local_wildcard_dict.get(matches[0])
|
||||
else:
|
||||
# count$$opt1|opt2|...
|
||||
options[0] = multi_select_pattern[1]
|
||||
options = expand_wildcard_or_return_string(options, multi_select_pattern[1], wildcard_pattern )
|
||||
elif select_range is not None and len(multi_select_pattern) == 3:
|
||||
# PATTERN: count$$ sep $$
|
||||
select_sep = multi_select_pattern[1]
|
||||
options[0] = multi_select_pattern[2]
|
||||
options = expand_wildcard_or_return_string(options, multi_select_pattern[2], wildcard_pattern )
|
||||
|
||||
adjusted_probabilities = []
|
||||
|
||||
total_prob = 0
|
||||
|
||||
for option in options:
|
||||
parts = option.split('::', 1)
|
||||
parts = option.split('::', 1) if isinstance(option, str) else f"{option}".split('::', 1)
|
||||
|
||||
if len(parts) == 2 and is_numeric_string(parts[0].strip()):
|
||||
config_value = float(parts[0].strip())
|
||||
else:
|
||||
@@ -178,15 +189,30 @@ def process(text, seed=None):
|
||||
if select_range is None:
|
||||
select_count = 1
|
||||
else:
|
||||
select_count = random_gen.integers(low=select_range[0], high=select_range[1]+1, size=1)
|
||||
def calculate_max(_options_length, _max_select_range):
|
||||
return min(_max_select_range + 1, _options_length + 1) if _max_select_range > 0 else _options_length + 1
|
||||
|
||||
if select_count > len(options):
|
||||
def calculate_select_count(_max_value, _min_select_range, random_gen):
|
||||
if max(_max_value, _min_select_range) <= 0:
|
||||
return 0
|
||||
# fix: low >= high
|
||||
elif _max_value == _min_select_range:
|
||||
return _max_value
|
||||
else:
|
||||
# fix: low >= high
|
||||
_low_value = min(_min_select_range, _max_value)
|
||||
_high_value = max(_min_select_range, _max_value)
|
||||
return random_gen.integers(low=_low_value, high=_high_value, size=1)
|
||||
select_count = calculate_select_count(calculate_max(len(options), select_range[1]), select_range[0], random_gen)
|
||||
|
||||
if select_count > len(options) or total_prob <= 1:
|
||||
random_gen.shuffle(options)
|
||||
selected_items = options
|
||||
else:
|
||||
selected_items = random_gen.choice(options, p=normalized_probabilities, size=select_count, replace=False)
|
||||
|
||||
selected_items2 = [re.sub(r'^\s*[0-9.]+::', '', x, 1) for x in selected_items]
|
||||
# x may be numpy.int32, convert to string
|
||||
selected_items2 = [re.sub(r'^\s*[0-9.]+::', '', str(x), count=1) for x in selected_items]
|
||||
replacement = select_sep.join(selected_items2)
|
||||
if '::' in replacement:
|
||||
pass
|
||||
@@ -194,11 +220,39 @@ def process(text, seed=None):
|
||||
replacements_found = True
|
||||
return replacement
|
||||
|
||||
pattern = r'{([^{}]*?)}'
|
||||
pattern = r'(?<!\\)\{((?:[^{}]|(?<=\\)[{}])*?)(?<!\\)\}'
|
||||
replaced_string = re.sub(pattern, replace_option, string)
|
||||
|
||||
return replaced_string, replacements_found
|
||||
|
||||
def get_wildcard_options(string):
|
||||
pattern = r"__([\w.\-+/*\\]+?)__"
|
||||
matches = re.findall(pattern, string)
|
||||
|
||||
options = []
|
||||
|
||||
for match in matches:
|
||||
keyword = match.lower()
|
||||
keyword = wildcard_normalize(keyword)
|
||||
if keyword in local_wildcard_dict:
|
||||
options.extend(local_wildcard_dict[keyword])
|
||||
elif '*' in keyword:
|
||||
subpattern = keyword.replace('*', '.*').replace('+', '\\+')
|
||||
total_patterns = []
|
||||
found = False
|
||||
for k, v in local_wildcard_dict.items():
|
||||
if re.match(subpattern, k) is not None or re.match(subpattern, k+'/') is not None:
|
||||
total_patterns += v
|
||||
found = True
|
||||
|
||||
if found:
|
||||
options.extend(total_patterns)
|
||||
elif '/' not in keyword:
|
||||
string_fallback = string.replace(f"__{match}__", f"__*/{match}__", 1)
|
||||
options.extend(get_wildcard_options(string_fallback))
|
||||
|
||||
return options
|
||||
|
||||
def replace_wildcard(string):
|
||||
pattern = r"__([\w.\-+/*\\]+?)__"
|
||||
matches = re.findall(pattern, string)
|
||||
@@ -209,7 +263,23 @@ def process(text, seed=None):
|
||||
keyword = match.lower()
|
||||
keyword = wildcard_normalize(keyword)
|
||||
if keyword in local_wildcard_dict:
|
||||
replacement = random_gen.choice(local_wildcard_dict[keyword])
|
||||
# look for adjusted probability
|
||||
adjusted_probabilities = []
|
||||
total_prob = 0
|
||||
options=local_wildcard_dict[keyword]
|
||||
for option in options:
|
||||
parts = option.split('::', 1)
|
||||
if len(parts) == 2 and is_numeric_string(parts[0].strip()):
|
||||
config_value = float(parts[0].strip())
|
||||
else:
|
||||
config_value = 1 # Default value if no configuration is provided
|
||||
|
||||
adjusted_probabilities.append(config_value)
|
||||
total_prob += config_value
|
||||
|
||||
normalized_probabilities = [prob / total_prob for prob in adjusted_probabilities]
|
||||
selected_item = random_gen.choice(options, p=normalized_probabilities, replace=False)
|
||||
replacement = re.sub(r'^\s*[0-9.]+::', '', selected_item, count=1)
|
||||
replacements_found = True
|
||||
string = string.replace(f"__{match}__", replacement, 1)
|
||||
elif '*' in keyword:
|
||||
@@ -235,7 +305,7 @@ def process(text, seed=None):
|
||||
stop_unwrap = False
|
||||
while not stop_unwrap and replace_depth > 1:
|
||||
replace_depth -= 1 # prevent infinite loop
|
||||
|
||||
|
||||
option_quantifier = [e.groupdict() for e in RE_WildCardQuantifier.finditer(text)]
|
||||
for match in option_quantifier:
|
||||
keyword = match['keyword'].lower()
|
||||
@@ -259,7 +329,7 @@ def process(text, seed=None):
|
||||
|
||||
|
||||
def is_numeric_string(input_str):
|
||||
return re.match(r'^-?\d+(\.\d+)?$', input_str) is not None
|
||||
return re.match(r'^-?(\d*\.?\d+|\d+\.?\d*)$', input_str) is not None
|
||||
|
||||
|
||||
def safe_float(x):
|
||||
@@ -289,6 +359,7 @@ def extract_lora_values(string):
|
||||
lbw = None
|
||||
lbw_a = None
|
||||
lbw_b = None
|
||||
loader = None
|
||||
|
||||
if len(item) > 0:
|
||||
lora = item[0]
|
||||
@@ -307,6 +378,8 @@ def extract_lora_values(string):
|
||||
lbw_b = safe_float(lbw_item[2:].strip())
|
||||
elif lbw_item.strip() != '':
|
||||
lbw = lbw_item
|
||||
elif sub_item.startswith("LOADER="):
|
||||
loader = sub_item[7:]
|
||||
|
||||
if a is None:
|
||||
a = 1.0
|
||||
@@ -314,7 +387,7 @@ def extract_lora_values(string):
|
||||
b = a
|
||||
|
||||
if lora is not None and lora not in added:
|
||||
result.append((lora, a, b, lbw, lbw_a, lbw_b))
|
||||
result.append((lora, a, b, lbw, lbw_a, lbw_b, loader))
|
||||
added.add(lora)
|
||||
|
||||
return result
|
||||
@@ -338,6 +411,8 @@ def resolve_lora_name(lora_name_cache, name):
|
||||
if x.endswith(name):
|
||||
return x
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def process_with_loras(wildcard_opt, model, clip, clip_encoder=None, seed=None, processed=None):
|
||||
"""
|
||||
@@ -358,7 +433,7 @@ def process_with_loras(wildcard_opt, model, clip, clip_encoder=None, seed=None,
|
||||
loras = extract_lora_values(pass1)
|
||||
pass2 = remove_lora_tags(pass1)
|
||||
|
||||
for lora_name, model_weight, clip_weight, lbw, lbw_a, lbw_b in loras:
|
||||
for lora_name, model_weight, clip_weight, lbw, lbw_a, lbw_b, loader in loras:
|
||||
lora_name_ext = lora_name.split('.')
|
||||
if ('.'+lora_name_ext[-1]) not in folder_paths.supported_pt_extensions:
|
||||
lora_name = lora_name+".safetensors"
|
||||
@@ -372,26 +447,36 @@ def process_with_loras(wildcard_opt, model, clip, clip_encoder=None, seed=None,
|
||||
path = None
|
||||
|
||||
if path is not None:
|
||||
print(f"LOAD LORA: {lora_name}: {model_weight}, {clip_weight}, LBW={lbw}, A={lbw_a}, B={lbw_b}")
|
||||
logging.info(f"LOAD LORA: {lora_name}: {model_weight}, {clip_weight}, LBW={lbw}, A={lbw_a}, B={lbw_b}, LOADER={loader}")
|
||||
|
||||
def default_lora():
|
||||
return nodes.LoraLoader().load_lora(model, clip, lora_name, model_weight, clip_weight)
|
||||
|
||||
if lbw is not None:
|
||||
if 'LoraLoaderBlockWeight //Inspire' not in nodes.NODE_CLASS_MAPPINGS:
|
||||
utils.try_install_custom_node(
|
||||
'https://github.com/ltdrdata/ComfyUI-Inspire-Pack',
|
||||
"To use 'LBW=' syntax in wildcards, 'Inspire Pack' extension is required.")
|
||||
|
||||
print(f"'LBW(Lora Block Weight)' is given, but the 'Inspire Pack' is not installed. The LBW= attribute is being ignored.")
|
||||
model, clip = default_lora()
|
||||
if loader is not None:
|
||||
if loader == 'nunchaku':
|
||||
if 'NunchakuFluxLoraLoader' not in nodes.NODE_CLASS_MAPPINGS:
|
||||
logging.warning("To use `LOADER=nunchaku`, 'ComfyUI-nunchaku' is required. The LOADER= attribute is being ignored.")
|
||||
cls = nodes.NODE_CLASS_MAPPINGS['NunchakuFluxLoraLoader']
|
||||
model = cls().load_lora(model, lora_name, model_weight)[0]
|
||||
else:
|
||||
cls = nodes.NODE_CLASS_MAPPINGS['LoraLoaderBlockWeight //Inspire']
|
||||
model, clip, _ = cls().doit(model, clip, lora_name, model_weight, clip_weight, False, 0, lbw_a, lbw_b, "", lbw)
|
||||
logging.warning(f"LORA LOADER NOT FOUND: '{loader}'")
|
||||
else:
|
||||
model, clip = default_lora()
|
||||
def default_lora():
|
||||
return nodes.LoraLoader().load_lora(model, clip, lora_name, model_weight, clip_weight)
|
||||
|
||||
if lbw is not None:
|
||||
if 'LoraLoaderBlockWeight //Inspire' not in nodes.NODE_CLASS_MAPPINGS:
|
||||
utils.try_install_custom_node(
|
||||
'https://github.com/ltdrdata/ComfyUI-Inspire-Pack',
|
||||
"To use 'LBW=' syntax in wildcards, 'Inspire Pack' extension is required.")
|
||||
|
||||
logging.warning("'LBW(Lora Block Weight)' is given, but the 'Inspire Pack' is not installed. The LBW= attribute is being ignored.")
|
||||
model, clip = default_lora()
|
||||
else:
|
||||
cls = nodes.NODE_CLASS_MAPPINGS['LoraLoaderBlockWeight //Inspire']
|
||||
model, clip, _ = cls().doit(model, clip, lora_name, model_weight, clip_weight, False, 0, lbw_a, lbw_b, "", lbw)
|
||||
|
||||
else:
|
||||
model, clip = default_lora()
|
||||
else:
|
||||
print(f"LORA NOT FOUND: {orig_lora_name}")
|
||||
logging.warning(f"LORA NOT FOUND: {orig_lora_name}")
|
||||
|
||||
pass3 = [x.strip() for x in pass2.split("BREAK")]
|
||||
pass3 = [x for x in pass3 if x != '']
|
||||
@@ -400,7 +485,7 @@ def process_with_loras(wildcard_opt, model, clip, clip_encoder=None, seed=None,
|
||||
pass3 = ['']
|
||||
|
||||
pass3_str = [f'[{x}]' for x in pass3]
|
||||
print(f"CLIP: {str.join(' + ', pass3_str)}")
|
||||
logging.info(f"CLIP: {str.join(' + ', pass3_str)}")
|
||||
|
||||
result = None
|
||||
|
||||
@@ -487,7 +572,7 @@ def split_string_with_sep(input_string):
|
||||
else:
|
||||
try:
|
||||
seed = int(matches[i][5:-1])
|
||||
except:
|
||||
except Exception:
|
||||
seed = None
|
||||
result_list.append(seed)
|
||||
|
||||
@@ -533,7 +618,7 @@ def wildcard_load():
|
||||
|
||||
try:
|
||||
read_wildcard_dict(config.get_config()['custom_wildcards'])
|
||||
except Exception as e:
|
||||
print(f"[Impact Pack] Failed to load custom wildcards directory.")
|
||||
except Exception:
|
||||
logging.info("[Impact Pack] Failed to load custom wildcards directory.")
|
||||
|
||||
print(f"[Impact Pack] Wildcards loading done.")
|
||||
logging.info("[Impact Pack] Wildcards loading done.")
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
import comfy
|
||||
import torch
|
||||
|
||||
from comfy import sampler_helpers
|
||||
|
||||
|
||||
class Unsampler:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "comfyui-impact-pack"
|
||||
description = "This extension offers various detector nodes and detailer nodes that allow you to configure a workflow that automatically enhances facial details. And provide iterative upscaler."
|
||||
version = "7.7.1"
|
||||
description = "This node pack offers various detector nodes and detailer nodes that allow you to configure a workflow that automatically enhances facial details. And provide iterative upscaler."
|
||||
version = "8.19.1"
|
||||
license = { file = "LICENSE.txt" }
|
||||
dependencies = ["segment-anything", "scikit-image", "piexif", "transformers", "opencv-python-headless", "GitPython", "scipy>=1.11.4"]
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ scikit-image
|
||||
piexif
|
||||
transformers
|
||||
opencv-python-headless
|
||||
GitPython
|
||||
scipy>=1.11.4
|
||||
numpy<2
|
||||
numpy
|
||||
dill
|
||||
matplotlib
|
||||
matplotlib
|
||||
git+https://github.com/facebookresearch/sam2
|
||||
@@ -0,0 +1,3 @@
|
||||
[lint]
|
||||
ignore = ["E402","E701"]
|
||||
exclude = ["install.py", "*.ipynb"]
|
||||
@@ -1,38 +0,0 @@
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import platform
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
comfy_path = '../..'
|
||||
|
||||
def rmtree(path):
|
||||
retry_count = 3
|
||||
|
||||
while True:
|
||||
try:
|
||||
retry_count -= 1
|
||||
|
||||
if platform.system() == "Windows":
|
||||
subprocess.check_call(['attrib', '-R', path + '\\*', '/S'])
|
||||
|
||||
shutil.rmtree(path)
|
||||
|
||||
return True
|
||||
|
||||
except Exception as ex:
|
||||
print(f"ex: {ex}")
|
||||
time.sleep(3)
|
||||
|
||||
if retry_count < 0:
|
||||
raise ex
|
||||
|
||||
print(f"Uninstall retry({retry_count})")
|
||||
|
||||
js_dest_path = os.path.join(comfy_path, "web", "extensions", "impact-pack")
|
||||
|
||||
if os.path.exists(js_dest_path):
|
||||
rmtree(js_dest_path)
|
||||
|
||||
|
||||