Skip to content

Configuration

s1dlx edited this page Mar 24, 2023 · 24 revisions

Configuration

We use hydra library to handle config files, see their docs for a comprehensive description of how it works. Here we explain the bare minimum setup to get you going with the extension.

Your extensions/sd-webui-bayesian-merger/ folder is organised as follows

├── README.md
├── bayesian_merger.py
├── conf/...
├── install.py
├── logs/...
├── models/...
├── requirements.txt
├── sd_webui_bayesian_merger/...
├── tests/...
└── wildcards/...

In this page we focus on conf/ folder and its content:

├── conf
│   ├── config.tmpl.yaml
│   └── payloads
│       ├── cargo
│       │   └── payload.tmpl.yaml
│       └── cargo.tmpl.yaml

As you can see there are three .tmpl.yaml files in a nested folder structure. You need to copy and rename the three of them in the following way:

  • config.tmpl.yaml -> config.yaml
  • cargo.tmpl.yaml -> cargo.yaml
  • payload.tmpl.yaml -> payload.yaml

resulting in

├── conf
│   ├── config.tmpl.yaml
│   ├── config.yaml
│   └── payloads
│       ├── cargo
│       │   ├── payload.tmpl.yaml
│       │   └── payload.yaml
│       ├── cargo.tmpl.yaml
│       └── cargo.yaml

Let's have a look at each of them

config.yaml

The file begins with a defaults section

defaults:
  - _self_
  - payloads: cargo

These will be the same for all the users, no need to change anything.


url: http://127.0.0.1:7860

this is the url to connect to webui API, the one above is the default one when launching webui with --api flag. In case you use --nowebui, change that to http://127.0.0.1:7861.


device: cpu

This is where the script will operate the merge and scoring, we suggest to leave it to cpu so that VMEM is free to be used for generations. In any case, you can set it to gpu and use your GPU VMEM for merging and scoring too.


wildcards_dir: path/to/wildcards/folder

This extension re-implements the wildcard extension for various reasons you do not need to care of. As a result, if you want to use wildcards in your prompts, you need to point tell the extension where to find them.


scorer_model_dir: path/where/to/save/scorer/models

This is where you want the aesthetic scorer models to be downloaded and stored.


model_a: path/to/model_a
model_b: path/to/model_b
skip_position_ids: 0

Where to find the two models to merge and what clip_skip value to use.


batch_size: 1

How many images to generate per prompt.


optimiser: bayes # tpe
init_points: 1
n_iters: 1

Here you can select an optimiser, the number of warmup/exploration points (init_points) and nunmber of optimisation/exploitation points (n_iters).


save_imgs: False

Whether to save generated images or not


scorer_method: cafe_style # laion, aes, cafe_aesthetic, cafe_style, cafe_waifu
scorer_model_name: sac+logos+ava1-l14-linearMSE.pth # ava+logos-l14-linearMSE.pth, ava+logos-l14-reluMSE.pth

Pick a scoring method and (in case of chad) a scoring model. In case of a method different from chad, only one model is available and it will automatically picked for you, no need to specify a scorer_model_name (I mean, you can but it will be ignored).


save_best: False
best_format: safetensors # ckpt
best_precision: 16 # 32

Whether to save the best merged model (at the end of the optimisaiton run) or not. In case that is set to True, you can also pick the model format and precision to be saved in


draw_unet_weights: False
draw_unet_base_alpha: False

These can be used to skip optimisation and draw only the UNET visualisation.

Clone this wiki locally