Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Array Support on main prompt #1503

Merged
merged 8 commits into from
Feb 25, 2024
Merged

Conversation

flannerybh
Copy link
Contributor

Idea to use arrays in the main prompt.
To use arrays, put all values inside double brackets. For example:
[[tall, short, fat, thin]] man.
would produce 4 images (tall man, short man, fat man, thin man). You also need to set your number of images to map, if you set the number of images higher, the array will just wrap around.

You can also use multiple arrays for example:
[[beautiful, ugly]] [[man, woman]] wearing a [[red, white, blue]] suit
would produce all combinations of each array (you'd need to set the image count to 12).

This can be used in conjunction with the "Freeze Seed" checkbox, so each image uses the same random seed so your images will look very similar except for the differences that come from the words in the array.

@xhoxye
Copy link
Contributor

xhoxye commented Dec 20, 2023

What is the difference between it and wildcards?

@flannerybh
Copy link
Contributor Author

What is the difference between it and wildcards?

A wild card is chosen at random. There's not guarantee that you would cycle through them all, or that you wouldn't use the same value twice. An array will deterministically cycle through all values.

It's also much quicker to use arrays because they can be added/edited right in the prompt rather than in a config file.

@flannerybh
Copy link
Contributor Author

@lllyasviel , just wanted to check if this was on your radar. This is my first contribution, let me know if there's something else I should do to move it along. Or if you're not interested in pulling.

Thanks!

@CraigOndrak
Copy link

Hi Guys, can this be please reviewed/merged so we can start using this amazing feature.

@flannerybh
Copy link
Contributor Author

@mashb1t is there anything I can do to get this approved/merged. Looks like a few people are interested.

@mashb1t
Copy link
Collaborator

mashb1t commented Jan 10, 2024

@flanneryhbh as much as i'd also want to see this feature merged there is nothing we can do. The Fooocus core dev team will be back mid/end of January, see update_log.md

(2023 Dec 21) Hi all, the feature updating of Fooocus will be paused for about two or three weeks because we have some other workloads. See you soon and we will come back in mid or late Jan. However, you may still see updates if other collaborators are fixing bugs or solving problems.

@andynormancx
Copy link

I've given it a test and it works as advertised, awesome. Just what I wanted.

A nice extra feature would be some sort of auto image number setting. I would be handy if there was a checkbox to mean it would automatically run the number of images to match the number of combinations.

I guess it might be good if the Generate button told you how many images it was about to create "Generate 12 images". But I'm guessing that would involve changing when the prompt is parsed, I've not really looked at the code in any detail yet.

And a clearly much more involved feature would be to have a label under the output images showing you the array combinations used for that image.

@almfisch
Copy link

Idea to use arrays in the main prompt. To use arrays, put all values inside double brackets. For example: [[tall, short, fat, thin]] man. would produce 4 images (tall man, short man, fat man, thin man). You also need to set your number of images to map, if you set the number of images higher, the array will just wrap around.

You can also use multiple arrays for example: [[beautiful, ugly]] [[man, woman]] wearing a [[red, white, blue]] suit would produce all combinations of each array (you'd need to set the image count to 12).

This can be used in conjunction with the "Freeze Seed" checkbox, so each image uses the same random seed so your images will look very similar except for the differences that come from the words in the array.

Perhaps it makes sense to use a syntax that is also used in other systems.
Then you can use prompts more easily in different systems without having to modify them too much.

In ComfyUi the syntax is like this:
{red|blue|yellow|green}

In Automatic1111 the same, but without brackets:
red|blue|yellow|green

@Ev-Bro
Copy link

Ev-Bro commented Jan 28, 2024

This doesnt seem to be working in the current version.

@flannerybh
Copy link
Contributor Author

Idea to use arrays in the main prompt. To use arrays, put all values inside double brackets. For example: [[tall, short, fat, thin]] man. would produce 4 images (tall man, short man, fat man, thin man). You also need to set your number of images to map, if you set the number of images higher, the array will just wrap around.
You can also use multiple arrays for example: [[beautiful, ugly]] [[man, woman]] wearing a [[red, white, blue]] suit would produce all combinations of each array (you'd need to set the image count to 12).
This can be used in conjunction with the "Freeze Seed" checkbox, so each image uses the same random seed so your images will look very similar except for the differences that come from the words in the array.

Perhaps it makes sense to use a syntax that is also used in other systems. Then you can use prompts more easily in different systems without having to modify them too much.

In ComfyUi the syntax is like this: {red|blue|yellow|green}

In Automatic1111 the same, but without brackets: red|blue|yellow|green

The pipe (|) notation in ComfyUi and Automatic1111 seem to be a wildcard system, where it picks a random value from the list. The array concept is deterministic, as it will cycle through the values in order. I think that's a way better feature. I'll leave the wildcard notation free for someone else to implement.

@andynormancx
Copy link

I’ve made my own additional changes to this to make it more flexible. They allow it to be used for applying arrays to prompt weighting for example. And also to be able to have an empty value as one of the array elements.

Not sure what the proper way of contributing this would be, I’m not up to speed on the workflow of PRs on public GitHub repos.

@mashb1t
Copy link
Collaborator

mashb1t commented Jan 29, 2024

@andynormancx you can make a PR to https://github.com/flanneryhbh/Fooocus-add-array-to-propt/tree/main so your changes will be reflected in this PR if @flanneryhbh accepts them.

@flannerybh
Copy link
Contributor Author

This doesnt seem to be working in the current version.

@Ev-Bro this feature is still in a Pull Request, meaning it's not in the current base version of Fooocus. If you are having trouble getting it to work in my forked branch, please elaborate.

@Ev-Bro
Copy link

Ev-Bro commented Jan 29, 2024

This doesnt seem to be working in the current version.

@Ev-Bro this feature is still in a Pull Request, meaning it's not in the current base version of Fooocus. If you are having trouble getting it to work in my forked branch, please elaborate.

My bad! Please ignore.

@mashb1t mashb1t mentioned this pull request Feb 3, 2024
@mashb1t mashb1t added the Size M medium change, isolated, testing with care label Feb 9, 2024
@metercai
Copy link

metercai commented Feb 17, 2024

This doesnt seem to be working in the current version.

@Ev-Bro this feature is still in a Pull Request, meaning it's not in the current base version of Fooocus. If you are having trouble getting it to work in my forked branch, please elaborate.

My bad! Please ignore.

@flanneryhbh This feature is merged on the other branch version and adds the ability to group words with wildcards,thanks! https://github.com/metercai/SimpleSDXL

@mashb1t mashb1t added this to the 2.2.0 milestone Feb 24, 2024
@mashb1t mashb1t changed the base branch from main to develop February 25, 2024 12:47
modules/async_worker.py Outdated Show resolved Hide resolved
@mashb1t mashb1t merged commit c898e6a into lllyasviel:develop Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Size M medium change, isolated, testing with care
Projects
None yet
Development

Successfully merging this pull request may close these issues.

batches
8 participants