diff --git a/.gitignore b/.gitignore index 3e3b8d0..31809ea 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ *.pyc userfiles/antilist.csv userfiles/config.csv -userfiles/*.json \ No newline at end of file +userfiles/*.json +superprompter/model_files +superprompter/model_files/*.* \ No newline at end of file diff --git a/OneButtonPromptNodes.py b/OneButtonPromptNodes.py index 422daa0..27d3346 100644 --- a/OneButtonPromptNodes.py +++ b/OneButtonPromptNodes.py @@ -25,6 +25,7 @@ genders = ["all", "male", "female"] emojis = [False, True] models = ["SD1.5", "SDXL", "Stable Cascade"] +prompt_enhancers = ["none", "superprompter"] subjects =["all"] subjectsubtypesobject = ["all"] subjectsubtypeshumanoid = ["all"] @@ -39,6 +40,9 @@ fluff_reverse_polarity = [False,True] artifymodeslist = ["standard", "remix", "super remix turbo"] artifyamountofartistslist = ["random", "0", "1", "2", "3", "4", "5"] +superprompterstyleslist = ['all'] +superprompterstyleslist += csv_to_list("superprompter_styles") + # Load up stuff for personal artists list, if any # find all artist files starting with personal_artits in userfiles @@ -238,6 +242,7 @@ class OneButtonPrompt: "subject_subtypes_concepts": (subjectsubtypesconcept, {"default": "all"}), "emojis":(emojis, {"default": False}), "base_model":(models, {"default": "SDXL"}), + "prompt_enhancer":(prompt_enhancers, {"default": "none"}), "seed": ("INT", {"default": 0, "min": 0, "max": 0xFFFFFFFFFFFFFFFF}), }, @@ -252,8 +257,8 @@ class OneButtonPrompt: CATEGORY = "OneButtonPrompt" - def Comfy_OBP(self, insanitylevel, custom_subject, seed, artist, imagetype, subject, imagemodechance, humanoids_gender, subject_subtype_objects, subject_subtypes_humanoids, subject_subtypes_concepts, emojis, custom_outfit, base_model): - generatedpromptlist = build_dynamic_prompt(insanitylevel,subject,artist,imagetype,False,"","","",1,"",custom_subject,True,"",imagemodechance, humanoids_gender, subject_subtype_objects, subject_subtypes_humanoids, subject_subtypes_concepts, False, emojis, seed, custom_outfit, True, base_model) + def Comfy_OBP(self, insanitylevel, custom_subject, seed, artist, imagetype, subject, imagemodechance, humanoids_gender, subject_subtype_objects, subject_subtypes_humanoids, subject_subtypes_concepts, emojis, custom_outfit, base_model, prompt_enhancer): + generatedpromptlist = build_dynamic_prompt(insanitylevel,subject,artist,imagetype,False,"","","",1,"",custom_subject,True,"",imagemodechance, humanoids_gender, subject_subtype_objects, subject_subtypes_humanoids, subject_subtypes_concepts, False, emojis, seed, custom_outfit, True, base_model, "", prompt_enhancer) #print(generatedprompt) generatedprompt = generatedpromptlist[0] prompt_g = generatedpromptlist[1] @@ -461,7 +466,8 @@ class OneButtonPreset: "OneButtonPreset": (allpresets, {"default": "Standard"}), }, "optional": { - "base_model":(models, {"default": "SDXL"}), + "base_model":(models, {"default": "SDXL"}), + "prompt_enhancer":(prompt_enhancers, {"default": "none"}), "seed": ("INT", {"default": 0, "min": 0, "max": 0xFFFFFFFFFFFFFFFF}), }, } @@ -476,7 +482,7 @@ class OneButtonPreset: CATEGORY = "OneButtonPrompt" - def Comfy_OBP_OneButtonPreset(self, OneButtonPreset, seed, base_model): + def Comfy_OBP_OneButtonPreset(self, OneButtonPreset, seed, base_model, prompt_enhancer): # load the stuff if(OneButtonPreset == OBPresets.RANDOM_PRESET_OBP): selected_opb_preset = OBPresets.get_obp_preset("Standard") @@ -521,6 +527,7 @@ class OneButtonPreset: seed=seed, base_model=base_model, OBP_preset=OneButtonPreset, + prompt_enhancer=prompt_enhancer, ) @@ -651,6 +658,47 @@ class OneButtonFlufferize: return (fluffed_prompt,) +class OneButtonSuperPrompt: + + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(s): + + return { + "required": { + "prompt": ("STRING", {"default": '', "multiline": True}), + "insanitylevel": ("INT", { + "default": 5, + "min": 1, #Minimum value + "max": 10, #Maximum value + "step": 1 #Slider's step + }), + "superpromptstyle": (superprompterstyleslist, {"default": "all"}), + }, + "optional": { + "seed": ("INT", {"default": 0, "min": 0, "max": 0xFFFFFFFFFFFFFFFF}), + }, + } + + RETURN_TYPES = ("STRING",) + RETURN_NAMES = ("super_prompt",) + + FUNCTION = "Comfy_OBP_SuperPrompt" + + #OUTPUT_NODE = False + + CATEGORY = "OneButtonPrompt" + + def Comfy_OBP_SuperPrompt(self, insanitylevel, prompt, superpromptstyle, seed): + # artify here + OBPsuperprompt = one_button_superprompt(insanitylevel=insanitylevel, prompt=prompt, seed=seed, superpromptstyle=superpromptstyle) + + print("Super prompt: " + OBPsuperprompt) + + return (OBPsuperprompt,) + # A dictionary that contains all nodes you want to export with their names # NOTE: names should be globally unique @@ -662,6 +710,7 @@ NODE_CLASS_MAPPINGS = { "SavePromptToFile": SavePromptToFile, "AutoNegativePrompt": AutoNegativePrompt, "OneButtonFlufferize": OneButtonFlufferize, + "OneButtonSuperPrompt": OneButtonSuperPrompt, } @@ -674,4 +723,5 @@ NODE_DISPLAY_NAME_MAPPINGS = { "SavePromptToFile": "Save Prompt To File", "AutoNegativePrompt": "Auto Negative Prompt", "OneButtonFlufferize": "One Button Flufferize", -} + "OneButtonSuperPrompt": "One Button SuperPrompt", +} \ No newline at end of file diff --git a/build_dynamic_prompt.py b/build_dynamic_prompt.py index e9991cf..b24c326 100644 --- a/build_dynamic_prompt.py +++ b/build_dynamic_prompt.py @@ -13,12 +13,16 @@ OBPresets = OneButtonPresets() # insanity level controls randomness of propmt 0-10 # forcesubject van be used to force a certain type of subject # Set artistmode to none, to exclude artists -def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all", imagetype = "all", onlyartists = False, antivalues = "", prefixprompt = "", suffixprompt ="",promptcompounderlevel ="1", seperator = "comma", givensubject="",smartsubject = True,giventypeofimage="", imagemodechance = 20, gender = "all", subtypeobject="all", subtypehumanoid="all", subtypeconcept="all", advancedprompting=True, hardturnoffemojis=False, seed=-1, overrideoutfit="", prompt_g_and_l = False, base_model = "SD1.5", OBP_preset = "", superprompter = False): +def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all", imagetype = "all", onlyartists = False, antivalues = "", prefixprompt = "", suffixprompt ="",promptcompounderlevel ="1", seperator = "comma", givensubject="",smartsubject = True,giventypeofimage="", imagemodechance = 20, gender = "all", subtypeobject="all", subtypehumanoid="all", subtypeconcept="all", advancedprompting=True, hardturnoffemojis=False, seed=-1, overrideoutfit="", prompt_g_and_l = False, base_model = "SD1.5", OBP_preset = "", prompt_enhancer = "none"): remove_weights = False less_verbose = False add_vomit = True add_quality = True + + superprompter = False + if(prompt_enhancer == "superprompter"): + superprompter = True if(superprompter==True): base_model = "Stable Cascade" @@ -4707,7 +4711,7 @@ def split_prompt_to_words(text): return totallist -def one_button_superprompt(insanitylevel = 5, prompt = "", seed = -1, override_subject = "" , override_outfit = "", chosensubject ="", gender = "", restofprompt = ""): +def one_button_superprompt(insanitylevel = 5, prompt = "", seed = -1, override_subject = "" , override_outfit = "", chosensubject ="", gender = "", restofprompt = "", superpromptstyle = ""): if(seed <= 0): seed = random.randint(1,1000000) @@ -4718,15 +4722,19 @@ def one_button_superprompt(insanitylevel = 5, prompt = "", seed = -1, override_s superprompterstyleslist = csv_to_list("superprompter_styles") descriptorlist = csv_to_list("descriptors") + usestyle = False + if(superpromptstyle != "" or superpromptstyle != "all"): + usestyle = True + restofprompt = restofprompt.lower() question = "" temperature_lookup = { - 1: 0.001, - 2: 0.01, - 3: 0.1, - 4: 0.3, - 5: 0.5, + 1: 0.01, + 2: 0.1, + 3: 0.3, + 4: 0.5, + 5: 0.6, 6: 0.7, 7: 1.0, 8: 2.5, @@ -4735,11 +4743,11 @@ def one_button_superprompt(insanitylevel = 5, prompt = "", seed = -1, override_s } max_new_tokens_lookup = { - 1: 25, - 2: 30, - 3: 35, - 4: 40, - 5: 50, + 1: 45, + 2: 45, + 3: 50, + 4: 55, + 5: 60, 6: 70, 7: 90, 8: 100, @@ -4749,10 +4757,10 @@ def one_button_superprompt(insanitylevel = 5, prompt = "", seed = -1, override_s top_p_lookup = { 1: 0.1, - 2: 0.5, - 3: 1.0, - 4: 1.25, - 5: 1.5, + 2: 1.0, + 3: 1.3, + 4: 1.5, + 5: 1.6, 6: 1.75, 7: 2.0, 8: 4.0, @@ -4810,24 +4818,26 @@ def one_button_superprompt(insanitylevel = 5, prompt = "", seed = -1, override_s if chosensubject not in ("humanoid","firstname","job","fictional","non fictional","human"): gender = "" + if(superpromptstyle == "" or superpromptstyle == "all"): + if "fantasy" in restofprompt or "d&d" in restofprompt or "dungeons and dragons" in restofprompt or "dungeons and dragons" in restofprompt: + superpromptstyle = random.choice(["fantasy style","d&d style"]) + elif "sci-fi" in restofprompt or "scifi" in restofprompt or "science fiction" in restofprompt: + superpromptstyle = random.choice(["sci-fi style","futuristic"]) + elif "cyberpunk" in restofprompt: + superpromptstyle = "cyberpunk" + elif "horror" in restofprompt: + superpromptstyle = "horror themed" + elif "evil" in restofprompt: + superpromptstyle = "evil" + elif "cinestill" in restofprompt or "movie still" in restofprompt or "cinematic" in restofprompt or "epic" in restofprompt: + superpromptstyle = random.choice(["cinematic","epic"]) + elif "fashion" in restofprompt: + superpromptstyle = random.choice(["elegant","glamourous"]) + elif "cute" in restofprompt or "adorable" in restofprompt or "kawaii" in restofprompt: + superpromptstyle = random.choice(["cute","adorable", "kawaii"]) - if "fantasy" in restofprompt or "d&d" in restofprompt or "dungeons and dragons" in restofprompt or "dungeons and dragons" in restofprompt: - superpromptstyle = random.choice(["fantasy style","d&d style"]) - elif "sci-fi" in restofprompt or "scifi" in restofprompt or "science fiction" in restofprompt: - superpromptstyle = random.choice(["sci-fi style","futuristic"]) - elif "cyberpunk" in restofprompt: - superpromptstyle = "cyberpunk" - elif "horror" in restofprompt: - superpromptstyle = "horror themed" - elif "evil" in restofprompt: - superpromptstyle = "evil" - elif "fashion" in restofprompt: - superpromptstyle = random.choice(["elegant","glamourous"]) - elif "cute" in restofprompt or "adorable" in restofprompt or "kawaii" in restofprompt: - superpromptstyle = random.choice(["cute","adorable", "kawaii"]) - - else: - superpromptstyle = random.choice(superprompterstyleslist) + else: + superpromptstyle = random.choice(superprompterstyleslist) if(words_to_check): question += "Make sure the subject is used: " + ', '.join(words_to_check) + " \n" @@ -4845,13 +4855,16 @@ def one_button_superprompt(insanitylevel = 5, prompt = "", seed = -1, override_s imagetype = "pixel art" elif "game" in restofprompt: imagetype = "video game artwork" + + usestyle = False - if imagetype != "" and normal_dist(insanitylevel): + + if imagetype != "" and (normal_dist(insanitylevel) or usestyle == True): question += "Expand the following " + gender + " " + subject_to_generate + " prompt to describe " + superpromptstyle + " " + imagetype + ": " elif imagetype != "": question += "Expand the following " + gender + " " + subject_to_generate + " prompt to describe " + imagetype + ": " - elif(normal_dist(insanitylevel)): + elif(normal_dist(insanitylevel) or usestyle == True): question += "Expand the following " + gender + " " + subject_to_generate + " prompt to make it more " + superpromptstyle else: question += "Expand the following " + gender + " " + subject_to_generate + " prompt to add more detail: " diff --git a/main.py b/main.py index bba4df3..9a94e10 100644 --- a/main.py +++ b/main.py @@ -13,7 +13,7 @@ from call_extras import * from model_lists import * -def generateimages(amount = 1, size = "all",model = "currently selected model",samplingsteps = "40",cfg= "7",hiresfix = True,hiressteps ="0",denoisestrength="0.6",samplingmethod="DPM++ SDE Karras", upscaler="R-ESRGAN 4x+", hiresscale="2",apiurl="http://127.0.0.1:7860",qualitygate=False,quality="7.6",runs="5",insanitylevel="5",subject="all", artist="all", imagetype="all",silentmode=False, workprompt="", antistring="",prefixprompt="", suffixprompt="", negativeprompt="",promptcompounderlevel = "1", seperator="comma", img2imgbatch = "1", img2imgsamplingsteps = "20", img2imgcfg = "7", img2imgsamplingmethod = "DPM++ SDE Karras", img2imgupscaler = "R-ESRGAN 4x+", img2imgmodel = "currently selected model", img2imgactivate = False, img2imgscale = "2", img2imgpadding = "64",img2imgdenoisestrength="0.3",ultimatesdupscale=False,usdutilewidth = "512", usdutileheight = "0", usdumaskblur = "8", usduredraw ="Linear", usduSeamsfix = "None", usdusdenoise = "0.35", usduswidth = "64", usduspadding ="32", usdusmaskblur = "8",controlnetenabled=False, controlnetmodel="",img2imgdenoisestrengthmod="-0.05",enableextraupscale = False,controlnetblockymode = False,extrasupscaler1 = "all",extrasupscaler2 ="all",extrasupscaler2visiblity="0.5",extrasupscaler2gfpgan="0",extrasupscaler2codeformer="0.15",extrasupscaler2codeformerweight="0.1",extrasresize="2",onlyupscale="false",givensubject="",smartsubject=True,giventypeofimage="",imagemodechance=20, gender="all", chosensubjectsubtypeobject="all", chosensubjectsubtypehumanoid="all", chosensubjectsubtypeconcept="all", increasestability = False, qualityhiresfix = False, qualitymode = "highest", qualitykeep="keep used", basesize = "512", promptvariantinsanitylevel = 0, givenoutfit = "", autonegativeprompt = True, autonegativepromptstrength = 0, autonegativepromptenhance = False, base_model = "SD1.5", OBP_preset = "", amountoffluff = "none"): +def generateimages(amount = 1, size = "all",model = "currently selected model",samplingsteps = "40",cfg= "7",hiresfix = True,hiressteps ="0",denoisestrength="0.6",samplingmethod="DPM++ SDE Karras", upscaler="R-ESRGAN 4x+", hiresscale="2",apiurl="http://127.0.0.1:7860",qualitygate=False,quality="7.6",runs="5",insanitylevel="5",subject="all", artist="all", imagetype="all",silentmode=False, workprompt="", antistring="",prefixprompt="", suffixprompt="", negativeprompt="",promptcompounderlevel = "1", seperator="comma", img2imgbatch = "1", img2imgsamplingsteps = "20", img2imgcfg = "7", img2imgsamplingmethod = "DPM++ SDE Karras", img2imgupscaler = "R-ESRGAN 4x+", img2imgmodel = "currently selected model", img2imgactivate = False, img2imgscale = "2", img2imgpadding = "64",img2imgdenoisestrength="0.3",ultimatesdupscale=False,usdutilewidth = "512", usdutileheight = "0", usdumaskblur = "8", usduredraw ="Linear", usduSeamsfix = "None", usdusdenoise = "0.35", usduswidth = "64", usduspadding ="32", usdusmaskblur = "8",controlnetenabled=False, controlnetmodel="",img2imgdenoisestrengthmod="-0.05",enableextraupscale = False,controlnetblockymode = False,extrasupscaler1 = "all",extrasupscaler2 ="all",extrasupscaler2visiblity="0.5",extrasupscaler2gfpgan="0",extrasupscaler2codeformer="0.15",extrasupscaler2codeformerweight="0.1",extrasresize="2",onlyupscale="false",givensubject="",smartsubject=True,giventypeofimage="",imagemodechance=20, gender="all", chosensubjectsubtypeobject="all", chosensubjectsubtypehumanoid="all", chosensubjectsubtypeconcept="all", increasestability = False, qualityhiresfix = False, qualitymode = "highest", qualitykeep="keep used", basesize = "512", promptvariantinsanitylevel = 0, givenoutfit = "", autonegativeprompt = True, autonegativepromptstrength = 0, autonegativepromptenhance = False, base_model = "SD1.5", OBP_preset = "", amountoffluff = "none", promptenhancer = "none"): loops = int(amount) # amount of images to generate steps = 0 upscalefilelist=[] @@ -136,7 +136,7 @@ def generateimages(amount = 1, size = "all",model = "currently selected model",s else: - randompromptlist = build_dynamic_prompt(insanitylevel,subject,artist,imagetype, False,antistring,prefixprompt,suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage,imagemodechance, gender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept,True,False,-1,givenoutfit, prompt_g_and_l=True, base_model=base_model, OBP_preset=OBP_preset) + randompromptlist = build_dynamic_prompt(insanitylevel,subject,artist,imagetype, False,antistring,prefixprompt,suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage,imagemodechance, gender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept,True,False,-1,givenoutfit, prompt_g_and_l=True, base_model=base_model, OBP_preset=OBP_preset, prompt_enhancer=promptenhancer) randomprompt = randompromptlist[0] randomsubject = randompromptlist[1] diff --git a/prompttester.py b/prompttester.py index 80f6db0..19a7080 100644 --- a/prompttester.py +++ b/prompttester.py @@ -11,7 +11,7 @@ from build_dynamic_prompt import * -def generateprompts(amount = 1,insanitylevel="5",subject="all", artist="all", imagetype="all",onlyartists=False, workprompt="", antistring="",prefixprompt="", suffixprompt="", negativeprompt="",promptcompounderlevel = "1", seperator="comma",givensubject="",smartsubject=True,giventypeofimage="",imagemodechance=20, gender = "all", subtypeobject = "all", subtypehumanoid = "all", subtypeconcept = "all", advancedprompting = True, hardturnoffemojis=False, seed=0, overrideoutfit="", prompt_g_and_l = False, base_model = "SD1.5", OBP_preset = "", superprompter=False): +def generateprompts(amount = 1,insanitylevel="5",subject="all", artist="all", imagetype="all",onlyartists=False, workprompt="", antistring="",prefixprompt="", suffixprompt="", negativeprompt="",promptcompounderlevel = "1", seperator="comma",givensubject="",smartsubject=True,giventypeofimage="",imagemodechance=20, gender = "all", subtypeobject = "all", subtypehumanoid = "all", subtypeconcept = "all", advancedprompting = True, hardturnoffemojis=False, seed=0, overrideoutfit="", prompt_g_and_l = False, base_model = "SD1.5", OBP_preset = "", prompt_enhancer="none"): loops = int(amount) # amount of images to generate steps = 0 @@ -19,7 +19,7 @@ def generateprompts(amount = 1,insanitylevel="5",subject="all", artist="all", im while steps < loops: # build prompt if(prompt_g_and_l == True): - resultlist = build_dynamic_prompt(insanitylevel,subject,artist,imagetype, onlyartists,antistring,prefixprompt,suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage,imagemodechance, gender, subtypeobject, subtypehumanoid, subtypeconcept, advancedprompting, hardturnoffemojis, seed, overrideoutfit, prompt_g_and_l, base_model, OBP_preset) + resultlist = build_dynamic_prompt(insanitylevel,subject,artist,imagetype, onlyartists,antistring,prefixprompt,suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage,imagemodechance, gender, subtypeobject, subtypehumanoid, subtypeconcept, advancedprompting, hardturnoffemojis, seed, overrideoutfit, prompt_g_and_l, base_model, OBP_preset, prompt_enhancer) result = resultlist[0] print("prompt_g") print(resultlist[1]) @@ -27,7 +27,7 @@ def generateprompts(amount = 1,insanitylevel="5",subject="all", artist="all", im print(resultlist[2]) else: - result = build_dynamic_prompt(insanitylevel,subject,artist,imagetype, onlyartists,antistring,prefixprompt,suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage,imagemodechance, gender, subtypeobject, subtypehumanoid, subtypeconcept, advancedprompting, hardturnoffemojis, seed, overrideoutfit, prompt_g_and_l, base_model, OBP_preset, superprompter) + result = build_dynamic_prompt(insanitylevel,subject,artist,imagetype, onlyartists,antistring,prefixprompt,suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage,imagemodechance, gender, subtypeobject, subtypehumanoid, subtypeconcept, advancedprompting, hardturnoffemojis, seed, overrideoutfit, prompt_g_and_l, base_model, OBP_preset, prompt_enhancer) #if(superprompter): # load_models() @@ -130,5 +130,5 @@ if __name__ == "__main__": , False #prompt_g_and_l , "SDXL" #base model , "" #preset "All (random)..." - , True # superprompter + , "superprompter" # superprompter ) \ No newline at end of file diff --git a/scripts/onebuttonprompt.py b/scripts/onebuttonprompt.py index 0835090..dbdd246 100644 --- a/scripts/onebuttonprompt.py +++ b/scripts/onebuttonprompt.py @@ -32,6 +32,8 @@ ANDtogglemode = ["none", "automatic", "prefix AND prompt + suffix", "prefix + pr seperatorlist = ["comma", "AND", "BREAK"] genders = ["all", "male", "female"] +prompt_enhancers = ["none", "superprompter"] + qualitymodelist = ["highest", "gated"] qualitykeeplist = ["keep used","keep all"] @@ -236,12 +238,12 @@ class Script(scripts.Script): def ui(self, is_img2img): - def gen_prompt(insanitylevel, subject, artist, imagetype, antistring, prefixprompt, suffixprompt, promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage, imagemodechance,chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept,givenoutfit, base_model, OBP_preset, amountoffluff): + def gen_prompt(insanitylevel, subject, artist, imagetype, antistring, prefixprompt, suffixprompt, promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage, imagemodechance,chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept,givenoutfit, base_model, OBP_preset, amountoffluff, promptenhancer): promptlist = [] for i in range(5): - base_prompt = build_dynamic_prompt(insanitylevel,subject,artist, imagetype, False, antistring,prefixprompt,suffixprompt,promptcompounderlevel,seperator,givensubject,smartsubject, giventypeofimage, imagemodechance,chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept,True,False,-1,givenoutfit,False,base_model, OBP_preset) + base_prompt = build_dynamic_prompt(insanitylevel,subject,artist, imagetype, False, antistring,prefixprompt,suffixprompt,promptcompounderlevel,seperator,givensubject,smartsubject, giventypeofimage, imagemodechance,chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept,True,False,-1,givenoutfit,False,base_model, OBP_preset, promptenhancer) fluffed_prompt = flufferizer(prompt=base_prompt, amountoffluff=amountoffluff) promptlist.append(fluffed_prompt) @@ -651,6 +653,10 @@ class Script(scripts.Script): ⭐ Flufferizer A simple and quick implementiation of Fooocus prompt magic + + 🤓 Prompt enhancer + + Choose for "superprompter" to super prompt the prompts """ @@ -661,6 +667,9 @@ class Script(scripts.Script): with gr.Row(variant="compact"): amountoffluff = gr.Dropdown( amountofflufflist, label="⭐ Flufferizer", value="dynamic") + with gr.Row(variant="compact"): + promptenhancer = gr.Dropdown( + prompt_enhancers, label="🤓 Prompt enhancer", value="none") with gr.Row(variant="compact"): with gr.Column(variant="compact"): promptcompounderlevel = gr.Dropdown( @@ -922,7 +931,7 @@ class Script(scripts.Script): extrasupscaler2codeformerweight = gr.Slider(0, 1, value="0.1", step=0.05, label="CodeFormer weight", visible = False) - genprom.click(gen_prompt, inputs=[insanitylevel,subject, artist, imagetype, antistring,prefixprompt, suffixprompt,promptcompounderlevel, seperator, givensubject,smartsubject,giventypeofimage,imagemodechance, chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept, givenoutfit, base_model, OBP_preset, amountoffluff], outputs=[prompt1, prompt2, prompt3,prompt4,prompt5]) + genprom.click(gen_prompt, inputs=[insanitylevel,subject, artist, imagetype, antistring,prefixprompt, suffixprompt,promptcompounderlevel, seperator, givensubject,smartsubject,giventypeofimage,imagemodechance, chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept, givenoutfit, base_model, OBP_preset, amountoffluff, promptenhancer], outputs=[prompt1, prompt2, prompt3,prompt4,prompt5]) prompt1toworkflow.click(prompttoworkflowprompt, inputs=prompt1, outputs=workprompt) prompt2toworkflow.click(prompttoworkflowprompt, inputs=prompt2, outputs=workprompt) @@ -930,7 +939,7 @@ class Script(scripts.Script): prompt4toworkflow.click(prompttoworkflowprompt, inputs=prompt4, outputs=workprompt) prompt5toworkflow.click(prompttoworkflowprompt, inputs=prompt5, outputs=workprompt) - startmain.click(generateimages, inputs=[amountofimages,size,model,samplingsteps,cfg,hiresfix,hiressteps,denoisestrength,samplingmethod, upscaler,hiresscale, apiurl, qualitygate, quality, runs,insanitylevel,subject, artist, imagetype, silentmode, workprompt, antistring, prefixprompt, suffixprompt,negativeprompt,promptcompounderlevel, seperator, img2imgbatch, img2imgsamplingsteps, img2imgcfg, img2imgsamplingmethod, img2imgupscaler, img2imgmodel,img2imgactivate, img2imgscale, img2imgpadding,img2imgdenoisestrength,ultimatesdupscale,usdutilewidth, usdutileheight, usdumaskblur, usduredraw, usduSeamsfix, usdusdenoise, usduswidth, usduspadding, usdusmaskblur, controlnetenabled, controlnetmodel,img2imgdenoisestrengthmod,enableextraupscale,controlnetblockymode,extrasupscaler1,extrasupscaler2,extrasupscaler2visiblity,extrasupscaler2gfpgan,extrasupscaler2codeformer,extrasupscaler2codeformerweight,extrasresize,onlyupscale,givensubject,smartsubject,giventypeofimage,imagemodechance, chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept, increasestability, qualityhiresfix, qualitymode, qualitykeep, basesize, promptvariantinsanitylevel, givenoutfit, autonegativeprompt, autonegativepromptstrength, autonegativepromptenhance, base_model, OBP_preset, amountoffluff]) + startmain.click(generateimages, inputs=[amountofimages,size,model,samplingsteps,cfg,hiresfix,hiressteps,denoisestrength,samplingmethod, upscaler,hiresscale, apiurl, qualitygate, quality, runs,insanitylevel,subject, artist, imagetype, silentmode, workprompt, antistring, prefixprompt, suffixprompt,negativeprompt,promptcompounderlevel, seperator, img2imgbatch, img2imgsamplingsteps, img2imgcfg, img2imgsamplingmethod, img2imgupscaler, img2imgmodel,img2imgactivate, img2imgscale, img2imgpadding,img2imgdenoisestrength,ultimatesdupscale,usdutilewidth, usdutileheight, usdumaskblur, usduredraw, usduSeamsfix, usdusdenoise, usduswidth, usduspadding, usdusmaskblur, controlnetenabled, controlnetmodel,img2imgdenoisestrengthmod,enableextraupscale,controlnetblockymode,extrasupscaler1,extrasupscaler2,extrasupscaler2visiblity,extrasupscaler2gfpgan,extrasupscaler2codeformer,extrasupscaler2codeformerweight,extrasresize,onlyupscale,givensubject,smartsubject,giventypeofimage,imagemodechance, chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept, increasestability, qualityhiresfix, qualitymode, qualitykeep, basesize, promptvariantinsanitylevel, givenoutfit, autonegativeprompt, autonegativepromptstrength, autonegativepromptenhance, base_model, OBP_preset, amountoffluff, promptenhancer]) interrupt.click(tryinterrupt, inputs=[apiurl]) automatedoutputsfolderbutton.click(openfolder) @@ -1236,12 +1245,12 @@ class Script(scripts.Script): - return [insanitylevel,subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring, seperator, givensubject, smartsubject, giventypeofimage, imagemodechance, chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept, promptvariantinsanitylevel, givenoutfit, autonegativeprompt, autonegativepromptstrength, autonegativepromptenhance, base_model, OBP_preset, amountoffluff] + return [insanitylevel,subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring, seperator, givensubject, smartsubject, giventypeofimage, imagemodechance, chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept, promptvariantinsanitylevel, givenoutfit, autonegativeprompt, autonegativepromptstrength, autonegativepromptenhance, base_model, OBP_preset, amountoffluff, promptenhancer] - def run(self, p, insanitylevel, subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring,seperator, givensubject, smartsubject, giventypeofimage, imagemodechance, chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept, promptvariantinsanitylevel, givenoutfit, autonegativeprompt, autonegativepromptstrength, autonegativepromptenhance, base_model, OBP_preset, amountoffluff): + def run(self, p, insanitylevel, subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring,seperator, givensubject, smartsubject, giventypeofimage, imagemodechance, chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept, promptvariantinsanitylevel, givenoutfit, autonegativeprompt, autonegativepromptstrength, autonegativepromptenhance, base_model, OBP_preset, amountoffluff, promptenhancer): images = [] infotexts = [] @@ -1315,7 +1324,7 @@ class Script(scripts.Script): #Here is where we build a "normal" prompt - base_prompt = build_dynamic_prompt(insanitylevel,subject,artist, imagetype, False, antistring, prefixprompt, suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage,imagemodechance,chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept,True,False,-1,givenoutfit, False, base_model, OBP_preset) + base_prompt = build_dynamic_prompt(insanitylevel,subject,artist, imagetype, False, antistring, prefixprompt, suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage,imagemodechance,chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept,True,False,-1,givenoutfit, False, base_model, OBP_preset, promptenhancer) fluffed_prompt = flufferizer(prompt=base_prompt, amountoffluff=amountoffluff) preppedprompt += fluffed_prompt diff --git a/superprompter/download_models.py b/superprompter/download_models.py index 4921ce1..ed59287 100644 --- a/superprompter/download_models.py +++ b/superprompter/download_models.py @@ -6,7 +6,8 @@ def download_models(): model_name = "roborovski/superprompt-v1" tokenizer = T5Tokenizer.from_pretrained(model_name) model = T5ForConditionalGeneration.from_pretrained(model_name, torch_dtype=torch.float16) - modelDir = os.path.expanduser("~") + "/.superprompter/model_files" + script_dir = os.path.dirname(os.path.abspath(__file__)) # Script directory + modelDir = os.path.join(script_dir, "./model_files/" ) os.makedirs(modelDir, exist_ok=True) tokenizer.save_pretrained(modelDir) model.save_pretrained(modelDir) diff --git a/superprompter/superprompter.py b/superprompter/superprompter.py index d8f3023..37acc4d 100644 --- a/superprompter/superprompter.py +++ b/superprompter/superprompter.py @@ -6,7 +6,8 @@ from transformers import T5Tokenizer, T5ForConditionalGeneration from superprompter.download_models import download_models global tokenizer, model -modelDir = os.path.expanduser("~") + "/.superprompter/model_files" +script_dir = os.path.dirname(os.path.abspath(__file__)) # Script directory +modelDir = os.path.join(script_dir, "./model_files/" ) def load_models():