Added One Button Presets to ComfyUI

This commit is contained in:
AIrjen
2024-02-03 07:47:12 +01:00
parent ad8b67735f
commit 0b21ea010d
4 changed files with 90 additions and 6 deletions
+79 -2
View File
@@ -13,6 +13,10 @@ sys.path.append(onebuttonprompt_path)
from build_dynamic_prompt import *
from csv_reader import *
from one_button_presets import OneButtonPresets
OBPresets = OneButtonPresets()
allpresets = list(OBPresets.opb_presets.keys())
artists = ["all", "all (wild)", "none", "popular", "greg mode", "3D", "abstract", "angular", "anime" ,"architecture", "art nouveau", "art deco", "baroque", "bauhaus", "cartoon", "character", "children's illustration", "cityscape", "cinema", "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", "fixed styles mode", "the tokinator"]
subjects =["all", "object", "animal", "humanoid", "landscape", "concept"]
@@ -435,6 +439,78 @@ class SavePromptToFile:
return ("done")
class OneButtonPreset:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"OneButtonPreset": (allpresets, {"default": "Standard"}),
},
"optional": {
"seed": ("INT", {"default": 0, "min": 0, "max": 0xFFFFFFFFFFFFFFFF}),
},
}
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("prompt",)
FUNCTION = "Comfy_OBP_OneButtonPreset"
#OUTPUT_NODE = False
CATEGORY = "OneButtonPrompt"
def Comfy_OBP_OneButtonPreset(self, OneButtonPreset, seed):
# load the stuff
selected_opb_preset = OBPresets.get_obp_preset(OneButtonPreset)
insanitylevel=selected_opb_preset["insanitylevel"]
subject=selected_opb_preset["subject"]
artist=selected_opb_preset["artist"]
chosensubjectsubtypeobject=selected_opb_preset["chosensubjectsubtypeobject"]
chosensubjectsubtypehumanoid=selected_opb_preset["chosensubjectsubtypehumanoid"]
chosensubjectsubtypeconcept=selected_opb_preset["chosensubjectsubtypeconcept"]
chosengender=selected_opb_preset["chosengender"]
imagetype=selected_opb_preset["imagetype"]
imagemodechance=selected_opb_preset["imagemodechance"]
givensubject=selected_opb_preset["givensubject"]
smartsubject=selected_opb_preset["smartsubject"]
givenoutfit=selected_opb_preset["givenoutfit"]
prefixprompt=selected_opb_preset["prefixprompt"]
suffixprompt=selected_opb_preset["suffixprompt"]
giventypeofimage=selected_opb_preset["giventypeofimage"]
antistring=selected_opb_preset["antistring"]
generatedprompt = build_dynamic_prompt(insanitylevel=insanitylevel,
forcesubject=subject,
artists=artist,
subtypeobject=chosensubjectsubtypeobject,
subtypehumanoid=chosensubjectsubtypehumanoid,
subtypeconcept=chosensubjectsubtypeconcept,
gender=chosengender,
imagetype=imagetype,
imagemodechance=imagemodechance,
givensubject=givensubject,
smartsubject=smartsubject,
overrideoutfit=givenoutfit,
prefixprompt=prefixprompt,
suffixprompt=suffixprompt,
giventypeofimage=giventypeofimage,
antivalues=antistring,
advancedprompting=False,
hardturnoffemojis=True,
seed=seed
)
return (generatedprompt,)
class AutoNegativePrompt:
@@ -486,20 +562,21 @@ class AutoNegativePrompt:
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,
"OneButtonPreset": OneButtonPreset,
"CreatePromptVariant": CreatePromptVariant,
"SavePromptToFile": SavePromptToFile,
"AutoNegativePrompt": AutoNegativePrompt,
}
# A dictionary that contains the friendly/humanly readable titles for the nodes
NODE_DISPLAY_NAME_MAPPINGS = {
"OneButtonPrompt": "One Button Prompt",
"OneButtonPreset": "One Button Preset",
"CreatePromptVariant": "Create Prompt Variant",
"SavePromptToFile": "Save Prompt To File",
"AutoNegativePrompt": "Auto Negative Prompt",
+7
View File
@@ -2749,6 +2749,13 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all
completeprompt = completeprompt.replace("-outfit-", "-minioutfit-",1)
if(rare_dist(insanitylevel)): # Use base outfit descriptor, until we are not.
completeprompt = completeprompt.replace("-outfitdescriptor-", "-descriptor-")
# if -outfit- is in the override, we want a consistent result
if("-outfit-" in overrideoutfit):
if(chance_roll(insanitylevel, "common")):
overrideoutfit = overrideoutfit.replace("-outfit-", random.choice(outfitlist))
else:
overrideoutfit = overrideoutfit.replace("-outfit-", random.choice(minioutfitlist))
if(overrideoutfit != ""):
completeprompt = completeprompt.replace("-sameoutfit-", overrideoutfit)
+1 -1
View File
@@ -46,7 +46,7 @@ def generateprompts(amount = 1,insanitylevel="5",subject="all", artist="all", im
print(result)
break
if(overrideoutfit != "" and overrideoutfit not in result and onlyartists == False):
if(overrideoutfit != "" and overrideoutfit not in result and onlyartists == False and "-outfit-" not in overrideoutfit):
print("The outfit override is not showing up!")
print("")
print(result)
+3 -3
View File
@@ -268,9 +268,9 @@ class Script(scripts.Script):
<font size="2">
One Button Prompt is now active. Just press the normal Generate button to start generating images.
The settings below give you more control over what you wish to generate.
Presets can be used to store and load settings.
Presets can be used to store and load settings.
Set the One Button Preset to "Custom..." to show all settings. The settings below give you more control over what you wish to generate.
</font>
""")
# Part of presets
@@ -278,7 +278,7 @@ class Script(scripts.Script):
OBP_preset = gr.Dropdown(
label="One Button Preset",
choices=[OBPresets.CUSTOM_OBP] + list(OBPresets.opb_presets.keys()),
value="Custom...",
value="Standard",
)