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

TOML support for sample prompt #504

Merged
merged 3 commits into from
May 15, 2023
Merged

TOML support for sample prompt #504

merged 3 commits into from
May 15, 2023

Conversation

Linaqruf
Copy link
Contributor

@Linaqruf Linaqruf commented May 14, 2023

Hi, I want to propose small changes for loading args.sample_prompt. I added .toml support so we can easily assign the sample prompt parameter to each key instead of putting all parameters in one line (using .txt). The sample prompt parameter is also more readable and easy to maintain. Not only that, we don't need to set the same parameter again because I borrowed the dataset_config approach by using [[prompt.subset]] to store additional parameters.

An example of sample_prompt.toml is as follows:

[prompt]
negative_prompt = "(worst quality, low quality:1.4)"
scale = 7
sample_steps = 20
width = 512
height = 768

[[prompt.subset]]
prompt = "masterpiece, best quality, masterpiece, best quality, solo, looking at viewer, short hair, bangs, red eyes, gloves, 1boy, holding, hair between eyes, closed mouth, upper body, weapon, male focus, red hair, black gloves, belt, sword, cape, holding weapon, armor, fur trim, holding sword, red background, red cape"

[[prompt.subset]]
prompt = "masterpiece, best quality, 1girl, solo, long hair, looking at viewer, smile, bangs, blue eyes, dress, ribbon, holding, bare shoulders, blue hair, flower, frills, teeth, sleeveless, hand up, signature, white dress, grin, red ribbon, blue sky, petals, neck ribbon, floating hair, sleeveless dress, blue background, light particles, blue theme, multicolored eyes, yellow flower, holding flower, orange flower, orange ribbon"

[[prompt.subset]]
prompt = "masterpiece, best quality, 1girl, solo, long hair, breasts, looking at viewer, smile, bangs, blue eyes, skirt, red eyes, thighhighs, holding, jewelry, medium breasts, very long hair, blue hair, weapon, braid, red hair, multicolored hair, sword, cape, holding weapon, armor, two-tone hair, thigh strap, heterochromia, holding sword, tiara, black background, crossed bangs, crown braid, split-color hair"

We can also set prompt into different resolution or using a different sampler for each prompt by putting important parameters to [[prompt.subset]].

Example:

[prompt]
negative_prompt = "(worst quality, low quality:1.4)"
scale = 7
sample_steps = 20

[[prompt.subset]]
prompt = "a dog"
width = 512
height = 768
seed = 1337

[[prompt.subset]]
prompt = "a cat"
width = 1024
height = 768

I also added .json support in the latest commit.

Thank you

@kohya-ss kohya-ss changed the base branch from main to dev May 15, 2023 11:45
@kohya-ss kohya-ss merged commit b556fc4 into kohya-ss:dev May 15, 2023
@kohya-ss
Copy link
Owner

Thank you for this! The .txt file is good enough for me, but this would make it easier to understand the prompt settings.

@Linaqruf
Copy link
Contributor Author

Thank you! I use it for Colab notebook so end user can easily add or edit the prompt config without needing further explanation about prompt args. It also to makes merging easier in the future. 😅

wkpark pushed a commit to wkpark/sd-scripts that referenced this pull request Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants