Merge pull request #101 from AIrjen/get_comfyterable

Get comfyterable
This commit is contained in:
AIrjen
2023-07-30 20:30:31 +02:00
committed by GitHub
3 changed files with 130 additions and 0 deletions
+88
View File
@@ -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"
}
+2
View File
@@ -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)
+40
View File
@@ -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.