h43lb1t0 / SD-WebUI-BatchCheckpointPrompt

Test a base prompt with different checkpoints and for the checkpoints specific prompt templates
MIT License
54 stars 3 forks source link

Check box for looping prompts, ability to repeat checkpoint use, embedded iterators with various lambda functions. #46

Closed RandyHaylor closed 1 year ago

RandyHaylor commented 1 year ago

These features are working pretty well, and I've been enjoying the ability to use these together to iterate through batches of lora checkpoints and weights for testing.

CheckPoint Names: [checkpointIterations=20],realisticVisionV30_v30VAE Prompts: <lyco:lycoName-[000001,lycoCount,++]:1>p1p3r

*the string for the initial value of the iterator is also used for the formatting of the output, so the numbers will increment like so: 000001, 000002, ...000011, ...

A prompt set up like this would produce 20 pictures, slowly increasing the one attribute weight:
CheckPoint Names: [checkpointIterations=20],realisticVisionV30_v30VAE Prompts: prompt text, (low key:[0,lowKeyIncrementer,+=,0.05])

In BatchParam.py there's an Operators dictionary with lamda functions. functions can be added here easily with as many variables as desired (just add defaults). simply pass in more variables in the iterator prompt [x,varName,lambda_name,n,a,b,c,d,...]

Important info and examples are currently in the Advanced Tab:

[CHECK BOX] Loop Through Prompts Prompt list will be cycled through if shorter than model list. A single prompt will repeat. A longer prompt list will have the extra prompts ignored.

Add this to your Checkpoint Names input(comma separated like the checkpoints) to cause each checkpoint to be used n times before moving to the next checkpoint. [checkpointRepetitions=n] Example Checkpoint Names: [checkpointIterations=5], checkpointName1, checkpointName2, checkpointName3 *note: this is different than setting the batch with {{count:n}} in that it will support multiple prompts and embedded prompt iterators.

[CHECK BOX] Enable Embedded Prompt Iterators Embedded Prompt Iterators allow you to have a number changed based on a function from generation to generation. Each embedded iterator has a unique name, the first time that embedding is found, the initial value is used. The next time that embedding is found, the operator is applied to the previous value.

Example Prompt 1: <lora:loraName-[000001,loraChkptIterator,+=1]:1> loraKeyWord –this outputs: loraKeyWord; loraKeyWord; loraKeyWord;… –(the number formatting of the initial value is applied to the output number string)

Example Prompt 2: A fat frog smoking a pipe, (cartoon:[0.0,myCartoonIterator,+=,0.1]), (realistic:[1.0,myRealisticIterator,-=,0.1]) –this outputs: A fat frog smoking a pipe, (cartoon:0.0), (realistic:1); A fat frog smoking a pipe, (cartoon:0.1), (realistic:0.9); …

Process Iterators: use the pattern [initVal,iteratorLabel,operator,operand,operand,operand…]. The brackets and contents will be replaced by the result of the operator. The initial value will be used first, and any subsequent call to the same iterator label will apply the operator using it’s optional operands.

Example Prompt 3: A fluffy dog on a trampoline (close up:[0.2,iterator1,+=,0.1]) –this outputs: A fluffy dog on a trampoline (close up:0.2); A fluffy dog on a trampoline (close up:0.3); A fluffy dog on a trampoline (close up:0.4); …

Functions available:

++,–,sqrt: [startInt,myIteratorName,++] [1,myIncrementor,++] (put after a lora/lyco training checkpoint…)

+=,-=,=,/=,%=,^=: [startInt,myAdderName,+=,operandFloat(default=1)] [0.3,myMultiplier,=,1.1] (this will increase slowly but faster as it goes)

log,log10,log2: [startInt,myIteratorName,sqrt,amplitudeFloat(default=1),FrequencyFloat(default=1)] [0.5,mySinIterator,sin,0.1(default=1),FrequencyFloat(default=1)] approach_limit: [startInt,myIteratorName,approach_limit,limitFloat(default=1),RateFloat(default=1)]

h43lb1t0 commented 1 year ago

i'm at the beginning of the exam phase, i don't have a lot of time. i understood and was able to use the iteration over the checkpoints. i think i understood what the prompt itterators should do, but i didn't get it working that way. Can you show me a concrete example?

RandyHaylor commented 1 year ago

There are explicit examples in the notes in the advanced tab. Try those and feel free to ask questions. No worries about the timing, I'm fine using my own fork and feel no urgency for you to merge my work. It might not even be coded in the direction you want to go so feel free to wait until you have time to review. I just thought I'd share since it's useful to me for comparing models or Lora epochs quickly. If you just take inspiration or ideas from what I've done to write things your own way that's also great. I'm not really concerned about whether or not my code gets merged, but happy to help with it if you want to use it. Thanks for reaching out and for sharing your project.

Good luck on exams!

h43lb1t0 commented 1 year ago

I like your idea, but i think it's to much for this. checkout the fork_mention branch. I've mentioned your fork there if you want to.

RandyHaylor commented 1 year ago

Thanks! I might just use my fork for my specific testing purposes. Maybe I'll throw some documentation up so other ppl can use it if they want. I might even adapt it a little more to the purpose.

h43lb1t0 commented 1 year ago

have fun with this script as base :)