Giter Club home page Giter Club logo

sd-dynamic-prompts's Introduction

Stable Diffusion Dynamic Prompts extension

A custom extension for AUTOMATIC1111/stable-diffusion-webui that implements an expressive template language for random or combinatorial prompt generation along with features to support deep wildcard directory structures.

Looking for ComfyUI nodes? Find them here.

Table of Contents

Basic Usage

Using this script, the prompt:

A {house|apartment|lodge|cottage} in {summer|winter|autumn|spring} by {2$$artist1|artist2|artist3}

Will produce any of the following prompts:

  • A house in summer by artist1, artist2
  • A lodge in autumn by artist3, artist1
  • A cottage in winter by artist2, artist3
  • ...

This is especially useful if you are searching for interesting combinations of artists and styles.

You can also pick a random string from a file. Assuming you have the file seasons.txt in WILDCARD_DIR (see below), then:

__seasons__ is coming

Might generate the following:

  • Winter is coming
  • Spring is coming
  • ...

You can also use the same wildcard twice

I love __seasons__ better than __seasons__
  • I love Winter better than Summer
  • I love Spring better than Spring

More complete documentation can be found here.
Prefer a tutorial? Click here
Need a wildcard library? We've got you covered.

Online resources

You can find a list of tutorials and wildcard packs here

Installation

The extension can be installed directly from within the Extensions tab within the Webui

You can also install it manually by running the following command from within the webui directory:

git clone https://github.com/adieyal/sd-dynamic-prompts/ extensions/sd-dynamic-prompts

You can create wildcard files in extensions/sd-dynamic-prompts/wildcards or you can leverage the pre-installed collections by using the "Wildcards Manager" tab in the Web UI.

Configuration

You can find various settings to change Dynamic Prompt's behaviour in the Settings tab in the Dynamic Prompts section.

Changing syntax

In case of a syntax clash with another extension, Dynamic Prompts allows you to change the definition of variant start and variant end. By default these are set to { and } respectively. , e.g. {red|green|blue}. In the settings tab, you can change these two any string, e.g. <red|green|blue> or even ::red|green|blue::.

By default, wildcards start with __(double underscore) and end with __. You can change this in the settings tab under wildcard wrap.

Wildcard settings

Dynamic Prompts automatically de-duplicates and sorts wildcard files before using them. If you would prefer to disable this functionality, you can uncheck the checkboxes in the settings tab.

Checking the "shuffle wildcards" checkbox will randomize the order of the wildcards, ensuring that running the combinatorial model will produce different images on different runs.

Save template to metadata

The default behavior is to resolve all the wildcards to a usable prompt, then that prompt is stored in the PNG info or txt file (e.g. I love Winter better than Summer). If you would also like to recall the original template with the wildcards you can turn this option on and you'll save:

I love Winter better than Summer
Template: I love __seasons__ better than __seasons__

Note: this additional "Template" section is not displayed in the generate page but will be available in PNG Info (or image browser, if you have that extension installed).

Troubleshooting

If you encounter an issue with Dynamic Prompts, follow these steps to resolve the problem:

  1. Check that you have installed the latest version of both the Dynamic Prompts extension and library. To check the installed versions, open the Need Help? accordion in the Dynamic Prompts section of txt2image. You can find the latest version number of the extension here and the library here.

  2. If the versions do not match, update the extension in the extensions tab and restart the webui. The extension should automatically update the library.

  3. If the above step does not work, you might need to manually update the library using the following command:

python -m pip install -U dynamicprompts[attentiongrabber,magicprompt]
  1. Restart the webui and check. If the webui uses a different python binary, find the correct path to the python binary and run:
/path/to/python/binary/python -m pip install -U dynamicprompts[attentiongrabber,magicprompt]
  1. If the Wildcard UI does not show, it could be due to an outdated library version. Check for errors in the terminal and update the library as described in step 3.

  2. If you get an error message saying "No values found for wildcard some/wildcard", ensure that the file wildcard.txt is in extensions/sd-dynamic-prompts/wildcards/some/. The full path is required, as relative paths are not currently supported.

  3. If the issue persists, search for solutions in the issues section on GitHub and the discussion forum. If you cannot find a solution, create a new issue and give it a descriptive name, such as "Wildcard values are being ignored in prompt templates". Provide the necessary context, including the versions of the Dynamic Prompts extension and library, and mention the operating system or colab being used. If there is an error in the terminal, copy and paste the entire text or take a screenshot.

  4. Finally, it is essential to test and apply any fixes we release. Your feedback is valuable, as an issue that works in our environment may not work in yours.

Compatible Scripts

Dynamic Prompts works particularly well with X/Y Plot - setting Dynamic Prompts to combinatorial mode while using X/Y Plot, lets you exhaustively test prompt and paramter variations simultaneously.

Template syntax

Documentation can be found here

