background things

trying to switch prompt during batches, so far no luck
This commit is contained in:
AIrjen
2023-05-22 21:38:23 +02:00
parent 8f82c07a08
commit 62d8e836ff
5 changed files with 123 additions and 84 deletions
+68 -38
View File
@@ -307,6 +307,17 @@ class Script(scripts.Script):
with gr.Column(scale=2):
ANDtoggle = gr.Dropdown(
ANDtogglemode, label="Prompt seperator mode", value="none")
with gr.Row():
gr.Markdown(
"""
<font size="2">
Other advanced options:
</font>
""")
with gr.Row():
with gr.Column(scale=1):
prompteachiteration = gr.Checkbox(
label="Generate new prompt for each Batch Size", value=False)
with gr.Row():
gr.Markdown(
"""
@@ -624,12 +635,12 @@ class Script(scripts.Script):
return [insanitylevel,subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring, seperator, givensubject, smartsubject, giventypeofimage]
return [insanitylevel,subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring, seperator, givensubject, smartsubject, giventypeofimage, prompteachiteration]
def run(self, p, insanitylevel, subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring,seperator, givensubject, smartsubject, giventypeofimage):
def run(self, p, insanitylevel, subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring,seperator, givensubject, smartsubject, giventypeofimage,prompteachiteration):
images = []
infotexts = []
@@ -664,42 +675,55 @@ class Script(scripts.Script):
for i in range(batches):
if(silentmode == False):
# prompt compounding
print("Starting generating the prompt")
preppedprompt = ""
if(ANDtoggle == "automatic"):
preppedprompt += prefixprompt + ", "
if(artist != "none"):
preppedprompt += build_dynamic_prompt(insanitylevel,subject,artist, imagetype, True, antistring)
if(subject == "humanoid"):
preppedprompt += ", " + promptcompounderlevel + " people"
if(subject == "landscape"):
preppedprompt += ", landscape"
if(subject == "animal"):
preppedprompt += ", " + promptcompounderlevel + " animals"
if(subject == "object"):
preppedprompt += ", " + promptcompounderlevel + " objects"
promptlist = []
negativepromptlist = []
# Either do this once, or for each iteration
if(prompteachiteration==True):
amountofpromptstogen = batchsize
else:
amountofpromptstogen = 1
if(ANDtoggle != "none" and ANDtoggle != "automatic"):
preppedprompt += prefixprompt
if(ANDtoggle != "none"):
if(ANDtoggle!="prefix + prefix + prompt + suffix"):
prefixprompt = ""
if(seperator == "comma"):
preppedprompt += " \n , "
else:
preppedprompt += " \n " + seperator + " "
#Here is where we build a "normal" prompt
preppedprompt += build_dynamic_prompt(insanitylevel,subject,artist, imagetype, False, antistring, prefixprompt, suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage)
for i in range(amountofpromptstogen):
# prompt compounding
print("Starting generating the prompt")
preppedprompt = ""
if(ANDtoggle == "automatic"):
preppedprompt += prefixprompt + ", "
if(artist != "none"):
preppedprompt += build_dynamic_prompt(insanitylevel,subject,artist, imagetype, True, antistring)
if(subject == "humanoid"):
preppedprompt += ", " + promptcompounderlevel + " people"
if(subject == "landscape"):
preppedprompt += ", landscape"
if(subject == "animal"):
preppedprompt += ", " + promptcompounderlevel + " animals"
if(subject == "object"):
preppedprompt += ", " + promptcompounderlevel + " objects"
# set everything ready
p.prompt = preppedprompt
p.negative_prompt = negativeprompt
if(ANDtoggle != "none" and ANDtoggle != "automatic"):
preppedprompt += prefixprompt
if(ANDtoggle != "none"):
if(ANDtoggle!="prefix + prefix + prompt + suffix"):
prefixprompt = ""
if(seperator == "comma"):
preppedprompt += " \n , "
else:
preppedprompt += " \n " + seperator + " "
#Here is where we build a "normal" prompt
preppedprompt += build_dynamic_prompt(insanitylevel,subject,artist, imagetype, False, antistring, prefixprompt, suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage)
if(silentmode == True):
# set everything ready
p.prompt = preppedprompt
p.negative_prompt = negativeprompt
promptlist.append(p.prompt)
negativepromptlist.append(p.negative_prompt)
else:
p.prompt = workprompt
#for j in range(batchsize):
@@ -710,11 +734,17 @@ class Script(scripts.Script):
print(p.prompt)
# finally figured out how to do multiple batch sizes
promptlist = []
for i in range(batchsize):
promptlist.append(p.prompt)
if(prompteachiteration==False):
promptlist = []
negativepromptlist = []
for i in range(batchsize):
promptlist.append(p.prompt)
negativepromptlist.append(p.negative_prompt)
p.prompt = promptlist
p.prompt = preppedprompt
p.all_prompts = promptlist
p.negativeprompt = negativeprompt
p.all_negative_prompts = negativepromptlist
p.batch_size = batchsize
processed = process_images(p)
images += processed.images