From ec3aaacbb20d8daa698af4b223ec603f7fb51c93 Mon Sep 17 00:00:00 2001 From: AIrjen Date: Sat, 13 Jan 2024 17:24:00 +0100 Subject: [PATCH] work on enhance positive --- build_dynamic_prompt.py | 56 +++++++++++++++++++-- csvfiles/basicbitchdescriptors.csv | 2 +- csvfiles/fictional characters.csv | 63 +++++++++++++++++++++++- csvfiles/materialcombinations.csv | 3 +- csvfiles/special_lists/negativewords.csv | 1 + csvfiles/special_lists/wordcombis.csv | 21 ++++++++ enhancepositivetester.py | 36 ++++++++++++++ 7 files changed, 176 insertions(+), 6 deletions(-) create mode 100644 csvfiles/special_lists/wordcombis.csv create mode 100644 enhancepositivetester.py diff --git a/build_dynamic_prompt.py b/build_dynamic_prompt.py index 4cf8469..9814d6c 100644 --- a/build_dynamic_prompt.py +++ b/build_dynamic_prompt.py @@ -147,6 +147,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all episodetitlelist = csv_to_list(csvfilename="episodetitles",antilist=antilist,skipheader=True) tokenlist = [] + # additional descriptor lists outfitdescriptorlist = csv_to_list("outfitdescriptors",antilist) @@ -286,8 +287,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all tokinatorlist = csv_to_list("tokinator", antilist,"./csvfiles/templates/",0,"?") styleslist = csv_to_list("styles", antilist,"./csvfiles/templates/",0,"?") - - + # subjects mainchooserlist = [] objectwildcardlist = [] @@ -1673,7 +1673,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all if(mainchooser in ["object", "animal", "humanoid", "concept"] and othertype == 0 and "portrait" not in completeprompt and generateshot == True and chance_roll(insanitylevel,shotsizechance)): completeprompt += "-shotsize- of a " elif("portrait" in completeprompt and generateshot == True and partlystylemode == False): - completeprompt += " ,close up of a " + completeprompt += " , close up of a " elif(mainchooser in ["landscape"] and generateshot == True and partlystylemode == False): completeprompt += " landscape of a " elif(generateshot == True): @@ -2658,6 +2658,9 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all + # prompt enhancer! + print("hello?") + completeprompt = enhance_positive(completeprompt, insanitylevel) completeprompt += ", " completeprompt += suffixprompt @@ -3888,6 +3891,53 @@ def build_dynamic_negative(positive_prompt = "", insanitylevel = 0, enhance = Fa return negative_result +def enhance_positive(positive_prompt = "", insanitylevel = 5): + + + wordcombilist = csv_to_list(csvfilename="wordcombis", directory="./csvfiles/special_lists/",delimiter="?") + + allwords = split_prompt_to_words(positive_prompt) + allwords = [elem.strip().lower() for elem in allwords] # lower them + + newwordlist = [] + addwords = "" + wordsfound = 0 + + #lower all! + + for combiset in wordcombilist: + + combiwords = set(combiset.split(', ')) + for combiword in combiwords: + for word in allwords: + if(word.lower() == combiword.lower()): + + wordsfound += 1 + combiwords2 = set(combiset.split(', ')) + for combiword2 in combiwords2: + newwordlist.append(combiword2) + + + newprompt = "bla" + + newwordlist = [word for word in newwordlist if word not in allwords] + newwordlist = list(set(newwordlist)) # make unique + + insanitylevel = max(0,insanitylevel - 6) + + j = 0 + for i in range(0,wordsfound): + if(random.randint(0,insanitylevel + j) == 0 and len(newwordlist) > 0): + addwords += ", " + newwordlist.pop(random.randrange(len(newwordlist))) + print(addwords) + j += 1 + + + + positive_prompt += addwords + + return positive_prompt + def replace_match(match): # Extract the first word from the match words = match.group(0)[1:-1].split('|') diff --git a/csvfiles/basicbitchdescriptors.csv b/csvfiles/basicbitchdescriptors.csv index 708778a..a4d705b 100644 --- a/csvfiles/basicbitchdescriptors.csv +++ b/csvfiles/basicbitchdescriptors.csv @@ -14,4 +14,4 @@ gorgeous lovely magnificent pleasant -pretty +pretty \ No newline at end of file diff --git a/csvfiles/fictional characters.csv b/csvfiles/fictional characters.csv index ca7be58..a2cce75 100644 --- a/csvfiles/fictional characters.csv +++ b/csvfiles/fictional characters.csv @@ -515,4 +515,65 @@ Rollo from Vikings;male Goldilocks;female Glinda;female Robin Hood;male -Lilith;female \ No newline at end of file +Lilith;female +Moiraine Damodred;femala +Dexter from dexter's lab;male +Johnny Bravo;male +Donald Duck;male +Scrooge McDuck;male +Daisy Duck;female +Goofy;male +Daffy Duck;male +Sylvanas Windrunner;female +Doomguy;male +Guybrush Threepwood;male +Tom Nook;male +Cayde-6;male +Chloe Price;female +Deckard Cain;male +Commander Shepard;genderless +Rayman;male +Ryu Hayabusa;male +Ayane Hiragana;female +Kasumi;female +Gordon Freeman;male +The Joker;male +Harley Quinn;female +GLaDOS;genderless +Agent 47;male +Sam Fisher;male +Rayne from BloodRayne;female +Sarah Kerrigan;female +Megaman;male +Max Payne;male +Ivy Valentine;female +Chell;female +Ciri;female +Yennefer of Vengerberg;female +Cammy;female +Aerith Gainsborough;female +Lucky Chloe;female +Jin Kazama;male +Heihachi Mishima;male +Akuma;male +Eddy Gordo;male +Lightning from FF13;female +Pacman;male +Jack Sparrow;male +Cersei Lannister;female +Austin Powers;male +Bella Swan;female +Beatrice Prior;female +Beetlejuice;male +Big bird;genderless +Buffy Summers;female +Bridget Jones;female +Catwoman;female +Charlie Brown;male +Cheshire Cat;male +Cookie Monster;male +Daisy Duke;female +Deadpool;male +Doctor Evil;male +Edward Cullen;male +Jessica Rabbit;female \ No newline at end of file diff --git a/csvfiles/materialcombinations.csv b/csvfiles/materialcombinations.csv index 86222b7..c57f38b 100644 --- a/csvfiles/materialcombinations.csv +++ b/csvfiles/materialcombinations.csv @@ -240,4 +240,5 @@ Synthetic Leather and Geometric Patterns Anti-Radiation Fabric and Neoprene Smart Glass and Weather-Resistant Textiles Silicon Rubber and Reflective Strips -Liquid Crystal Polymer and Ultra-Thin Alloy \ No newline at end of file +Liquid Crystal Polymer and Ultra-Thin Alloy +Lilac and Gooseberry's \ No newline at end of file diff --git a/csvfiles/special_lists/negativewords.csv b/csvfiles/special_lists/negativewords.csv index 1547c97..92dbd58 100644 --- a/csvfiles/special_lists/negativewords.csv +++ b/csvfiles/special_lists/negativewords.csv @@ -57,6 +57,7 @@ faded;bright, sunny, light, vibrant, colorful noir;bright, sunny, light, vibrant, colorful horror;bright, sunny, light, vibrant, colorful, beautiful, cute monster;beautiful, cute, adorable +monstrous;beautiful, cute, adorable creepy;beautiful, cute, adorable luminism;monochromatic, washed out fortnite;photograph, realism, photorealism diff --git a/csvfiles/special_lists/wordcombis.csv b/csvfiles/special_lists/wordcombis.csv new file mode 100644 index 0000000..02cb9da --- /dev/null +++ b/csvfiles/special_lists/wordcombis.csv @@ -0,0 +1,21 @@ +alluring, appealing, attractive, beautiful, charming, cozy, cute, elegant, exquisite, flawless, glamourous, good-looking, gorgeous, lovely, magnificent, pleasant, pretty +gothic, dark, moody, monochromatic, ugly, gritty, grim, macabre, goth, horror +cute, kawaii, chibi, endearing, appealing, tiny, lovable, sweet, innocent +photograph, realism, photorealism, photography, photo, RAW photo +industrial, mechanical, photorealism, modernist, minimalist +vibrant, colorful, vivid, expressive, rainbow +dramatic, epic +dynamic, action +ordinary, mundane, plain, common, boring, drab +unattractive, ugly, amateurish +organic, flora, fauna, nature, nature-inspired +dream, dreamy, dreamlike, magic, magical, fantastic, fairy tale +simple, minimalist, minimalistic +futuristic, sci fi, sci-fi, modern +portrait, close up, close-up +fashionable, fashion, haute couture +concept art, fantasy, sci-fi +cinema, cinematic, cinestill, movie still +anime, manga +funny, whimsical, fun +authentic, traditional, classic \ No newline at end of file diff --git a/enhancepositivetester.py b/enhancepositivetester.py new file mode 100644 index 0000000..81904cd --- /dev/null +++ b/enhancepositivetester.py @@ -0,0 +1,36 @@ +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,positive_prompt = "",insanitylevel="0",enhance=False,existing_negative_prompt=""): + loops = int(amount) # amount of images to generate + steps = 0 + originalpositiveprompt = positive_prompt + + insanitylevel = int(insanitylevel) + while steps < loops: + # build prompt + if originalpositiveprompt == "": + positive_prompt = build_dynamic_prompt(insanitylevel=insanitylevel) + result = enhance_positive(positive_prompt=positive_prompt, insanitylevel=insanitylevel) + print("enhanced prompt: " + result) + print("") + print("loop " + str(steps)) + print("") + + + steps += 1 + + + print("") + print("All done!") + +generateprompts(10,"",5,False,"") \ No newline at end of file