Fuzzy Glob/recursive wildcard file/directory matching

In addition to standard wildcard tokens such as __times__ -> times.txt, you can also use globbing to match against multiple files at once. For instance:

__colors*__ will match any of the following:

  • WILDCARD_DIR/colors.txt
  • WILDCARD_DIR/colors1.txt
  • WILDCARD_DIR/nested/folder/colors1.txt

__light/**/*__ will match:

  • WILDCARD_DIR/nested/folder/light/a.txt
  • WILDCARD_DIR/nested/folder/light/b.txt

but won't match

  • WILDCARD_DIR/nested/folder/dark/a.txt
  • WILDCARD_DIR/a.txt

You can also used character ranges [0-9] and [a-z] and single wildcard characters ?. For more examples see this article.

WILDCARD_DIR defaults to extensions/sd-dynamic-prompts/wildcards.

Combinatorial Generation

Instead of generating random prompts from a template, combinatorial generation produced every possible prompt from the given string. For example: I {love|hate} {New York|Chicago} in {June|July|August}

will produce:

  • I love New York in June
  • I love New York in July
  • I love New York in August
  • I love Chicago in June
  • I love Chicago in July
  • I love Chicago in August
  • I hate New York in June
  • I hate New York in July
  • I hate New York in August
  • I hate Chicago in June
  • I hate Chicago in July
  • I hate Chicago in August

If a __wildcard__ is provided, then a new prompt will be produced for every value in the wildcard file. For example: My favourite season is __seasons__

will produce:

  • My favourite season is Summer
  • My favourite season is August
  • My favourite season is Winter
  • My favourite season is Sprint

You also arbitrarily nest combinations inside wildcards and wildcards in combinations.

Combinatorial generation can be useful if you want to create an image for every artist in a file. It can be enabled by checking the Combinatorial generation checkbox in the ui. In order to prevent accidentially producing thousands of images, you can limit the total number of prompts generated using the Max Generations slider. A value of 0 (the default) will not set any limit.

Combinatorial Batches

The combinatorial batches slider lets you repeat the same set of prompts a number of times with different seeds. The default number of batches is 1.

Increasing the maximum number of generations

By default, the Batch count silder of automatic1111 has a maximum value of 100. This can limit the maximum number of generations when using combinatorial generation. You can change the maximum value of this slider by editing ui-config.json and change:

txt2img/Batch count/maximum": 100

to something larger like:

txt2img/Batch count/maximum": 1000

Fixed seed

Select this if you want to use the same seed for every generated image. If there are no wildcards then all the images will be identical. It is useful if you want to test the effect of a particular modifier. For example:

A beautiful day at the beach __medium/photography/filmtypes__

That way you can isolate the effect of each film type on a particular scene. Here are some of the results:

Magic Prompt

Use one of a number of prompt generation models to spice up your prompt.

Using Gustavosta's MagicPrompt model, Trained on 80,000 prompts from Lexica.art, it can help give you interesting new prompts on a given subject. Here are some automatically generated variations for "dogs playing football":

dogs playing football, in the streets of a japanese town at night, with people watching in wonder, in the style of studio ghibli and makoto shinkai, highly detailed digital art, trending on artstation

dogs playing football, in the background is a nuclear explosion. photorealism. hq. hyper. realistic. 4 k. award winning.

dogs playing football, in the background is a nuclear explosion. photorealistic. realism. 4 k wideshot. cinematic. unreal engine. artgerm. marc simonetti. jc leyendecker

This is compatible with the wildcard syntax described above.

Other models

The first time you use a model, it is downloaded. It is approximately 500mb and so will take some time depending on how fast your connection is. It will also take a few seconds on first activation as the model is loaded into memory. Note, if you're low in VRAM, you might get a Cuda error. My GPU uses less than 8GB but YMMV.

You can control the maximum prompt length with the Max magic prompt length slider. Magic prompt creativity can adjust the generated prompt but you will need to experiment with this setting.

Use the Magic prompt blocklist regex to filter out keywords. For example, if you want to avoid prompts containing Greg Rutkowski, add his name to this field.

If you are generating many prompts using Magic Prompt, then increasing the Magic Prompt batch size can improve significantly improve prompt generation speed. This may only be noticeable if you are not generating images as well since image generation is much slower than prompt generation.

I'm feeling lucky

Use the lexica.art API to create random prompts. Useful if you're looking for inspiration, or are simply too lazy to think of your own prompts. When this option is selected, the prompt in the main prompt box is used as a search string. For example, prompt "Mech warrior" might return:

  • A large robot stone statue in the middle of a forest by Greg Rutkowski, Sung Choi, Mitchell Mohrhauser, Maciej Kuciara, Johnson Ting, Maxim Verehin, Peter Konig, final fantasy , 8k photorealistic, cinematic lighting, HD, high details, atmospheric,
  • a beautiful portrait painting of a ( ( ( cyberpunk ) ) ) armor by simon stalenhag and pascal blanche and alphonse mucha and nekro. in style of digital art. colorful comic, film noirs, symmetry, brush stroke, vibrating colors, hyper detailed. octane render. trending on artstation
  • symmetry!! portrait of a robot astronaut, floral! horizon zero dawn machine, intricate, elegant, highly detailed, digital painting, artstation, concept art, smooth, sharp focus, illustration, art by artgerm and greg rutkowski and alphonse mucha, 8 k

