From ef9dda2710653eb33ed8f944c39db68330ba98a6 Mon Sep 17 00:00:00 2001 From: AIrjen <130234949+AIrjen@users.noreply.github.com> Date: Sun, 30 Jul 2023 20:24:02 +0200 Subject: [PATCH 1/3] Create comfyui_integration.md --- user_guides/comfyui_integration.md | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 user_guides/comfyui_integration.md diff --git a/user_guides/comfyui_integration.md b/user_guides/comfyui_integration.md new file mode 100644 index 0000000..60eb89a --- /dev/null +++ b/user_guides/comfyui_integration.md @@ -0,0 +1,40 @@ +# ComfyUI integration +In this codebase there is a custom node, that can be used in ComfyUI. +Work is still in progress for all features to work flawlessly in ComfyUI, but a start has been made. + +You can slam it in every workflow, where you replace it with the Positive Prompt node. + +![image](https://github.com/AIrjen/OneButtonPrompt/assets/130234949/a9c6b449-772b-495c-b39d-eda0be38a203) + + +## Installing in ComfyUI + +Navigate to your ComfyUI directory, and run the following command: +``` +git clone https://github.com/AIrjen/OneButtonPrompt +``` + +This should create a OneButtonPrompt directory in the ComfyUI folder. + +![image](https://github.com/AIrjen/OneButtonPrompt/assets/130234949/5d9cfdd3-8342-4aff-a9a4-ecbbc7151856) + +From this folder, manually copy the file +``` +OneButtonPrompt-node.py +``` + +Into the ComfyUI\custom_nodes\ folder. +That should look like this: + +![image](https://github.com/AIrjen/OneButtonPrompt/assets/130234949/f2c9630e-790b-4a34-b46f-54dbb18b87d5) + +After that, restart ComfyUI, and you are ready to go. + +### Known issues + +1. ComfyUI does NOT store the prompt in the image, but the workflow. Since the prompt is not in the workflow, it is not saved. I am unsure wether there is a custom node for this. +2. There is a SEED option in the One Button Prompt node, this is a hacky thing. It is just there to make sure it is refired each time you generate an image. +3. Prompts are styled for Automatic1111, so it uses prompt switching, which is not supported by ComfyUI. +4. Easy installer not yet available. + +Issues will be investigated over time. From f3525bb6cd7558b3edb316e87953069b68e60739 Mon Sep 17 00:00:00 2001 From: AIrjen <130234949+AIrjen@users.noreply.github.com> Date: Sun, 30 Jul 2023 20:25:36 +0200 Subject: [PATCH 2/3] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 88f2a32..713f7ec 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ It is best used on all-purpose models, such as Stable Difussion 1.5 or those bas A simple user guide for first time use and settings is available [here](https://github.com/AIrjen/OneButtonPrompt/blob/main/user_guides/my_first_generation.md). +It is also now available as a custom node for ComfyUI, with some limitations. [Check installation doc here](https://github.com/AIrjen/OneButtonPrompt/blob/main/user_guides/comfyui_integration.md) + # Features - __Full prompt generation__ with the click of a button. ==> [guide to my first generation](https://github.com/AIrjen/OneButtonPrompt/blob/main/user_guides/my_first_generation.md) - Supports __TXT2IMG, IMG2IMG, ControlNET, inpainting and latent couple__. ==> [guide to IMG2IMG and ControlNET](https://github.com/AIrjen/OneButtonPrompt/blob/main/user_guides/the_next_generation_img2img_and_controlnet.md) From 3cfe23cb10363940e67451b3f6781537c961e2c2 Mon Sep 17 00:00:00 2001 From: AIrjen Date: Sun, 30 Jul 2023 20:29:31 +0200 Subject: [PATCH 3/3] Push the node! --- OneButtonPrompt-node.py | 88 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 OneButtonPrompt-node.py diff --git a/OneButtonPrompt-node.py b/OneButtonPrompt-node.py new file mode 100644 index 0000000..a0e1708 --- /dev/null +++ b/OneButtonPrompt-node.py @@ -0,0 +1,88 @@ +import sys +import os + +# adding Folder_2/subfolder to the system path +# sys.path.insert(0, '/home/amninder/Desktop/project/Folder_2/subfolder') +custom_nodes_path = os.path.dirname(__file__) +onebuttonprompt_path = os.path.join(custom_nodes_path, "..", "onebuttonprompt") +sys.path.insert(0, onebuttonprompt_path) + +from build_dynamic_prompt import * + +artists = ["all", "none", "popular", "greg mode", "3D", "abstract", "angular", "anime" ,"architecture", "art nouveau", "art deco", "baroque", "bauhaus", "cartoon", "character", "children's illustration", "cityscape", "clean", "cloudscape", "collage", "colorful", "comics", "cubism", "dark", "detailed", "digital", "expressionism", "fantasy", "fashion", "fauvism", "figurativism", "gore", "graffiti", "graphic design", "high contrast", "horror", "impressionism", "installation", "landscape", "light", "line drawing", "low contrast", "luminism", "magical realism", "manga", "melanin", "messy", "monochromatic", "nature", "nudity", "photography", "pop art", "portrait", "primitivism", "psychedelic", "realism", "renaissance", "romanticism", "scene", "sci-fi", "sculpture", "seascape", "space", "stained glass", "still life", "storybook realism", "street art", "streetscape", "surrealism", "symbolism", "textile", "ukiyo-e", "vibrant", "watercolor", "whimsical"] +imagetypes = ["all", "all - force multiple", "photograph", "octane render","digital art","concept art", "painting", "portrait", "anime key visual", "only other types", "only templates mode", "art blaster mode", "quality vomit mode", "color cannon mode", "unique art mode", "massive madness mode", "photo fantasy mode", "subject only mode"] +subjects =["all", "object", "animal", "humanoid", "landscape", "concept"] +genders = ["all", "male", "female"] + +subjectsubtypesobject = ["all", "generic objects", "vehicles", "food", "buildings", "space", "flora"] +subjectsubtypeshumanoid = ["all", "generic humans", "generic human relations", "celebrities e.a.", "fictional characters", "humanoids", "based on job or title", "based on first name"] +subjectsubtypesconcept = ["all", "event", "the X of Y concepts", "lines from poems", "lines from songs"] + + +class OneButtonPrompt: + + + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(s): + + return { + "required": { + "prompt": ("STRING", {"input_format": {"generatedprompt": "STRING"}}) + }, + "optional": { + "insanitylevel": ("INT", { + "default": 5, + "min": 1, #Minimum value + "max": 10, #Maximum value + "step": 1 #Slider's step + }), + "artist": (artists, {"default": "all"}), + "imagetype": (imagetypes, {"default": "all"}), + "imagemodechance": ("INT", { + "default": 20, + "min": 1, #Minimum value + "max": 100, #Maximum value + "step": 1 #Slider's step + }), + "subject": (subjects, {"default": "all"}), + "custom_subject": ("STRING", { + "multiline": False, #True if you want the field to look like the one on the ClipTextEncode node + "default": "" + }), + "subject_subtype_objects": (subjectsubtypesobject, {"default": "all"}), + "subject_subtypes_humanoids": (subjectsubtypeshumanoid, {"default": "all"}), + "humanoids_gender": (genders, {"default": "all"}), + "subject_subtypes_concepts": (subjectsubtypesconcept, {"default": "all"}), + + "seed": ("INT", {"default": 0, "min": 0, "max": 0xFFFFFFFFFFFFFFFF}), + }, + } + + RETURN_TYPES = ("STRING",) + RETURN_NAMES = ("prompt",) + + FUNCTION = "Comfy_OBP" + + #OUTPUT_NODE = False + + CATEGORY = "OneButtonPrompt" + + def Comfy_OBP(self, prompt, insanitylevel, custom_subject,seed, artist,imagetype, subject, imagemodechance, humanoids_gender, subject_subtype_objects, subject_subtypes_humanoids, subject_subtypes_concepts): + generatedprompt = build_dynamic_prompt(insanitylevel,subject,artist,imagetype,False,"","","",1,"",custom_subject,True,"",imagemodechance, humanoids_gender, subject_subtype_objects, subject_subtypes_humanoids, subject_subtypes_concepts) + #print(generatedprompt) + return (generatedprompt,) + + +# A dictionary that contains all nodes you want to export with their names +# NOTE: names should be globally unique +NODE_CLASS_MAPPINGS = { + "OneButtonPrompt": OneButtonPrompt +} + +# A dictionary that contains the friendly/humanly readable titles for the nodes +NODE_DISPLAY_NAME_MAPPINGS = { + "OneButtonPrompt": "One Button Prompt" +}