diff --git a/build_dynamic_prompt.py b/build_dynamic_prompt.py index 8c8f662..241b028 100644 --- a/build_dynamic_prompt.py +++ b/build_dynamic_prompt.py @@ -10,7 +10,7 @@ from random_functions import * # 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"): +def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all", imagetype = "all", onlyartists = False): completeprompt = ", " @@ -19,8 +19,10 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all humanspecial = 0 wereanimaladded = 0 isweighted = 0 + amountofimagetypes = 0 hybridorswap = "" artistmode = "normal" + insideshot = 0 if(insanitylevel==0): insanitylevel = random.randint(1, 10) # 10 = add everything, 1 is add almost nothing @@ -58,7 +60,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all # possible?: think about curated artist list? artistsplacement = "front" - if(uncommon_dist(insanitylevel)): + if(uncommon_dist(insanitylevel) and onlyartists == False): artistsplacement = "back" if(artists == "all" and artistsplacement == "front"): @@ -84,9 +86,14 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all if modeselector < 5 and end - step >= 2: artistmodeslist = ["hybrid", "stopping", "adding", "switching", "enhancing"] artistmode = artistmodeslist[modeselector] - if artistmode in ["hybrid","switching"] and end - step == 1: + if (artistmode in ["hybrid","switching"] and end - step == 1): artistmode = "normal" + if(onlyartists == True and artistmode == "enhancing"): + artistmode = "normal" + if(onlyartists == True and step == end): + step = step - 1 + if artistmode in ["hybrid", "stopping", "adding","switching"]: completeprompt += " [" @@ -124,14 +131,31 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all completeprompt += "]" + if(onlyartists == True): + completeprompt = completeprompt.strip(", ") + print("only generated these artists:" + completeprompt) + return completeprompt + + completeprompt = completeprompt + ", " + + if artistmode in ["enhancing"]: completeprompt += " [" - if(imagetype != "all"): - completeprompt += " " + imagetype + " " - elif(normal_dist(insanitylevel)): + if(imagetype != "all" and imagetype != "all - force multiple" and imagetype != "only other types"): + completeprompt += " " + imagetype + ", " + elif(imagetype == "all - force multiple" or unique_dist(insanitylevel)): + amountofimagetypes = random.randint(2,3) + elif(imagetype == "only other types"): + othertype = 1 + completeprompt = add_from_csv(completeprompt, "othertypes", 1, ""," of a ") + + if(imagetype == "all" and normal_dist(insanitylevel) and amountofimagetypes <= 1): + amountofimagetypes = 1 + + for i in range(amountofimagetypes): # one in 6 images is a complex/other type if(random.randint(0,5) < 5): completeprompt = add_from_csv(completeprompt, "imagetypes", 1, "",",") @@ -140,9 +164,9 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all completeprompt = add_from_csv(completeprompt, "othertypes", 1, ""," of a ") - if(mainchooser in ["object", "animal", "humanoid", "concept"] and othertype == 0 and "portait" not in completeprompt): + if(mainchooser in ["object", "animal", "humanoid", "concept"] and othertype == 0 and "portrait" not in completeprompt): completeprompt = add_from_csv(completeprompt, "shotsizes", 0, ""," of a ") - elif("portait" in completeprompt): + elif("portrait" in completeprompt): completeprompt += " ,close up of a " # Multiple subjects doesnt really work, need to think of other way to do multiple subjects. Maybe AND in the prompt? # if(subjectchooser in ["object", "animal", "humanoid"] and rare_dist(insanitylevel)): @@ -277,7 +301,14 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all completeprompt += ":" + "-location-" + ":" + str(random.randint(1,5)) + "]" hybridorswap = "" - if(normal_dist(insanitylevel)): + # shots from inside can create cool effects in landscapes + if(legendary_dist(insanitylevel)): + insideshot = 1 + completeprompt += " from inside of a " + addontolocation = ["locations","buildings"] + completeprompt = add_from_csv(completeprompt, random.choice(addontolocation), 0, "","") + + if(normal_dist(insanitylevel) and insideshot == 0): completeprompt += " and " if(rare_dist(insanitylevel)): completeprompt = add_from_csv(completeprompt, "descriptors", 0, "","") @@ -286,6 +317,8 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all addontolocation = ["locations","buildings", "vehicles"] completeprompt = add_from_csv(completeprompt, random.choice(addontolocation), 0, "","") + + if(subjectchooser == "event"): completeprompt = add_from_csv(completeprompt, "events", 0, "\"","\"") @@ -315,6 +348,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all humanspecial = 1 speciallist = [" riding a -animal- ", "holding a -object- ", " driving a -vehicle-", " visiting a -building-", "with a -animal-", "surrounded by -object-s"] completeprompt += random.choice(speciallist) + # SD understands emoji's. Can be used to manipulate facial expressions. # emoji, legendary @@ -377,8 +411,13 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all if(uncommon_dist(insanitylevel)): completeprompt = add_from_csv(completeprompt, "accessories", 1, "","") + if(legendary_dist(insanitylevel) and subjectchooser not in ["landscape", "concept"]): + insideshot = 1 + completeprompt += ", from inside of a " + addontolocation = ["locations","buildings"] + completeprompt = add_from_csv(completeprompt, random.choice(addontolocation), 0, "","") - if(subjectchooser not in ["landscape", "concept"] and humanspecial != 1 and normal_dist(insanitylevel)): + if(subjectchooser not in ["landscape", "concept"] and humanspecial != 1 and insideshot == 0 and normal_dist(insanitylevel)): backgroundtypelist = ["landscape", "buildingbackground", "insidebuilding"] backgroundtype = random.choice(backgroundtypelist) if(backgroundtype == "landscape"): @@ -439,6 +478,9 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all if(uncommon_dist(insanitylevel)): completeprompt = add_from_csv(completeprompt, "vomit", 1, "","") + #adding a great work of art, like starry night has cool effects. But this should happen only very rarely. + if(novel_dist(insanitylevel)): + completeprompt = add_from_csv(completeprompt, "greatworks", 1, "in style of ","") # everyone loves the adding quality. The better models don't need this, but lets add it anyway if(uncommon_dist(insanitylevel)): @@ -582,7 +624,6 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all completeprompt = re.sub(',\(', ', (', completeprompt) completeprompt = re.sub('a The', 'The', completeprompt) - completeprompt = re.sub('ss ', 's ', completeprompt) completeprompt = re.sub(' +', ' ', completeprompt[2:]) # remove first character, that is always a comma. Remove any excess spaces diff --git a/csvfiles/accessories.csv b/csvfiles/accessories.csv index 6cd89d4..23d3889 100644 --- a/csvfiles/accessories.csv +++ b/csvfiles/accessories.csv @@ -102,6 +102,11 @@ Circlet -vehicle- Tattoo -building- Tattoo Three-eyed +one-eyed Hair ribbons Fangs -Belts \ No newline at end of file +Belts +-material- helmet +Cape +Cloak +-material- trimmings \ No newline at end of file diff --git a/csvfiles/animals.csv b/csvfiles/animals.csv index e2472b3..e2590a5 100644 --- a/csvfiles/animals.csv +++ b/csvfiles/animals.csv @@ -324,4 +324,14 @@ Brachiosaurus Allosaurus Ankylosaurus Diplodocus -Pterodactyl \ No newline at end of file +Pterodactyl +Pikachu +Charizard +Mewtwo +Bulbasaur +Squirtle +Jigglypuff +Snorlax +Eevee +Gyarados +Dragonite \ No newline at end of file diff --git a/csvfiles/artmovements.csv b/csvfiles/artmovements.csv index c60356c..0a67397 100644 --- a/csvfiles/artmovements.csv +++ b/csvfiles/artmovements.csv @@ -134,4 +134,5 @@ Minecraft MinecraftCore Orientalism Art Dieselpunk -Synthwave Art \ No newline at end of file +Synthwave Art +Emopunk \ No newline at end of file diff --git a/csvfiles/buildings.csv b/csvfiles/buildings.csv index 26d8b1b..36e6f73 100644 --- a/csvfiles/buildings.csv +++ b/csvfiles/buildings.csv @@ -173,4 +173,8 @@ The Sydney Opera House The Eiffel Tower The Pyramids of Teotihuacan The Burj Khalifa -The Golden Gate Bridge \ No newline at end of file +The Golden Gate Bridge +Stargate +Portal +Monolith +-color- Monoliths \ No newline at end of file diff --git a/csvfiles/colors.csv b/csvfiles/colors.csv index eebea9a..9949db4 100644 --- a/csvfiles/colors.csv +++ b/csvfiles/colors.csv @@ -45,4 +45,5 @@ Neon Lime green Rainbow Psychedelic -Gradient \ No newline at end of file +Gradient +Pearlescent \ No newline at end of file diff --git a/csvfiles/concept_prefix.csv b/csvfiles/concept_prefix.csv index 2c1a4cf..759f096 100644 --- a/csvfiles/concept_prefix.csv +++ b/csvfiles/concept_prefix.csv @@ -93,4 +93,6 @@ Gift Pillars Burden Dawn -Need \ No newline at end of file +Need +Shape +Labyrinth \ No newline at end of file diff --git a/csvfiles/concept_suffix.csv b/csvfiles/concept_suffix.csv index 1f88e3c..3da9864 100644 --- a/csvfiles/concept_suffix.csv +++ b/csvfiles/concept_suffix.csv @@ -75,4 +75,7 @@ Pain Beauty Blood Elegance -Study \ No newline at end of file +Study +Metal +Paradise +Sea \ No newline at end of file diff --git a/csvfiles/cultures.csv b/csvfiles/cultures.csv index 420d86d..db224ac 100644 --- a/csvfiles/cultures.csv +++ b/csvfiles/cultures.csv @@ -173,4 +173,7 @@ Georgian Regency Atomic Age Digital Age -Baroque \ No newline at end of file +Baroque +Pirate +Dark ages +Burlesque \ No newline at end of file diff --git a/csvfiles/descriptors.csv b/csvfiles/descriptors.csv index da6944a..6746db3 100644 --- a/csvfiles/descriptors.csv +++ b/csvfiles/descriptors.csv @@ -283,4 +283,9 @@ Folded Glam Chic Zen -Rustic \ No newline at end of file +Rustic +Rich +Varied +Injured +Scrumptious +Kintsugi \ No newline at end of file diff --git a/csvfiles/fictional characters.csv b/csvfiles/fictional characters.csv index 531e7ef..ff52af6 100644 --- a/csvfiles/fictional characters.csv +++ b/csvfiles/fictional characters.csv @@ -30,7 +30,6 @@ Tinker Bell Peter Pan Captain Hook Winnie the Pooh -Shrek Donkey from Shrek Fiona from Shrek Pinocchio @@ -58,11 +57,6 @@ Slinky Dog from Toy Story Jessie from Toy Story Rex from Toy Story Hamm from Toy Story -Nemo from Finding Nemo -Dory from Finding Nemo -Marlin from Finding Nemo -Crush from Finding Nemo -Squirt from Finding Nemo Lightning McQueen from Cars Mater from Cars Doc Hudson from Cars @@ -71,9 +65,6 @@ Sulley Randall Boggs Remy from Ratatouille Linguini from Ratatouille -Carl Fredricksen from Up -Dug from Up -Russell from Up Joy from Inside Out Sadness from Inside Out Anger from Inside Out @@ -225,12 +216,6 @@ Tauriel Thranduil Arwen Glorfindel -Beren -Luthien -Melian -Tuor -Idril -Earendil Harry Potter Hermione Granger Ron Weasley @@ -370,21 +355,18 @@ Ryu Ken Masters Chun-Li Sub-Zero -Scorpion +Scorpion from Mortal Kombat Solid Snake Big Boss Ezio Auditore Altair Ibn-La'Ahad Aloy -Joel -Ellie Geralt of Rivia Trevor Philips Michael De Santa Franklin Clinton Niko Bellic Tommy Vercetti -CJ Marcus Fenix Dom Santiago Arthur Morgan @@ -392,23 +374,12 @@ John Marston Red Dead Redemption Arthur Curry Cole MacGrath -Bugs Bunny SpongeBob SquarePants Homer Simpson -Scooby-Doo -Tom and Jerry -Pikachu -Woody Woodpecker Betty Boop -Mickey Mouse -Donald Duck -Goofy -Daffy Duck -Garfield Bart Simpson Fred Flintstone Shrek -Stewie Griffin Pink Panther Popeye Charlie Brown @@ -435,81 +406,69 @@ Kyle Broflovski Peter Griffin Brian Griffin Stewie Griffin -Bender +Bender from Futurama Fry from Futurama Leela from Futurama Roger from American Dad -Steve Smith from American Dad -Homer Simpson from The Simpsons -Walter White from Breaking Bad -Tony Soprano from The Sopranos -Don Draper from Mad Men -Ross Geller from Friends -Jerry Seinfeld from Seinfeld -Michael Scott from The Office -Carrie Bradshaw from Sex and the City -Buffy Summers from Buffy the Vampire Slayer -Tyrion Lannister from Game of Thrones -Olivia Pope from Scandal -Dexter Morgan from Dexter -Meredith Grey from Grey's Anatomy -Rachel Green from Friends -Sheldon Cooper from The Big Bang Theory -Lorelai Gilmore from Gilmore Girls -Cookie Lyon from Empire -Barney Stinson from How I Met Your Mother -Daenerys Targaryen from Game of Thrones -Sherlock Holmes from Sherlock -Leslie Knope from Parks and Recreation -Alicia Florrick from The Good Wife +Steve Smith +Walter White +Tony Soprano +Don Draper +Ross Geller +Jerry Seinfeld +Michael Scott +Carrie Bradshaw +Buffy Summers +Tyrion Lannister +Olivia Pope +Dexter Morgan +Meredith Grey +Rachel Green +Sheldon Cooper +Lorelai Gilmore +Cookie Lyon +Barney Stinson +Daenerys Targaryen +Sherlock Holmes +Leslie Knope +Alicia Florrick Eleven from Stranger Things -Carrie Mathison from Homeland -Mindy Lahiri from The Mindy Project +Carrie Mathison +Mindy Lahiri Agent Dale Cooper from Twin Peaks -Eric Cartman from South Park -Will Byers from Stranger Things -Dr. House from House -Claire Underwood from House of Cards -Rick Grimes from The Walking Dead -Carrie Brownstein from Portlandia -Abed Nadir from Community -Agent Mulder from The X-Files -Carmela Soprano from The Sopranos -Fred Flintstone from The Flintstones -Leslie Poole from Veep -Jesse Pinkman from Breaking Bad -Lorelei Lee from The Marvelous Mrs. Maisel -Tracy Jordan from 30 Rock -Omar Little from The Wire -Dwight Schrute from The Office -Tyrone Biggums from Chappelle's Show -Omarosa Manigault Newman from The Apprentice -Issa Dee from Insecure -David Brent from The Office -Betty Draper from Mad Men -Kenny Powers from Eastbound & Down -Selina Meyer from Veep -Peggy Olson from Mad Men +Eric Cartman +Will Byers +Dr. House +Claire Underwood +Rick Grimes +Carrie Brownstein +Abed Nadir +Agent Mulder +Carmela Soprano +Leslie Poole +Jesse Pinkman +Lorelei Lee +Tracy Jordan +Omar Little +Dwight Schrute +Tyrone Biggums +Omarosa Manigault Newman +Issa Dee +David Brent +Betty Draper +Kenny Powers +Selina Meyer +Peggy Olson Ash Ketchum Misty from pokemon Brock from pokemon -Gary Oak from pokemon -Professor Oak from pokemon -Nurse Joy from pokemon -Officer Jenny from pokemon +Gary Oak +Professor Oak +Nurse Joy +Officer Jenny Jessie from pokemon James from pokemon Team rocket -Pikachu -Charizard -Mewtwo -Bulbasaur -Squirtle -Jigglypuff -Snorlax -Eevee -Gyarados -Dragonite John Wick Captain -material-beard -animal-man @@ -541,4 +500,7 @@ Levi Ackerman Saitama Jotaro Kujo Guts -Alucard \ No newline at end of file +Alucard +-animal- like human +Kermit the frog +Miss piggy \ No newline at end of file diff --git a/csvfiles/greatworks.csv b/csvfiles/greatworks.csv new file mode 100644 index 0000000..a105d4f --- /dev/null +++ b/csvfiles/greatworks.csv @@ -0,0 +1,13 @@ +Starry Night +Mona Lisa +Laocoön +the david +girl with the pearl earring +the birth of venus +the last supper +the great wave +Venus of Willendorf +Bust of Nefertiti +Christ Pantocrator +The Creation of Adam +The Scream \ No newline at end of file diff --git a/csvfiles/hairstyles.csv b/csvfiles/hairstyles.csv index 2f99dc4..81c5548 100644 --- a/csvfiles/hairstyles.csv +++ b/csvfiles/hairstyles.csv @@ -101,4 +101,5 @@ Side-swept curls Pigtails Braided pigtails Space buns -Mermaid waves \ No newline at end of file +Mermaid waves +Balayage \ No newline at end of file diff --git a/csvfiles/imagetypes.csv b/csvfiles/imagetypes.csv index 7278b2c..61925fa 100644 --- a/csvfiles/imagetypes.csv +++ b/csvfiles/imagetypes.csv @@ -31,5 +31,6 @@ Unreal Engine VRay Abstract Fractal -Portait -Raw digital photo \ No newline at end of file +portrait +Raw digital photo +Airbrush painting \ No newline at end of file diff --git a/csvfiles/jobs.csv b/csvfiles/jobs.csv index a9cbf39..a06651f 100644 --- a/csvfiles/jobs.csv +++ b/csvfiles/jobs.csv @@ -359,4 +359,6 @@ Sultan Geisha Yogi Adventurer -Royalty \ No newline at end of file +Royalty +Cowboy +Cowgirl \ No newline at end of file diff --git a/csvfiles/lighting.csv b/csvfiles/lighting.csv index f257355..27d56cf 100644 --- a/csvfiles/lighting.csv +++ b/csvfiles/lighting.csv @@ -33,4 +33,5 @@ Black lighting Gel lighting -color- lighting Moonlight -Sunlight \ No newline at end of file +Sunlight +Accent lighting \ No newline at end of file diff --git a/csvfiles/locations.csv b/csvfiles/locations.csv index af8b7c8..b150a74 100644 --- a/csvfiles/locations.csv +++ b/csvfiles/locations.csv @@ -669,4 +669,9 @@ The Great Barrier Reef The Terracotta Army The Moai of Easter Island -material- caverns -city of -material- \ No newline at end of file +city of -material- +-color- nebula +Wormhole +Portal +Bamboo Forest +Labyrinth \ No newline at end of file diff --git a/csvfiles/materials.csv b/csvfiles/materials.csv index 2bfb1e8..d455345 100644 --- a/csvfiles/materials.csv +++ b/csvfiles/materials.csv @@ -109,4 +109,8 @@ Vines Cobblestone Moss Scales -Alabaster \ No newline at end of file +Alabaster +Jelly +Pearl +Opal +Diamond \ No newline at end of file diff --git a/csvfiles/moods.csv b/csvfiles/moods.csv index d68cc77..f73d362 100644 --- a/csvfiles/moods.csv +++ b/csvfiles/moods.csv @@ -28,4 +28,6 @@ Horror Dark Light Relaxed -Tranquil \ No newline at end of file +Tranquil +Regret +Suffering \ No newline at end of file diff --git a/csvfiles/objects.csv b/csvfiles/objects.csv index aa95a4d..d02d2a1 100644 --- a/csvfiles/objects.csv +++ b/csvfiles/objects.csv @@ -401,4 +401,5 @@ Baklava Strudel Beignet Scone -Bread \ No newline at end of file +Bread +Skull \ No newline at end of file diff --git a/csvfiles/othertypes.csv b/csvfiles/othertypes.csv index 3524f5b..24489a4 100644 --- a/csvfiles/othertypes.csv +++ b/csvfiles/othertypes.csv @@ -79,4 +79,11 @@ mandala zentangle Natural parks travel poster Stained glass window -Miniature diorama \ No newline at end of file +Miniature diorama +Anime key visual +Multiple layers of silhouette +Retro comic style artwork +Metal pin +a felt muppet +Glitch art +a ceramic coffee mug \ No newline at end of file diff --git a/csvfiles/outfits.csv b/csvfiles/outfits.csv index 6337398..3dcba64 100644 --- a/csvfiles/outfits.csv +++ b/csvfiles/outfits.csv @@ -191,7 +191,7 @@ Onesie or footed pajamas Sleep shorts and tank top Boxer shorts and t-shirt Nightshirt and leggings -Satin or silk chemise +Satin chemise Babydoll Kimono Wedding dress @@ -486,6 +486,7 @@ Field jacket Chore coat Raincoat Fur coat +Fur trimmed coat Armor Short skirt and a long jacket -material- outfit diff --git a/csvfiles/poses.csv b/csvfiles/poses.csv index bb7bc2f..6e6c07c 100644 --- a/csvfiles/poses.csv +++ b/csvfiles/poses.csv @@ -62,4 +62,6 @@ fashion modeling pose relaxing pose sleeping pose Contrapposto -Tilted head \ No newline at end of file +Tilted head +Action scene +Fluid movement \ No newline at end of file diff --git a/csvfiles/shotsizes.csv b/csvfiles/shotsizes.csv index fcdd651..6ebdfd6 100644 --- a/csvfiles/shotsizes.csv +++ b/csvfiles/shotsizes.csv @@ -36,4 +36,5 @@ cinematic shot overhead angle Sharp focus Street level shot -Fashion shot \ No newline at end of file +Fashion shot +Full length frame \ No newline at end of file diff --git a/csvfiles/vomit.csv b/csvfiles/vomit.csv index 91292ad..acd1e3d 100644 --- a/csvfiles/vomit.csv +++ b/csvfiles/vomit.csv @@ -49,4 +49,6 @@ Light sparkles Complex background Plain white background Zentangle -Mandala \ No newline at end of file +Mandala +Luminous trails +Kintsugi \ No newline at end of file diff --git a/random_functions.py b/random_functions.py index cc35dfd..4d7e00d 100644 --- a/random_functions.py +++ b/random_functions.py @@ -24,4 +24,10 @@ def unique_dist(insanitylevel): roll = (random.randint(1, 75) There are an immense number of image types, not only paintings and photo's, but also isometric renders and funko pops. You can however, overwrite it with the most popular ones. + + + 1. all --> normally picks a image type as random. Can choose a 'other' more unique type. + + 2. all - force multiple --> idea by redditor WestWordHoeDown, it forces to choose between 2 and 3 image types - 1. photograph + 3. photograph - 2. octane render + 4. octane render - 3. digital art + 5. digital art - 4. concept art + 6. concept art - 5. painting + 7. painting - 6. portait + 6. portrait + + 7. anime key visual + + 8. only other types --> Will pick only from the more unique types, such as stained glass window or a funko pop + + + + ### Location of existing prompt + + + If you put a prompt in the prompt field, it will be added onto the generated prompt. You can determine where to put it in the front or the back of the generated prompt. + + 1. at the back + + 2. in the front """ ) - return [insanitylevel,subject, artist, imagetype, promptlocation] + with gr.Tab("Workflow assist"): + with gr.Row(): + silentmode = gr.Checkbox( + label="surpressing mode, turns off prompt generation") + with gr.Row(): + gr.Markdown( + """ + + Workflow assist, suggestions by redditor Woisek. + + With surpressing mode, you turn off the automatic generation of new prompts on 'generate', and can just use normal prompting. So you can work and finetune any fun prompts without turning of the script. + + Below here, you can generate a set of random prompts, and start working from there instead. It works on the settings in the Main tab. + + """) + with gr.Row(): + genprom = gr.Button("Generate me some prompts!") + with gr.Row(): + prompt1 = gr.Textbox(label="prompt 1") + with gr.Row(): + prompt2 = gr.Textbox(label="prompt 2") + with gr.Row(): + prompt3 = gr.Textbox(label="prompt 3") + with gr.Row(): + prompt4 = gr.Textbox(label="prompt 4") + with gr.Row(): + prompt5 = gr.Textbox(label="prompt 5") + with gr.Tab("Advanced"): + with gr.Row(): + promptcompounderlevel = gr.Dropdown( + promptcompounder, label="Prompt compunder", value=1) + with gr.Row(): + ANDtoggle = gr.Dropdown( + ANDtogglemode, label="Prompt seperator mode", value="comma") + with gr.Row(): + gr.Markdown( + """ + ### Prompt compounder + + + Normally, it creates a single random prompt. With prompt compounder, it will generate multiple prompts and compound them together. + + Keep at 1 for normal behavior. + Set to different values to compound that many prompts together. My suggestion is to try 2 first. + + This was originally a bug in the first release when using multiple batches, now brought back as a feature. + Raised by redditor drone2222, to bring this back as a toggle, since it did create interesting results. So here it is. + + You can toggle the separator mode. Standardly this is a comma, but you can choose an AND and a newline. + + You can also choose for "current prompt + AND". This is best used in conjuction with the Latent Couple extension when you want some control. Set the prompt compounder equal to the amount of areas defined in Laten Couple. + + Example flow: + + Set the Latent Couple extension to 2 area's (standard setting) + + In the main tab, set the subject to humanoids + + In the prompt field then add for example: Art by artistname, 2 people + + Set the prompt compounder to: 2 + + "automatic AND" is entirely build around Latent Couple. It will pass artists and the amount of people/animals/objects to generate in the prompt automatically. Set the prompt compounder equal to the amount of areas defined in Laten Couple. + + Example flow: + + Set the Latent Couple extension to 2 area's (standard setting) + + In the main tab, set the subject to humanoids + + Leave the prompt field empty + + Set the prompt compounder to: 2 + + + + + """ + ) + genprom.click(gen_prompt, inputs=[insanitylevel,subject, artist, imagetype], outputs=[prompt1, prompt2, prompt3,prompt4,prompt5]) + + + + + return [insanitylevel,subject, artist, imagetype, promptlocation, promptcompounderlevel, ANDtoggle, silentmode] - def run(self, p, insanitylevel, subject, artist, imagetype, promptlocation): + + + + def run(self, p, insanitylevel, subject, artist, imagetype, promptlocation, promptcompounderlevel, ANDtoggle, silentmode): images = [] infotexts = [] - if p.prompt != "": + if(silentmode and p.prompt != ""): + print("Silent mode turned on, not generating a prompt. Using current prompt.") + elif(silentmode): + print("Warning, silent mode is turned on, but no current prompt has been given.") + elif p.prompt != "": print("Prompt is not empty, adding current prompt " + promptlocation + " of the generated prompt") batches = p.n_iter @@ -120,14 +243,56 @@ class Script(scripts.Script): originalprompt = p.prompt + for i in range(batches): - if(promptlocation == "in the front"): - p.prompt = originalprompt + ", " + build_dynamic_prompt(insanitylevel,subject,artist, imagetype) - else: - p.prompt = build_dynamic_prompt(insanitylevel,subject,artist, imagetype) + ", " + originalprompt # add existing prompt to the back? + if(silentmode == False): + # prompt compounding + print("Starting generating the prompt") + preppedprompt = "" + if(ANDtoggle == "automatic AND" and originalprompt == ""): + if(artist != "none"): + originalprompt += build_dynamic_prompt(insanitylevel,subject,artist, imagetype, True) + if(subject == "humanoid"): + originalprompt += ", " + str(promptcompounderlevel) + " people" + if(subject == "landscape"): + originalprompt += ", landscape" + if(subject == "animal"): + originalprompt += ", " + str(promptcompounderlevel) + " animals" + if(subject == "object"): + originalprompt += ", " + str(promptcompounderlevel) + " objects" + + if(ANDtoggle != "AND" and ANDtoggle != "comma" and originalprompt != ""): + preppedprompt += originalprompt + " \n AND " + + for i in range(promptcompounderlevel): + if(ANDtoggle == "automatic AND"): + preppedprompt += originalprompt + ", " + build_dynamic_prompt(insanitylevel,subject,"none", imagetype) + elif(ANDtoggle != "AND" and ANDtoggle != "comma" and originalprompt != ""): + preppedprompt += originalprompt + ", " + build_dynamic_prompt(insanitylevel,subject,artist, imagetype) + else: + preppedprompt += build_dynamic_prompt(insanitylevel,subject,artist, imagetype) + if(i + 1 != promptcompounderlevel): + if(ANDtoggle == "comma"): + preppedprompt += ", " + else: + preppedprompt += " \n AND " + + + if(promptlocation == "in the front" and originalprompt != "" and (ANDtoggle == "AND" or ANDtoggle == "comma")): + p.prompt = originalprompt + ", " + preppedprompt + elif(promptlocation == "at the back" and originalprompt != "" and (ANDtoggle == "AND" or ANDtoggle == "comma")): + p.prompt = preppedprompt + ", " + originalprompt # add existing prompt to the back? + else: + p.prompt = preppedprompt # dont add anything + + for j in range(batchsize): + print(" ") + print("Full prompt to be processed:") + print(" ") + print(p.prompt) processed = process_images(p) images += processed.images infotexts += processed.infotexts @@ -135,7 +300,8 @@ class Script(scripts.Script): # Only move up a seed, when there are multiple batchsizes, and we had the first one done. if(initialbatchsize != 1): p.seed += 1 - + + p.seed +=1 # just return all the things p.n_iter = 0 p.batch_size = 0