Leaving the prompt box blank returns a list of completely randomly chosen prompts.

Attention grabber

This option randomly selects a keyword in your prompt and adds a random amount of emphasis. Below is an example of how this affects the prompt:

a portrait an anthropomorphic panda mage casting a spell, wearing mage robes, landscape in background, cute, dnd character art portrait, by jason felix and peter mohrbacher, cinematic lighting

Tick the Fixed seed checkbox under Advanced options to see how emphasis changes your image without changing seed.

Write prompts to file

Check the write prompts to file checkbox in order to create a file with all generated prompts. The generated file is a slugified version of the prompt and can be found in the same directory as the generated images, e.g. outputs/txt2img-images

Jinja2 templates

Jinja2 templates is an experimental feature that enables you to define prompts imperatively. This is an advanced feature and is only recommended for users who are comfortable writing scripts.

To enable, open the advanced accordion and select Enable Jinja2 templates.

You can read about them in more detail here

WILDCARD_DIR

The extension looks for wildcard files in WILDCARD_DIR. The default location is /path/to/stable-diffusion-webui/extensions/sd-dynamic-prompts/wildcards. It can also be manually defined in the main webui config.json under wildcard_dir. When in doubt, the help text for the extension in the webui lists the full path to WILDCARD_DIR

Collections

The collections directory contains modifier libraries that you can use as is or to bootstrap your own. To get started, either use the Wildcard Manager tab to copy a one or more collections to your wildcards folder, or you can manually copy the files across. Three collections are bundled with the dynamic prompts extension.

If you're using a Unix/Linux O/S, you can easily create a symlink to the relevant collection rather than copying it across if you don't plan to alter it. E.g.

ln -sr collections/parrotzone wildcards/

You can also download additional extensions by running python _tools/download_collections.py from within the extension's root directory, i.e. extensions/sd-dynamic-prompts/

Dynamic Prompts and Random Seeds

Random seeds play an important role in controlling the randomness of the generated outputs. Let's discuss how Dynamic Prompts works with random seeds in different scenarios.

Without Dynamic Prompts Enabled

  1. If the seed is set to -1: A random seed is picked. This seed is used to generate the first image, then the next image is created using seed + 1, and this pattern continues for subsequent images.
  2. If the seed is set to a specific number greater than -1: The process is similar to the one above, but starts with the user-specified seed.
  3. If the variation seed is defined, but variation strength is zero: The process remains the same as in the previous two points.
  4. If the variation seed is set to a number greater than 0: Every image is generated using the same initial seed (randomly selected or set by the user). The variation seed is either random (if set to -1) or the value chosen by the user. The first image is generated with the variation seed, the next with variation seed + 1, and so on.

Using With Dynamic Prompts Enabled in Random/Standard Mode:

  1. If the seed is set to -1: The process is similar to the first point in the previous section. However, the prompt is also selected using the same seed (if the random prompt generator is used).
  2. If the seed is set to a number greater than -1: The process is similar to the second point in the previous section. However, the difference is that a random prompt is also generated using the chosen seed (if the prompt generator is used).
  3. If the fixed seed checkbox is checked: The same seed is used for all images and prompts. This means the same image is generated repeatedly (this is useful for combinatorial generation).
  4. If both the fixed seed and unlink seed from prompt checkboxes are checked: A random seed is used for the prompt, but the same seed is used for all images. This setting can be useful if you want to see how different prompts affect the generation of the same image.

Variation Seeds with Dynamic Prompts

  1. Variation strength set to 0: Variations are ignored.
  2. Variation set to a number > 0: A variation seed is assigned to every image, incrementing by one each time. However, only 1 prompt is generated since you are looking for variations of the same image.

Combinatorial Mode with Variation Strength > 0

In this case, it only generates the first image for you, which is probably not what you want. To get the desired results, you might need to adjust the settings or use a different mode.

sd-dynamic-prompts's People

Contributors

adieyal avatar akx avatar brimston3 avatar chriscsc avatar cobryan05 avatar dbitterlich avatar eltociear avatar eugenii10 avatar evanjs avatar funwhilelost avatar galvanized avatar icryo avatar jgrunik avatar jjmenet avatar jmpaz avatar ju1-js avatar mcmonkey4eva avatar mmaker-gh avatar ruin0x11 avatar shiverczar avatar shoffing avatar simonmcnair avatar sineswiper avatar snipervld avatar space-nuko avatar theawesomegoat avatar w-e-w avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sd-dynamic-prompts's Issues

