diff --git a/README.MD b/README.MD index a181693..dd30faf 100644 --- a/README.MD +++ b/README.MD @@ -116,6 +116,7 @@ When this error has occurred, please check the network environment. ## Update **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.
+* Commit [UserPromptGeneratorTxtImgWithReference](#UserPromptGeneratorTxtImgWithReference) node. * Commit [GrayValue](#GrayValue) node, output the grayscale values corresponding to the RGB color values. * [LUT Apply](#LUT), [TextImageV2](#TextImageV2), [TextImage](#TextImage), [SimpleTextImage](#SimpleTextImage) nodes to support defining multiple folders in ```resource-dir.ini```, separated by commas, semicolons, or spaces. Simultaneously supports refreshing real-time updates. * [LUT Apply](#LUT), [TextImageV2](#TextImageV2), [TextImage](#TextImage), [SimpleTextImage](#SimpleTextImage) nodes support defining multi directory fonts and lut folders, and support refreshing and real-time updates. @@ -816,6 +817,19 @@ Node options: * describe: Prompt word description. Enter a simple description here. * limit_word: Maximum length limit for output prompt words. For example, 200 means that the output text will be limited to 200 words. + +### UserPromptGeneratorTxtImgWithReference +UserCompt preset for generating SD text to image prompt words based on input content. + +Node options: +![image](image/userprompt_generator_txt2img_with_reference_node.jpg) + +* reference_text: Reference text input. Usually it is a style description of the image. +* template: Prompt word template. Currently, only the 'SD txt2img prompt' is available. +* describe: Prompt word description. Enter a simple description here. +* limit_word: Maximum length limit for output prompt words. For example, 200 means that the output text will be limited to 200 words. + + ### UserPromptGeneratorReplaceWord UserPrompt preset used to replace a keyword in text with different content. This is not only a simple replacement, but also a logical sorting of the text based on the context of the prompt words to achieve the rationality of the output content. diff --git a/README_CN.MD b/README_CN.MD index fd52b07..bd61a43 100644 --- a/README_CN.MD +++ b/README_CN.MD @@ -116,6 +116,7 @@ os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com' ## 更新说明 **如果本插件更新后出现依赖包错误,请双击运行插件目录下的```install_requirements.bat```(官方便携包),或 ```install_requirements_aki.bat```(秋叶整合包) 重新安装依赖包。 +* 添加 [UserPromptGeneratorTxtImgWithReference](#UserPromptGeneratorTxtImgWithReference) 节点。 * 添加 [GrayValue](#GrayValue) 节点,输出RGB色值对应的灰度值。 * [LUT Apply](#LUT), [TextImageV2](#TextImageV2), [TextImage](#TextImage), [SimpleTextImage](#SimpleTextImage) 等节点支持在 ```resource_dir.ini``` 中定义多个文件夹,之间用逗号,分号或者空格分隔。同时支持刷新实时更新。 * 添加 [HumanPartsUltra](#HumanPartsUltra) 节点,用于人物肢体分割。本节点是基于[metal3d/ComfyUI_Human_Parts](https://github.com/metal3d/ComfyUI_Human_Parts) 的重新封装,感谢原作者。 @@ -805,6 +806,18 @@ ImageScaleByAspectRatio的V2升级版 * describe: 提示词描述。在这里输入简单的描述。 * limit_word: 输出的提示词最大长度限制。例如200即表示输出文本将被限制在200个词以内。 +### UserPromptGeneratorTxtImgWithReference +用于参考输入的内容生成SD文本到图片提示词的UserPrompt预设。 + +节点选项说明: +![image](image/userprompt_generator_txt2img_with_reference_node.jpg) + +* reference_text: 参考文本输入。通常是图片的风格描述。 +* template: 提示词模板。目前仅有“SD txt2img prompt”可用。 +* describe: 提示词描述。在这里输入简单的描述。 +* limit_word: 输出的提示词最大长度限制。例如200即表示输出文本将被限制在200个词以内。 + + ### UserPromptGeneratorReplaceWord 用于将文本中的某个关键词替换为不同内容的UserPrompt预设。这不仅是简单的替换,还可以根据提示词上下文进行文字逻辑梳理以达到输出内容的合理性。 diff --git a/image/userprompt_generator_txt2img_with_reference_node.jpg b/image/userprompt_generator_txt2img_with_reference_node.jpg new file mode 100644 index 0000000..88c10c9 Binary files /dev/null and b/image/userprompt_generator_txt2img_with_reference_node.jpg differ diff --git a/py/user_prompt_generator.py b/py/user_prompt_generator.py index 27d19f0..9da85bf 100644 --- a/py/user_prompt_generator.py +++ b/py/user_prompt_generator.py @@ -1,5 +1,42 @@ from .imagefunc import log +class LS_UserPromptGenerator_Txt2ImgPromptWithReference: + + def __init__(self): + self.NODE_NAME = 'UserPromptGenerator-Txt2ImgPromptWithReference' + + @classmethod + def INPUT_TYPES(self): + template_list = ['SD txt2img prompt',] + return { + "required": { + "template": (template_list,), + "reference_text": ("STRING", {"multiline": False,"forceInput":True}), + "describe": ("STRING", {"default": "1 girl","multiline": True}), + "limit_words": ("INT", {"default": 200, "min": 2, "max": 999, "step": 1}), + }, + "optional": { + } + } + + RETURN_TYPES = ("STRING", ) + RETURN_NAMES = ("user_prompt", ) + FUNCTION = 'user_prompt_generator_txt2img_prompt_with_reference' + CATEGORY = '😺dzNodes/LayerUtility/Prompt' + + def user_prompt_generator_txt2img_prompt_with_reference(self, template, reference_text, describe, limit_words): + + if template == 'SD txt2img prompt': + prompt = (f'The REFERENCE TEXT is "{reference_text}".\r\n' + f"You are creating a prompt for Stable Diffusion to generate an image.\r\n" + f"Using '{describe}' as the basic content and depicting it as main subject, refer to the visual style described in the REFERENCE TEXT, polish and embellish it to describe into text.\r\n" + f"The word limit for the answer is between {int(limit_words * 0.7)} - {int(limit_words * 1.1)} words. Not too little, nor too much.\r\n" + f"Only output the prompt itself, don't output any unnecessary content like word count info.") + + log(f'{self.NODE_NAME} Processed. result is \r\n"{prompt}".') + return (prompt,) + + class LS_UserPromptGenerator_Txt2ImgPrompt: def __init__(self): @@ -73,10 +110,12 @@ class LS_UserPromptGenerator_ReplaceWord: NODE_CLASS_MAPPINGS = { "LayerUtility: UserPromptGeneratorTxt2ImgPrompt": LS_UserPromptGenerator_Txt2ImgPrompt, + "LayerUtility: UserPromptGeneratorTxt2ImgPromptWithReference": LS_UserPromptGenerator_Txt2ImgPromptWithReference, "LayerUtility: UserPromptGeneratorReplaceWord": LS_UserPromptGenerator_ReplaceWord } NODE_DISPLAY_NAME_MAPPINGS = { "LayerUtility: UserPromptGeneratorTxt2ImgPrompt": "LayerUtility: UserPrompt Generator Txt2Img", + "LayerUtility: UserPromptGeneratorTxt2ImgPromptWithReference": "LayerUtility: UserPrompt Generator Txt2Img with Reference", "LayerUtility: UserPromptGeneratorReplaceWord": "LayerUtility: UserPrompt Generator Replace Word" } \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 4c88c00..54db61b 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 = "1.0.66" +version = "1.0.67" license = "MIT" dependencies = ["numpy", "pillow", "torch", "matplotlib", "Scipy", "scikit_image", "scikit_learn", "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", "transparent-background", "huggingface_hub", "accelerate", "bitsandbytes", "torchscale", "wandb", "hydra-core", "psd-tools", "inference-cli[yolo-world]", "inference-gpu[yolo-world]", "onnxruntime"] diff --git a/resource_dir.ini.example b/resource_dir.ini.example index 88ad38d..ca39fad 100644 --- a/resource_dir.ini.example +++ b/resource_dir.ini.example @@ -1,2 +1,2 @@ -FONT_dir=C:\font,C:\another\font -LUT_dir=C:\lut,C:\another\lut \ No newline at end of file +FONT_dir=C:\font,D:\other_font +LUT_dir=C:\lut,D:\other_lut \ No newline at end of file