fix:error when ComfyUI-Impack-Pack and ComfyUI_InstantID were not installed

This commit is contained in:
yolain
2024-03-03 08:13:26 +08:00
parent f9d01ff53b
commit ff1add1557
5 changed files with 42 additions and 30 deletions
+4
View File
@@ -41,6 +41,10 @@ Usage:<br>
**v1.0.9 [2024-3-2]**
- Fixed the error when ComfyUI-Impack-Pack and ComfyUI_InstantID were not installed
- Fixed `easy pipeIn`
-
(f9d01ff)
- Added `easy instantIDApply` - you need installed [ComfyUI_InstantID](https://github.com/cubiq/ComfyUI_InstantID) fisrt, Workflow[Example](https://github.com/yolain/ComfyUI-Easy-Use/blob/main/README.en.md#InstantID)
- Fixed `easy detailerFix` not added to the list of nodes available for saving images formatting extensions
- Fixed `easy XYInputs: PromptSR` errors are reported when replacing negative prompts
+4 -1
View File
@@ -43,9 +43,12 @@ stage_c 与 stage_b 可以使用[checkpoints](https://huggingface.co/stabilityai
## 更新日志
**v1.0.9 [2024-3-3]**
**v1.0.9 [2024-3-2]**
- 修复未安装 ComfyUI-Impack-Pack 和 ComfyUI_InstantID 时报错
- 修复 `easy pipeIn` - pipe设为可不必选
(f9d01ff)
- 新增 `easy instantIDApply` - 需要先安装 [ComfyUI_InstantID](https://github.com/cubiq/ComfyUI_InstantID), 工作流参考[示例](https://github.com/yolain/ComfyUI-Easy-Use?tab=readme-ov-file#InstantID)
- 修复 `easy detailerFix` 未添加到保存图片格式化扩展名可用节点列表
- 修复 `easy XYInputs: PromptSR` 在替换负面提示词时报错
+23 -14
View File
@@ -16,7 +16,7 @@ from .log import log_node_info, log_node_error, log_node_warn
from .wildcards import process_with_loras, get_wildcard_list, process
from .adv_encode import advanced_encode
from .libs.utils import find_nearest_steps, find_wildcards_seed, is_linked_styles_selector, easySave, get_local_filepath
from .libs.utils import find_nearest_steps, find_wildcards_seed, is_linked_styles_selector, easySave, get_local_filepath, add_folder_path_and_extensions
from .libs.loader import easyLoader
from .libs.sampler import easySampler
from .libs.xyplot import easyXYPlot
@@ -25,6 +25,17 @@ from .libs.controlnet import easyControlnet
sampler = easySampler()
easyCache = easyLoader()
model_path = folder_paths.models_dir
add_folder_path_and_extensions("ultralytics_bbox", [os.path.join(model_path, "ultralytics", "bbox")], folder_paths.supported_pt_extensions)
add_folder_path_and_extensions("ultralytics_segm", [os.path.join(model_path, "ultralytics", "segm")], folder_paths.supported_pt_extensions)
add_folder_path_and_extensions("ultralytics", [os.path.join(model_path, "ultralytics")], folder_paths.supported_pt_extensions)
add_folder_path_and_extensions("mmdets_bbox", [os.path.join(model_path, "mmdets", "bbox")], folder_paths.supported_pt_extensions)
add_folder_path_and_extensions("mmdets_segm", [os.path.join(model_path, "mmdets", "segm")], folder_paths.supported_pt_extensions)
add_folder_path_and_extensions("mmdets", [os.path.join(model_path, "mmdets")], folder_paths.supported_pt_extensions)
add_folder_path_and_extensions("sams", [os.path.join(model_path, "sams")], folder_paths.supported_pt_extensions)
add_folder_path_and_extensions("onnx", [os.path.join(model_path, "onnx")], {'.onnx'})
add_folder_path_and_extensions("instantid", [os.path.join(model_path, "instantid")], {'.bin'})
# ---------------------------------------------------------------提示词 开始----------------------------------------------------------------------#
# 正面提示词
@@ -819,7 +830,7 @@ class fullLoader:
"empty_samples": samples, }
}
return {"ui": {"positive": positive_wildcard_prompt, "negative": negative_wildcard_prompt}, "result": (pipe, model, vae, clip, positive, negative, samples)}
return {"ui": {"positive": positive_wildcard_prompt, "negative": negative_wildcard_prompt}, "result": (pipe, model, vae, clip, positive_embeddings_final, negative_embeddings_final, samples)}
# A1111简易加载器
class a1111Loader:
@@ -3529,10 +3540,9 @@ class pipeIn:
@classmethod
def INPUT_TYPES(s):
return {
"required":{
"pipe": ("PIPE_LINE",),
},
"required": {},
"optional": {
"pipe": ("PIPE_LINE",),
"model": ("MODEL",),
"pos": ("CONDITIONING",),
"neg": ("CONDITIONING",),
@@ -3551,7 +3561,7 @@ class pipeIn:
CATEGORY = "EasyUse/Pipe"
def flush(self, pipe, model=None, pos=None, neg=None, latent=None, vae=None, clip=None, image=None, xyplot=None, my_unique_id=None):
def flush(self, pipe=None, model=None, pos=None, neg=None, latent=None, vae=None, clip=None, image=None, xyplot=None, my_unique_id=None):
model = model if model is not None else pipe.get("model")
if model is None:
@@ -3572,15 +3582,16 @@ class pipeIn:
if clip is None:
log_node_warn(f'pipeIn[{my_unique_id}]', "Clip missing from pipeLine")
if image is None:
image = pipe.get("images")
image = pipe.get("images") if pipe is not None else None
else:
batch_size = pipe["loader_settings"]["batch_size"] if "batch_size" in pipe["loader_settings"] else 1
samples = {"samples": vae.encode(image)}
samples = RepeatLatentBatch().repeat(samples, batch_size)[0]
seed = pipe.get("seed")
if seed is None:
log_node_warn(f'pipeIn[{my_unique_id}]', "Seed missing from pipeLine")
xyplot = xyplot or pipe['loader_settings']['xyplot'] if 'xyplot' in pipe['loader_settings'] else None
if pipe is None:
pipe = {"loader_settings": {"positive": "", "negative": "", "xyplot": None}}
xyplot = xyplot if xyplot is not None else pipe['loader_settings']['xyplot'] if xyplot in pipe['loader_settings'] else None
new_pipe = {
"model": model,
@@ -3591,12 +3602,10 @@ class pipeIn:
"samples": samples,
"images": image,
"seed": seed,
"seed": pipe.get('seed') if pipe is not None and "seed" in pipe else None,
"loader_settings": {
**pipe["loader_settings"],
"positive": "",
"negative": "",
"xyplot": xyplot
}
}
+11
View File
@@ -16,6 +16,17 @@ def compare_revision(num):
comfy_ui_revision = get_comfyui_revision()
return True if comfy_ui_revision == 'Unknown' or int(comfy_ui_revision) >= num else False
import folder_paths
def add_folder_path_and_extensions(folder_name, full_folder_paths, extensions):
for full_folder_path in full_folder_paths:
folder_paths.add_model_folder_path(folder_name, full_folder_path)
if folder_name in folder_paths.folder_names_and_paths:
current_paths, current_extensions = folder_paths.folder_names_and_paths[folder_name]
updated_extensions = current_extensions | extensions
folder_paths.folder_names_and_paths[folder_name] = (current_paths, updated_extensions)
else:
folder_paths.folder_names_and_paths[folder_name] = (full_folder_paths, extensions)
def find_nearest_steps(clip_id, prompt):
"""Find the nearest KSampler or preSampling node that references the given id."""
def check_link_to_clip(node_id, clip_id, visited=None, node=None):
-15
View File
@@ -156,21 +156,6 @@ def prompt_seed_update(json_data):
if isinstance(v['inputs']['seed_num'], int):
v['inputs']['seed_num'] = value
# 修改和seed节点连接的节点 (没有作用,不生效)
# if cls == 'easy seed':
# outputs = extra_data.get('outputs')
# if outputs and outputs[0] and 'links' in outputs[0]:
# for id in outputs[0]['links']:
# for x in workflow["nodes"]:
# if "inputs" in x and x['inputs'] != []:
# x_seed_num = next((i for i in x['inputs'] if i['name'] == 'seed_num' and i['type'] == 'INT'), None)
# if x_seed_num is not None and "link" in x_seed_num and id == x_seed_num['link']:
# widgets_values = x['widgets_values']
# if widgets_values:
# widgets_values[len(widgets_values)-1] = action
# widgets_values[len(widgets_values)-2] = value
# print(x)
return value is not None