Display unprocessed prompt with wildcards alongside processed prompt

In jtkelm's wildcards script (repo link seems to be dead, but it should be similar to this), prompts are displayed both raw and unprocessed in the dialog box.

  • Wildcard prompt: The raw text before it has been processed. This includes wildcards used
    • e.g. __season__
  • Example: the processed prompt, with wildcards replaced with the selection for each item
    • e.g. winter
  • Negative: unmodified negative prompt

While it might not be as helpful in "Generate forever" sessions without ensuring the wildcards are also exported, it could be helpful for single generations, and can help the user ensure their expressions are working as intended.

Though, after thinking on it, I wonder what we'd choose to display if this was implemented, since dynamic prompting allows for combinations and options.
Would we display the initial raw prompt without any evaluation?
What about recursive wildcard evaluation? Would that make this feature less useful?

"Person" wildcard also drew from "personaction" wildcard

I had a person wildcard with three names, but when I used it, I was getting images with prompts like "through a window," and "in space" and I realized it was taking from both the person wildcard and the personaction wildcard. I haven't noticed this until I updated to the .5 version of this script.

cant enable script. it does not work either

you used to use the script drop down but it is no longer found there. it also doesn't work either so it's not just globally enabled (plus even if it was, because it's not in the drop down it has no options or settings)

Prompt limit of 125

I have tested this in several ways.

It seems the current prompt limit when using wildcards is 125 (the value listed on the UI, next to the "Generate" button); after this value, the wildcards stop working.

Or at least, this is happening on my end.

If this pattern is possible {3$${and|,}$$__values__}

Describe the bug
A clear and concise description of what the bug is.

normalcy ex) {3$$__paser__$$__values__}
-> __values__ __paser__ __values__ __paser__ __values__
-> [ a and b , c ],[ b , c and c ],[ a and b and c ], ...

bug ex) {3$${and|,}$$__values__}
-> {3$$and$$a}
-> [ a and a and a] , [ b and b and ]

I think it needs to be upgraded

def _parse_combinations(self, combinations_str):

Version used
What version of the extension are you using? You can see it next to Dynamic Prompt v[VERSION] in the scripts dropdown.

under 0.25.0

To Reproduce
Steps to reproduce the behaviour, include the prompt you used if applicable:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Also mention which checkboxes have been set.

Expected behaviour
A clear and concise description of what you expected to happen.

Additional context
Add any other context about the problem here.

Updated, wildcards now linked to seed? (breaks previous usage)

This is absolutely beyond amazing, thank you so much for its development,
however updating to try and take advantage of the new features has broken my previous usage of the script.

With the wildcards locked to seeds? pressing 'generate' with wildcards now always returns the same result. This is a problem because I took advantage of wildcards primarily because they meant I could find a good seed with the surrounding prompt, but vary it.
For example I could press generate and randomize the characters features with wildcards but hold the rest of their construction.

If this was meant as a 'fix' for it not being locked to the seed before, could this please be returned with a toggle, e.g. 'separate wildcard randomization from seed'.

__textfile__ not working

I tried to install by terminal and also via extensions in Gradio by it's not taking any __textfile__ . I do have them in the wildcards folder downloaded by git.
Ubuntu 20

Not showing up in the UI

Hello!

While I do have it installed (used the git clone command into my extension directory) and it shows up in the extensions tab :
image

It does not show anywhere else in my UI. No tab no extra option in the settings, nothing.

I am using a fresh colab so it is not due to residual files.

Best regards,

Wildcard files containing seeds?

Really loving this script- Is there any way we can have a wildcard file with seeds in it? In IMG2IMG I tried with prompt "(blah blah), Seed: seedlist" and it used the seed listed in the "seed" field in the UI, instead. I would really love a way to control the seed used via prompt and, of course, use a wildcard file for them....if any of that's at all possible. Thanks!

Simpler syntax for multiple wildcards

{{2-3$$__artist__}}

Just tried to use the above and it failed. Script seems to demand I do:

{{2-3$$__artist__|__artist__|__artist__}}

I'd also like to do things like:

{{2$$__artist__|__movement__}}

to give a mix of two artists, two movements, or one of each; without having to put each twice.

"File <full path> not found for the __<wildcard>__ wildcard."

I can't tell if I've done the setup wrong, or if I'm running into a bug. Installed from the Extension's page, and it's saying I'm up-to-date.

I've got my files in the default WILDCARD_DIR, like such:
scripts\wildcards\clothing\outfits.txt
scripts\wildcards\clothing\shoes.txt
scripts\wildcards\clothing\tops.txt
scripts\wildcards\clothing\bottoms.txt
scripts\wildcards\test.txt

test.txt contents (all on new lines, edited with Notepad so it probably has the Windows formatting)

