Autorunner (#25)

* Some first steps

* Fancy filename work

and started on model choosing

* progress

* Decent first version working

* Stabilisation and fixes

* Added quality gate

Started reworking how prompts are generated from scripts. So it works more in line with One Button run

* Reworked how prompt compounder works

* Started some work on IMG2IMG

* Some changes and fixes

* Added img2img options to interface

* First version of ultimate sd upscale

Some fun with buttons as well

* added ultimate SD upscale logic to UI

some small bugfixes as well

* controlnet tile resample integration (!!!)

* Some changes

Controlnet is misbehaving, researching

* Fixed controlnet

started work on extras upscaling

* Finished upscale with extras

* Working on upscale only mode

* Some stability and Ui changes

* Minor changes

* Update one_button_run_and_upscale.md

Started work on user_guide

* Minor bug in size choosing

* Update one_button_run_and_upscale.md

* Update README.md

* Update my_first_generation.md

* Update my_first_generation.md

* Update my_first_generation.md

* added folder button

hacky fix for PLMS en UniPC

* Update my_first_generation.md

* Update README.md

* Update my_first_generation.md

* Update one_button_run_and_upscale.md

* last bits

finally stable?

* last bug?

* Update one_button_run_and_upscale.md

* Stability fixes

* fixing the last bug
This commit is contained in:
AIrjen
2023-05-13 16:29:53 +02:00
committed by GitHub
parent 8385fcdb95
commit 849d965af5
15 changed files with 1958 additions and 709 deletions
+376 -60
View File
@@ -1,20 +1,58 @@
import modules.scripts as scripts
import gradio as gr
import os
import platform
import subprocess as sp
from modules import images
from modules.processing import process_images, Processed
from modules.processing import Processed
from modules.shared import opts, cmd_opts, state
from build_dynamic_prompt import *
from main import *
from model_lists import *
subjects = ["all","object","animal","humanoid", "landscape", "concept"]
artists = ["all", "none", "popular", "greg mode", "3D", "abstract", "angular", "anime" ,"architecture", "art nouveau", "art deco", "baroque", "bauhaus", "cartoon", "character", "children's illustration", "cityscape", "clean", "cloudscape", "collage", "colorful", "comics", "cubism", "dark", "detailed", "digital", "expressionism", "fantasy", "fashion", "fauvism", "figurativism", "gore", "graffiti", "graphic design", "high contrast", "horror", "impressionism", "installation", "landscape", "light", "line drawing", "low contrast", "luminism", "magical realism", "manga", "melanin", "messy", "monochromatic", "nature", "nudity", "photography", "pop art", "portrait", "primitivism", "psychedelic", "realism", "renaissance", "romanticism", "scene", "sci-fi", "sculpture", "seascape", "space", "stained glass", "still life", "storybook realism", "street art", "streetscape", "surrealism", "symbolism", "textile", "ukiyo-e", "vibrant", "watercolor", "whimsical"]
imagetypes = ["all", "all - force multiple", "photograph", "octane render","digital art","concept art", "painting", "portrait", "anime key visual", "only other types"]
promptmode = ["at the back", "in the front"]
promptcompounder = ["1", "2", "3", "4", "5"]
ANDtogglemode = ["comma", "AND", "current prompt + AND", "current prompt + AND + current prompt", "automatic AND"]
ANDtogglemode = ["none", "automatic", "prefix AND prompt + suffix", "prefix + prefix + prompt + suffix"]
seperatorlist = ["comma", "AND", "BREAK"]
#for autorun and upscale
sizelist = ["all", "portrait", "wide", "square", "ultrawide"]
modellist = get_models()
modellist.insert(0,"all")
modellist.insert(0,"currently selected model") # First value us the currently selected model
upscalerlist = get_upscalers()
upscalerlist.insert(0,"automatic")
upscalerlist.insert(0,"all")
samplerlist = get_samplers()
samplerlist.insert(0,"all")
#for img2img
img2imgupscalerlist = get_upscalers_for_img2img()
img2imgupscalerlist.insert(0,"automatic")
img2imgupscalerlist.insert(0,"all")
img2imgsamplerlist = get_samplers_for_img2img()
img2imgsamplerlist.insert(0,"all")
#for ultimate SD upscale
seams_fix_types = ["None","Band pass","Half tile offset pass","Half tile offset pass + intersections"]
redraw_modes = ["Linear","Chess","None"]
#folder stuff
folder_symbol = '\U0001f4c2' # 📂
sys.path.append(os.path.abspath(".."))
class Script(scripts.Script):
@@ -27,17 +65,33 @@ class Script(scripts.Script):
def ui(self, is_img2img):
def gen_prompt(insanitylevel, subject, artist, imagetype, antistring):
def gen_prompt(insanitylevel, subject, artist, imagetype, antistring, prefixprompt, suffixprompt, promptcompounderlevel, seperator):
promptlist = []
for i in range(5):
promptlist.append(build_dynamic_prompt(insanitylevel,subject,artist, imagetype, False, antistring))
promptlist.append(build_dynamic_prompt(insanitylevel,subject,artist, imagetype, False, antistring,prefixprompt,suffixprompt,promptcompounderlevel,seperator))
return promptlist
def prompttoworkflowprompt(text):
return text
# Copied code from WebUI
def openfolder():
script_dir = os.path.dirname(os.path.abspath(__file__)) # Script directory
automatedoutputsfolder = os.path.join(script_dir, "../automated_outputs/" )
path = os.path.normpath(automatedoutputsfolder)
if platform.system() == "Windows":
os.startfile(path)
elif platform.system() == "Darwin":
sp.Popen(["open", path])
elif "microsoft-standard-WSL2" in platform.uname().release:
sp.Popen(["wsl-open", path])
else:
sp.Popen(["xdg-open", path])
with gr.Tab("Main"):
@@ -55,8 +109,9 @@ class Script(scripts.Script):
imagetypes, label="type of image", value="all")
with gr.Row():
with gr.Column():
promptlocation = gr.Dropdown(
promptmode, label="Location of existing prompt", value="at the back")
prefixprompt = gr.Textbox(label="Place this in front of generated prompt (prefix)",value="")
suffixprompt = gr.Textbox(label="Place this at back of generated prompt (suffix)",value="")
negativeprompt = gr.Textbox(label="Use this negative prompt",value="")
with gr.Row():
with gr.Column():
antistring = gr.Textbox(label="Filter out following properties (comma seperated). Example ""film grain, purple, cat"" ")
@@ -129,14 +184,11 @@ class Script(scripts.Script):
### Location of existing prompt
### Other prompt fields
<font size="2">
If you put a prompt in the prompt field, it will be added onto the generated prompt. You can determine where to put it in the front or the back of the generated prompt.
The existing prompt and negative prompt fields are ignored.
1. at the back
2. in the front
Add a prompt prefix, suffix and the negative prompt in the respective fields. They will be automatically added during processing.
</font>
@@ -148,6 +200,8 @@ class Script(scripts.Script):
This way, you don't ever have to add it manually again. This file won't be overwritten during upgrades.
Idea by redditor jonesaid.
</font>
"""
)
@@ -200,9 +254,13 @@ class Script(scripts.Script):
with gr.Column(scale=1):
promptcompounderlevel = gr.Dropdown(
promptcompounder, label="Prompt compounder", value="1")
with gr.Row():
with gr.Column(scale=1):
seperator = gr.Dropdown(
seperatorlist, label="Prompt seperator", value="comma")
with gr.Column(scale=2):
ANDtoggle = gr.Dropdown(
ANDtogglemode, label="Prompt seperator mode", value="comma")
ANDtogglemode, label="Prompt seperator mode", value="none")
with gr.Row():
gr.Markdown(
"""
@@ -217,9 +275,9 @@ class Script(scripts.Script):
This was originally a bug in the first release when using multiple batches, now brought back as a feature.
Raised by redditor drone2222, to bring this back as a toggle, since it did create interesting results. So here it is.
You can toggle the separator mode. Standardly this is a comma, but you can choose an AND and a newline.
You can toggle the separator mode. Standardly this is a comma, but you can choose an AND or a BREAK.
You can also choose for "current prompt + AND" or "current prompt + AND + current prompt". This is best used in conjuction with the Latent Couple extension when you want some control. Set the prompt compounder equal to the amount of areas defined in Laten Couple.
You can also choose the prompt seperator mode for use with Latent Couple extension
Example flow:
@@ -227,11 +285,15 @@ class Script(scripts.Script):
In the main tab, set the subject to humanoids
In the prompt field then add for example: Art by artistname, 2 people
In the prefix prompt field then add for example: Art by artistname, 2 people
Set the prompt compounder to: 2
Set the Prompt seperator to: AND
"automatic AND" is entirely build around Latent Couple. It will pass artists and the amount of people/animals/objects to generate in the prompt automatically. Set the prompt compounder equal to the amount of areas defined in Laten Couple.
Set the Prompt Seperator mode to: prefix AND prompt + suffix
"automatic" is entirely build around Latent Couple. It will pass artists and the amount of people/animals/objects to generate in the prompt automatically. Set the prompt compounder equal to the amount of areas defined in Laten Couple.
Example flow:
@@ -243,27 +305,285 @@ class Script(scripts.Script):
Set the prompt compounder to: 2
Set the Prompt seperator to: AND
Set the Prompt Seperator mode to: automatic
</font>
"""
)
genprom.click(gen_prompt, inputs=[insanitylevel,subject, artist, imagetype, antistring], outputs=[prompt1, prompt2, prompt3,prompt4,prompt5])
with gr.Tab("One Button Run and Upscale"):
with gr.Row():
gr.Markdown(
"""
### TXT2IMG
<font size="2">
Start WebUi with option --api for this to work.
</font>
"""
)
with gr.Row():
with gr.Column(scale=1):
startmain = gr.Button("Start generating and upscaling!")
automatedoutputsfolderbutton = gr.Button(folder_symbol)
apiurl = gr.Textbox(label="URL", value="http://127.0.0.1:7860")
with gr.Column(scale=1):
onlyupscale = gr.Checkbox(label="Don't generate, only upscale", value=False)
gr.Markdown(
"""
<font size="2">
Only upscale will not use txt2img to generate an image.
Instead it will pick up all files in the \\upscale_me\\ folder and upscale them with below settings.
</font>
"""
)
with gr.Row():
with gr.Column(scale=1):
amountofimages = gr.Slider(1, 50, value="20", step=1, label="Amount of images to generate")
size = gr.Dropdown(
sizelist, label="Size to generate", value="all")
with gr.Row(scale=1):
samplingsteps = gr.Slider(1, 100, value="20", step=1, label="Sampling steps")
cfg = gr.Slider(1,20, value="6.0", step=0.1, label="CFG")
with gr.Row(scale=1):
hiresfix = gr.Checkbox(label="hires. fix", value=True)
hiressteps = gr.Slider(0, 100, value = "0", step=1, label="Hires steps")
hiresscale = gr.Slider(1, 4, value = "2", step=0.05, label="Scale")
denoisestrength = gr.Slider(0, 1, value="0.60", step=0.01, label="Denoise strength")
with gr.Column(scale=1):
model = gr.Dropdown(
modellist, label="model to use", value="currently selected model")
with gr.Column(scale=1):
samplingmethod = gr.Dropdown(
samplerlist, label= "Sampler", value="all")
upscaler = gr.Dropdown(
upscalerlist, label="hires upscaler", value="all")
with gr.Row():
gr.Markdown(
"""
### Quality Gate
<font size="2">
Uses aesthetic image scorer extension to check the quality of the image.
Once turned on, it will retry for n amount of times to get an image with the quality score. If not, it will take the best image so far and continue.
Idea and inspiration by xKean.
</font>
"""
)
with gr.Row():
qualitygate = gr.Checkbox(label="Quality Gate", value=False)
quality = gr.Slider(1, 10, value = "7.2", step=0.1, label="Quality", visible = False)
runs = gr.Slider(1, 50, value = "5", step=1, label="Amount of tries", visible = False)
with gr.Row():
gr.Markdown(
"""
### IMG2IMG upscale
"""
)
with gr.Row():
img2imgactivate = gr.Checkbox(label="Upscale image with IMG2IMG", value=True)
with gr.Row():
with gr.Column(scale=1):
img2imgbatch = gr.Slider(1, 5, value="1", step=1, label="Amount times to repeat upscaling with IMG2IMG (loopback)")
img2imgsamplingsteps = gr.Slider(1, 100, value="20", step=1, label="img2img Sampling steps")
img2imgcfg = gr.Slider(1,20, value="6", step=0.1, label="img2img CFG")
img2imgdenoisestrength = gr.Slider(0, 1, value="0.30", step=0.01, label="img2img denoise strength")
img2imgdenoisestrengthmod = gr.Slider(-1,1, value = "-0.05", step=0.01, label="adjust denoise each img2img batch")
with gr.Column(scale=1):
img2imgmodel = gr.Dropdown(
modellist, label="img2img model to use", value="currently selected model")
img2imgsamplingmethod = gr.Dropdown(
img2imgsamplerlist, label= "img2img sampler", value="all")
img2imgupscaler = gr.Dropdown(
img2imgupscalerlist, label="img2img upscaler", value="all")
with gr.Row():
img2imgscale = gr.Slider(1, 4, value="2", step=0.05, label="img2img scale")
img2imgpadding = gr.Slider(32, 256, value="64", step=12, label="img2img padding")
with gr.Row():
ultimatesdupscale = gr.Checkbox(label="Use Ultimate SD Upscale script instead", value=False)
gr.Markdown(
"""
<font size="2">
This requires the Ultimate SD Upscale extension, install this if you haven't
</font>
"""
)
with gr.Row():
with gr.Column(scale = 1):
#usdutilewidth, usdutileheight, usdumaskblur, usduredraw, usduSeamsfix, usdusdenoise, usduswidth, usduspadding, usdusmaskblur
#usdutilewidth = "512", usdutileheight = "0", usdumaskblur = "8", usduredraw ="Linear", usduSeamsfix = "None", usdusdenoise = "0.35", usduswidth = "64", usduspadding ="32", usdusmaskblur = "8"
usdutilewidth = gr.Slider(0, 2048, value="512", step=12, label="tile width", visible = False)
usdutileheight = gr.Slider(0, 2048, value="0", step=12, label="tile height", visible = False)
usdumaskblur = gr.Slider(0, 64, value="8", step=1, label="Mask blur", visible = False)
usduredraw = gr.Dropdown(
redraw_modes, label="Type", value="Linear", visible = False)
with gr.Column(scale = 1):
usduSeamsfix = gr.Dropdown(
seams_fix_types, label="Seams fix", value="None", visible = False)
usdusdenoise = gr.Slider(0, 1, value="0.35", step=0.01, label="Seams denoise strenght", visible = False)
usduswidth = gr.Slider(0, 128, value="64", step=12, label="Seams Width", visible = False)
usduspadding = gr.Slider(0, 128, value="32", step=12, label="Seams padding", visible = False)
usdusmaskblur = gr.Slider(0, 64, value="8", step=1, label="Seams Mask blur (offset pass only)", visible = False)
with gr.Row():
with gr.Column(scale = 1):
controlnetenabled = gr.Checkbox(label="Enable controlnet tile resample", value=False)
controlnetblockymode = gr.Checkbox(label="also enable wierd blocky upscale mode", value=False)
with gr.Column(scale = 1):
controlnetmodel = gr.Textbox(label="Controlnet tile model name", value = "control_v11f1e_sd15_tile [a371b31b]")
with gr.Row():
gr.Markdown(
"""
<font size="2">
This requires Controlnet 1.1 extension and the tile resample model, install this if you haven't
In settings for Controlnet, enable "Allow other script to control this extension"
Don't use wierd blocky upscale mode. Or maybe do?
</font>
"""
)
with gr.Row():
with gr.Column(scale = 1):
enableextraupscale = gr.Checkbox(label="Enable upscale with extras", value=False)
with gr.Row():
with gr.Column(scale = 1):
extrasresize = gr.Slider(0, 8, value="2", step=0.05, label="Upscale resize", visible = False)
extrasupscaler1 = gr.Dropdown(
img2imgupscalerlist, label="upscaler 1", value="all", visible = False)
extrasupscaler2 = gr.Dropdown(
img2imgupscalerlist, label="upscaler 2", value="all", visible = False)
extrasupscaler2visiblity = gr.Slider(0, 1, value="0.5", step=0.05, label="Upscaler 2 vis.", visible = False)
with gr.Column(scale = 1):
extrasupscaler2gfpgan = gr.Slider(0, 1, value="0", step=0.05, label="GFPGAN vis.", visible = False)
extrasupscaler2codeformer = gr.Slider(0, 1, value="0.15", step=0.05, label="CodeFormer vis.", visible = False)
extrasupscaler2codeformerweight = gr.Slider(0, 1, value="0.1", step=0.05, label="CodeFormer weight", visible = False)
genprom.click(gen_prompt, inputs=[insanitylevel,subject, artist, imagetype, antistring,prefixprompt, suffixprompt,promptcompounderlevel, seperator], outputs=[prompt1, prompt2, prompt3,prompt4,prompt5])
prompt1toworkflow.click(prompttoworkflowprompt, inputs=prompt1, outputs=workprompt)
prompt2toworkflow.click(prompttoworkflowprompt, inputs=prompt2, outputs=workprompt)
prompt3toworkflow.click(prompttoworkflowprompt, inputs=prompt3, outputs=workprompt)
prompt4toworkflow.click(prompttoworkflowprompt, inputs=prompt4, outputs=workprompt)
prompt5toworkflow.click(prompttoworkflowprompt, inputs=prompt5, outputs=workprompt)
startmain.click(generateimages, inputs=[amountofimages,size,model,samplingsteps,cfg,hiresfix,hiressteps,denoisestrength,samplingmethod, upscaler,hiresscale, apiurl, qualitygate, quality, runs,insanitylevel,subject, artist, imagetype, silentmode, workprompt, antistring, prefixprompt, suffixprompt,negativeprompt,promptcompounderlevel, seperator, img2imgbatch, img2imgsamplingsteps, img2imgcfg, img2imgsamplingmethod, img2imgupscaler, img2imgmodel,img2imgactivate, img2imgscale, img2imgpadding,img2imgdenoisestrength,ultimatesdupscale,usdutilewidth, usdutileheight, usdumaskblur, usduredraw, usduSeamsfix, usdusdenoise, usduswidth, usduspadding, usdusmaskblur, controlnetenabled, controlnetmodel,img2imgdenoisestrengthmod,enableextraupscale,controlnetblockymode,extrasupscaler1,extrasupscaler2,extrasupscaler2visiblity,extrasupscaler2gfpgan,extrasupscaler2codeformer,extrasupscaler2codeformerweight,extrasresize,onlyupscale])
automatedoutputsfolderbutton.click(openfolder)
# Turn things off and on for onlyupscale and txt2img
def onlyupscalevalues(onlyupscale):
onlyupscale = not onlyupscale
return {
amountofimages: gr.update(visible=onlyupscale),
size: gr.update(visible=onlyupscale),
samplingsteps: gr.update(visible=onlyupscale),
cfg: gr.update(visible=onlyupscale),
hiresfix: gr.update(visible=onlyupscale),
hiressteps: gr.update(visible=onlyupscale),
hiresscale: gr.update(visible=onlyupscale),
denoisestrength: gr.update(visible=onlyupscale),
upscaler: gr.update(visible=onlyupscale),
model: gr.update(visible=onlyupscale),
samplingmethod: gr.update(visible=onlyupscale),
upscaler: gr.update(visible=onlyupscale),
qualitygate: gr.update(visible=onlyupscale),
quality: gr.update(visible=onlyupscale),
runs: gr.update(visible=onlyupscale)
}
onlyupscale.change(
onlyupscalevalues,
[onlyupscale],
[amountofimages,size,samplingsteps,cfg,hiresfix,hiressteps,hiresscale,denoisestrength,upscaler,model,samplingmethod,upscaler,qualitygate,quality,runs]
)
# Turn things off and on for hiresfix
def hireschangevalues(hiresfix):
return {
hiressteps: gr.update(visible=hiresfix),
hiresscale: gr.update(visible=hiresfix),
denoisestrength: gr.update(visible=hiresfix),
upscaler: gr.update(visible=hiresfix)
}
return [insanitylevel,subject, artist, imagetype, promptlocation, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring]
hiresfix.change(
hireschangevalues,
[hiresfix],
[hiressteps,hiresscale,denoisestrength,upscaler]
)
# Turn things off and on for quality gate
def qgatechangevalues(qualitygate):
return {
quality: gr.update(visible=qualitygate),
runs: gr.update(visible=qualitygate)
}
qualitygate.change(
qgatechangevalues,
[qualitygate],
[quality,runs]
)
# Turn things off and on for USDU
def ultimatesdupscalechangevalues(ultimatesdupscale):
return {
usdutilewidth: gr.update(visible=ultimatesdupscale),
usdutileheight: gr.update(visible=ultimatesdupscale),
usdumaskblur: gr.update(visible=ultimatesdupscale),
usduredraw: gr.update(visible=ultimatesdupscale),
usduSeamsfix: gr.update(visible=ultimatesdupscale),
usdusdenoise: gr.update(visible=ultimatesdupscale),
usduswidth: gr.update(visible=ultimatesdupscale),
usduspadding: gr.update(visible=ultimatesdupscale),
usdusmaskblur: gr.update(visible=ultimatesdupscale)
}
ultimatesdupscale.change(
ultimatesdupscalechangevalues,
[ultimatesdupscale],
[usdutilewidth,usdutileheight,usdumaskblur,usduredraw,usduSeamsfix,usdusdenoise,usduswidth,usduspadding,usdusmaskblur]
)
# Turn things off and on for EXTRAS
def enableextraupscalechangevalues(enableextraupscale):
return {
extrasupscaler1: gr.update(visible=enableextraupscale),
extrasupscaler2: gr.update(visible=enableextraupscale),
extrasupscaler2visiblity: gr.update(visible=enableextraupscale),
extrasresize: gr.update(visible=enableextraupscale),
extrasupscaler2gfpgan: gr.update(visible=enableextraupscale),
extrasupscaler2codeformer: gr.update(visible=enableextraupscale),
extrasupscaler2codeformerweight: gr.update(visible=enableextraupscale)
}
enableextraupscale.change(
enableextraupscalechangevalues,
[enableextraupscale],
[extrasupscaler1,extrasupscaler2,extrasupscaler2visiblity,extrasresize, extrasupscaler2gfpgan,extrasupscaler2codeformer,extrasupscaler2codeformerweight]
)
return [insanitylevel,subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring, seperator]
def run(self, p, insanitylevel, subject, artist, imagetype, promptlocation, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring):
def run(self, p, insanitylevel, subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring,seperator):
images = []
infotexts = []
@@ -275,23 +595,23 @@ class Script(scripts.Script):
batchsize = p.batch_size
p.n_iter = 1
p.batch_size = 1
originalprompt = p.prompt
if(silentmode and workprompt != ""):
print("Workflow mode turned on, not generating a prompt. Using workflow prompt.")
elif(silentmode):
print("Warning, workflow mode is turned on, but no workprompt has been given.")
elif p.prompt != "":
print("Prompt is not empty, adding current prompt " + promptlocation + " of the generated prompt")
elif p.prompt != "" or p.negative_prompt != "":
print("Please note that existing prompt and negative prompt fields are (no longer) used")
if(ANDtoggle == "automatic AND" and artist == "none"):
print("Automatic AND and artist mode set to none, don't work together well. Ignoring this setting!")
if(ANDtoggle == "automatic" and artist == "none"):
print("Automatic and artist mode set to none, don't work together well. Ignoring this setting!")
artist = "all"
if(ANDtoggle == "automatic AND" and originalprompt != ""):
print("Automatic AND doesnt work well if there is an original prompt filled in. Ignoring the original prompt!")
originalprompt = ""
if(ANDtoggle == "automatic" and (prefixprompt != "")):
print("Automatic doesnt work well if there is an prefix prompt filled in. Ignoring this prompt fields!")
prefixprompt = ""
@@ -301,41 +621,37 @@ class Script(scripts.Script):
# prompt compounding
print("Starting generating the prompt")
preppedprompt = ""
if(ANDtoggle == "automatic AND" and originalprompt == ""):
if(artist != "none"):
originalprompt += build_dynamic_prompt(insanitylevel,subject,artist, imagetype, True, antistring)
if(subject == "humanoid"):
originalprompt += ", " + promptcompounderlevel + " people"
if(subject == "landscape"):
originalprompt += ", landscape"
if(subject == "animal"):
originalprompt += ", " + promptcompounderlevel + " animals"
if(subject == "object"):
originalprompt += ", " + promptcompounderlevel + " objects"
if(ANDtoggle != "AND" and ANDtoggle != "comma" and originalprompt != ""):
preppedprompt += originalprompt + " \n AND "
for i in range(int(promptcompounderlevel)):
if(ANDtoggle == "automatic AND"):
preppedprompt += originalprompt + ", " + build_dynamic_prompt(insanitylevel,subject,"none", imagetype, False, antistring)
elif(ANDtoggle != "AND" and ANDtoggle != "comma" and originalprompt != "" and ANDtoggle != "current prompt + AND" ):
preppedprompt += originalprompt + ", " + build_dynamic_prompt(insanitylevel,subject,artist, imagetype, False, antistring)
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"
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 += build_dynamic_prompt(insanitylevel,subject,artist, imagetype, False, antistring)
if(i + 1 != int(promptcompounderlevel)):
if(ANDtoggle == "comma"):
preppedprompt += ", "
else:
preppedprompt += " \n AND "
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)
if(promptlocation == "in the front" and originalprompt != "" and (ANDtoggle == "AND" or ANDtoggle == "comma")):
p.prompt = originalprompt + ", " + preppedprompt
elif(promptlocation == "at the back" and originalprompt != "" and (ANDtoggle == "AND" or ANDtoggle == "comma")):
p.prompt = preppedprompt + ", " + originalprompt # add existing prompt to the back?
else:
p.prompt = preppedprompt # dont add anything
# set everything ready
p.prompt = preppedprompt
p.negative_prompt = negativeprompt
if(silentmode == True):
p.prompt = workprompt