Removing values from list on generation of wildcards

This commit is contained in:
AIrjen
2023-06-28 22:09:16 +02:00
parent 24b86d26dc
commit f04298fd37
4 changed files with 53 additions and 12 deletions
+35 -9
View File
@@ -768,6 +768,9 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all
if(onlyartists == True and artistmode == "enhancing"):
artistmode = "normal"
# if there are not enough artists in the list, then just go normal
if(len(artistlist) < 3):
artistmode = "normal"
if(onlyartists == True and step == end):
step = step - 1
@@ -1172,7 +1175,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all
completeprompt += "-timeperiod-, "
if(mainchooser not in ["landscape"] and rare_dist(insanitylevel) and generatefocus == True):
completeprompt += "-focus- "
completeprompt += "-focus-, "
@@ -1201,7 +1204,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all
completeprompt += random.choice(photoadditionlist) + ", "
if(isphoto == 1 and generatecamera == True):
completeprompt += random.choice(cameralist) + ", "
completeprompt += "-camera-, "
if(normal_dist(insanitylevel) or isphoto == 1):
if(generatelens == True):
@@ -1366,9 +1369,9 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all
# custom style list
if(uncommon_dist(insanitylevel) and generatestyle == True):
completeprompt += random.choice(stylestiloralist) + ", "
completeprompt += "-styletilora-, "
if(uncommon_dist(insanitylevel)):
completeprompt += random.choice(stylestiloralist) + ", "
completeprompt += "-styletilora-, "
# custom suffix list
@@ -1407,6 +1410,9 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all
artistmode = artistmodeslist[modeselector]
if artistmode in ["hybrid","switching"] and end - step == 1:
artistmode = "normal"
# if there are not enough artists in the list, then just go normal
if(len(artistlist) < 3):
artistmode = "normal"
if artistmode in ["hybrid", "stopping", "adding","switching"]:
completeprompt += " ["
@@ -1473,7 +1479,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all
if(unique_dist(insanitylevel)): # sometimes, its just nice to have descriptor and a normal "outfit". We use mini outfits for this!
completeprompt = completeprompt.replace("-outfit-", "-minioutfit-",1)
completeprompt = completeprompt.replace("-artist-", "art by -artist-")
# lol, this needs a rewrite :D
@@ -1545,18 +1551,21 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all
"-humanaddition-" in completeprompt or
"-overalladdition-" in completeprompt or
"-focus-" in completeprompt or
"-direction-" in completeprompt):
allwildcardslistnohybrid = [ "-color-","-object-", "-animal-", "-fictional-","-nonfictional-","-building-","-vehicle-","-location-","-conceptprefix-","-food-","-haircolor-","-hairstyle-","-job-", "-accessory-", "-humanoid-", "-manwoman-", "-human-", "-colorscheme-", "-mood-", "-genderdescription-", "-artmovement-", "-malefemale-", "-bodytype-", "-minilocation-", "-minilocationaddition-", "-pose-", "-season-", "-minioutfit-", "-elaborateoutfit-", "-minivomit-", "-vomit-", "-rpgclass-", "-subjectfromfile-", "-brand-", "-space-", "-artist-", "-imagetype-", "-othertype-", "-quality-", "-lighting-", "-camera-", "-lens-","-imagetypequality-", "-poemline-", "-songline-", "-greatwork-", "-artistfantasy-", "-artistpopular-", "-artistromanticism-", "-artistphotography-", "-emoji-", "-timeperiod-", "-shotsize-", "-musicgenre-", "-animaladdition-", "-addontolocationinside-", "-addontolocation-", "-objectaddition-", "-humanaddition-", "-overalladdition-", "-focus-", "-direction-"]
allwildcardslistnohybridlists = [colorlist, objectlist, animallist, fictionallist, nonfictionallist, buildinglist, vehiclelist, locationlist,conceptprefixlist,foodlist,haircolorlist, hairstylelist,joblist, accessorielist, humanoidlist, manwomanlist, humanlist, colorschemelist, moodlist, genderdescriptionlist, artmovementlist, malefemalelist, bodytypelist, minilocationlist, minilocationadditionslist, poselist, seasonlist, minioutfitlist, elaborateoutfitlist, minivomitlist, vomitlist, rpgclasslist, customsubjectslist, brandlist, spacelist, artistlist, imagetypelist, othertypelist, qualitylist, lightinglist, cameralist, lenslist, imagetypequalitylist, poemlinelist, songlinelist, greatworklist, fantasyartistlist, popularartistlist, romanticismartistlist, photographyartistlist, emojilist, timeperiodlist, shotsizelist, musicgenrelist, animaladditionlist, addontolocationinsidelist, addontolocationlist, objectadditionslist, humanadditionlist, overalladditionlist, focuslist, directionlist]
"-direction-" in completeprompt or
"-styletilora-" in completeprompt):
allwildcardslistnohybrid = [ "-color-","-object-", "-animal-", "-fictional-","-nonfictional-","-building-","-vehicle-","-location-","-conceptprefix-","-food-","-haircolor-","-hairstyle-","-job-", "-accessory-", "-humanoid-", "-manwoman-", "-human-", "-colorscheme-", "-mood-", "-genderdescription-", "-artmovement-", "-malefemale-", "-bodytype-", "-minilocation-", "-minilocationaddition-", "-pose-", "-season-", "-minioutfit-", "-elaborateoutfit-", "-minivomit-", "-vomit-", "-rpgclass-", "-subjectfromfile-", "-brand-", "-space-", "-artist-", "-imagetype-", "-othertype-", "-quality-", "-lighting-", "-camera-", "-lens-","-imagetypequality-", "-poemline-", "-songline-", "-greatwork-", "-artistfantasy-", "-artistpopular-", "-artistromanticism-", "-artistphotography-", "-emoji-", "-timeperiod-", "-shotsize-", "-musicgenre-", "-animaladdition-", "-addontolocationinside-", "-addontolocation-", "-objectaddition-", "-humanaddition-", "-overalladdition-", "-focus-", "-direction-", "-styletilora-"]
allwildcardslistnohybridlists = [colorlist, objectlist, animallist, fictionallist, nonfictionallist, buildinglist, vehiclelist, locationlist,conceptprefixlist,foodlist,haircolorlist, hairstylelist,joblist, accessorielist, humanoidlist, manwomanlist, humanlist, colorschemelist, moodlist, genderdescriptionlist, artmovementlist, malefemalelist, bodytypelist, minilocationlist, minilocationadditionslist, poselist, seasonlist, minioutfitlist, elaborateoutfitlist, minivomitlist, vomitlist, rpgclasslist, customsubjectslist, brandlist, spacelist, artistlist, imagetypelist, othertypelist, qualitylist, lightinglist, cameralist, lenslist, imagetypequalitylist, poemlinelist, songlinelist, greatworklist, fantasyartistlist, popularartistlist, romanticismartistlist, photographyartistlist, emojilist, timeperiodlist, shotsizelist, musicgenrelist, animaladditionlist, addontolocationinsidelist, addontolocationlist, objectadditionslist, humanadditionlist, overalladditionlist, focuslist, directionlist, stylestiloralist]
allwildcardslistwithhybrid = ["-material-", "-descriptor-", "-outfit-", "-conceptsuffix-","-culture-", "-objecttotal-"]
allwildcardslistwithhybridlists = [materiallist, descriptorlist,outfitlist,conceptsuffixlist,culturelist, objecttotallist]
# 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)
for wildcard in allwildcardslistwithhybrid:
attachedlist = allwildcardslistwithhybridlists[allwildcardslistwithhybrid.index(wildcard)]
@@ -1580,6 +1589,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all
# function
def replacewildcard(completeprompt, insanitylevel, wildcard,listname, activatehybridorswap):
if(len(listname) == 0):
# handling empty lists
completeprompt = completeprompt.replace(wildcard, "",1)
@@ -1598,7 +1608,18 @@ def replacewildcard(completeprompt, insanitylevel, wildcard,listname, activatehy
completeprompt = completeprompt.replace(wildcard, hybridorswapreplacementvalue,1)
completeprompt = completeprompt.replace(wildcard, random.choice(listname),1)
#if list is not empty
if(bool(listname)):
replacementvalue = random.choice(listname)
listname.remove(replacementvalue)
if(wildcard == "-artist-"):
replacementvalue = "art by " + replacementvalue
else:
replacementvalue = ""
completeprompt = completeprompt.replace(wildcard, replacementvalue,1)
return completeprompt
@@ -1615,6 +1636,9 @@ def cleanup(completeprompt):
# Move the extracted matches to the end of completeprompt
completeprompt += " " + " ".join(matches)
# sometimes if there are not enough artist, we get left we things formed as (:1.2)
completeprompt = re.sub('\(\:\d+\.\d+\)', '', completeprompt)
# all cleanup steps moved here
completeprompt = re.sub('\[ ', '[', completeprompt)
completeprompt = re.sub('\[,', '[', completeprompt)
@@ -1652,6 +1676,8 @@ def cleanup(completeprompt):
completeprompt = re.sub('(?<!\()\s?\(', ' (', completeprompt)
completeprompt = re.sub('\)(?![\s)])', ') ', completeprompt)
completeprompt = completeprompt.strip(", ")
return completeprompt
+2 -1
View File
@@ -127,4 +127,5 @@ Dread
Element
Magic
Underworld
Bird
Bird
-musicgenre--wizards
1 Ocean
127 Element
128 Magic
129 Underworld
130 Bird
131 -musicgenre--wizards
+15 -1
View File
@@ -22,4 +22,18 @@ funk
dance
techno
modern
R&B
R&B
disco
glitch
EDM
happy hardcore
gospel
Lo-Fi
Hi-Fi
New Age
Rock
hard rock
indie rock
psychedelic rock
progressive
trance
1 pop
22 dance
23 techno
24 modern
25 R&B
26 disco
27 glitch
28 EDM
29 happy hardcore
30 gospel
31 Lo-Fi
32 Hi-Fi
33 New Age
34 Rock
35 hard rock
36 indie rock
37 psychedelic rock
38 progressive
39 trance
+1 -1
View File
@@ -46,4 +46,4 @@ def generateprompts(amount = 1,insanitylevel="5",subject="all", artist="all", im
print("")
print("All done!")
generateprompts(10,9,"humanoid","all","only templates mode",False,"","","PREFIXPROMPT" ,"SUFFIXPROMPT","",1,"","",True,"",100)
generateprompts(10,9,"humanoid","all","all",False,"","","PREFIXPROMPT" ,"SUFFIXPROMPT","",1,"","",True,"",100)