Summer
Autumn
Winter
Spring

When I type in the prompt a lake in __test__ I get the auto complete suggestions showing up as soon as I type __, which is a good sign everything is in the right directory. If I select one of the files, it lists out all the options in it so I can manually pick one, which again makes me think I'm set up correctly.

However, when I go to run it, I get this error in the command prompt:
File E:\Documents\AI\ImgGen\stable-diffusion-webui\extensions\stable-diffusion-webui-wildcards\wildcards\test.txt not found for the __test__ wildcard.

It gets even worse when I try to use the clothing ones:
File E:\Documents\AI\ImgGen\stable-diffusion-webui\extensions\stable-diffusion-webui-wildcards\wildcards\clothing/outfits.txt not found for the __clothing/outfits__ wildcard.
Notice the full path there. It's swapping between \ and / for the directory. Not good!

The lake never generates with anything other than a vibrant green trees and grass around it (take your pick on Summer or Spring), and the text under the image generation is always this (minus the seed changing)

a lake in test
Steps: 28, Sampler: Euler a, CFG scale: 11, Seed: 945332860, Size: 512x768, Clip skip: 2, Wildcard prompt: a lake in __test__

I assume if the wildcards were working one of the prompts would replace test with one of the seasons?

errors while using Magic prompit

I am getting this error message while using Magic prompit :

AttributeError: 'NoneType' object has no attribute 'keys'

what i want to achieve for example if my prompit is like this { cat | dog | chicken } in the garden and are { happy | sad }

what i want to achieve is i get prompits like this

cat in the garden and are happy
cat in the garden and are sad
dog in the garden and are happy
dog in the garden and are sad
chicken in the garden and are happy
chicken in the garden and are sad

and the text file will be the same as the mentioned prompits and when it finish it stops , how can i achieve that ?

Combinatorial generation doesn't work as expected?

Nice extension but i think it doesnt work as documented

I installed it (as extension)
chose Dynamic prompting v0.13.7 (in Script section)
checked box Combinatorial generation
set Combinatorial batches to 4
prompt: test {dog|cat|rabbit}

according to docs i should have 3 images with combination of 3 different animals
but i get 4 images with one of animals every time (same animal for all 4 images)

am i doing something wrong?

Error loading script: dynamic_prompting.py

I don't understand why the script is not working for me.

Error loading script: dynamic_prompting.py Traceback (most recent call last): File "~~~/stable-diffusion-webui/modules/scripts.py", line 159, in load_scripts exec(compiled, module.__dict__) File "~~~/stable-diffusion-webui/scripts/dynamic_prompting.py", line 52, in <module> class WildcardManager: File "~~~/stable-diffusion-webui/scripts/dynamic_prompting.py", line 65, in WildcardManager def get_files(self, relative:bool=False) -> list[Path]: TypeError: 'type' object is not subscriptable

Send the generated prompt into in-paint / img2img

I'm loving this script! So much fun to mess around with!

Is it possible to send the generated prompt in txt2img over to inpainting / img2img? Currently I'm just copying and pasting the generated prompt into the in-paint tab. It's only a minor annoyance is all. Having a button to send the prompt and settings would be cool!

Thanks again!

Scan wildcards directory recursively

With a large number of wildcards, it can be unwieldy to maintain several large files in a single directory.
It would be nice if this script could scan recursively for wildcards in file structures of arbitrary depth.

Here is how I am handling it in my repository, using rglob.

Also note that other repositories such as a1111-sd-webui-tagcomplete have already implemented support for this feature; a similar update to dynamic prompting would complement this nicely.

To help improve readability, I also changed the script text element to display paths relative to WILDCARD_DIR, and made the list scrollable, to prevent a large number of wildcard files from expanding the page uncontrollably.

Happy to make a PR if the use case is valid and the changes (or something similar) sound acceptable.

Great script but weighted prompts do not work with it

For example (muscles:1.1) and (muscles:1.9) will give you wildly different results.

with text files I've tried (muscles:1.__num__) with the num text file being number 1 through 9 so output being (muscles:1.#).

I've also tried (muscles1.1) through (muscles1.9) in a textfile then using __muscles__ and that didn't work. I also tried without parenthesis and it didn't work. Bascially every possible way to do it in combination with pulling from a text file did not work.

I looked through the code and can't understand why it's not working when ( ) + prompt weights are involved.

How to use emuneration?

I saw in the notes that i can use
If a wildcard is provided, then a new prompt will be produced for every value in the wildcard file. For example: My favourite season is seasons

will produce:

My favourite season is Summer
My favourite season is August
My favourite season is Winter
My favourite season is Sprint

But this doesn't work. I tried using combination number, batch number, as well as * but it justs picks the things randomly from the file.

I think it should work like below

file contains 3 colors
red
black
white

my favorite color is MyColor (Some modifier) and it should give me 3 images with

