commit QueueStop node

This commit is contained in:
chflame163
2024-06-27 18:58:53 +08:00
parent 49004bb3d1
commit b352799020
9 changed files with 402 additions and 7 deletions
+9
View File
@@ -80,6 +80,7 @@ When this error has occurred, please check the network environment.
## Update
<font size="4">**If the dependency package error after updating, please reinstall the relevant dependency packages. </font><br />
* Commit [QueueStop](#QueueStop) node, used to terminate the queue operation.
* Optimize performance of the ```vitmate``` method for Ultra nodes when processing large-size image.
* [CropByMaskV2](#CropByMaskV2) add option to round the cutting size by multiples.
* Commit [CheckMask](#CheckMask) node, it detect whether the mask contains sufficient effective areas. Commit [HSVValue](#HSVValue) node, it convert color values to HSV values.
@@ -1216,6 +1217,14 @@ Node Options:
* case_2: case_2 string.
* case_3: case_3 string.
### <a id="table1">QueueStop</a>
![image](image/queue_stop_example.jpg)
Stop the current queue. When executed at this node, the queue will stop. The workflow diagram above illustrates that if the image is larger than 1Mega pixels, the queue will stop executing.
Node Options:
![image](image/queue_stop_node.jpg)
* mode: Stop mode. Currently, only stop mode can be selected.
* stop: If true, the queue will stop. If false, the queue will continue to execute.
### <a id="table1">PurgeVRAM</a>
![image](image/purge_vram_example.jpg)
+10
View File
@@ -80,6 +80,7 @@ git clone https://github.com/chflame163/ComfyUI_LayerStyle.git
## 更新说明
<font size="4">**如果本插件更新后出现依赖包错误,请重新安装相关依赖包。
* 添加 [QueueStop](#QueueStop) 节点,用于停止队列。
* 优化Ultra节点的```vitmatte```方法在处理大尺寸图片时的性能。
* [CropByMaskV2](#CropByMaskV2) 增加裁切尺寸按倍数取整选项。
* 添加 [CheckMask](#CheckMask) 节点, 用于检测遮罩是否包含足够的有效区域。
@@ -1206,6 +1207,15 @@ BooleanOperator的升级版,增加了节点内数值输入,增加了大于
* case_2: case_2字符串。
* case_3: case_3字符串。
### <a id="table1">QueueStop</a>
![image](image/queue_stop_example.jpg)
停止当前的队列。执行到此节点时,队列将停止。上图工作流示意了如果图片大于1Mega像素时,队列将停止执行。
节点选项说明:
![image](image/queue_stop_node.jpg)
* mode: 停止模式。当前仅能选择stop一种模式。
* stop: 如果为True,队列将停止。如果为False,队列将继续执行。
### <a id="table1">PurgeVRAM</a>
![image](image/purge_vram_example.jpg)
Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

+30 -2
View File
@@ -1,5 +1,4 @@
from .imagefunc import AnyType
from .imagefunc import extract_all_numbers_from_str
from .imagefunc import AnyType, log, extract_all_numbers_from_str
any = AnyType("*")
@@ -420,8 +419,36 @@ class SwitchCaseNode:
return (output,)
class QueueStopNode():
def __init__(self):
pass
@classmethod
def INPUT_TYPES(self):
mode_list = ["stop"]
return {
"required": {
"any": (any, ),
"mode": (mode_list,),
"stop": ("BOOLEAN", {"default": True}),
},
}
RETURN_TYPES = (any,)
RETURN_NAMES = ("any",)
FUNCTION = 'stop_node'
CATEGORY = '😺dzNodes/LayerUtility/SystemIO'
def stop_node(self, any, mode,stop):
if mode == "stop":
if stop:
log(f"Queue stopped, it was terminated by node.", "error")
from comfy.model_management import InterruptProcessingException
raise InterruptProcessingException()
return (any,)
NODE_CLASS_MAPPINGS = {
"LayerUtility: QueueStop": QueueStopNode,
"LayerUtility: SwitchCase": SwitchCaseNode,
"LayerUtility: If ": IfExecute,
"LayerUtility: StringCondition": StringCondition,
@@ -438,6 +465,7 @@ NODE_CLASS_MAPPINGS = {
}
NODE_DISPLAY_NAME_MAPPINGS = {
"LayerUtility: QueueStop": "LayerUtility: Queue Stop",
"LayerUtility: SwitchCase": "LayerUtility: Switch Case",
"LayerUtility: If ": "LayerUtility: If",
"LayerUtility: StringCondition": "LayerUtility: String Condition",
+8 -2
View File
@@ -1404,9 +1404,15 @@ def generate_VITMatte(image:Image, trimap:Image, local_files_only:bool=False) ->
trimap = trimap.convert('L')
max_size = 2048
width, height = image.size
ratio = width / height
target_width = math.sqrt(ratio * max_size * max_size)
target_height = target_width / ratio
target_width = int(target_width)
target_height = int(target_height)
log(f"vitmatte image size {width}x{height} too large, resize to {target_width}x{target_height} for processing.")
if width * height > max_size * max_size:
image = image.resize((max_size, max_size), Image.BILINEAR)
trimap = trimap.resize((max_size, max_size), Image.BILINEAR)
image = image.resize((target_width, target_height), Image.BILINEAR)
trimap = trimap.resize((target_width, target_height), Image.BILINEAR)
model_name = "hustvl/vitmatte-small-composition-1k"
vit_matte_model = load_VITMatte_model(model_name=model_name, local_files_only=local_files_only)
inputs = vit_matte_model.processor(images=image, trimaps=trimap, return_tensors="pt")
+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 = "1.0.9"
version = "1.0.10"
license = "MIT"
dependencies = ["numpy", "pillow", "torch", "matplotlib", "Scipy", "scikit_image", "opencv-contrib-python", "pymatting", "segment_anything", "timm", "addict", "yapf", "colour-science", "wget", "mediapipe", "loguru", "typer_config", "fastapi", "rich", "google-generativeai", "diffusers", "omegaconf", "tqdm", "transformers", "kornia", "image-reward", "ultralytics", "blend_modes", "blind-watermark", "qrcode", "pyzbar", "psd-tools"]
+2 -2
View File
@@ -1,4 +1,4 @@
numpy
numpy<2.0
pillow
torch
matplotlib
@@ -21,7 +21,7 @@ google-generativeai
diffusers
omegaconf
tqdm
transformers
transformers>=4.38.2
kornia
image-reward
ultralytics
+342
View File
@@ -0,0 +1,342 @@
{
"last_node_id": 11,
"last_link_id": 15,
"nodes": [
{
"id": 11,
"type": "LayerUtility: NumberCalculator",
"pos": [
622,
680
],
"size": [
260.3999938964844,
78
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "a",
"type": "*",
"link": 13
},
{
"name": "b",
"type": "*",
"link": 14
}
],
"outputs": [
{
"name": "int",
"type": "INT",
"links": [
15
],
"shape": 3,
"slot_index": 0
},
{
"name": "float",
"type": "FLOAT",
"links": null,
"shape": 3
}
],
"properties": {
"Node name for S&R": "LayerUtility: NumberCalculator"
},
"widgets_values": [
"*"
]
},
{
"id": 6,
"type": "LayerUtility: QueueStop",
"pos": [
1259,
485
],
"size": {
"0": 315,
"1": 78
},
"flags": {},
"order": 4,
"mode": 0,
"inputs": [
{
"name": "any",
"type": "*",
"link": 5
},
{
"name": "stop",
"type": "BOOLEAN",
"link": 11,
"widget": {
"name": "stop"
}
}
],
"outputs": [
{
"name": "any",
"type": "*",
"links": [
12
],
"shape": 3,
"slot_index": 0
}
],
"properties": {
"Node name for S&R": "LayerUtility: QueueStop"
},
"widgets_values": [
"stop",
true
]
},
{
"id": 3,
"type": "PreviewImage",
"pos": [
1626,
482
],
"size": {
"0": 376.1998596191406,
"1": 331.6813659667969
},
"flags": {},
"order": 5,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 12
}
],
"properties": {
"Node name for S&R": "PreviewImage"
}
},
{
"id": 7,
"type": "LayerUtility: GetImageSize",
"pos": [
370,
680
],
"size": [
218.39999389648438,
66
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 7
}
],
"outputs": [
{
"name": "width",
"type": "INT",
"links": [
13
],
"shape": 3,
"slot_index": 0
},
{
"name": "height",
"type": "INT",
"links": [
14
],
"shape": 3,
"slot_index": 1
},
{
"name": "original_size",
"type": "BOX",
"links": null,
"shape": 3
}
],
"properties": {
"Node name for S&R": "LayerUtility: GetImageSize"
}
},
{
"id": 9,
"type": "LayerUtility: BooleanOperatorV2",
"pos": [
916,
678
],
"size": [
277.20001220703125,
126
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"name": "a",
"type": "*",
"link": 15
},
{
"name": "b",
"type": "*",
"link": null
}
],
"outputs": [
{
"name": "output",
"type": "BOOLEAN",
"links": [
11
],
"shape": 3,
"slot_index": 0
},
{
"name": "string",
"type": "STRING",
"links": null,
"shape": 3
}
],
"properties": {
"Node name for S&R": "LayerUtility: BooleanOperatorV2"
},
"widgets_values": [
"",
"1048576",
">"
]
},
{
"id": 2,
"type": "LoadImage",
"pos": [
13,
482
],
"size": {
"0": 315,
"1": 314
},
"flags": {},
"order": 0,
"mode": 0,
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
5,
7
],
"shape": 3,
"slot_index": 0
},
{
"name": "MASK",
"type": "MASK",
"links": null,
"shape": 3
}
],
"properties": {
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"3840x2160car.jpg",
"image"
]
}
],
"links": [
[
5,
2,
0,
6,
0,
"*"
],
[
7,
2,
0,
7,
0,
"IMAGE"
],
[
11,
9,
0,
6,
1,
"BOOLEAN"
],
[
12,
6,
0,
3,
0,
"IMAGE"
],
[
13,
7,
0,
11,
0,
"*"
],
[
14,
7,
1,
11,
1,
"*"
],
[
15,
11,
0,
9,
0,
"*"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.9090909090909091,
"offset": [
614.8169336983026,
127.3944912940982
]
}
},
"version": 0.4
}