commit ImageBatchToList and ImageListToBatch nodes

This commit is contained in:
chflame163
2026-01-11 09:30:22 +08:00
parent 0d88b177d4
commit 3ab3e38192
6 changed files with 127 additions and 3 deletions
+16
View File
@@ -147,6 +147,7 @@ When this error has occurred, please check the network environment.
<font size="4">**If the dependency package error after updating, please double clicking ```repair_dependency.bat``` (for Official ComfyUI Protable) or ```repair_dependency_aki.bat``` (for ComfyUI-aki-v1.x) in the plugin folder to reinstall the dependency packages. </font><br />
* Commit [ImageBatchToList](#ImageBatchToList) and [ImageListToBatch](#ImageListToBatch) nodes, Used for converting single batches of images into multiple small batches and vice versa, with option to define the maximum number of images in each small batch.
* Commit [DistortDisplace](#DistortDisplace) node, Generate displacement deformation effects for material images.
* Commit [MaskEdgeUltraDetailV3](#MaskEdgeUltraDetailV3) node, By processing different partitions through inputting a trimap mask, a more refined overall mask including translucent parts is generated.
* Commit [ImageCompositeHandleMask](#ImageCompositeHandleMask) node, used to generate local feathering masks and cropping data.
@@ -1835,6 +1836,21 @@ Outputs:
* file_name: Output a list of file names corresponding to the images.
* frame_count: Output the total number of images.
### <a id="table1">ImageBatchToList</a>
Convert a batch of images into multiple smaller batches, with option to define the maximum number of images in each small batch.
Node Options:
![image](image/image_batch_to_list(multi)_node.jpg)
* batch_size: The maximum number of images in each small batch.
### <a id="table1">ImageListToBatch</a>
Merge multiple small batches of images into one large batch.
![image](image/image_batch_to_list(multi)_node.jpg)
# <a id="table1">LayerMask</a>
![image](image/layermask_nodes.jpg)
+13
View File
@@ -128,6 +128,7 @@ os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
## 更新说明
<font size="4">**如果本插件更新后出现依赖包错误,请双击运行插件目录下的```install_requirements.bat```(官方便携包),或 ```install_requirements_aki.bat```(秋叶整合包) 重新安装依赖包。
* 添加 [ImageBatchToList](#ImageBatchToList) 和 [ImageListToBatch](#ImageListToBatch) 节点, 用于图片单个大批次和多个小批次互相转换,支持定义小批次数量。
* 添加 [DistortDisplace](#DistortDisplace) 节点, 为材质图片生成置换变形效果。
* 添加 [MaskEdgeUltraDetailV3](#MaskEdgeUltraDetailV3) 节点, 通过输入trimap遮罩对不同分区处理,生成包括更加精细半透明部分的整体遮罩。
* 添加 [ImageCompositeHandleMask](#ImageCompositeHandleMask) 节点, 用于生成局部羽化遮罩以及对应的裁切数据。
@@ -1646,6 +1647,18 @@ BooleanOperator的升级版,增加了节点内数值输入,增加了大于
* file_name: 输出图片对应的文件名列表。
* frame_count: 输出图片总数。
### <a id="table1">ImageBatchToList</a>
将一个图片大批次转换为若干小批次,可定义每个小批次的图片数量上限。
节点选项说明:
![image](image/image_batch_to_list(multi)_node.jpg)
* batch_size: 每个小批次的图片数量上限。
### <a id="table1">ImageListToBatch</a>
将多个图片小批次合并为一个大批次。
![image](image/image_batch_to_list(multi)_node.jpg)
# <a id="table1">LayerMask</a>
![image](image/layermask_nodes.jpg)
Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

+97 -2
View File
@@ -1,3 +1,4 @@
import torch
from .imagefunc import AnyType, log, extract_all_numbers_from_str
@@ -461,6 +462,95 @@ class QueueStopNode():
return (any,)
class LS_ImageBatchToMultiList:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"image": ("IMAGE",),
"batch_size": ("INT", {
"default": 6,
"min": 1,
"max": 64,
"step": 1
}),
}
}
RETURN_TYPES = ("IMAGE",)
RETURN_NAMES = ("image", )
OUTPUT_IS_LIST = (True,)
FUNCTION = "image_batch_to_multi_list"
CATEGORY = '😺dzNodes/LayerUtility/Data'
def image_batch_to_multi_list(self, image, batch_size):
"""
image: [B, H, W, C]
输出: list of IMAGE batch,每个 batch 大小 <= batch_size
"""
B = image.shape[0]
out = []
for i in range(0, B, batch_size):
batch = image[i:i + batch_size]
out.append(batch)
return (out,)
class LS_MultiImageListToBatch:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"image": ("IMAGE",),
}
}
RETURN_TYPES = ("IMAGE",)
RETURN_NAMES = ("image", )
INPUT_IS_LIST = True
FUNCTION = "multi_image_list_to_batch"
CATEGORY = '😺dzNodes/LayerUtility/Data'
def multi_image_list_to_batch(self, image):
"""
image: list of IMAGE batch
每个元素 shape 为 [Bi, Hi, Wi, C]
输出: 单一 IMAGE batch [sum(Bi), H, W, C]
"""
# 以第一个 batch 的第一张图作为基准尺寸
base_h, base_w = image[0].shape[1:3]
out = []
for batch in image:
# batch: [B, H, W, C]
if batch.shape[1:3] != (base_h, base_w):
# 转成 [B, C, H, W]
batch = batch.permute(0, 3, 1, 2)
batch = comfy.utils.common_upscale(
batch,
base_w,
base_h,
upscale_method="bicubic",
crop="center"
)
# 转回 [B, H, W, C]
batch = batch.permute(0, 2, 3, 1)
out.append(batch)
# 沿 batch 维拼接
out = torch.cat(out, dim=0)
return (out,)
NODE_CLASS_MAPPINGS = {
"LayerUtility: QueueStop": QueueStopNode,
"LayerUtility: SwitchCase": SwitchCaseNode,
@@ -475,7 +565,10 @@ NODE_CLASS_MAPPINGS = {
"LayerUtility: Integer": IntegerNode,
"LayerUtility: Float": FloatNode,
"LayerUtility: Boolean": BooleanNode,
"LayerUtility: Seed": SeedNode
"LayerUtility: Seed": SeedNode,
"LayerUtility: ImageBatchToList": LS_ImageBatchToMultiList,
"LayerUtility: ImageListToBatch": LS_MultiImageListToBatch,
}
NODE_DISPLAY_NAME_MAPPINGS = {
@@ -492,5 +585,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"LayerUtility: Integer": "LayerUtility: Integer",
"LayerUtility: Float": "LayerUtility: Float",
"LayerUtility: Boolean": "LayerUtility: Boolean",
"LayerUtility: Seed": "LayerUtility: Seed"
"LayerUtility: Seed": "LayerUtility: Seed",
"LayerUtility: ImageBatchToList": "LayerUtility: Image Batch To List(Multi)",
"LayerUtility: ImageListToBatch": "LayerUtility: Image List To Batch(Multi)",
}
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "comfyui_layerstyle"
description = "A set of nodes for ComfyUI it generate image like Adobe Photoshop's Layer Style. the Drop Shadow is first completed node, and follow-up work is in progress."
version = "2.0.35"
version = "2.0.36"
license = {text = "MIT License"}
dependencies = ["numpy", "pillow", "torch", "matplotlib", "Scipy", "scikit_image", "scikit_learn", "opencv-contrib-python", "pymatting", "timm", "colour-science", "transformers", "blend_modes", "huggingface_hub", "loguru"]