From 62d8e836ff82cfbf96c666c40035bd7931acf9b6 Mon Sep 17 00:00:00 2001 From: AIrjen Date: Mon, 22 May 2023 21:38:23 +0200 Subject: [PATCH 1/6] background things trying to switch prompt during batches, so far no luck --- build_dynamic_prompt.py | 87 ++++++++--------- csvfiles/special_lists/backgroundtypes.csv | 9 ++ csvfiles/special_lists/insideshots.csv | 4 + csvfiles/special_lists/photoadditions.csv | 1 + scripts/onebuttonprompt.py | 106 +++++++++++++-------- 5 files changed, 123 insertions(+), 84 deletions(-) create mode 100644 csvfiles/special_lists/backgroundtypes.csv create mode 100644 csvfiles/special_lists/insideshots.csv create mode 100644 csvfiles/special_lists/photoadditions.csv diff --git a/build_dynamic_prompt.py b/build_dynamic_prompt.py index 6bb2a3f..37a4c8e 100644 --- a/build_dynamic_prompt.py +++ b/build_dynamic_prompt.py @@ -92,26 +92,35 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all custominputsuffixlist = csv_to_list("custom_input_suffix",antilist,"./userfiles/") generatecustominputsuffix = bool(custominputsuffixlist) # True of not empty + # special lists + backgroundtypelist = csv_to_list("backgroundtypes", antilist,"./csvfiles/special_lists/") + insideshotlist = csv_to_list("insideshots", antilist,"./csvfiles/special_lists/") + photoadditionlist = csv_to_list("photoadditions", antilist,"./csvfiles/special_lists/") - generateoutfit = True - generatebodytype = True - generateaccesorie = True - generateartmovement = True - generatebackground = True - generatecamera = True - generatecolorscheme = True - generatedescriptors = True - generatedirection = True - generatefocus = True - generatehairstyle = True - generatelens = True - generatelighting = True - generatemood = True - generatepose = True - generatevomit = True - generatequality = True - generateshot = True - generatetimeperiod = True + + generateoutfit = bool(outfitlist) + generatebodytype = bool(bodytypelist) + generateaccesorie = bool(accessorielist) + generateartmovement = bool(artmovementlist) + generatecamera = bool(cameralist) + generatecolorscheme = bool(colorschemelist) + generatedescriptors = bool(descriptorlist) + generatedirection = bool(directionlist) + generatefocus = bool(focuslist) + generatehairstyle = bool(hairstylelist) + generatelens = bool(lenslist) + generatelighting = bool(lightinglist) + generatemood = bool(moodlist) + generatepose = bool(poselist) + generatevomit = bool(vomitlist) + generatequality = bool(qualitylist) + generateshot = bool(shotsizelist) + generatetimeperiod = bool(timeperiodlist) + + # specials: + generatebackground = bool(backgroundtypelist) + generateinsideshot = bool(insideshotlist) + generatephotoaddition = bool(photoadditionlist) # Smart subject logic if(givensubject !="" and smartsubject == True): @@ -179,10 +188,11 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all # background foundinlist = any(word.lower() in [item.lower() for item in locationlist] for word in givensubjectlist) foundinlist2 = any(word.lower() in [item.lower() for item in buildinglist] for word in givensubjectlist) - keywordslist = ["location","background"] + keywordslist = ["location","background", "inside"] keywordsinstring = any(word.lower() in givensubject.lower() for word in keywordslist) if(foundinlist == True or foundinlist2 == True or keywordsinstring == True): generatebackground = False + generateinsideshot = False # accessorielist foundinlist = any(word.lower() in [item.lower() for item in accessorielist] for word in givensubjectlist) @@ -295,9 +305,8 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all # custom prefix list - if(uncommon_dist(insanitylevel) and generatecustominputprefix == True): - completeprompt += random.choice(custominputprefixlist) + ", " - if(uncommon_dist(insanitylevel)): + for i in range(2): + if(uncommon_dist(insanitylevel) and generatecustominputprefix == True): completeprompt += random.choice(custominputprefixlist) + ", " @@ -530,7 +539,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all if unique_dist(insanitylevel): animaladdlist = ["baby", "were", "giant", "monster"] animaladdedsomething = 1 - completeprompt += random.choice(animaladdlist) + " -animal-" + completeprompt += random.choice(animaladdlist) + " -animal- " if(animaladdedsomething != 1): completeprompt += random.choice(animallist) + " " @@ -751,28 +760,13 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all if(uncommon_dist(insanitylevel)): completeprompt += random.choice(accessorielist) + ", " - if(legendary_dist(insanitylevel) and subjectchooser not in ["landscape", "concept"] and generatebackground == True): + if(legendary_dist(insanitylevel) and subjectchooser not in ["landscape", "concept"] and generateinsideshot == True): insideshot = 1 - completeprompt += ", from inside of a " - addontolocation = [locationlist,buildinglist] - completeprompt += random.choice(random.choice(addontolocation)) + ", " + completeprompt += random.choice(insideshotlist) + ", " if(subjectchooser not in ["landscape", "concept"] and humanspecial != 1 and insideshot == 0 and uncommon_dist(insanitylevel) and generatebackground == True): - backgroundtypelist = ["landscape", "buildingbackground", "insidebuilding"] - backgroundtype = random.choice(backgroundtypelist) - if(backgroundtype == "landscape"): - completeprompt += "background is " + random.choice(locationlist) + ", " - elif(backgroundtype == "buildingbackground"): - completeprompt += ", background is " - if(uncommon_dist(insanitylevel)): - completeprompt += random.choice(descriptorlist) + " " - completeprompt += random.choice(buildinglist) + ", " - elif(backgroundtype == "insidebuilding"): - completeprompt += ", inside a " - if(uncommon_dist(insanitylevel)): - completeprompt += random.choice(descriptorlist) + " " - completeprompt += random.choice(buildinglist) + ", " - + completeprompt += random.choice(backgroundtypelist) + ", " + @@ -801,10 +795,11 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all completeprompt += random.choice(lightinglist) + ", " # determine wether we have a photo or not - if("hoto" in completeprompt): + if("photo" in completeprompt.lower()): isphoto = 1 - if(common_dist(insanitylevel) and not "film grain" in antilist): - completeprompt += ", film grain, " + + if(common_dist(insanitylevel) and isphoto == 1 and generatephotoaddition == True): + completeprompt += random.choice(photoadditionlist) if(isphoto == 1 and generatecamera == True): completeprompt += random.choice(cameralist) + ", " diff --git a/csvfiles/special_lists/backgroundtypes.csv b/csvfiles/special_lists/backgroundtypes.csv new file mode 100644 index 0000000..ee8d29d --- /dev/null +++ b/csvfiles/special_lists/backgroundtypes.csv @@ -0,0 +1,9 @@ +background is -location- +background is -building- +inside a -building- +background is -descriptor- -location- +background is -descriptor- -building- +inside a -descriptor- -building- +plain background +plain -color- background +-color- and -color- background \ No newline at end of file diff --git a/csvfiles/special_lists/insideshots.csv b/csvfiles/special_lists/insideshots.csv new file mode 100644 index 0000000..654e20d --- /dev/null +++ b/csvfiles/special_lists/insideshots.csv @@ -0,0 +1,4 @@ +from inside of a -location- +from inside of a -building- +from inside of a -descriptor- -location- +from inside of a -descriptor- -building- \ No newline at end of file diff --git a/csvfiles/special_lists/photoadditions.csv b/csvfiles/special_lists/photoadditions.csv new file mode 100644 index 0000000..9e21197 --- /dev/null +++ b/csvfiles/special_lists/photoadditions.csv @@ -0,0 +1 @@ +film grain \ No newline at end of file diff --git a/scripts/onebuttonprompt.py b/scripts/onebuttonprompt.py index a31390f..eb79e27 100644 --- a/scripts/onebuttonprompt.py +++ b/scripts/onebuttonprompt.py @@ -307,6 +307,17 @@ class Script(scripts.Script): with gr.Column(scale=2): ANDtoggle = gr.Dropdown( ANDtogglemode, label="Prompt seperator mode", value="none") + with gr.Row(): + gr.Markdown( + """ + + Other advanced options: + + """) + with gr.Row(): + with gr.Column(scale=1): + prompteachiteration = gr.Checkbox( + label="Generate new prompt for each Batch Size", value=False) with gr.Row(): gr.Markdown( """ @@ -624,12 +635,12 @@ class Script(scripts.Script): - return [insanitylevel,subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring, seperator, givensubject, smartsubject, giventypeofimage] + return [insanitylevel,subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring, seperator, givensubject, smartsubject, giventypeofimage, prompteachiteration] - def run(self, p, insanitylevel, subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring,seperator, givensubject, smartsubject, giventypeofimage): + def run(self, p, insanitylevel, subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring,seperator, givensubject, smartsubject, giventypeofimage,prompteachiteration): images = [] infotexts = [] @@ -664,42 +675,55 @@ class Script(scripts.Script): for i in range(batches): if(silentmode == False): - # prompt compounding - print("Starting generating the prompt") - preppedprompt = "" - if(ANDtoggle == "automatic"): - preppedprompt += prefixprompt + ", " - if(artist != "none"): - preppedprompt += build_dynamic_prompt(insanitylevel,subject,artist, imagetype, True, antistring) - if(subject == "humanoid"): - preppedprompt += ", " + promptcompounderlevel + " people" - if(subject == "landscape"): - preppedprompt += ", landscape" - if(subject == "animal"): - preppedprompt += ", " + promptcompounderlevel + " animals" - if(subject == "object"): - preppedprompt += ", " + promptcompounderlevel + " objects" + promptlist = [] + negativepromptlist = [] + # Either do this once, or for each iteration + if(prompteachiteration==True): + amountofpromptstogen = batchsize + else: + amountofpromptstogen = 1 - if(ANDtoggle != "none" and ANDtoggle != "automatic"): - preppedprompt += prefixprompt - - if(ANDtoggle != "none"): - if(ANDtoggle!="prefix + prefix + prompt + suffix"): - prefixprompt = "" - if(seperator == "comma"): - preppedprompt += " \n , " - else: - preppedprompt += " \n " + seperator + " " - - #Here is where we build a "normal" prompt - preppedprompt += build_dynamic_prompt(insanitylevel,subject,artist, imagetype, False, antistring, prefixprompt, suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage) + for i in range(amountofpromptstogen): + # prompt compounding + print("Starting generating the prompt") + preppedprompt = "" + + if(ANDtoggle == "automatic"): + preppedprompt += prefixprompt + ", " + if(artist != "none"): + preppedprompt += build_dynamic_prompt(insanitylevel,subject,artist, imagetype, True, antistring) + if(subject == "humanoid"): + preppedprompt += ", " + promptcompounderlevel + " people" + if(subject == "landscape"): + preppedprompt += ", landscape" + if(subject == "animal"): + preppedprompt += ", " + promptcompounderlevel + " animals" + if(subject == "object"): + preppedprompt += ", " + promptcompounderlevel + " objects" - # set everything ready - p.prompt = preppedprompt - p.negative_prompt = negativeprompt + if(ANDtoggle != "none" and ANDtoggle != "automatic"): + preppedprompt += prefixprompt + + if(ANDtoggle != "none"): + if(ANDtoggle!="prefix + prefix + prompt + suffix"): + prefixprompt = "" + if(seperator == "comma"): + preppedprompt += " \n , " + else: + preppedprompt += " \n " + seperator + " " + + #Here is where we build a "normal" prompt + preppedprompt += build_dynamic_prompt(insanitylevel,subject,artist, imagetype, False, antistring, prefixprompt, suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage) - if(silentmode == True): + # set everything ready + p.prompt = preppedprompt + p.negative_prompt = negativeprompt + promptlist.append(p.prompt) + negativepromptlist.append(p.negative_prompt) + + + else: p.prompt = workprompt #for j in range(batchsize): @@ -710,11 +734,17 @@ class Script(scripts.Script): print(p.prompt) # finally figured out how to do multiple batch sizes - promptlist = [] - for i in range(batchsize): - promptlist.append(p.prompt) + if(prompteachiteration==False): + promptlist = [] + negativepromptlist = [] + for i in range(batchsize): + promptlist.append(p.prompt) + negativepromptlist.append(p.negative_prompt) - p.prompt = promptlist + p.prompt = preppedprompt + p.all_prompts = promptlist + p.negativeprompt = negativeprompt + p.all_negative_prompts = negativepromptlist p.batch_size = batchsize processed = process_images(p) images += processed.images From 288ce64294200af5528bd977b83a3bd79cd83af8 Mon Sep 17 00:00:00 2001 From: AIrjen Date: Tue, 23 May 2023 22:19:52 +0200 Subject: [PATCH 2/6] additions and more additions --- build_dynamic_prompt.py | 127 +++++++++------------ csv_reader.py | 4 +- csvfiles/haircolors.csv | 4 +- csvfiles/special_lists/backgroundtypes.csv | 7 +- csvfiles/special_lists/buildhair.csv | 6 + csvfiles/special_lists/buildoutfit.csv | 13 +++ csvfiles/special_lists/humanadditions.csv | 13 +++ csvfiles/special_lists/objectadditions.csv | 11 ++ 8 files changed, 109 insertions(+), 76 deletions(-) create mode 100644 csvfiles/special_lists/buildhair.csv create mode 100644 csvfiles/special_lists/buildoutfit.csv create mode 100644 csvfiles/special_lists/humanadditions.csv create mode 100644 csvfiles/special_lists/objectadditions.csv diff --git a/build_dynamic_prompt.py b/build_dynamic_prompt.py index 37a4c8e..8834b97 100644 --- a/build_dynamic_prompt.py +++ b/build_dynamic_prompt.py @@ -96,6 +96,10 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all backgroundtypelist = csv_to_list("backgroundtypes", antilist,"./csvfiles/special_lists/") insideshotlist = csv_to_list("insideshots", antilist,"./csvfiles/special_lists/") photoadditionlist = csv_to_list("photoadditions", antilist,"./csvfiles/special_lists/") + buildhairlist = csv_to_list("buildhair", antilist,"./csvfiles/special_lists/") + buildoutfitlist = csv_to_list("buildoutfit", antilist,"./csvfiles/special_lists/") + objectadditionslist = csv_to_list("objectadditions", antilist,"./csvfiles/special_lists/") + humanadditionlist = csv_to_list("humanadditions", antilist,"./csvfiles/special_lists/") generateoutfit = bool(outfitlist) @@ -121,6 +125,10 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all generatebackground = bool(backgroundtypelist) generateinsideshot = bool(insideshotlist) generatephotoaddition = bool(photoadditionlist) + generatehairstyle = bool(buildhairlist) + generateoutfit = bool(buildoutfitlist) + generateobjectaddition = bool(objectadditionslist) + generatehumanaddition = bool(humanadditionlist) # Smart subject logic if(givensubject !="" and smartsubject == True): @@ -418,7 +426,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all if artistmode in ["switching","adding"]: completeprompt += ":" + str(random.randint(1,18)) if artistmode in ["hybrid", "stopping","adding", "switching"]: - completeprompt += "]" + completeprompt += "] " if(onlyartists == True): @@ -509,18 +517,18 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all if(hybridorswap == "hybrid"): if(uncommon_dist(insanitylevel)): - completeprompt += "|" + random.choice(hybridlist) + "]" + completeprompt += "|" + random.choice(hybridlist) + "] " else: completeprompt += "|" completeprompt += random.choice(chosenobjecttype) + " " - completeprompt += "]" + completeprompt += "] " if(hybridorswap == "swap"): if(uncommon_dist(insanitylevel)): - completeprompt += ":" + random.choice(hybridlist) + ":" + str(random.randint(1,5)) + "]" + completeprompt += ":" + random.choice(hybridlist) + ":" + str(random.randint(1,5)) + "] " else: completeprompt += ":" completeprompt += random.choice(chosenobjecttype) + " " - completeprompt += ":" + str(random.randint(1,5)) + "]" + completeprompt += ":" + str(random.randint(1,5)) + "] " else: completeprompt += " " + givensubject + " " @@ -545,14 +553,14 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all if(hybridorswap == "hybrid"): if(uncommon_dist(insanitylevel)): - completeprompt += "|" + random.choice(hybridlist) + "]" + completeprompt += "|" + random.choice(hybridlist) + "] " else: - completeprompt += "| -animal- ]" + completeprompt += "| -animal- ] " if(hybridorswap == "swap"): if(uncommon_dist(insanitylevel)): - completeprompt += ":" + random.choice(hybridlist) + ":" + str(random.randint(1,5)) + "]" + completeprompt += ":" + random.choice(hybridlist) + ":" + str(random.randint(1,5)) + "] " else: - completeprompt += ":-animal-:" + str(random.randint(1,5)) + "]" + completeprompt += ":-animal-:" + str(random.randint(1,5)) + "] " else: completeprompt += " " + givensubject + " " @@ -578,9 +586,9 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all completeprompt += random.choice(fictionallist) + " " if(hybridorswap == "hybrid"): - completeprompt += "|" + random.choice(hybridhumanlist) + "]" + completeprompt += "|" + random.choice(hybridhumanlist) + " ] " if(hybridorswap == "swap"): - completeprompt += ":" + random.choice(hybridhumanlist) + ":" + str(random.randint(1,5)) + "]" + completeprompt += ":" + random.choice(hybridhumanlist) + ":" + str(random.randint(1,5)) + "] " hybridorswap = "" if(subjectchooser == "non fictional"): @@ -592,9 +600,9 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all completeprompt += random.choice(nonfictionallist) + " " if(hybridorswap == "hybrid"): - completeprompt += "|" + random.choice(hybridhumanlist) + "]" + completeprompt += "|" + random.choice(hybridhumanlist) + "] " if(hybridorswap == "swap"): - completeprompt += ":" + random.choice(hybridhumanlist) + ":" + str(random.randint(1,5)) + "]" + completeprompt += ":" + random.choice(hybridhumanlist) + ":" + str(random.randint(1,5)) + "] " hybridorswap = "" if(subjectchooser == "humanoid"): @@ -606,9 +614,9 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all completeprompt += random.choice(humanoidlist) + " " if(hybridorswap == "hybrid"): - completeprompt += "|" + random.choice(hybridhumanlist) + "]" + completeprompt += "|" + random.choice(hybridhumanlist) + "] " if(hybridorswap == "swap"): - completeprompt += ":" + random.choice(hybridhumanlist) + ":" + str(random.randint(1,5)) + "]" + completeprompt += ":" + random.choice(hybridhumanlist) + ":" + str(random.randint(1,5)) + "] " hybridorswap = "" else: completeprompt += " " + givensubject + " " @@ -626,9 +634,9 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all completeprompt += random.choice(locationlist) + " " if(hybridorswap == "hybrid"): - completeprompt += "|" + "-location-" + "]" + completeprompt += "|" + "-location-" + "] " if(hybridorswap == "swap"): - completeprompt += ":" + "-location-" + ":" + str(random.randint(1,5)) + "]" + completeprompt += ":" + "-location-" + ":" + str(random.randint(1,5)) + "] " else: completeprompt += " " + givensubject + " " @@ -662,30 +670,17 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all else: completeprompt += " " + givensubject + " " - # object with a face - if(mainchooser == "object" and unique_dist(insanitylevel)): - completeprompt += " with a face " - - # object materials - if(mainchooser == "object" and uncommon_dist(insanitylevel)): - completeprompt += " made from -material- " - - # object detailing - if(mainchooser == "object" and rare_dist(insanitylevel)): - completeprompt += " detailed with " - if(uncommon_dist(insanitylevel)): - completeprompt += random.choice(descriptorlist) + " " - completeprompt += "-material- patterns " - + # object additions + for i in range(2): + if(mainchooser == "object" and uncommon_dist(insanitylevel) and generateobjectaddition == True): + completeprompt += random.choice(objectadditionslist) + ", " + # riding an animal, holding an object or driving a vehicle, rare - if(subjectchooser in ["animal as human,","human","fictional", "non fictional", "humanoid"] and rare_dist(insanitylevel)): + if(subjectchooser in ["animal as human,","human","fictional", "non fictional", "humanoid"] and rare_dist(insanitylevel) and generatehumanaddition == True): humanspecial = 1 - speciallist = [" riding a -animal- ", " holding a -object- ", " driving a -vehicle-", " visiting a -building-", " with a -animal-", " surrounded by -object-s", " eating -food-"] - completeprompt += random.choice(speciallist) + completeprompt += random.choice(humanadditionlist) + " " - - completeprompt += ", " # SD understands emoji's. Can be used to manipulate facial expressions. @@ -695,8 +690,8 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all # cosplaying - if(subjectchooser in ["animal as human", "non fictional", "humanoid"] and rare_dist(insanitylevel) and humanspecial != 1): - completeprompt += "cosplaying as " + random.choice(fictionallist) + ", " + #if(subjectchooser in ["animal as human", "non fictional", "humanoid"] and rare_dist(insanitylevel) and humanspecial != 1): + # completeprompt += "cosplaying as " + random.choice(fictionallist) + ", " # Job # either go job or activity, not both @@ -706,9 +701,9 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all completeprompt += random.choice(random.choice(joboractivitylist)) + ", " - if(subjectchooser in ["animal as human","human","job", "fictional", "non fictional", "humanoid"] and legendary_dist(insanitylevel)): - skintypelist = ["-color-", "-material-"] - completeprompt += ", with " + random.choice(skintypelist) + " skin, " + # if(subjectchooser in ["animal as human","human","job", "fictional", "non fictional", "humanoid"] and legendary_dist(insanitylevel)): + # skintypelist = ["-color-", "-material-"] + # completeprompt += ", with " + random.choice(skintypelist) + " skin, " # custom mid list if(uncommon_dist(insanitylevel) and generatecustominputmid == True): @@ -719,37 +714,13 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all # outfit builder if(subjectchooser in ["animal as human","human","fictional", "non fictional", "humanoid"] and normal_dist(insanitylevel) and generateoutfit == True): - completeprompt += ", wearing " - if(normal_dist(insanitylevel)): - completeprompt += random.choice(descriptorlist) + " " - if(uncommon_dist(insanitylevel)): - completeprompt += random.choice(culturelist) + " " - if(normal_dist(insanitylevel)): - completeprompt += " -color- " - if(rare_dist(insanitylevel)): - completeprompt += " -material- " - - if rare_dist(insanitylevel): - hybridorswaplist = ["hybrid", "swap"] - hybridorswap = random.choice(hybridorswaplist) - completeprompt += "[" - - completeprompt += random.choice(outfitlist) + " " - - if(hybridorswap == "hybrid"): - completeprompt += "|" + "-outfit-" + "]" - if(hybridorswap == "swap"): - completeprompt += ":" + "-outfit-" + ":" + str(random.randint(1,5)) + "]" - hybridorswap = "" - completeprompt += ", " - + completeprompt += ", wearing " + random.choice(buildoutfitlist) + ", " if(subjectchooser in ["animal as human","human","fictional", "non fictional", "humanoid"] and uncommon_dist(insanitylevel) and humanspecial != 1 and generatepose == True): completeprompt += random.choice(poselist) + ", " if(subjectchooser in ["human","job","fictional", "non fictional", "humanoid"] and normal_dist(insanitylevel) and generatehairstyle == True): - completeprompt += random.choice(haircolorlist) + " " - completeprompt += " hair styled as " + random.choice(hairstylelist) + ", " + completeprompt += random.choice(buildhairlist) + ", " if(subjectchooser in ["animal as human,","human","fictional", "non fictional", "humanoid"] and normal_dist(insanitylevel) and generateaccesorie == True): completeprompt += random.choice(accessorielist) + ", " @@ -799,7 +770,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all isphoto = 1 if(common_dist(insanitylevel) and isphoto == 1 and generatephotoaddition == True): - completeprompt += random.choice(photoadditionlist) + completeprompt += random.choice(photoadditionlist) + ", " if(isphoto == 1 and generatecamera == True): completeprompt += random.choice(cameralist) + ", " @@ -843,7 +814,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all if artistmode in ["enhancing"]: - completeprompt += "::" + str(random.randint(1,17)) + "]" + completeprompt += "::" + str(random.randint(1,17)) + "] " @@ -906,7 +877,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all if artistmode in ["switching","adding"]: completeprompt += ":" + str(random.randint(1,18)) if artistmode in ["hybrid", "stopping","adding", "switching"]: - completeprompt += "]" + completeprompt += "] " # end of the artist stuff @@ -930,7 +901,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all #end of the while loop, now clean up the prompt # lol, this needs a rewrite :D - while "-color-" in completeprompt or "-material-" in completeprompt or "-animal-" in completeprompt or "-object-" in completeprompt or "-fictional-" in completeprompt or "-nonfictional-" in completeprompt or "-conceptsuffix-" in completeprompt or "-building-" in completeprompt or "-vehicle-" in completeprompt or "-outfit-" in completeprompt or "-location-" in completeprompt or "-conceptprefix-" in completeprompt or "-descriptor-" in completeprompt or "-food-" in completeprompt: + while "-color-" in completeprompt or "-material-" in completeprompt or "-animal-" in completeprompt or "-object-" in completeprompt or "-fictional-" in completeprompt or "-nonfictional-" in completeprompt or "-conceptsuffix-" in completeprompt or "-building-" in completeprompt or "-vehicle-" in completeprompt or "-outfit-" in completeprompt or "-location-" in completeprompt or "-conceptprefix-" in completeprompt or "-descriptor-" in completeprompt or "-food-" in completeprompt or "-haircolor-" in completeprompt or "-hairstyle-" in completeprompt or "-job-" in completeprompt or "-culture-" in completeprompt: while "-object-" in completeprompt: completeprompt = completeprompt.replace('-object-', random.choice(objectlist),1) @@ -972,6 +943,18 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all while "-food-" in completeprompt: completeprompt = completeprompt.replace('-food-', random.choice(foodlist),1) + + while "-haircolor-" in completeprompt: + completeprompt = completeprompt.replace('-haircolor-', random.choice(haircolorlist),1) + + while "-hairstyle-" in completeprompt: + completeprompt = completeprompt.replace('-hairstyle-', random.choice(hairstylelist),1) + + while "-job-" in completeprompt: + completeprompt = completeprompt.replace('-job-', random.choice(joblist),1) + + while "-culture-" in completeprompt: + completeprompt = completeprompt.replace('-culture-', random.choice(culturelist),1) diff --git a/csv_reader.py b/csv_reader.py index 14056c2..afec379 100644 --- a/csv_reader.py +++ b/csv_reader.py @@ -27,7 +27,7 @@ def csv_to_list(csvfilename, antilist=[], directory="./csvfiles/", lowerandstrip full_path = os.path.join(script_dir, directory ) userfilesfolder = os.path.join(script_dir, userfilesdirectory ) # check if there is a replace file - if(directory=="./csvfiles/"): + if(directory=="./csvfiles/" or directory=="./csvfiles/special_lists/"): for filename in os.listdir(userfilesfolder): if(filename == userfilereplacename): # Just override the parameters, and let it run normally @@ -47,7 +47,7 @@ def csv_to_list(csvfilename, antilist=[], directory="./csvfiles/", lowerandstrip csvlist.append(row[0]) # do the add ons! - if(directory=="./csvfiles/"): + if(directory=="./csvfiles/" or directory=="./csvfiles/special_lists/"): if(os.path.isfile(userfilesfolder + csvfilename + "_addon" + ".csv")): with open(userfilesfolder + csvfilename + "_addon" + ".csv", "r", newline="",encoding="utf8") as file: reader = csv.reader(file, delimiter=",") diff --git a/csvfiles/haircolors.csv b/csvfiles/haircolors.csv index 47e268b..ec7f289 100644 --- a/csvfiles/haircolors.csv +++ b/csvfiles/haircolors.csv @@ -15,4 +15,6 @@ White Dark Light -color- --color- and -color- \ No newline at end of file +-color- and -color- +Pink +Rainbow \ No newline at end of file diff --git a/csvfiles/special_lists/backgroundtypes.csv b/csvfiles/special_lists/backgroundtypes.csv index ee8d29d..6938380 100644 --- a/csvfiles/special_lists/backgroundtypes.csv +++ b/csvfiles/special_lists/backgroundtypes.csv @@ -1,9 +1,14 @@ background is -location- +background is [-location-|-location-] background is -building- +background is [-building-|-building-] +background is [-location-|-building-] inside a -building- background is -descriptor- -location- background is -descriptor- -building- inside a -descriptor- -building- plain background plain -color- background --color- and -color- background \ No newline at end of file +-color- and -color- background +-descriptor- background +-culture- background \ No newline at end of file diff --git a/csvfiles/special_lists/buildhair.csv b/csvfiles/special_lists/buildhair.csv new file mode 100644 index 0000000..cf0b0c0 --- /dev/null +++ b/csvfiles/special_lists/buildhair.csv @@ -0,0 +1,6 @@ +-haircolor- hair styled as -hairstyle- +-descriptor- hair styled as -hairstyle- +-hairstyle- hair +-descriptor- hair +-descriptor- -haircolor- hair +-culture- hair \ No newline at end of file diff --git a/csvfiles/special_lists/buildoutfit.csv b/csvfiles/special_lists/buildoutfit.csv new file mode 100644 index 0000000..3575c71 --- /dev/null +++ b/csvfiles/special_lists/buildoutfit.csv @@ -0,0 +1,13 @@ +-descriptor- -outfit- +-descriptor- -culture- -outfit- +-descriptor- -culture- -material- -outfit- +-descriptor- -culture- -material- -color- -outfit- +-culture- -outfit- +-material- -outfit- +-color- -outfit- +-material- -color- -outfit- +-descriptor- -color- -outfit- +-descriptor- -material- -outfit- +-job- -outfit- +[-outfit-|-outfit-] +-descriptor- [-outfit-|-outfit-] \ No newline at end of file diff --git a/csvfiles/special_lists/humanadditions.csv b/csvfiles/special_lists/humanadditions.csv new file mode 100644 index 0000000..2cce8bc --- /dev/null +++ b/csvfiles/special_lists/humanadditions.csv @@ -0,0 +1,13 @@ +riding a -animal- +holding a -object- +driving a -vehicle- +visiting a -building- +visiting -location- +with a -animal- +surrounded by -object-s +eating -food- +and -fictional- +and -nonfictional- +cosplaying as -fictional- +with -color- skin +with -material- skin \ No newline at end of file diff --git a/csvfiles/special_lists/objectadditions.csv b/csvfiles/special_lists/objectadditions.csv new file mode 100644 index 0000000..5100cc3 --- /dev/null +++ b/csvfiles/special_lists/objectadditions.csv @@ -0,0 +1,11 @@ +with a face +made from -material- +detailed with -material- patterns +detailed with -material- -descriptor- patterns +-descriptor- details +-color- patterns +-material- patterns +-descriptor- -color- patterns +-material- frame +intricate details +smooth \ No newline at end of file From 754ecf7f88220c6e5a1b057bea81e7dde979bb1a Mon Sep 17 00:00:00 2001 From: AIrjen Date: Wed, 24 May 2023 22:16:17 +0200 Subject: [PATCH 3/6] working on stuff --- build_dynamic_prompt.py | 62 ++++++++++++++++++++++++++++++++++++-- scripts/onebuttonprompt.py | 3 +- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/build_dynamic_prompt.py b/build_dynamic_prompt.py index 8834b97..8db4bfb 100644 --- a/build_dynamic_prompt.py +++ b/build_dynamic_prompt.py @@ -902,13 +902,33 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all # lol, this needs a rewrite :D while "-color-" in completeprompt or "-material-" in completeprompt or "-animal-" in completeprompt or "-object-" in completeprompt or "-fictional-" in completeprompt or "-nonfictional-" in completeprompt or "-conceptsuffix-" in completeprompt or "-building-" in completeprompt or "-vehicle-" in completeprompt or "-outfit-" in completeprompt or "-location-" in completeprompt or "-conceptprefix-" in completeprompt or "-descriptor-" in completeprompt or "-food-" in completeprompt or "-haircolor-" in completeprompt or "-hairstyle-" in completeprompt or "-job-" in completeprompt or "-culture-" in completeprompt: - while "-object-" in completeprompt: - completeprompt = completeprompt.replace('-object-', random.choice(objectlist),1) + replacewildcard(completeprompt, insanitylevel, "-object-", objectlist,True) + #while "-object-" in completeprompt: + # completeprompt = completeprompt.replace('-object-', random.choice(objectlist),1) while "-location-" in completeprompt: completeprompt = completeprompt.replace('-location-', random.choice(locationlist),1) while "-outfit-" in completeprompt: + # sometimes, its just nice to have descriptor and a normal "outfit" + if(unique_dist(insanitylevel)): + completeprompt = completeprompt.replace('-outfit-', 'outfit',1) + + # do the hybrid/swap thing in here instead + if(rare_dist(insanitylevel)): + hybridorswaplist = ["hybrid", "swap"] + hybridorswap = random.choice(hybridorswaplist) + hybridorswapreplacementvalue = "[" + random.choice(outfitlist) + + if(hybridorswap == "hybrid"): + hybridorswapreplacementvalue += "|" + random.choice(outfitlist) + "] " + if(hybridorswap == "swap"): + if(uncommon_dist(insanitylevel)): + hybridorswapreplacementvalue += ":" + random.choice(outfitlist) + ":" + str(random.randint(1,20)) + "] " + + completeprompt = completeprompt.replace('-outfit-', hybridorswapreplacementvalue,1) + + completeprompt = completeprompt.replace('-outfit-', random.choice(outfitlist),1) while "-building-" in completeprompt: @@ -939,6 +959,20 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all completeprompt = completeprompt.replace('-conceptprefix-', random.choice(conceptprefixlist),1) while "-descriptor-" in completeprompt: + # lets also make it sometimes swap the descriptor. Cause its fun! + if(unique_dist(insanitylevel)): + hybridorswaplist = ["hybrid", "swap"] + hybridorswap = random.choice(hybridorswaplist) + hybridorswapreplacementvalue = "[" + random.choice(descriptorlist) + + if(hybridorswap == "hybrid"): + hybridorswapreplacementvalue += "|" + random.choice(descriptorlist) + "] " + if(hybridorswap == "swap"): + if(uncommon_dist(insanitylevel)): + hybridorswapreplacementvalue += ":" + random.choice(descriptorlist) + ":" + str(random.randint(1,20)) + "] " + + completeprompt = completeprompt.replace('-descriptor-', hybridorswapreplacementvalue,1) + completeprompt = completeprompt.replace('-descriptor-', random.choice(descriptorlist),1) while "-food-" in completeprompt: @@ -993,4 +1027,26 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all print(completeprompt) return completeprompt - \ No newline at end of file + + + # function +def replacewildcard(completeprompt, insanitylevel, wildcard,listname, activatehybridorswap): + + while wildcard in completeprompt: + if(unique_dist(insanitylevel) and activatehybridorswap == True): + hybridorswaplist = ["hybrid", "swap"] + hybridorswap = random.choice(hybridorswaplist) + hybridorswapreplacementvalue = "[" + random.choice(listname) + + if(hybridorswap == "hybrid"): + hybridorswapreplacementvalue += "|" + random.choice(listname) + "] " + if(hybridorswap == "swap"): + if(uncommon_dist(insanitylevel)): + hybridorswapreplacementvalue += ":" + random.choice(listname) + ":" + str(random.randint(1,20)) + "] " + + completeprompt = completeprompt.replace('-descriptor-', hybridorswapreplacementvalue,1) + + + completeprompt = completeprompt.replace(wildcard, random.choice(listname),1) + + return completeprompt \ No newline at end of file diff --git a/scripts/onebuttonprompt.py b/scripts/onebuttonprompt.py index eb79e27..62ec581 100644 --- a/scripts/onebuttonprompt.py +++ b/scripts/onebuttonprompt.py @@ -724,7 +724,8 @@ class Script(scripts.Script): else: - p.prompt = workprompt + preppedprompt = workprompt + p.prompt = preppedprompt #for j in range(batchsize): From a71818f79b75c9bd4f3331b5e70458280313cada Mon Sep 17 00:00:00 2001 From: AIrjen Date: Fri, 26 May 2023 10:45:03 +0200 Subject: [PATCH 4/6] rollback of changes made --- scripts/onebuttonprompt.py | 111 +++++++++++++------------------------ 1 file changed, 40 insertions(+), 71 deletions(-) diff --git a/scripts/onebuttonprompt.py b/scripts/onebuttonprompt.py index 62ec581..d40ab27 100644 --- a/scripts/onebuttonprompt.py +++ b/scripts/onebuttonprompt.py @@ -307,17 +307,6 @@ class Script(scripts.Script): with gr.Column(scale=2): ANDtoggle = gr.Dropdown( ANDtogglemode, label="Prompt seperator mode", value="none") - with gr.Row(): - gr.Markdown( - """ - - Other advanced options: - - """) - with gr.Row(): - with gr.Column(scale=1): - prompteachiteration = gr.Checkbox( - label="Generate new prompt for each Batch Size", value=False) with gr.Row(): gr.Markdown( """ @@ -635,12 +624,12 @@ class Script(scripts.Script): - return [insanitylevel,subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring, seperator, givensubject, smartsubject, giventypeofimage, prompteachiteration] + return [insanitylevel,subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring, seperator, givensubject, smartsubject, giventypeofimage] - def run(self, p, insanitylevel, subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring,seperator, givensubject, smartsubject, giventypeofimage,prompteachiteration): + def run(self, p, insanitylevel, subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring,seperator, givensubject, smartsubject, giventypeofimage): images = [] infotexts = [] @@ -675,57 +664,43 @@ class Script(scripts.Script): for i in range(batches): if(silentmode == False): + # prompt compounding + print("Starting generating the prompt") + preppedprompt = "" - promptlist = [] - negativepromptlist = [] - # Either do this once, or for each iteration - if(prompteachiteration==True): - amountofpromptstogen = batchsize - else: - amountofpromptstogen = 1 + if(ANDtoggle == "automatic"): + preppedprompt += prefixprompt + ", " + if(artist != "none"): + preppedprompt += build_dynamic_prompt(insanitylevel,subject,artist, imagetype, True, antistring) + if(subject == "humanoid"): + preppedprompt += ", " + promptcompounderlevel + " people" + if(subject == "landscape"): + preppedprompt += ", landscape" + if(subject == "animal"): + preppedprompt += ", " + promptcompounderlevel + " animals" + if(subject == "object"): + preppedprompt += ", " + promptcompounderlevel + " objects" - for i in range(amountofpromptstogen): - # prompt compounding - print("Starting generating the prompt") - preppedprompt = "" - - if(ANDtoggle == "automatic"): - preppedprompt += prefixprompt + ", " - if(artist != "none"): - preppedprompt += build_dynamic_prompt(insanitylevel,subject,artist, imagetype, True, antistring) - if(subject == "humanoid"): - preppedprompt += ", " + promptcompounderlevel + " people" - if(subject == "landscape"): - preppedprompt += ", landscape" - if(subject == "animal"): - preppedprompt += ", " + promptcompounderlevel + " animals" - if(subject == "object"): - preppedprompt += ", " + promptcompounderlevel + " objects" + if(ANDtoggle != "none" and ANDtoggle != "automatic"): + preppedprompt += prefixprompt + + if(ANDtoggle != "none"): + if(ANDtoggle!="prefix + prefix + prompt + suffix"): + prefixprompt = "" + if(seperator == "comma"): + preppedprompt += " \n , " + else: + preppedprompt += " \n " + seperator + " " + + #Here is where we build a "normal" prompt + preppedprompt += build_dynamic_prompt(insanitylevel,subject,artist, imagetype, False, antistring, prefixprompt, suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage) - if(ANDtoggle != "none" and ANDtoggle != "automatic"): - preppedprompt += prefixprompt - - if(ANDtoggle != "none"): - if(ANDtoggle!="prefix + prefix + prompt + suffix"): - prefixprompt = "" - if(seperator == "comma"): - preppedprompt += " \n , " - else: - preppedprompt += " \n " + seperator + " " - - #Here is where we build a "normal" prompt - preppedprompt += build_dynamic_prompt(insanitylevel,subject,artist, imagetype, False, antistring, prefixprompt, suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage) + # set everything ready + p.prompt = preppedprompt + p.negative_prompt = negativeprompt - # set everything ready - p.prompt = preppedprompt - p.negative_prompt = negativeprompt - promptlist.append(p.prompt) - negativepromptlist.append(p.negative_prompt) - - - else: - preppedprompt = workprompt - p.prompt = preppedprompt + if(silentmode == True): + p.prompt = workprompt #for j in range(batchsize): @@ -735,17 +710,11 @@ class Script(scripts.Script): print(p.prompt) # finally figured out how to do multiple batch sizes - if(prompteachiteration==False): - promptlist = [] - negativepromptlist = [] - for i in range(batchsize): - promptlist.append(p.prompt) - negativepromptlist.append(p.negative_prompt) + promptlist = [] + for i in range(batchsize): + promptlist.append(p.prompt) - p.prompt = preppedprompt - p.all_prompts = promptlist - p.negativeprompt = negativeprompt - p.all_negative_prompts = negativepromptlist + p.prompt = promptlist p.batch_size = batchsize processed = process_images(p) images += processed.images @@ -761,4 +730,4 @@ class Script(scripts.Script): # just return all the things p.n_iter = 0 p.batch_size = 0 - return Processed(p=p, images_list=images, info=infotexts[0], infotexts=infotexts, all_seeds=all_seeds, all_prompts=all_prompts) + return Processed(p=p, images_list=images, info=infotexts[0], infotexts=infotexts, all_seeds=all_seeds, all_prompts=all_prompts) \ No newline at end of file From 5d915a6ebdcf8c3e66724ff9717ce9a4c638ba37 Mon Sep 17 00:00:00 2001 From: AIrjen Date: Fri, 26 May 2023 11:34:49 +0200 Subject: [PATCH 5/6] Working on handling empty lists --- build_dynamic_prompt.py | 157 ++++++++++++--------------------- main.py | 1 + prompttester.py | 38 ++++++++ userfiles/vehicles_replace.csv | 0 4 files changed, 94 insertions(+), 102 deletions(-) create mode 100644 prompttester.py create mode 100644 userfiles/vehicles_replace.csv diff --git a/build_dynamic_prompt.py b/build_dynamic_prompt.py index 8db4bfb..e0ce50c 100644 --- a/build_dynamic_prompt.py +++ b/build_dynamic_prompt.py @@ -501,7 +501,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all completeprompt += random.choice(culturelist) + " " if(mainchooser == "object"): - objecttypelist = [objectlist, buildinglist, vehiclelist, foodlist] # first select a random list, then randomly select from the corresponding list + objectwildcardlist = ["-object-", "-building-","-vehicle-","-food-"] # using wildcards for replacements # if we have a given subject, we should skip making an actual subject if(givensubject == ""): @@ -511,23 +511,23 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all hybridorswap = random.choice(hybridorswaplist) completeprompt += "[" - chosenobjecttype = random.choice(objecttypelist) + chosenobjectwildcard = random.choice(objectwildcardlist) - completeprompt += random.choice(chosenobjecttype) + " " + completeprompt += chosenobjectwildcard + " " if(hybridorswap == "hybrid"): if(uncommon_dist(insanitylevel)): completeprompt += "|" + random.choice(hybridlist) + "] " else: completeprompt += "|" - completeprompt += random.choice(chosenobjecttype) + " " + completeprompt += random.choice(chosenobjectwildcard) + " " completeprompt += "] " if(hybridorswap == "swap"): if(uncommon_dist(insanitylevel)): completeprompt += ":" + random.choice(hybridlist) + ":" + str(random.randint(1,5)) + "] " else: completeprompt += ":" - completeprompt += random.choice(chosenobjecttype) + " " + completeprompt += chosenobjectwildcard + " " completeprompt += ":" + str(random.randint(1,5)) + "] " else: completeprompt += " " + givensubject + " " @@ -899,97 +899,45 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all #end of the while loop, now clean up the prompt - - # lol, this needs a rewrite :D - while "-color-" in completeprompt or "-material-" in completeprompt or "-animal-" in completeprompt or "-object-" in completeprompt or "-fictional-" in completeprompt or "-nonfictional-" in completeprompt or "-conceptsuffix-" in completeprompt or "-building-" in completeprompt or "-vehicle-" in completeprompt or "-outfit-" in completeprompt or "-location-" in completeprompt or "-conceptprefix-" in completeprompt or "-descriptor-" in completeprompt or "-food-" in completeprompt or "-haircolor-" in completeprompt or "-hairstyle-" in completeprompt or "-job-" in completeprompt or "-culture-" in completeprompt: - replacewildcard(completeprompt, insanitylevel, "-object-", objectlist,True) - #while "-object-" in completeprompt: - # completeprompt = completeprompt.replace('-object-', random.choice(objectlist),1) - while "-location-" in completeprompt: - completeprompt = completeprompt.replace('-location-', random.choice(locationlist),1) + # first some manual stuff for outfit - while "-outfit-" in completeprompt: - # sometimes, its just nice to have descriptor and a normal "outfit" - if(unique_dist(insanitylevel)): + if(unique_dist(insanitylevel)): # sometimes, its just nice to have descriptor and a normal "outfit" completeprompt = completeprompt.replace('-outfit-', 'outfit',1) # do the hybrid/swap thing in here instead - if(rare_dist(insanitylevel)): - hybridorswaplist = ["hybrid", "swap"] - hybridorswap = random.choice(hybridorswaplist) - hybridorswapreplacementvalue = "[" + random.choice(outfitlist) - - if(hybridorswap == "hybrid"): - hybridorswapreplacementvalue += "|" + random.choice(outfitlist) + "] " - if(hybridorswap == "swap"): - if(uncommon_dist(insanitylevel)): - hybridorswapreplacementvalue += ":" + random.choice(outfitlist) + ":" + str(random.randint(1,20)) + "] " - - completeprompt = completeprompt.replace('-outfit-', hybridorswapreplacementvalue,1) - - - completeprompt = completeprompt.replace('-outfit-', random.choice(outfitlist),1) + # if(rare_dist(insanitylevel)): + # hybridorswaplist = ["hybrid", "swap"] + # hybridorswap = random.choice(hybridorswaplist) + # hybridorswapreplacementvalue = "[" + random.choice(outfitlist) + # + # if(hybridorswap == "hybrid"): + # hybridorswapreplacementvalue += "|" + random.choice(outfitlist) + "] " + # if(hybridorswap == "swap"): + # if(uncommon_dist(insanitylevel)): + # hybridorswapreplacementvalue += ":" + random.choice(outfitlist) + ":" + str(random.randint(1,20)) + "] " + # + # completeprompt = completeprompt.replace('-outfit-', hybridorswapreplacementvalue,1) + + # lol, this needs a rewrite :D + while "-color-" in completeprompt or "-material-" in completeprompt or "-animal-" in completeprompt or "-object-" in completeprompt or "-fictional-" in completeprompt or "-nonfictional-" in completeprompt or "-conceptsuffix-" in completeprompt or "-building-" in completeprompt or "-vehicle-" in completeprompt or "-outfit-" in completeprompt or "-location-" in completeprompt or "-conceptprefix-" in completeprompt or "-descriptor-" in completeprompt or "-food-" in completeprompt or "-haircolor-" in completeprompt or "-hairstyle-" in completeprompt or "-job-" in completeprompt or "-culture-" in completeprompt: + allwildcardslistnohybrid = [ "-color-","-object-", "-animal-", "-fictional-","-nonfictional-","-building-","-vehicle-","-location-","-conceptprefix-","-food-","-haircolor-","-hairstyle-","-job-"] + allwildcardslistnohybridlists = [colorlist, objectlist, animallist, fictionallist, nonfictionallist, buildinglist, vehiclelist, locationlist,conceptprefixlist,foodlist,haircolorlist, hairstylelist,joblist] + allwildcardslistwithhybrid = ["-material-", "-descriptor-", "-outfit-", "-conceptsuffix-","-culture-"] + allwildcardslistwithhybridlists =[materiallist, descriptorlist,outfitlist,conceptsuffixlist,culturelist] - while "-building-" in completeprompt: - completeprompt = completeprompt.replace('-building-', random.choice(buildinglist),1) + # keywordsinstring = any(word.lower() in givensubject.lower() for word in keywordslist) + for wildcard in allwildcardslistnohybrid: + attachedlist = allwildcardslistnohybridlists[allwildcardslistnohybrid.index(wildcard)] + completeprompt = replacewildcard(completeprompt, insanitylevel, wildcard, attachedlist,False) - while "-vehicle-" in completeprompt: - completeprompt = completeprompt.replace('-vehicle-', random.choice(vehiclelist),1) - while "-conceptsuffix-" in completeprompt: - completeprompt = completeprompt.replace('-conceptsuffix-', random.choice(conceptsuffixlist),1) + for wildcard in allwildcardslistwithhybrid: + attachedlist = allwildcardslistwithhybridlists[allwildcardslistwithhybrid.index(wildcard)] + completeprompt = replacewildcard(completeprompt, insanitylevel, wildcard, attachedlist,True) + + - while "-color-" in completeprompt: - completeprompt = completeprompt.replace('-color-', random.choice(colorlist),1) - - while "-material-" in completeprompt: - completeprompt = completeprompt.replace('-material-', random.choice(materiallist),1) - - while "-fictional-" in completeprompt: - completeprompt = completeprompt.replace('-fictional-', random.choice(fictionallist),1) - - while "-nonfictional-" in completeprompt: - completeprompt = completeprompt.replace('-nonfictional-', random.choice(nonfictionallist),1) - - while "-animal-" in completeprompt: - completeprompt = completeprompt.replace('-animal-', random.choice(animallist),1) - - while "-conceptprefix-" in completeprompt: - completeprompt = completeprompt.replace('-conceptprefix-', random.choice(conceptprefixlist),1) - - while "-descriptor-" in completeprompt: - # lets also make it sometimes swap the descriptor. Cause its fun! - if(unique_dist(insanitylevel)): - hybridorswaplist = ["hybrid", "swap"] - hybridorswap = random.choice(hybridorswaplist) - hybridorswapreplacementvalue = "[" + random.choice(descriptorlist) - - if(hybridorswap == "hybrid"): - hybridorswapreplacementvalue += "|" + random.choice(descriptorlist) + "] " - if(hybridorswap == "swap"): - if(uncommon_dist(insanitylevel)): - hybridorswapreplacementvalue += ":" + random.choice(descriptorlist) + ":" + str(random.randint(1,20)) + "] " - - completeprompt = completeprompt.replace('-descriptor-', hybridorswapreplacementvalue,1) - - completeprompt = completeprompt.replace('-descriptor-', random.choice(descriptorlist),1) - - while "-food-" in completeprompt: - completeprompt = completeprompt.replace('-food-', random.choice(foodlist),1) - - while "-haircolor-" in completeprompt: - completeprompt = completeprompt.replace('-haircolor-', random.choice(haircolorlist),1) - - while "-hairstyle-" in completeprompt: - completeprompt = completeprompt.replace('-hairstyle-', random.choice(hairstylelist),1) - - while "-job-" in completeprompt: - completeprompt = completeprompt.replace('-job-', random.choice(joblist),1) - - while "-culture-" in completeprompt: - completeprompt = completeprompt.replace('-culture-', random.choice(culturelist),1) - @@ -1031,22 +979,27 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all # function def replacewildcard(completeprompt, insanitylevel, wildcard,listname, activatehybridorswap): - - while wildcard in completeprompt: - if(unique_dist(insanitylevel) and activatehybridorswap == True): - hybridorswaplist = ["hybrid", "swap"] - hybridorswap = random.choice(hybridorswaplist) - hybridorswapreplacementvalue = "[" + random.choice(listname) - - if(hybridorswap == "hybrid"): - hybridorswapreplacementvalue += "|" + random.choice(listname) + "] " - if(hybridorswap == "swap"): - if(uncommon_dist(insanitylevel)): - hybridorswapreplacementvalue += ":" + random.choice(listname) + ":" + str(random.randint(1,20)) + "] " - - completeprompt = completeprompt.replace('-descriptor-', hybridorswapreplacementvalue,1) + if(len(listname) == 0): + print("HELLO THERE") + print(wildcard) + print(listname) + completeprompt = completeprompt.replace(wildcard, "",1) + else: + while wildcard in completeprompt: + if(unique_dist(insanitylevel) and activatehybridorswap == True): + hybridorswaplist = ["hybrid", "swap"] + hybridorswap = random.choice(hybridorswaplist) + hybridorswapreplacementvalue = "[" + random.choice(listname) + + if(hybridorswap == "hybrid"): + hybridorswapreplacementvalue += "|" + random.choice(listname) + "] " + if(hybridorswap == "swap"): + if(uncommon_dist(insanitylevel)): + hybridorswapreplacementvalue += ":" + random.choice(listname) + ":" + str(random.randint(1,20)) + "] " + + completeprompt = completeprompt.replace(wildcard, hybridorswapreplacementvalue,1) - completeprompt = completeprompt.replace(wildcard, random.choice(listname),1) + completeprompt = completeprompt.replace(wildcard, random.choice(listname),1) return completeprompt \ No newline at end of file diff --git a/main.py b/main.py index 763b142..ef016f4 100644 --- a/main.py +++ b/main.py @@ -23,6 +23,7 @@ def generateimages(amount = 1, size = "all",model = "currently selected model",s originalsize=size originalmodel = model originalimg2imgmodel = img2imgmodel + insanitylevel = int(insanitylevel) if(onlyupscale==True): script_dir = os.path.dirname(os.path.abspath(__file__)) # Script directory diff --git a/prompttester.py b/prompttester.py new file mode 100644 index 0000000..a567f07 --- /dev/null +++ b/prompttester.py @@ -0,0 +1,38 @@ +import sys, os +import random +import uuid +import re +from datetime import datetime +sys.path.append(os.path.abspath("..")) + + +from build_dynamic_prompt import * + + + +def generateprompts(amount = 1,insanitylevel="5",subject="all", artist="all", imagetype="all",silentmode=False, workprompt="", antistring="",prefixprompt="", suffixprompt="", negativeprompt="",promptcompounderlevel = "1", seperator="comma",givensubject="",smartsubject=True,giventypeofimage=""): + loops = int(amount) # amount of images to generate + steps = 0 + + insanitylevel = int(insanitylevel) + while steps < loops: + # build prompt + if(silentmode==True and workprompt == ""): + print("Trying to use provided workflow prompt, but is empty. Generating a random prompt instead.") + + result = build_dynamic_prompt(insanitylevel,subject,artist,imagetype, False,antistring,prefixprompt,suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage) + + print("") + print("loop " + str(steps)) + print("") + + + + + steps += 1 + + + print("") + print("All done!") + +generateprompts(10,5, "object") \ No newline at end of file diff --git a/userfiles/vehicles_replace.csv b/userfiles/vehicles_replace.csv new file mode 100644 index 0000000..e69de29 From 276c5606436d672caece45af05d4d032256b0ef6 Mon Sep 17 00:00:00 2001 From: AIrjen Date: Fri, 26 May 2023 13:49:24 +0200 Subject: [PATCH 6/6] new additions look stable --- build_dynamic_prompt.py | 177 +++++++++++++++++---- csvfiles/special_lists/animaladditions.csv | 4 + csvfiles/special_lists/buildaccessorie.csv | 11 ++ prompttester.py | 2 +- userfiles/vehicles_replace.csv | 0 5 files changed, 159 insertions(+), 35 deletions(-) create mode 100644 csvfiles/special_lists/animaladditions.csv create mode 100644 csvfiles/special_lists/buildaccessorie.csv delete mode 100644 userfiles/vehicles_replace.csv diff --git a/build_dynamic_prompt.py b/build_dynamic_prompt.py index e0ce50c..240b65a 100644 --- a/build_dynamic_prompt.py +++ b/build_dynamic_prompt.py @@ -100,11 +100,126 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all buildoutfitlist = csv_to_list("buildoutfit", antilist,"./csvfiles/special_lists/") objectadditionslist = csv_to_list("objectadditions", antilist,"./csvfiles/special_lists/") humanadditionlist = csv_to_list("humanadditions", antilist,"./csvfiles/special_lists/") + animaladditionlist = csv_to_list("animaladditions", antilist,"./csvfiles/special_lists/") + buildaccessorielist = csv_to_list("buildaccessorie", antilist,"./csvfiles/special_lists/") + + + # subjects + mainchooserlist = [] + objectwildcardlist = [] + hybridlist = [] + hybridhumanlist = [] + humanoidsubjectchooserlist = [] + eventsubjectchooserlist = [] + addontolocationinside = [] + addontolocation = [] + + generatevehicle = bool(vehiclelist) + generateobject = bool(objectlist) + generatefood = bool(foodlist) + generatebuilding = bool(buildinglist) + generateobject = generatevehicle + generateobject + generatefood + generatebuilding + + if(generatevehicle): + objectwildcardlist.append("-vehicle-") + hybridlist.append("-vehicle-") + addontolocation.append(vehiclelist) + + if(generateobject): + objectwildcardlist.append("-object-") + hybridlist.append("-object-") + + if(generatefood): + objectwildcardlist.append("-food-") + hybridlist.append("-food-") + + if(generatebuilding): + objectwildcardlist.append("-building-") + hybridlist.append("-building-") + addontolocation.append(buildinglist) + addontolocationinside.append(buildinglist) + + if(generateobject): + mainchooserlist.append("object") + + generatefictionalcharacter = bool(fictionallist) + generatenonfictionalcharacter = bool(nonfictionallist) + generatehumanoids = bool(humanoidlist) + generatemanwoman = bool(manwomanlist) + generatejob = bool(joblist) + generatehumanoid = generatefictionalcharacter + generatenonfictionalcharacter + generatehumanoids + generatemanwoman + generatejob + + + if(generatefictionalcharacter): + humanoidsubjectchooserlist.append("fictional") + hybridlist.append("-fictional-") + hybridhumanlist.append("-fictional-") + + if(generatefictionalcharacter): + humanoidsubjectchooserlist.append("non fictional") + hybridlist.append("-nonfictional-") + hybridhumanlist.append("-nonfictional-") + + if(generatehumanoids): + humanoidsubjectchooserlist.append("humanoid") + hybridlist.append("-humanoid-") + hybridhumanlist.append("-humanoid-") + + if(generatemanwoman): + humanoidsubjectchooserlist.append("human") + + if(generatejob): + humanoidsubjectchooserlist.append("job") + + if(generatehumanoid): + mainchooserlist.append("humanoid") + + + generateanimal = bool(animallist) + + if(generateanimal): + mainchooserlist.append("animal") + hybridlist.append("-animal-") + + generatelandscape = bool(locationlist) + + if(generatelandscape): + mainchooserlist.append("landscape") + addontolocation.append(locationlist) + addontolocationinside.append(locationlist) + + generateevent = bool(eventlist) + generateconcepts = bool(conceptprefixlist) + bool(conceptsuffixlist) + + generateconcept = generateevent + generateconcepts + + if(generateevent): + eventsubjectchooserlist.append("event") + + if(generateconcepts): + eventsubjectchooserlist.append("concept") + + if(generateconcept): + mainchooserlist.append("concept") + + + + + + #mainchooserlist = ["object","animal","humanoid", "landscape", "concept"] + #objectwildcardlist = ["-object-", "-building-","-vehicle-","-food-"] # using wildcards for replacements + #hybridlist = ["-animal-", "-object-", "-fictional-", "-nonfictional-", "-building-", "-vehicle-","-food-"] + #humanoidsubjectchooserlist = ["human", "job", "fictional", "non fictional", "humanoid"] + #eventsubjectchooserlist = ["event", "concept"] + + + + # normals generateoutfit = bool(outfitlist) generatebodytype = bool(bodytypelist) - generateaccesorie = bool(accessorielist) + generateaccessorie = bool(accessorielist) generateartmovement = bool(artmovementlist) generatecamera = bool(cameralist) generatecolorscheme = bool(colorschemelist) @@ -120,6 +235,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all generatequality = bool(qualitylist) generateshot = bool(shotsizelist) generatetimeperiod = bool(timeperiodlist) + generateemoji = bool(emojilist) # specials: generatebackground = bool(backgroundtypelist) @@ -129,9 +245,11 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all generateoutfit = bool(buildoutfitlist) generateobjectaddition = bool(objectadditionslist) generatehumanaddition = bool(humanadditionlist) + generateanimaladdition = bool(animaladditionlist) + generateaccessories = bool(buildaccessorielist) # Smart subject logic - if(givensubject !="" and smartsubject == True): + if(givensubject != "" and smartsubject == True): # Remove any list that has a matching word in the list # Remove any list/logic with keywords, such as: @@ -205,7 +323,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all # accessorielist foundinlist = any(word.lower() in [item.lower() for item in accessorielist] for word in givensubjectlist) if(foundinlist == True): - generateaccesorie = False + generateaccessorie = False # lenslist foundinlist = any(word.lower() in [item.lower() for item in lenslist] for word in givensubjectlist) @@ -326,8 +444,8 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all print("Setting insanity level to " + str(insanitylevel)) # main chooser: 0 object, 1 animal, 2 humanoid, 3 landscape, 4 event/concept - mainchooserlist = ["object","animal","humanoid", "landscape", "concept"] - mainchooser = mainchooserlist[random.randint(0, 4)] + #mainchooserlist = ["object","animal","humanoid", "landscape", "concept"] + mainchooser = random.choice(mainchooserlist) if(forcesubject != "" and forcesubject != "all"): mainchooser = forcesubject @@ -341,17 +459,17 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all else: subjectchooser = "animal as human" if(mainchooser == "humanoid"): - subjectchooserlist = ["human", "job", "fictional", "non fictional", "humanoid"] - subjectchooser = subjectchooserlist[random.randint(0, 4)] + #humanoidsubjectchooserlist = ["human", "job", "fictional", "non fictional", "humanoid"] + subjectchooser = random.choice(humanoidsubjectchooserlist) if(mainchooser == "landscape"): subjectchooser = "landscape" if(mainchooser == "concept"): - subjectchooserlist = ["event", "concept"] - subjectchooser = subjectchooserlist[random.randint(0, 1)] + #eventsubjectchooserlist = ["event", "concept"] + subjectchooser = random.choice(eventsubjectchooserlist) - hybridlist = ["-animal-", "-object-", "-fictional-", "-nonfictional-", "-building-", "-vehicle-","-food-"] - hybridhumanlist = ["-fictional-", "-nonfictional-"] + #hybridlist = ["-animal-", "-object-", "-fictional-", "-nonfictional-", "-building-", "-vehicle-","-food-"] + #hybridhumanlist = ["-fictional-", "-nonfictional-"] # start artist part @@ -501,7 +619,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all completeprompt += random.choice(culturelist) + " " if(mainchooser == "object"): - objectwildcardlist = ["-object-", "-building-","-vehicle-","-food-"] # using wildcards for replacements + # objectwildcardlist = ["-object-", "-building-","-vehicle-","-food-"] # using wildcards for replacements # if we have a given subject, we should skip making an actual subject if(givensubject == ""): @@ -544,10 +662,9 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all hybridorswap = random.choice(hybridorswaplist) completeprompt += "[" - if unique_dist(insanitylevel): - animaladdlist = ["baby", "were", "giant", "monster"] + if(unique_dist(insanitylevel) and generateanimaladdition == True): animaladdedsomething = 1 - completeprompt += random.choice(animaladdlist) + " -animal- " + completeprompt += random.choice(animaladditionlist) + " -animal- " if(animaladdedsomething != 1): completeprompt += random.choice(animallist) + " " @@ -646,8 +763,8 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all if(unique_dist(insanitylevel)): insideshot = 1 completeprompt += " from inside of a " - addontolocation = [locationlist,buildinglist] - completeprompt += random.choice(random.choice(addontolocation)) + " " + #addontolocationinside = [locationlist,buildinglist] + completeprompt += random.choice(random.choice(addontolocationinside)) + " " if(normal_dist(insanitylevel) and insideshot == 0): completeprompt += " and " @@ -656,7 +773,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all if(rare_dist(insanitylevel)): completeprompt += random.choice(culturelist) + " " - addontolocation = [locationlist,buildinglist, vehiclelist] + #addontolocation = [locationlist,buildinglist, vehiclelist] completeprompt += random.choice(random.choice(addontolocation)) + " " @@ -666,7 +783,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all completeprompt += " \"" + random.choice(eventlist) + "\" " if(subjectchooser == "concept"): - completeprompt += " \" The " + random.choice(conceptprefixlist) + " of " + random.choice(conceptsuffixlist) + "\" " + completeprompt += " \" The -conceptprefix- of -conceptsuffix- \" " else: completeprompt += " " + givensubject + " " @@ -685,7 +802,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all # SD understands emoji's. Can be used to manipulate facial expressions. # emoji, legendary - if(subjectchooser in ["animal as human,","human","fictional", "non fictional", "humanoid"] and legendary_dist(insanitylevel)): + if(subjectchooser in ["animal as human,","human","fictional", "non fictional", "humanoid"] and legendary_dist(insanitylevel) and generateemoji== True): completeprompt += random.choice(emojilist) + ", " @@ -722,14 +839,8 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all if(subjectchooser in ["human","job","fictional", "non fictional", "humanoid"] and normal_dist(insanitylevel) and generatehairstyle == True): completeprompt += random.choice(buildhairlist) + ", " - if(subjectchooser in ["animal as human,","human","fictional", "non fictional", "humanoid"] and normal_dist(insanitylevel) and generateaccesorie == True): - completeprompt += random.choice(accessorielist) + ", " - # Sometimes get 2 - if(uncommon_dist(insanitylevel)): - completeprompt += random.choice(accessorielist) + ", " - # or even three, these are fun and often minor :) - if(uncommon_dist(insanitylevel)): - completeprompt += random.choice(accessorielist) + ", " + if(subjectchooser in ["animal as human,","human","fictional", "non fictional", "humanoid"] and normal_dist(insanitylevel) and generateaccessorie == True and generateaccessories == True): + completeprompt += random.choice(buildaccessorielist) + ", " if(legendary_dist(insanitylevel) and subjectchooser not in ["landscape", "concept"] and generateinsideshot == True): insideshot = 1 @@ -920,9 +1031,9 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all # completeprompt = completeprompt.replace('-outfit-', hybridorswapreplacementvalue,1) # lol, this needs a rewrite :D - while "-color-" in completeprompt or "-material-" in completeprompt or "-animal-" in completeprompt or "-object-" in completeprompt or "-fictional-" in completeprompt or "-nonfictional-" in completeprompt or "-conceptsuffix-" in completeprompt or "-building-" in completeprompt or "-vehicle-" in completeprompt or "-outfit-" in completeprompt or "-location-" in completeprompt or "-conceptprefix-" in completeprompt or "-descriptor-" in completeprompt or "-food-" in completeprompt or "-haircolor-" in completeprompt or "-hairstyle-" in completeprompt or "-job-" in completeprompt or "-culture-" in completeprompt: - allwildcardslistnohybrid = [ "-color-","-object-", "-animal-", "-fictional-","-nonfictional-","-building-","-vehicle-","-location-","-conceptprefix-","-food-","-haircolor-","-hairstyle-","-job-"] - allwildcardslistnohybridlists = [colorlist, objectlist, animallist, fictionallist, nonfictionallist, buildinglist, vehiclelist, locationlist,conceptprefixlist,foodlist,haircolorlist, hairstylelist,joblist] + while "-color-" in completeprompt or "-material-" in completeprompt or "-animal-" in completeprompt or "-object-" in completeprompt or "-fictional-" in completeprompt or "-nonfictional-" in completeprompt or "-conceptsuffix-" in completeprompt or "-building-" in completeprompt or "-vehicle-" in completeprompt or "-outfit-" in completeprompt or "-location-" in completeprompt or "-conceptprefix-" in completeprompt or "-descriptor-" in completeprompt or "-food-" in completeprompt or "-haircolor-" in completeprompt or "-hairstyle-" in completeprompt or "-job-" in completeprompt or "-culture-" in completeprompt or "-accessory-" in completeprompt or "-humanoid-" in completeprompt: + allwildcardslistnohybrid = [ "-color-","-object-", "-animal-", "-fictional-","-nonfictional-","-building-","-vehicle-","-location-","-conceptprefix-","-food-","-haircolor-","-hairstyle-","-job-", "-accessory-", "-humanoid-" ] + allwildcardslistnohybridlists = [colorlist, objectlist, animallist, fictionallist, nonfictionallist, buildinglist, vehiclelist, locationlist,conceptprefixlist,foodlist,haircolorlist, hairstylelist,joblist, accessorielist, humanoidlist] allwildcardslistwithhybrid = ["-material-", "-descriptor-", "-outfit-", "-conceptsuffix-","-culture-"] allwildcardslistwithhybridlists =[materiallist, descriptorlist,outfitlist,conceptsuffixlist,culturelist] @@ -980,9 +1091,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all # function def replacewildcard(completeprompt, insanitylevel, wildcard,listname, activatehybridorswap): if(len(listname) == 0): - print("HELLO THERE") - print(wildcard) - print(listname) + # handling empty lists completeprompt = completeprompt.replace(wildcard, "",1) else: diff --git a/csvfiles/special_lists/animaladditions.csv b/csvfiles/special_lists/animaladditions.csv new file mode 100644 index 0000000..c9ca671 --- /dev/null +++ b/csvfiles/special_lists/animaladditions.csv @@ -0,0 +1,4 @@ +baby +were +giant +monster \ No newline at end of file diff --git a/csvfiles/special_lists/buildaccessorie.csv b/csvfiles/special_lists/buildaccessorie.csv new file mode 100644 index 0000000..86c5dbf --- /dev/null +++ b/csvfiles/special_lists/buildaccessorie.csv @@ -0,0 +1,11 @@ +-accessory- +-descriptor- -accessory- +-culture- -accessory- +-color- -accessory- +-accessory-, -accessory- +-descriptor- -accessory-, -accessory- +-descriptor- -accessory-, -descriptor- -accessory- +-descriptor- -accessory-, -culture- -accessory- +-culture- -accessory-, -accessory- +-accessory-, -accessory-, -accessory- +-descriptor- -accessory-, -accessory-, -accessory- \ No newline at end of file diff --git a/prompttester.py b/prompttester.py index a567f07..bd5f12c 100644 --- a/prompttester.py +++ b/prompttester.py @@ -35,4 +35,4 @@ def generateprompts(amount = 1,insanitylevel="5",subject="all", artist="all", im print("") print("All done!") -generateprompts(10,5, "object") \ No newline at end of file +generateprompts(100,10) \ No newline at end of file diff --git a/userfiles/vehicles_replace.csv b/userfiles/vehicles_replace.csv deleted file mode 100644 index e69de29..0000000