my favorite color is red
my favorite color is black
my favorite color is white

Bug? Can't generate batches using dynamic prompting v0.4.3

Increasing batch size does nothing with this script on. Tried using no wildcards, reducing size of image, different samplers, etc. The only thing that makes batch size work again is turning off the script. Batch size increases overall speed of generating many images in cards with lots of vram so it's very useful.

I have a 3090 using voldy commit hash f49c08ea566385db339c6628f65c3a121033f67c

Combinatorial Generation, possible limitation (silently breaks), possible suggestion

In the readme examples for Combinatorial Generation, it demonstrates multiple {} contents, and a single wildcard, however it mentions nesting in both directions.
But as soon as I have more than 1 wildcard, it silently breaks for me and I have to restart.

If that's an intended limitation because of the excessive amount of possibilities with multiple wildcards, though that confuses me with "This upper limit ensures that you don't accidentally create a template that unexpectedly produces thousands of images" being mentioned. I wonder if you could potentially target a specific wildcard list for the combinational generation.
For example {wildcard} would have the generation go through that, with randomized elements of other wildcards. That way you could have a wildcard you desire seeing all the elements of, and set your batch to its size, and give another form of utility for this extension.

Is it possible to use the same random seelction multiple times in a prompt?

I have a file of random "careers" for characters. I'm hoping to reuse the random choice to indicated both the career and the uniform the character is wearing but I am not having much success.

I've tried:

A __career__ wearing a __career__ outfit but what I end up with is something like:

A teacher wearing a fishmonger's outfit [NOTE: not that there's anything wrong with that in real life!] when I wanted a teacher in a teacher's outfit

I thought I'd be clever and see if using "$1" or "\1" as a regex group holder would work, but that failed miserably :)

Artists should be restricted to artists recognized by SD

You tried to be exhaustive with the artists, I understand very well your aim but you fell into the same trap I fall myself some weeks ago when I tried to create SD artits database. The fact is only a very small subset of all artists existing has been used the train Stable Diffusion. The list of artists should be reduced to the one SD has been trained with, otherwise you kinda just produce veru unprecise artist style.

I advice you to read this article
https://waxy.org/2022/08/exploring-12-million-of-the-images-used-to-train-stable-diffusions-image-generator/

Let me take an example I took your french_mannerist_painters list
Ambroise Dubois, Antoine Caron, Francesco Primaticcio, François Quesnel, Luca Penni, Marc Duval, Martin Fréminet, Master of Flora,
Toussaint Dubreuil

I render six images with each of them using that prompt
a deer in the forest by
a close-up portrait of a woman by
an old king by
merchants in a city by
a bird on a tree branch by
the last judgement by

Here are the kind of result i got

Duval Marc
Duval, Marc
Dubois, Ambroise
Dubois, Ambroise
Penni, Luca
Penni, Luca
Quesnel, François
Quesnel, François

I can tell you SD doesn't know any of those artists style, maybe he knows they are renaissance artists not even but that's all

Now I render the same prompt with renaissance artist I know SD is aware of

Bellini, Giovanni
Bellini, Giovanni
** Masaccio**
Masaccio
Parmigianino
Parmigianino
van Eyck, Jan
van Eyck, Jan
Veronese, Paolo
Veronese, Paolo

For your artist lists to be really useful you will need to change your mind and reduce your lists dramatically. From my personal research, so far I have not found more than 50 renaissance artists known from SD and still for certain I have some doubts

Now the question is how .. i'm not aware of any "certified artists" list of SD. Probably the first step is to reduce to the artist list that others found out like the 1800 artists described into the article mentionned above.

Hope this won't kill your day.

Errors when loading SD

I'm getting these errors when loading StableDiffusion, not sure what they're affecting specifically, so i thought I'd share them with you to see if you know more about this. Thanks in advance for your assistance in this.

Untitled

Request: A problem with Combinatorial generation

So, I get it, you don't want the user to accidentally generate thousands of prompts and all, but, really, that's on the user.

The way you have it set now, I can have, at max, 32 combinations, unless I am missing something here... I could be, but, due to my processing limitations, I can't have the batch size very high.

So if I am doing everything right, I can only do a batch size of 2 and the max for batch count (Unless there is someway to change that) is 16. Now my problem is I have 20 objects and 30 situations, objects in one file, situations in the other, and I want to combine them and that's like 600 combinations.

Can we please get a better way to limit how many we can generate at a time.
Or, if there is a way I can do it with the current system, can we get an explanation as to how.

Thanks -J

Dynamic Prompts inside Wildcard files

Would it be possible to make it so that dynamic prompts are read correctly from inside of the wildcard .txts? For example, I have a wildcard file I use to pick random outfits and would like to attach specific randomly chosen backgrounds to each outfit inside the .txt, but right now the images generate a combination of all the tags inside of { | | | } markers rather than selecting one.

