From 55b7c0d66bca93f8a43964c762d06b6d8f67d878 Mon Sep 17 00:00:00 2001 From: AIrjen Date: Tue, 18 Apr 2023 22:02:00 +0200 Subject: [PATCH] Added workflow assist tab --- csvfiles/cultures.csv | 4 +- csvfiles/lighting.csv | 3 +- csvfiles/outfits.csv | 2 +- scripts/onebuttonprompt.py | 91 +++++++++++++++++++++++++++++--------- 4 files changed, 76 insertions(+), 24 deletions(-) diff --git a/csvfiles/cultures.csv b/csvfiles/cultures.csv index 3e2612c..db224ac 100644 --- a/csvfiles/cultures.csv +++ b/csvfiles/cultures.csv @@ -174,4 +174,6 @@ Regency Atomic Age Digital Age Baroque -Pirate \ No newline at end of file +Pirate +Dark ages +Burlesque \ No newline at end of file diff --git a/csvfiles/lighting.csv b/csvfiles/lighting.csv index f257355..27d56cf 100644 --- a/csvfiles/lighting.csv +++ b/csvfiles/lighting.csv @@ -33,4 +33,5 @@ Black lighting Gel lighting -color- lighting Moonlight -Sunlight \ No newline at end of file +Sunlight +Accent lighting \ No newline at end of file diff --git a/csvfiles/outfits.csv b/csvfiles/outfits.csv index 2e9f752..3dcba64 100644 --- a/csvfiles/outfits.csv +++ b/csvfiles/outfits.csv @@ -191,7 +191,7 @@ Onesie or footed pajamas Sleep shorts and tank top Boxer shorts and t-shirt Nightshirt and leggings -Satin or silk chemise +Satin chemise Babydoll Kimono Wedding dress diff --git a/scripts/onebuttonprompt.py b/scripts/onebuttonprompt.py index a2e7aff..34b1173 100644 --- a/scripts/onebuttonprompt.py +++ b/scripts/onebuttonprompt.py @@ -24,7 +24,17 @@ class Script(scripts.Script): def show(self, is_img2img): return True + def ui(self, is_img2img): + def gen_prompt(insanitylevel, subject, artist, imagetype): + + promptlist = [] + + for i in range(5): + promptlist.append(build_dynamic_prompt(insanitylevel,subject,artist, imagetype)) + + return promptlist + with gr.Tab("Main"): with gr.Row(): insanitylevel = gr.Slider(1, 10, value=7, step=1, label="Higher levels increases complexity and randomness of generated prompt") @@ -150,15 +160,52 @@ class Script(scripts.Script): """ ) - - return [insanitylevel,subject, artist, imagetype, promptlocation, promptcompounderlevel, ANDtoggle] + with gr.Tab("Workflow assist"): + with gr.Row(): + silentmode = gr.Checkbox( + label="silent mode, turns off prompt generation") + with gr.Row(): + gr.Markdown( + """ + + Workflow assist, suggestions by redditor Woisek. + + With silent mode, you turn off the automatic generation of new prompts on generate, and can just use normal prompting. So you can work and finetune any fun prompts without turning of the script. + + Below here, you can generate a set of random prompts, and start working from there instead. + + """) + with gr.Row(): + genprom = gr.Button("Generate me some prompts!") + with gr.Row(): + prompt1 = gr.Textbox(label="prompt 1") + with gr.Row(): + prompt2 = gr.Textbox(label="prompt 2") + with gr.Row(): + prompt3 = gr.Textbox(label="prompt 3") + with gr.Row(): + prompt4 = gr.Textbox(label="prompt 4") + with gr.Row(): + prompt5 = gr.Textbox(label="prompt 5") + + + genprom.click(gen_prompt, inputs=[insanitylevel,subject, artist, imagetype], outputs=[prompt1, prompt2, prompt3,prompt4,prompt5]) + + return [insanitylevel,subject, artist, imagetype, promptlocation, promptcompounderlevel, ANDtoggle, silentmode] - def run(self, p, insanitylevel, subject, artist, imagetype, promptlocation, promptcompounderlevel, ANDtoggle): + + + + def run(self, p, insanitylevel, subject, artist, imagetype, promptlocation, promptcompounderlevel, ANDtoggle, silentmode): images = [] infotexts = [] - if p.prompt != "": + if(silentmode and p.prompt != ""): + print("Silent mode turned on, not generating a prompt. Using current prompt.") + elif(silentmode): + print("Warning, silent mode is turned on, but no current prompt has been given.") + elif p.prompt != "": print("Prompt is not empty, adding current prompt " + promptlocation + " of the generated prompt") batches = p.n_iter @@ -172,23 +219,24 @@ class Script(scripts.Script): for i in range(batches): - # prompt compounding - print("Starting generating the prompt") - preppedprompt = "" - for i in range(promptcompounderlevel): - preppedprompt += build_dynamic_prompt(insanitylevel,subject,artist, imagetype) - if(i + 1 != promptcompounderlevel): - if(ANDtoggle): - preppedprompt += " \n AND " - else: - preppedprompt += ", " + if(silentmode == False): + # prompt compounding + print("Starting generating the prompt") + preppedprompt = "" + for i in range(promptcompounderlevel): + preppedprompt += build_dynamic_prompt(insanitylevel,subject,artist, imagetype) + if(i + 1 != promptcompounderlevel): + if(ANDtoggle): + preppedprompt += " \n AND " + else: + preppedprompt += ", " - if(promptlocation == "in the front" and originalprompt != ""): - p.prompt = originalprompt + ", " + preppedprompt - elif(promptlocation == "at the back" and originalprompt != ""): - p.prompt = preppedprompt + ", " + originalprompt # add existing prompt to the back? - else: - p.prompt = preppedprompt # dont add anything + if(promptlocation == "in the front" and originalprompt != ""): + p.prompt = originalprompt + ", " + preppedprompt + elif(promptlocation == "at the back" and originalprompt != ""): + p.prompt = preppedprompt + ", " + originalprompt # add existing prompt to the back? + else: + p.prompt = preppedprompt # dont add anything for j in range(batchsize): @@ -204,7 +252,8 @@ class Script(scripts.Script): # Only move up a seed, when there are multiple batchsizes, and we had the first one done. if(initialbatchsize != 1): p.seed += 1 - + + p.seed +=1 # just return all the things p.n_iter = 0 p.batch_size = 0