diff --git a/README.MD b/README.MD
index 749425c..9005f8e 100644
--- a/README.MD
+++ b/README.MD
@@ -147,7 +147,7 @@ When this error has occurred, please check the network environment.
**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.
-* [PurgeVRAM](#PurgeVRAM) node add any output.
+* Commit [PurgeVRAM V2](#PurgeVRAMV2) node.
* Commit [ChoiceTextPreset](#ChoiceTextPreset) and [TextPreseter](#TextPreseter) nodes, used for preset text and selecting preset text output.
* [StringCondition](#StringCondition) add the option of comparing strings to determine if they are the same.
* Commit [NameToColor](#NameToColor) node, Output colors based on their names.
@@ -1714,6 +1714,10 @@ Node Options:
* purge_cache: Clean up cache。
* purge_models: Unload all loaded models。
+### PurgeVRAMV2
+
+Unlike PurgeVRM, this node is not mandatory and can access any input in the process while maintaining the original output, allowing for flexible cleaning.
+
### ImageTaggerSave
diff --git a/README_CN.MD b/README_CN.MD
index 292ace8..738083d 100644
--- a/README_CN.MD
+++ b/README_CN.MD
@@ -128,7 +128,7 @@ os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
## 更新说明
**如果本插件更新后出现依赖包错误,请双击运行插件目录下的```install_requirements.bat```(官方便携包),或 ```install_requirements_aki.bat```(秋叶整合包) 重新安装依赖包。
-* [PurgeVRAM](#PurgeVRAM)增加any输出。
+* 添加 [PurgeVRAM V2](#PurgeVRAMV2) 节点,不强制执行,增加any输出,便于在流程中灵活释放显存。
* 添加 [ChoiceTextPreset](#ChoiceTextPreset) 和 [TextPreseter](#TextPreseter) 节点,用于预设文本和选择预设文本输出。
* [StringCondition](#StringCondition) 节点增加比较字符串是否相同功能。
* 添加 [NameToColor](#NameToColor)节点,根据颜色名称输出颜色。
@@ -1522,12 +1522,15 @@ BooleanOperator的升级版,增加了节点内数值输入,增加了大于
### PurgeVRAM

清理GPU显存。可以接入任意类型的输入,当执行到这个节点时将清理VRAM以及RAM中的垃圾对象。通常放置在推理任务完成的节点之后,例如VAE Decode节点。
+此节点为强制执行,即接在此节点之前的所有节点都将被执行。
节点选项说明:
* purge_cache: 清理缓存。
* purge_models: 清理已加载的模型。
-
+### PurgeVRAMV2
+
+与PurgeVRAM不同,此节点不是强制执行,可在流程中接入任意输入,并保持原输出,灵活清理。
### ImageTaggerSave

diff --git a/image/purge_vram_example.jpg b/image/purge_vram_example.jpg
index ad6d44b..981dfff 100644
Binary files a/image/purge_vram_example.jpg and b/image/purge_vram_example.jpg differ
diff --git a/image/purge_vram_v2_example.jpg b/image/purge_vram_v2_example.jpg
new file mode 100644
index 0000000..ad6d44b
Binary files /dev/null and b/image/purge_vram_v2_example.jpg differ
diff --git a/py/purge_vram.py b/py/purge_vram.py
index 92429f3..2777233 100644
--- a/py/purge_vram.py
+++ b/py/purge_vram.py
@@ -8,7 +8,39 @@ any = AnyType("*")
class PurgeVRAM:
def __init__(self):
- self.NODE_NAME = 'PurgeVRAM'
+ pass
+
+ @classmethod
+ def INPUT_TYPES(cls):
+ return {
+ "required": {
+ "anything": (any, {}),
+ "purge_cache": ("BOOLEAN", {"default": True}),
+ "purge_models": ("BOOLEAN", {"default": True}),
+ },
+ "optional": {
+ }
+ }
+
+ RETURN_TYPES = ()
+ FUNCTION = "purge_vram"
+ CATEGORY = '😺dzNodes/LayerUtility/SystemIO'
+ OUTPUT_NODE = True
+
+ def purge_vram(self, anything, purge_cache, purge_models):
+ import torch.cuda
+ import gc
+ import comfy.model_management
+ clear_memory()
+ if purge_models:
+ comfy.model_management.unload_all_models()
+ comfy.model_management.soft_empty_cache()
+ return (None,)
+
+class PurgeVRAM_V2:
+
+ def __init__(self):
+ self.NODE_NAME = 'PurgeVRAM V2'
@classmethod
def INPUT_TYPES(cls):
@@ -25,11 +57,11 @@ class PurgeVRAM:
RETURN_TYPES = (any,)
RETURN_NAMES = ("any",)
- FUNCTION = "purge_vram"
+ FUNCTION = "purge_vram_v2"
CATEGORY = '😺dzNodes/LayerUtility/SystemIO'
OUTPUT_NODE = True
- def purge_vram(self, anything, purge_cache, purge_models):
+ def purge_vram_v2(self, anything, purge_cache, purge_models):
clear_memory()
if purge_models:
comfy.model_management.unload_all_models()
@@ -38,9 +70,11 @@ class PurgeVRAM:
NODE_CLASS_MAPPINGS = {
- "LayerUtility: PurgeVRAM": PurgeVRAM
+ "LayerUtility: PurgeVRAM": PurgeVRAM,
+ "LayerUtility: PurgeVRAM V2": PurgeVRAM_V2,
}
NODE_DISPLAY_NAME_MAPPINGS = {
- "LayerUtility: PurgeVRAM": "LayerUtility: Purge VRAM"
+ "LayerUtility: PurgeVRAM": "LayerUtility: Purge VRAM",
+ "LayerUtility: PurgeVRAM V2": "LayerUtility: Purge VRAM V2",
}
\ No newline at end of file
diff --git a/pyproject.toml b/pyproject.toml
index e7ecd0d..39726bc 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -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.14"
+version = "2.0.15"
license = "MIT"
dependencies = ["numpy", "pillow", "torch", "matplotlib", "Scipy", "scikit_image", "scikit_learn", "opencv-contrib-python", "pymatting", "timm", "colour-science", "transformers", "blend_modes", "huggingface_hub", "loguru"]