diff --git a/PulidFluxHook.py b/PulidFluxHook.py index a614278..a01ed90 100644 --- a/PulidFluxHook.py +++ b/PulidFluxHook.py @@ -70,7 +70,7 @@ def __call__(self, input_args, extra_options): img = out['img'] temp_img = img for i, callback in enumerate(self.callback): - if sigma <= self.kwargs[i]["sigma_start"] and sigma >= self.kwargs[i]["sigma_end"]: + if self.kwargs[i]["sigma_start"] >= sigma >= self.kwargs[i]["sigma_end"]: img = img + callback(temp_img, pulid_model=self.kwargs[i]['pulid_model'], ca_idx=self.kwargs[i]['ca_idx'], @@ -118,7 +118,7 @@ def __call__(self, input_args, extra_options): real_img, txt = img[:, txt.shape[1]:, ...], img[:, :txt.shape[1], ...] temp_img = real_img for i, callback in enumerate(self.callback): - if sigma <= self.kwargs[i]["sigma_start"] and sigma >= self.kwargs[i]["sigma_end"]: + if self.kwargs[i]["sigma_start"] >= sigma >= self.kwargs[i]["sigma_end"]: real_img = real_img + callback(temp_img, pulid_model=self.kwargs[i]['pulid_model'], ca_idx=self.kwargs[i]['ca_idx'], @@ -159,9 +159,8 @@ def pulid_forward_orig( img = self.img_in(img) vec = self.time_in(timestep_embedding(timesteps, 256).to(img.dtype)) if self.params.guidance_embed: - if guidance is None: - raise ValueError("Didn't get guidance strength for guidance distilled model.") - vec = vec + self.guidance_in(timestep_embedding(guidance, 256).to(img.dtype)) + if guidance is not None: + vec = vec + self.guidance_in(timestep_embedding(guidance, 256).to(img.dtype)) vec = vec + self.vector_in(y) txt = self.txt_in(txt) @@ -171,9 +170,6 @@ def pulid_forward_orig( blocks_replace = patches_replace.get("dit", {}) - # pulid_temp_attrs = transformer_options.get(PatchKeys.pulid_patch_key_attrs, {}) - # pulid_temp_attrs['timesteps'] = timesteps - for i, block in enumerate(self.double_blocks): # 0 -> 18 if ("double_block", i) in blocks_replace: @@ -212,8 +208,6 @@ def block_wrap(args): if add is not None: img += add - # pulid_temp_attrs['double_blocks_txt'] = txt - img = torch.cat((txt, img), 1) for i, block in enumerate(self.single_blocks): diff --git a/README.md b/README.md index 286b26e..db313cb 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ - Solved [ComfyUI-PuLID-Flux](https://github.com/balazik/ComfyUI-PuLID-Flux) model pollution problem. - Supported use with `TeaCache` (Need use with [ComfyUI_Patches_ll](https://github.com/lldacing/ComfyUI_Patches_ll)). - Supported use with [Comfy-WaveSpeed](https://github.com/chengzeyi/Comfy-WaveSpeed), supported by `Comfy-WaveSpeed` in [commit-36ba3c8](https://github.com/chengzeyi/Comfy-WaveSpeed/commit/36ba3c8b74735d4521828507a4bf323df1a9a9d0). +- Supported simple use with `First Block Cache` (Can use with [ComfyUI_Patches_ll](https://github.com/lldacing/ComfyUI_Patches_ll)). Must uninstall or disable `ComfyUI-PuLID-Flux` and other PuLID-Flux nodes before install this plugin. Due to certain reasons, I used the same node's name `ApplyPulidFlux`. diff --git a/README_CN.md b/README_CN.md index f522eea..1525c50 100644 --- a/README_CN.md +++ b/README_CN.md @@ -3,6 +3,7 @@ - 解决插件 [ComfyUI-PuLID-Flux](https://github.com/balazik/ComfyUI-PuLID-Flux) 存在的模型污染问题。 - 支持使用[TeaCache](https://github.com/ali-vilab/TeaCache)加速(`TeaCache`加速需要配合[ComfyUI_Patches_ll](https://github.com/lldacing/ComfyUI_Patches_ll)使用)。 - 支持使用[Comfy-WaveSpeed](https://github.com/chengzeyi/Comfy-WaveSpeed)加速, Comfy-WaveSpeed在[提交记录-36ba3c8](https://github.com/chengzeyi/Comfy-WaveSpeed/commit/36ba3c8b74735d4521828507a4bf323df1a9a9d0)中提供支持。 +- 支持使用简单的`First Block Cache`加速(可以配合[ComfyUI_Patches_ll](https://github.com/lldacing/ComfyUI_Patches_ll)使用)。 在安装此插件之前,必须卸载或禁用`ComfyUI-PuLID-Flux`和其他PuLID Flux节点, 因为由于某些原因,我使用了同样的节点名`ApplyPulidFlux` @@ -36,7 +37,7 @@ - 使用 [TeaCache](https://github.com/ali-vilab/TeaCache)加速, 必须加在[`FluxForwardOverrider` and `ApplyTeaCachePatch`](https://github.com/lldacing/ComfyUI_Patches_ll)之前. - 使用 [Comfy-WaveSpeed](https://github.com/chengzeyi/Comfy-WaveSpeed)加速, 必须加在[`ApplyFBCacheOnModel`](https://github.com/lldacing/ComfyUI_Patches_ll)之前. - FixPulidFluxPatch (已弃用) - - 如果想使用 [TeaCache](https://github.com/ali-vilab/TeaCache)加速, 必须~~加在 `ApplyPulidFlux` 节点之后, 并~~在后面连接节点 [`FluxForwardOverrider` and `ApplyTeaCachePatch`](https://github.com/lldacing/ComfyUI_Patches_ll). + - 如果想使用 [TeaCache](https://github.com/ali-vilab/TeaCache)加速, 必须加在 `ApplyPulidFlux` 节点之后, 并在后面连接节点 [`FluxForwardOverrider` and `ApplyTeaCachePatch`](https://github.com/lldacing/ComfyUI_Patches_ll). ## 感谢 diff --git a/pyproject.toml b/pyproject.toml index 8afbf7f..82a0453 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui_pulid_flux_ll" description = "The implementation for PuLID-Flux, support use with TeaCache and WaveSpeed, no model pollution." -version = "1.0.7" +version = "1.0.8" license = {file = "LICENSE"} dependencies = ['facexlib', 'insightface', 'onnxruntime', 'onnxruntime-gpu; sys_platform != "darwin" and platform_machine == "x86_64"', 'ftfy', 'timm']