A way to enable globally

It would be nice if the extension could be globally enabled using a toggle in the settings instead of having to choose from plugins. Less cumbersome and also allows you to use dynamic prompts within other scripts.

Option Tweaking

Thank You for updating the script into an extension - great improvements and possibilities!

Noticed (in one of the closed issues) that it might be tricky to make it work with other scripts / integrate it into SD. I'm interested in X/Y plot in particular (to allow option tweaking, like changing hypernets, steps, CFG, etc.).

Is it possible with the current iteration of Dynamic Prompting / possible at all?

Write prompt to file error

Describe the bug

INFO:dynamic_prompting.py:Prompt matrix will create 8 images in a total of 8 batches.
ERROR:dynamic_prompting.py:Failed to write prompts to file: 'charmap' codec can't encode character '\u0142' in position 1208: character maps to

Version used
Dynamic-prompt extension 0.25.0

think is due to my artist.txt wildcard file that contain nord-european painter with Ä (142 in my charmap) in their name.
some google search suggest it correspond to this polish char: ł

Nested dynamic prompting?

I'd like to try something like this

A {male|female} {elf|orc|goblin} {warrior|priest|wizard} {walking in the {forest|desert}|running in the {jungle|arctic}}

but the script does not give me the alternatives at the end. I end up with results like:

A female elf priest {walking in the forest|running in the arctic} ... so it's picking the variables but not recursively picking the setting. Is that possible to do?

Thanks,

TB

Magic Prompt breaks automatic1111 built in Alternating Words

If you write a prompt like:

a painting of [Eva Green|Scarlett Johanson|deborah ann woll|Emily Blunt]

and activate Magic Prompt, the resulting rendered prompt will be:

a painting of [Eva Green, Scarlett Johanson, deborah ann woll, Emily Blunt]

switching the "|" with a comma ",".

That will result in multiple subjects instead of an alternated one.

