|
import sys, os |
|
import random |
|
import uuid |
|
import re |
|
from superprompter.superprompter import * |
|
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",onlyartists=False, workprompt="", antistring="",prefixprompt="", suffixprompt="", negativeprompt="",promptcompounderlevel = "1", seperator="comma",givensubject="",smartsubject=True,giventypeofimage="",imagemodechance=20, gender = "all", subtypeobject = "all", subtypehumanoid = "all", subtypeconcept = "all", advancedprompting = True, hardturnoffemojis=False, seed=0, overrideoutfit="", prompt_g_and_l = False, base_model = "SD1.5", OBP_preset = "", prompt_enhancer="none", preset_prefix = "", preset_suffix =""): |
|
loops = int(amount) |
|
steps = 0 |
|
|
|
insanitylevel = int(insanitylevel) |
|
while steps < loops: |
|
|
|
if(prompt_g_and_l == True): |
|
resultlist = build_dynamic_prompt(insanitylevel,subject,artist,imagetype, onlyartists,antistring,prefixprompt,suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage,imagemodechance, gender, subtypeobject, subtypehumanoid, subtypeconcept, advancedprompting, hardturnoffemojis, seed, overrideoutfit, prompt_g_and_l, base_model, OBP_preset, prompt_enhancer) |
|
result = resultlist[0] |
|
print("prompt_g") |
|
print(resultlist[1]) |
|
print("prompt_l") |
|
print(resultlist[2]) |
|
|
|
else: |
|
result = build_dynamic_prompt(insanitylevel,subject,artist,imagetype, onlyartists,antistring,prefixprompt,suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage,imagemodechance, gender, subtypeobject, subtypehumanoid, subtypeconcept, advancedprompting, hardturnoffemojis, seed, overrideoutfit, prompt_g_and_l, base_model, OBP_preset, prompt_enhancer,"","", preset_prefix, preset_suffix) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print("") |
|
print("loop " + str(steps)) |
|
print("") |
|
if(onlyartists == True): |
|
print(result) |
|
print("") |
|
|
|
if(result.count("-")>1 and imagetype == "only templates"): |
|
print("Is there a mistake in wildcards?") |
|
print("") |
|
print(result) |
|
break |
|
|
|
if(givensubject != "" and givensubject not in result and imagetype == "only templates"): |
|
print("No givensubject, there must be an issue:") |
|
print("") |
|
print(result) |
|
break |
|
|
|
if(overrideoutfit != "" and overrideoutfit not in result and onlyartists == False and "-outfit-" not in overrideoutfit): |
|
print("The outfit override is not showing up!") |
|
print("") |
|
print(result) |
|
break |
|
|
|
if(" OR " in result or ";" in result): |
|
print("There is a mistake in a OR statement") |
|
print("") |
|
print(result) |
|
break |
|
|
|
|
|
|
|
resultnew = result |
|
resultnew = resultnew.replace("-eye-", " eye ") |
|
resultnew = resultnew.replace("-of-", " of ") |
|
resultnew = resultnew.replace("-the-", " the ") |
|
resultnew = resultnew.replace("-up-", " up ") |
|
resultnew = resultnew.replace("-in-", " in ") |
|
resultnew = resultnew.replace("-au-", " au ") |
|
resultnew = resultnew.replace("-da-", " da ") |
|
resultnew = resultnew.replace("-doo-", " doo ") |
|
resultnew = resultnew.replace("-and-", " and ") |
|
resultnew = resultnew.replace("-o-", " o ") |
|
resultnew = resultnew.replace("-horse-", " horse ") |
|
matches = re.findall(r'-\w+-', resultnew) |
|
|
|
|
|
wildcards = [match for match in matches if ',' not in match and ' ' not in match] |
|
|
|
|
|
if(wildcards): |
|
print("There is a wildcard still in the prompt") |
|
print("") |
|
print(result) |
|
break |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
steps += 1 |
|
|
|
|
|
print("") |
|
print("All done!") |
|
|
|
if __name__ == "__main__": |
|
generateprompts(10,5 |
|
,"all" |
|
,"all" |
|
,"all" |
|
, False |
|
,"","" |
|
,"" |
|
,"" |
|
,"",1,"" |
|
,"" |
|
,True, |
|
"",5 |
|
, "all" |
|
, "all" |
|
, "all" |
|
, "all" |
|
, False |
|
, True |
|
, -1 |
|
, "" |
|
, False |
|
, "SDXL" |
|
, "" |
|
, "" |
|
, "hello" |
|
, "" |
|
) |