From fe32eda5396613bb1dcf4fcdac953603008ffa10 Mon Sep 17 00:00:00 2001 From: yolain Date: Fri, 14 Jun 2024 23:02:28 +0800 Subject: [PATCH] fix:fooocus inpaint not working in latest comfy version #211 --- README.en.md | 2 ++ README.md | 3 ++- py/libs/adv_encode.py | 8 ++++---- py/libs/fooocus.py | 12 ++++++++---- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/README.en.md b/README.en.md index 1b3884c..e99faa7 100644 --- a/README.en.md +++ b/README.en.md @@ -30,6 +30,7 @@ - Background removal nodes for the RMBG-1.4 model supporting BriaAI, [BriaAI Guide](https://huggingface.co/briaai/RMBG-1.4) - Forcibly cleared the memory usage of the comfy UI model are supported - Stable Diffusion 3 multi-account API nodes are supported +- Support Stable Diffusion 3 model ## Installation Clone the repo into the **custom_nodes** directory and install the requirements: @@ -44,6 +45,7 @@ Double-click install.bat to install the required dependencies **v1.1.9** +- Support for Stable Diffusion 3 model - Added `easy applyInpaint` - All inpainting mode in this node **v1.1.8** diff --git a/README.md b/README.md index c594138..d729e23 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ - 支持Stable Diffusion 3 多账号API节点 - 支持IC-Light的应用 [示例参考](https://github.com/yolain/ComfyUI-Yolain-Workflows?tab=readme-ov-file#2-5-ic-light) | [代码整合来源](https://github.com/huchenlei/ComfyUI-IC-Light) | [技术参考](https://github.com/lllyasviel/IC-Light) - 中文提示词自动识别,使用[opus-mt-zh-en模型](https://huggingface.co/Helsinki-NLP/opus-mt-zh-en) +- 支持 sd3 模型 ## 安装 将存储库克隆到 **custom_nodes** 目录并安装依赖 @@ -51,7 +52,7 @@ git clone https://github.com/yolain/ComfyUI-Easy-Use **v1.1.9** -- 支持 sd3_medium_incl_clips 模型 +- 支持 sd3 模型 - 增加 `easy applyInpaint` - 局部重绘全模式节点 (相比与之前的kSamplerInpating节点逻辑会更合理些) **v1.1.8** diff --git a/py/libs/adv_encode.py b/py/libs/adv_encode.py index 8fe8721..66031fd 100644 --- a/py/libs/adv_encode.py +++ b/py/libs/adv_encode.py @@ -6,9 +6,9 @@ import itertools from comfy import model_management from comfy.sdxl_clip import SDXLClipModel, SDXLRefinerClipModel, SDXLClipG try: - from comfy.sd3_clip import SD3ClipModel, SDT5XXLModel + from comfy.sd3_clip import SD3ClipModel, T5XXLModel except: - SD3ClipModel, SDT5XXLModel = None, None + SD3ClipModel, T5XXLModel = None, None pass from nodes import NODE_CLASS_MAPPINGS, ConditioningConcat, ConditioningZeroOut, ConditioningSetTimestepRange, ConditioningCombine @@ -353,7 +353,7 @@ def advanced_encode(clip, text, token_normalization, weight_interpretation, w_ma out = lg_out pooled = torch.cat((l_pooled, g_pooled), dim=-1) - # t5xxl not working, need to fix + # t5xxl if 't5xxl' in tokenized and clip.cond_stage_model.t5xxl is not None: t5_out, t5_pooled = advanced_encode_from_tokens(tokenized['t5xxl'], token_normalization, @@ -414,7 +414,7 @@ def advanced_encode(clip, text, token_normalization, weight_interpretation, w_ma else: conditioning = cond - # setTimeRange + # setTimeStepRange if time_start > 0 or time_end < 1: conditioning_2, = ConditioningSetTimestepRange().set_range(conditioning, 0, time_start) conditioning_1, = ConditioningZeroOut().zero_out(conditioning) diff --git a/py/libs/fooocus.py b/py/libs/fooocus.py index 9e69f12..6f5e2df 100644 --- a/py/libs/fooocus.py +++ b/py/libs/fooocus.py @@ -1,3 +1,5 @@ +#credit to Acly for this module +#from https://github.com/Acly/comfyui-inpaint-nodes import torch import comfy from comfy.model_patcher import ModelPatcher @@ -32,16 +34,18 @@ class InpaintWorker: loaded_keys.add(key) not_loaded = sum(1 for x in lora if x not in loaded_keys) - log_node_info(self.node_name, - f"{len(loaded_keys)} Lora keys loaded, {not_loaded} remaining keys not found in model." - ) + if not_loaded > 0: + log_node_info(self.node_name, + f"{len(loaded_keys)} Lora keys loaded, {not_loaded} remaining keys not found in model." + ) return patch_dict def calculate_weight_patched(self: ModelPatcher, patches, weight, key): remaining = [] for p in patches: - alpha, v, strength_model = p + alpha = p[0] + v = p[1] is_fooocus_patch = isinstance(v, tuple) and len(v) == 2 and v[0] == "fooocus" if not is_fooocus_patch: