From ae7146bb95c62d881f909868a9c1e8c63cc4be44 Mon Sep 17 00:00:00 2001 From: AIrjen <130234949+AIrjen@users.noreply.github.com> Date: Sat, 30 Sep 2023 08:11:43 +0200 Subject: [PATCH] Finished samesubject logic --- build_dynamic_prompt.py | 66 ++++++++++++++++++----- csvfiles/special_lists/buildhair.csv | 2 +- csvfiles/special_lists/humanadditions.csv | 2 +- prompttester.py | 2 +- 4 files changed, 57 insertions(+), 15 deletions(-) diff --git a/build_dynamic_prompt.py b/build_dynamic_prompt.py index ae50938..acabd63 100644 --- a/build_dynamic_prompt.py +++ b/build_dynamic_prompt.py @@ -1957,6 +1957,29 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all # In front and the back? completeprompt = parse_custom_functions(completeprompt, insanitylevel) + # Sometimes change he/she to the actual subject + if(normal_dist(insanitylevel) + and "-human-" in completeprompt or + "-humanoid-" in completeprompt or + "-manwoman-" in completeprompt or + "-job-" in completeprompt or + "-fictional-" in completeprompt or + "-nonfictional-" in completeprompt or + "-firstname-" in completeprompt or + "-malefemale-" in completeprompt): + completeprompt = completeprompt.replace("-heshe-", "-samehumansubject-",1) + + # Sometimes change he/she to the actual subject + if(normal_dist(insanitylevel) + and "-animal-" in completeprompt or + "-object-" in completeprompt or + "-vehicle-" in completeprompt or + "-food-" in completeprompt or + "-objecttotal-" in completeprompt or + "-space-" in completeprompt or + "-flora-" in completeprompt): + completeprompt = completeprompt.replace("-heshe-", "-sameothersubject-",1) + # hair descriptor if(rare_dist(insanitylevel)): # Use base outfit descriptor, until we are not. completeprompt = completeprompt.replace("-hairdescriptor-", "-descriptor-",1) @@ -2680,23 +2703,38 @@ def replacewildcard(completeprompt, insanitylevel, wildcard,listname, activatehy if(wildcard == "-outfit-" or wildcard == "-minioutfit-"): completeprompt = completeprompt.replace("-sameoutfit-", replacementvalue,1) - if(wildcard in ["-animal-" - ,"-human-" + if(wildcard in ["-human-" ,"-humanoid-" - , "-manwoman-" - , "-malefemale-" - , "-object-" - , "-fictional-" + , "-manwoman-" + , "-job-"] + and "-samehumansubject-" in completeprompt): + if(completeprompt.index(wildcard) < completeprompt.index("-samehumansubject-")): + completeprompt = completeprompt.replace("-samehumansubject-", "the " + replacementvalue) + + if(wildcard in ["-fictional-" , "-nonfictional-" - , "-building-" + , "-firstname-"] + and "-samehumansubject-" in completeprompt): + if(completeprompt.index(wildcard) < completeprompt.index("-samehumansubject-")): + completeprompt = completeprompt.replace("-samehumansubject-", replacementvalue) + + # This one last, since then it is the only subject we have left + if(wildcard in ["-malefemale-"] + and "-samehumansubject-" in completeprompt): + if(completeprompt.index(wildcard) < completeprompt.index("-samehumansubject-")): + completeprompt = completeprompt.replace("-samehumansubject-", "the " + replacementvalue,1) + + if(wildcard in ["-animal-" + , "-object-" , "-vehicle-" , "-food-" - , "-job-" - , "-objecttotal-" + , "-objecttotal-" , "-space-" - , "-firstname-"] - and chance_roll(insanitylevel, "uncommon")): - completeprompt = completeprompt.replace("-heshe-", "the " + replacementvalue,1) + , "-flora-"] + and "-sameothersubject-" in completeprompt): + if(completeprompt.index(wildcard) < completeprompt.index("-sameothersubject-")): + completeprompt = completeprompt.replace("-sameothersubject-", "the " + replacementvalue,1) + @@ -2835,6 +2873,10 @@ def parse_custom_functions(completeprompt, insanitylevel = 5): arguments = [arg.strip() for arg in match.split(';')] # Evaluate the 'or()' function and append the result to the results list + + # For debugging, enable these lines + #print(completeprompt) + #print(arguments) or_replacement = custom_or(arguments, insanitylevel) completematch = 'OR(' + match + ')' completeprompt = completeprompt.replace(completematch, or_replacement) diff --git a/csvfiles/special_lists/buildhair.csv b/csvfiles/special_lists/buildhair.csv index 0533cd5..ffee89d 100644 --- a/csvfiles/special_lists/buildhair.csv +++ b/csvfiles/special_lists/buildhair.csv @@ -1,3 +1,3 @@ -OR(;-heshe- has;uncommon) OR(-haircolor-;-hairdescriptor-;-culture-;uncommon) hair OR(styled as -hairstyle-;,;rare) +OR(;-heshe- has;uncommon) OR(-haircolor-;-hairdescriptor-;-culture-;uncommon) hair OR(styled as -hairstyle-;, ;rare) OR(;-heshe- has;uncommon) OR(-haircolor-; -hairstyle-) OR(hairstyle;hair) , -hisher- hair is OR(-haircolor-;-hairdescriptor-;-culture-;uncommon) OR(;and styled as -hairstyle-;rare) \ No newline at end of file diff --git a/csvfiles/special_lists/humanadditions.csv b/csvfiles/special_lists/humanadditions.csv index 5667cea..93bcba6 100644 --- a/csvfiles/special_lists/humanadditions.csv +++ b/csvfiles/special_lists/humanadditions.csv @@ -11,6 +11,6 @@ OR(;, -heshe- is;rare) -miniactivity- OR(in;at) a OR(-location-;-building-;-wate OR(;, -heshe- is;rare) wearing -elaborateoutfit- - OR(-animal-;-humanoid-) OR(;hybrid;normal) OR(;, -heshe-;rare) as -culture- -rpgclass- -OR(;, -heshe- is;rare) sitting in a OR(-descriptor-;uncommon) -chair- +OR(;, -heshe- is;rare) sitting in a OR(;-descriptor-;uncommon) -chair- OR(;, -heshe- is;rare) inside a -container- OR(;, -heshe- is;rare) OR(surrounded by;being looked at by) a OR(couple;group) of OR(;-descriptor-;uncommon) OR(people;-malefemale-s;animals) OR(;wearing OR(;-descriptor-;uncommon) -outfit-;rare) \ No newline at end of file diff --git a/prompttester.py b/prompttester.py index ea23f70..9c9b76e 100644 --- a/prompttester.py +++ b/prompttester.py @@ -51,7 +51,7 @@ def generateprompts(amount = 1,insanitylevel="5",subject="all", artist="all", im print("") print("All done!") -generateprompts(10,10 +generateprompts(100,10 ,"" # subject ,"all","all",False,"","","PREFIXPROMPT" ,"SUFFIXPROMPT -heshe- is looking here"