diff --git a/OneButtonPromptNodes.py b/OneButtonPromptNodes.py index d63d1c5..c573e53 100644 --- a/OneButtonPromptNodes.py +++ b/OneButtonPromptNodes.py @@ -449,12 +449,6 @@ class AutoNegativePrompt: "postive_prompt": ("STRING", {"default": '', "multiline": True}), }, "optional": { - "insanitylevel": ("INT", { - "default": 0, - "min": 0, #Minimum value - "max": 10, #Maximum value - "step": 1 #Slider's step - }), "base_negative": ("STRING", { "multiline": True, #True if you want the field to look like the one on the ClipTextEncode node "default": "text, watermark" @@ -465,6 +459,12 @@ class AutoNegativePrompt: "max": 1, #Maximum value "step": 1, #Slider's step }), + "insanitylevel": ("INT", { + "default": 0, + "min": 0, #Minimum value + "max": 10, #Maximum value + "step": 1 #Slider's step + }), "seed": ("INT", {"default": 0, "min": 0, "max": 0xFFFFFFFFFFFFFFFF}), }, diff --git a/csvfiles/special_lists/negativewords.csv b/csvfiles/special_lists/negativewords.csv index 8bb50ed..8710139 100644 --- a/csvfiles/special_lists/negativewords.csv +++ b/csvfiles/special_lists/negativewords.csv @@ -1,6 +1,7 @@ primer;negative photo;painting,abstract,camera,anime,cartoon,sketch,3d,render,illustration photograph;painting,abstract,camera,anime,cartoon,sketch,3d,render,illustration +photography;painting,abstract,camera,anime,cartoon,sketch,3d,render,illustration photographic;painting,abstract,camera,anime,cartoon,sketch,3d,render,illustration cinematic;painting,surrealism,camera,anime,cartoon,abstract,illustration cinema;painting,surrealism,camera,anime,cartoon,abstract,illustration @@ -60,7 +61,6 @@ creepy;beautiful, cute, adorable luminism;monochromatic, washed out fortnite;photograph, realism, photorealism ink;bright, sunny, light, vibrant, colorful -light;dark, moody, night, monochromatic, washed out happy;dark, moody, night, monochromatic, washed out joy;dark, moody, night, monochromatic, washed out joyful;dark, moody, night, monochromatic, washed out diff --git a/main.py b/main.py index dffca40..a5e580a 100644 --- a/main.py +++ b/main.py @@ -13,7 +13,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="",imagemodechance=20, gender="all", chosensubjectsubtypeobject="all", chosensubjectsubtypehumanoid="all", chosensubjectsubtypeconcept="all", increasestability = False, qualityhiresfix = False, qualitymode = "highest", qualitykeep="keep used", basesize = "512", promptvariantinsanitylevel = 0, givenoutfit = ""): +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, gender="all", chosensubjectsubtypeobject="all", chosensubjectsubtypehumanoid="all", chosensubjectsubtypeconcept="all", increasestability = False, qualityhiresfix = False, qualitymode = "highest", qualitykeep="keep used", basesize = "512", promptvariantinsanitylevel = 0, givenoutfit = "", autonegativeprompt = True, autonegativepromptstrength = 0, autonegativepromptenhance = False): loops = int(amount) # amount of images to generate steps = 0 upscalefilelist=[] @@ -22,10 +22,13 @@ def generateimages(amount = 1, size = "all",model = "currently selected model",s randomprompt = "" filename="" continuewithnextpart = True + randomsubject = "" originalmodel = model originalsamplingmethod = samplingmethod + originalnegativeprompt = negativeprompt + originalimg2imgmodel = img2imgmodel originalimg2imgsamplingmethod = img2imgsamplingmethod originalimg2imgupscaler = img2imgupscaler @@ -133,23 +136,31 @@ def generateimages(amount = 1, size = "all",model = "currently selected model",s else: - randomprompt = build_dynamic_prompt(insanitylevel,subject,artist,imagetype, False,antistring,prefixprompt,suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage,imagemodechance, gender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept,True,False,-1,givenoutfit) + randompromptlist = build_dynamic_prompt(insanitylevel,subject,artist,imagetype, False,antistring,prefixprompt,suffixprompt,promptcompounderlevel, seperator,givensubject,smartsubject,giventypeofimage,imagemodechance, gender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept,True,False,-1,givenoutfit, prompt_g_and_l=True) + randomprompt = randompromptlist[0] + randomsubject = randompromptlist[1] - # make the filename, from from a to the first comma - # find the index of the first comma after "of a" or end of the prompt - if(randomprompt.find("of a ") != -1): - start_index = randomprompt.find("of a ") + len("of a ") - end_index = randomprompt.find(",", start_index) - if(end_index == -1): - end_index=len(randomprompt) - else: - start_index = 0 - end_index = 128 - + if(autonegativeprompt): + negativeprompt = build_dynamic_negative(positive_prompt=randomprompt, insanitylevel=autonegativepromptstrength,enhance=autonegativepromptenhance, existing_negative_prompt=originalnegativeprompt) + if(randomsubject == ""): + # make the filename, from from a to the first comma + # find the index of the first comma after "of a" or end of the prompt + if(randomprompt.find("of a ") != -1): + start_index = randomprompt.find("of a ") + len("of a ") + end_index = randomprompt.find(",", start_index) + if(end_index == -1): + end_index=len(randomprompt) + else: + start_index = 0 + end_index = 128 + + - # extract the desired substring using slicing - filename = randomprompt[start_index:end_index] + # extract the desired substring using slicing + filename = randomprompt[start_index:end_index] + else: + filename = randomsubject # cleanup some unsafe things in the filename filename = filename.replace("\"", "") diff --git a/scripts/onebuttonprompt.py b/scripts/onebuttonprompt.py index c47ecad..fa03fec 100644 --- a/scripts/onebuttonprompt.py +++ b/scripts/onebuttonprompt.py @@ -317,7 +317,6 @@ class Script(scripts.Script): with gr.Column(variant="compact"): 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(variant="compact"): gr.Markdown(""" @@ -652,6 +651,28 @@ class Script(scripts.Script): """ ) + with gr.Tab("Negative prompt"): + gr.Markdown( + """ + ### Negative prompt settings + + """ + ) + with gr.Column(variant="compact"): + with gr.Row(variant="compact"): + autonegativeprompt = gr.Checkbox(label="🤖🚫💬 Auto generate negative prompt", value=True) + autonegativepromptenhance = gr.Checkbox(label="📈🚫💬 Enable base enhancement prompt", value=False) + with gr.Row(variant="compact"): + autonegativepromptstrength = gr.Slider(0, 10, value="0", step=1, label="🎲🚫💬 Randomness of negative prompt (lower is more consistency)") + gr.Markdown( + """ + ### Base negative prompt is added on + + """ + ) + with gr.Row(): + negativeprompt = gr.Textbox(label="🚫💬 Base negative prompt",value="") + with gr.Tab("One Button Run and Upscale"): with gr.Row(variant="compact"): gr.Markdown( @@ -835,7 +856,7 @@ class Script(scripts.Script): 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,givensubject,smartsubject,giventypeofimage,imagemodechance, chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept, increasestability, qualityhiresfix, qualitymode, qualitykeep, basesize, promptvariantinsanitylevel, givenoutfit]) + 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,givensubject,smartsubject,giventypeofimage,imagemodechance, chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept, increasestability, qualityhiresfix, qualitymode, qualitykeep, basesize, promptvariantinsanitylevel, givenoutfit, autonegativeprompt, autonegativepromptstrength, autonegativepromptenhance]) interrupt.click(tryinterrupt, inputs=[apiurl]) automatedoutputsfolderbutton.click(openfolder) @@ -998,12 +1019,12 @@ class Script(scripts.Script): - return [insanitylevel,subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring, seperator, givensubject, smartsubject, giventypeofimage, imagemodechance, chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept, promptvariantinsanitylevel, givenoutfit] + return [insanitylevel,subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring, seperator, givensubject, smartsubject, giventypeofimage, imagemodechance, chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept, promptvariantinsanitylevel, givenoutfit, autonegativeprompt, autonegativepromptstrength, autonegativepromptenhance] - def run(self, p, insanitylevel, subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring,seperator, givensubject, smartsubject, giventypeofimage, imagemodechance, chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept, promptvariantinsanitylevel, givenoutfit): + def run(self, p, insanitylevel, subject, artist, imagetype, prefixprompt,suffixprompt,negativeprompt, promptcompounderlevel, ANDtoggle, silentmode, workprompt, antistring,seperator, givensubject, smartsubject, giventypeofimage, imagemodechance, chosengender, chosensubjectsubtypeobject, chosensubjectsubtypehumanoid, chosensubjectsubtypeconcept, promptvariantinsanitylevel, givenoutfit, autonegativeprompt, autonegativepromptstrength, autonegativepromptenhance): images = [] infotexts = [] @@ -1097,6 +1118,10 @@ class Script(scripts.Script): print(" ") print(p.prompt) + if(autonegativeprompt): + p.negative_prompt = build_dynamic_negative(positive_prompt=p.prompt, insanitylevel=autonegativepromptstrength,enhance=autonegativepromptenhance, existing_negative_prompt=p.negative_prompt) + + promptlist = [] if(batchsize>1): # finally figured out how to do multiple batch sizes