diff --git a/build_dynamic_prompt.py b/build_dynamic_prompt.py index 7cebc50..701347a 100644 --- a/build_dynamic_prompt.py +++ b/build_dynamic_prompt.py @@ -10,7 +10,7 @@ from random_functions import * # insanity level controls randomness of propmt 0-10 # forcesubject van be used to force a certain type of subject # Set artistmode to none, to exclude artists -def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all", imagetype = "all", onlyartists = False, antivalues = "", prefixprompt = "", suffixprompt ="",promptcompounderlevel ="1", seperator = "comma", givensubject="",smartsubject = True,giventypeofimage=""): +def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all", imagetype = "all", onlyartists = False, antivalues = "", prefixprompt = "", suffixprompt ="",promptcompounderlevel ="1", seperator = "comma", givensubject="",smartsubject = True,giventypeofimage="", imagemodechance = 20): # first build up a complete anti list. Those values are removing during list building @@ -229,7 +229,7 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all mainchooserlist.append("concept") # determine wether we have a special mode or not - if(random.randint(1,20) == 1 and imagetype == "all"): + if(random.randint(1,int(imagemodechance)) == 1 and imagetype == "all" and giventypeofimage == ""): imagetype = random.choice(imagetypemodelist) # override imagetype with a random "mode" value @@ -243,43 +243,43 @@ def build_dynamic_prompt(insanitylevel = 5, forcesubject = "all", artists = "all massivemadnessmode = False onlysubjectmode = False # determine wether we should go for a template or not. Not hooked up to insanitylevel - if((not specialmode) or imagetype == "only templates mode"): + if(imagetype == "only templates mode"): specialmode = True templatemode = True print("Running with a randomized template instead of a randomized prompt") - if((not specialmode) or imagetype == "art blaster mode"): + if(imagetype == "art blaster mode"): specialmode = True artblastermode = True print("Running in art blaster mode") - if((not specialmode) or imagetype == "unique art mode"): + if(imagetype == "unique art mode"): specialmode = True uniqueartmode = True print("Running in unique art mode") - if((not specialmode) or imagetype == "quality vomit mode"): + if(imagetype == "quality vomit mode"): specialmode = True qualityvomitmode = True print("Running in quality vomit mode") - if((not specialmode) or imagetype == "color cannon mode"): + if(imagetype == "color cannon mode"): specialmode = True colorcannonmode = True print("Running in color cannon mode") - if((not specialmode) or imagetype == "photo fantasy mode"): + if(imagetype == "photo fantasy mode"): specialmode = True photofantasymode = True print("Running in photo fantasy mode") - if((not specialmode) or imagetype == "massive madness mode"): + if(imagetype == "massive madness mode"): specialmode = True massivemadnessmode = True print("Running in massive madness mode") print("Are you ready for this?") - if((not specialmode) or imagetype == "subject only mode"): + if(imagetype == "subject only mode"): specialmode = True onlysubjectmode = True print("Running in only subject mode") diff --git a/main.py b/main.py index ef016f4..a77db0a 100644 --- a/main.py +++ b/main.py @@ -12,7 +12,7 @@ from call_extras import * from model_lists import * -def generateimages(amount = 1, size = "all",model = "currently selected model",samplingsteps = "40",cfg= "7",hiresfix = True,hiressteps ="0",denoisestrength="0.6",samplingmethod="DPM++ SDE Karras", upscaler="R-ESRGAN 4x+", hiresscale="2",apiurl="http://127.0.0.1:7860",qualitygate=False,quality="7.6",runs="5",insanitylevel="5",subject="all", artist="all", imagetype="all",silentmode=False, workprompt="", antistring="",prefixprompt="", suffixprompt="", negativeprompt="",promptcompounderlevel = "1", seperator="comma", img2imgbatch = "1", img2imgsamplingsteps = "20", img2imgcfg = "7", img2imgsamplingmethod = "DPM++ SDE Karras", img2imgupscaler = "R-ESRGAN 4x+", img2imgmodel = "currently selected model", img2imgactivate = False, img2imgscale = "2", img2imgpadding = "64",img2imgdenoisestrength="0.3",ultimatesdupscale=False,usdutilewidth = "512", usdutileheight = "0", usdumaskblur = "8", usduredraw ="Linear", usduSeamsfix = "None", usdusdenoise = "0.35", usduswidth = "64", usduspadding ="32", usdusmaskblur = "8",controlnetenabled=False, controlnetmodel="",img2imgdenoisestrengthmod="-0.05",enableextraupscale = False,controlnetblockymode = False,extrasupscaler1 = "all",extrasupscaler2 ="all",extrasupscaler2visiblity="0.5",extrasupscaler2gfpgan="0",extrasupscaler2codeformer="0.15",extrasupscaler2codeformerweight="0.1",extrasresize="2",onlyupscale="false",givensubject="",smartsubject=True,giventypeofimage=""): +def generateimages(amount = 1, size = "all",model = "currently selected model",samplingsteps = "40",cfg= "7",hiresfix = True,hiressteps ="0",denoisestrength="0.6",samplingmethod="DPM++ SDE Karras", upscaler="R-ESRGAN 4x+", hiresscale="2",apiurl="http://127.0.0.1:7860",qualitygate=False,quality="7.6",runs="5",insanitylevel="5",subject="all", artist="all", imagetype="all",silentmode=False, workprompt="", antistring="",prefixprompt="", suffixprompt="", negativeprompt="",promptcompounderlevel = "1", seperator="comma", img2imgbatch = "1", img2imgsamplingsteps = "20", img2imgcfg = "7", img2imgsamplingmethod = "DPM++ SDE Karras", img2imgupscaler = "R-ESRGAN 4x+", img2imgmodel = "currently selected model", img2imgactivate = False, img2imgscale = "2", img2imgpadding = "64",img2imgdenoisestrength="0.3",ultimatesdupscale=False,usdutilewidth = "512", usdutileheight = "0", usdumaskblur = "8", usduredraw ="Linear", usduSeamsfix = "None", usdusdenoise = "0.35", usduswidth = "64", usduspadding ="32", usdusmaskblur = "8",controlnetenabled=False, controlnetmodel="",img2imgdenoisestrengthmod="-0.05",enableextraupscale = False,controlnetblockymode = False,extrasupscaler1 = "all",extrasupscaler2 ="all",extrasupscaler2visiblity="0.5",extrasupscaler2gfpgan="0",extrasupscaler2codeformer="0.15",extrasupscaler2codeformerweight="0.1",extrasresize="2",onlyupscale="false",givensubject="",smartsubject=True,giventypeofimage="",imagemodechance=20): loops = int(amount) # amount of images to generate steps = 0 upscalefilelist=[] @@ -70,7 +70,7 @@ def generateimages(amount = 1, size = "all",model = "currently selected model",s print(workprompt) else: - randomprompt = build_dynamic_prompt(insanitylevel,subject,artist,imagetype, False,antistring,prefixprompt,suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage) + randomprompt = build_dynamic_prompt(insanitylevel,subject,artist,imagetype, False,antistring,prefixprompt,suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage,imagemodechance) # make the filename, from from a to the first comma start_index = randomprompt.find("of a ") + len("of a ") diff --git a/prompttester.py b/prompttester.py index b9a3f5d..3ae879e 100644 --- a/prompttester.py +++ b/prompttester.py @@ -10,7 +10,7 @@ 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=""): +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): loops = int(amount) # amount of images to generate steps = 0 @@ -18,7 +18,7 @@ def generateprompts(amount = 1,insanitylevel="5",subject="all", artist="all", im while steps < loops: # build prompt - result = build_dynamic_prompt(insanitylevel,subject,artist,imagetype, onlyartists,antistring,prefixprompt,suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage) + result = build_dynamic_prompt(insanitylevel,subject,artist,imagetype, onlyartists,antistring,prefixprompt,suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage,imagemodechance) print("") print("loop " + str(steps)) @@ -46,4 +46,4 @@ def generateprompts(amount = 1,insanitylevel="5",subject="all", artist="all", im print("") print("All done!") -generateprompts(10,5,"all","none","photo fantasy mode",False,"","","PREFIXPROMPT" ,"SUFFIXPROMPT","",1,"","") \ No newline at end of file +generateprompts(10,9,"all","none","all",False,"","","PREFIXPROMPT" ,"SUFFIXPROMPT","",1,"","",True,"",1) \ No newline at end of file diff --git a/scripts/onebuttonprompt.py b/scripts/onebuttonprompt.py index 85221b4..fb2f876 100644 --- a/scripts/onebuttonprompt.py +++ b/scripts/onebuttonprompt.py @@ -76,12 +76,12 @@ class Script(scripts.Script): def ui(self, is_img2img): - def gen_prompt(insanitylevel, subject, artist, imagetype, antistring, prefixprompt, suffixprompt, promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage): + def gen_prompt(insanitylevel, subject, artist, imagetype, antistring, prefixprompt, suffixprompt, promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage, imagemodechance): promptlist = [] for i in range(5): - promptlist.append(build_dynamic_prompt(insanitylevel,subject,artist, imagetype, False, antistring,prefixprompt,suffixprompt,promptcompounderlevel,seperator,givensubject,smartsubject, giventypeofimage)) + promptlist.append(build_dynamic_prompt(insanitylevel,subject,artist, imagetype, False, antistring,prefixprompt,suffixprompt,promptcompounderlevel,seperator,givensubject,smartsubject, giventypeofimage, imagemodechance)) return promptlist @@ -115,9 +115,13 @@ class Script(scripts.Script): with gr.Column(scale=1, variant="compact"): artist = gr.Dropdown( artists, label="Artists", value="all") + with gr.Row(): with gr.Column(scale=2, variant="compact"): imagetype = gr.Dropdown( imagetypes, label="type of image", value="all") + with gr.Column(scale=2, variant="compact"): + imagemodechance = gr.Slider( + 1, 100, value="20", step=1, label="One in X chance to use special image type mode") with gr.Row(): gr.Markdown(""" @@ -218,10 +222,32 @@ class Script(scripts.Script): 8. only other types --> Will pick only from the more unique types, such as stained glass window or a funko pop - 9. only templates --> Will only choose from a set of wildcarded prompt templates. Templates have been gathered from various sources, such as CivitAI, prompthero, promptbook, etc. + 9. only templates mode --> Will only choose from a set of wildcarded prompt templates. Templates have been gathered from various sources, such as CivitAI, prompthero, promptbook, etc. - only templates is perfect for beginners, who want to see some good results fast. + only templates mode is perfect for beginners, who want to see some good results fast. + 10. art blaster mode --> Special generation mode that focusses on art movements, stylings and artists. + + 11. quality vomit mode --> Special generation mode that focusses on qualifiers and stylings. + + 12. color cannon mode --> Special generation mode that focusses on color scheme's and moods. + + 13. unique art mode --> Special generation mode that focusses on other image types, art movements, stylings and lighting. + + 14. massive madness mode --> Special generation mode, creates prompt soup. Almost pure randomness. + + 15. photo fantasy mode --> Special generation mode that focusses on photographs, cameras, lenses and lighting. + + 16. subject only mode --> Will only generate a subject, with no additional frills. + + ### One in X chance to use special image type mode + + + This controls how often it will pick a special generation mode. It is a 1 in X chance. So lower means more often. + + When set to 1, it will always pick a random special generation mode. When set to 20, it is a 1 in 20 chance this will happen. +