-
Notifications
You must be signed in to change notification settings - Fork 87
/
prompttester.py
138 lines (115 loc) · 6.65 KB
/
prompttester.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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) # amount of images to generate
steps = 0
insanitylevel = int(insanitylevel)
while steps < loops:
# build prompt
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)
#if(superprompter):
# load_models()
# superpromptresult1 = answer(input_text=result, max_new_tokens=150, repetition_penalty=1.5, temperature=0.5, top_p=0.1, top_k=10, seed=seed)
# superpromptresult2 = answer(input_text="Help me prompt this a little bit better and concise: """ + result + "" , max_new_tokens=150, repetition_penalty=1.5, temperature=0.5, top_p=0.1, top_k=10, seed=seed)
# superpromptresult3 = answer(input_text="Make this more artful: """ + result + "" , max_new_tokens=150, repetition_penalty=1.5, temperature=5.0, top_p=5, top_k=1, seed=seed)
# superpromptresult4 = answer(input_text="Describe this for me please: """ + result + "" , max_new_tokens=150, repetition_penalty=1.5, temperature=5.0, top_p=5, top_k=1, seed=seed)
# unload_models()
#print (result + " --- " + superpromptresult1 + " --- " + superpromptresult2 + " --- " + superpromptresult3 + " --- " + superpromptresult4)
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
# Use regex to find words enclosed by hyphens, the wildcards1
# make some minor exceptions
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)
# Filter out matches with commas and spaces
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
#if("game" in result or "movie" in result or "series" in result):
# print("TEST THIS")
# print("")
# print(result)
# break
steps += 1
print("")
print("All done!")
if __name__ == "__main__":
generateprompts(10,5
,"all" # subject
,"all" # artists
,"all" # image type "only other types", "only templates mode", "all - anime", "art blaster mode", "quality vomit mode", "color cannon mode", "unique art mode", "massive madness mode", "photo fantasy mode", "subject only mode", "fixed styles mode", "dynamic templates mode", "artify mode"
, False # only artists
,"",""
,"" #prefix prompt -- masterpiece, best quality, very aesthetic, absurdres
,"" #suffix prompt
,"",1,""
,"" # subject override
,True, # smart subject
"",5
, "all" # gender
, "all" # object types
, "all" # humanoid types -- all,generic humans,generic human relations, multiple humans, celebrities e.a.,fictional,humanoids, based on job or title,based on first name
, "all" # concept types
, False # prompt switching
, True # Turn off emojis
, -1 # seed
, "" #outfit override
, False #prompt_g_and_l
, "SDXL" #base model
, "" #preset "All (random)..."
, "" # superprompter
, "hello" # preset prefix
, "" # preset suffix
)