Version: should be a729de9 (it's not in the scripts dropdown)

To Reproduce
see above.

Only magic prompt checkbox has been set.

Cheers.

[request] weight to wild card lines

it would be nice if we had a way to add a weight to lines of a wild card instead of copying and pasting that same line multiple times
example:

hot[9]
cold[9]
freezing[3]
burning[3]
on fire
frozen

this could make hot 3 times as likely as freezing and freezing 3 times as likely as frozen
in addition to this, something we can put on the line that is nothing, for the chance to get no selection and control that chance with a weight

Bug fix on the missing logger

Hi,

The extension is a masterpiece and I love it.

I am trying to add the "wildcard_dir":"D:\\wildcards" in stable-diffustion-webui/config.json

but the error shows as below:

Error loading script: dynamic_prompting.py
Traceback (most recent call last):
  File "C:\stable-diffusion-webui\extensions\sd-dynamic-prompts\prompts\, line 16, in ensure_directory
    self._path.mkdir(parents=True, exist_ok=True)
AttributeError: 'str' object has no attribute 'mkdir'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\stable-diffusion-webui\modules\scripts.py", line 170, in load
    exec(compiled, module.__dict__)
  File "C:\stable-diffusion-webui\extensions\sd-dynamic-prompts\scripts\y", line 133, in <module>
    wildcard_manager.ensure_directory()
  File "C:\stable-diffusion-webui\extensions\sd-dynamic-prompts\prompts\, line 18, in ensure_directory
    logger.exception(f"Failed to create directory {self._path}")
NameError: name 'logger' is not defined

seems is python missing a logger library.

logger.exception(f"Failed to create directory {self._path}")
======
print (f"Failed to create directory {self._path}")

I try to fix it by replacing logger with print, it works for a while, but error shows in other lines

in pick_wildcards
    return re_wildcard.sub(lambda x: self._replace_wildcard(x), template)
  File "C:\stable-diffusion-webui\extensions\sd-dynamic-prompts\prompts\generators\randomprompt.py", line 100, in <lambda>
    return re_wildcard.sub(lambda x: self._replace_wildcard(x), template)
  File "C:\stable-diffusion-webui\extensions\sd-dynamic-prompts\prompts\generators\randomprompt.py", line 78, in _replace_wildcard
    wildcard_files = self._wildcard_manager.match_files(wildcard)
  File "C:\stable-diffusion-webui\extensions\sd-dynamic-prompts\prompts\wildcardmanager.py", line 33, in match_files
    WildcardFile(path) for path in self._path.rglob(f"{wildcard}.{constants.WILDCARD_SUFFIX}")
AttributeError: 'str' object has no attribute 'rglob'

If I use the default WILDCARD_DIR, everything works fine.
May I know can the extension support change wildcard_dir to D:\ drive?

MagicPrompt is broken

I am not saying anything, but it is broken:

Traceback (most recent call last):
  File "D:\Emergency\Stable Diffusion WebUI\modules\ui.py", line 185, in f
    res = list(func(*args, **kwargs))
  File "D:\Emergency\Stable Diffusion WebUI\webui.py", line 54, in f
    res = func(*args, **kwargs)
  File "D:\Emergency\Stable Diffusion WebUI\modules\txt2img.py", line 45, in txt2img
    processed = modules.scripts.scripts_txt2img.run(p, *args)
  File "D:\Emergency\Stable Diffusion WebUI\modules\scripts.py", line 296, in run
    processed = script.run(p, *script_args)
  File "D:\Emergency\Stable Diffusion WebUI\extensions\sd-dynamic-prompts\scripts\dynamic_prompting.py", line 137, in run
    prompt_generator = MagicPromptGenerator(
TypeError: MagicPromptGenerator.__init__() takes 2 positional arguments but 4 were given

Steps to reproduce:

  1. Turn MagicPrompt on
  2. Write some initial text (not sure it is needed)
  3. Start generation

Why do you send it more arguments than needed?

magic prompt limited edition ?

Here is my prompt :

on stage, club, indoor, table, seats, chair, bar, standing microphone, realistic lighting, colored lighting,
highly detailed, digital painting, concept art, smooth, sharp focus, sharp focus, illustration, hyperdetailed, hyperreal, trending on artstation
ilya kuvshinov and range murata,

Here is what is send to the generator :

on stage, club, indoor, table, seats, chair, bar, standing microphone, realistic lighting, colored lighting,
highly detailed, digital painting, concept art, smooth, sharp focus, sharp focus, illustration, hyperdetailed, hyperreal, trending on artstation
ilya kuvshinov and range murata, holding

The only thing added is "holding"... I had that multiple times, seems like the longer the prompt is, the less magic prompt works. Maybe because of some arbitrary limitation, but this is annoying really fast.

Here is the PNG if you want to extract the data from it. https://i.imgur.com/cJVCyAG.png

I wish we can enable the plugin to have no regards about the prompt lenght or something, maybe the plugin can have some sort of button you clic and it give you random parameters that you can choose to add to your prompt ?

ImportError: cannot import name 'FeelingLuckyGenerator'

Describe the bug
When I updated the extension, I got this error in the terminal.

ImportError: cannot import name 'FeelingLuckyGenerator' from 'prompts.generators' (F:\repos\auto111\stable-diffusion-webui\extensions\sd-dynamic-prompts\prompts\generators\__init__.py)

Version used
Dynamic Prompts doesn't show in the scripts dropdown. But I just updated.

To Reproduce
Steps to reproduce the behaviour, include the prompt you used if applicable:

  1. Updated extension
  2. Saw error in terminal

Dynamic Parameters in the Prompt and range parameters

Could be helpfull something like the grid generation but using the prompt, something like:

%CFG_SCALE=29|30|31|32% %SAMPLIG_METHOD=Euler a|Euler% etc etc.

And maybe better, something like ranges as the number of parameters to print:

%CFG_SCALE=$$29-35% //This could be also applyed to the basic prompting, but is not helpier than the usage with generation params

Installed but missing

The exstion is installed but is no longer showing in the drop down menu after 0.15< just updated from 0.14 which did show in the menu

How to use it as an extension?

Many thanks to see there are many updates recently.
I see the script are changed into an extension since 0.11.
But the UI is still in the "script" drop-down menu. Maybe it should move to the setting page?

I want to use it with an other script to run repeatly, but currently the Combinatorial mode is not working with batchs.

Wildcard progressive autocomplete

I do apologise if this is the wrong place as I'm not sure what implements this, but when writing a prompt, I can use the tab key to autocomplete wildcards. This is very useful, except it will auto-complete whichever one is the top one, rather than filling in only what is "common" to the current possibilities. This means I have to type out a considerable amount before I can auto-complete usefully.

For example, if the three files are "foofoo", "foobar" and "foobaz". I would expect the following:

  1. f<TAB> becomes "foo"
  2. foob<TAB> becomes "fooba"

Currently, f<TAB> would just autocomplete whichever happens to be first in the list of possibilities.

Wildcards in batch img2img

I love wildcards and almost always use them, but there's two functions that can't seem to use them.

The first is batch processing. The wildcards script works but only uses one value for all images in the whole batch count. This dynamic prompting script actually just gives me an error when I try to do batch processing. (batch processing is in the img2img tab, it lets you run img2img on an entire folder of images with the same prompt and values). I would love to be able to use batch processing with dynamic prompting, and a unique combination of wildcard values in every individual image generation in the batch.

The second is wildcard/dynamic negative prompts. I sometimes use wildcards as a way of just adding variability, and I would love to be able to have "(adjective)" as my negative prompt to generate more kinds of variation in my generations. Right now it doesn't seem to recognize a wildcard in the negative text book, and the generated image's txt file just says "adjective" instead of assigning it a value.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.