Skip to content

kohya-ss/sd-webui-additional-networks

Repository files navigation

Additional Networks for generating images

日本語の文章は下のほうにあります。

Change History is moved to the bottom of the page. 更新履歴はページ末尾に移しました。

Stable Diffusion web UI now seems to support LoRA trained by sd-scripts Thank you for great work!!!

About

This extension is for AUTOMATIC1111's Stable Diffusion web UI, allows the Web UI to add some networks (e.g. LoRA) to the original Stable Diffusion model to generate images. Currently LoRA is supported. The addition is on-the-fly, the merging is not required.

This extension supports the LoRA models (*.ckpt or *.safetensors) trained by our scripts in sd-scripts. The models from other LoRA implementations are not supported.

This extension does not support training.

Other networks other than LoRA may be supported in the future.

Installation

  1. Open "Extensions" tab.
  2. Open "Install from URL" tab in the tab.
  3. Enter URL of this repo to "URL for extension's git repository".
  4. Press "Install" button.
  5. Restart Web UI.

How to use

Put the LoRA models (*.pt, *.ckpt or *.safetensors) inside the sd-webui-additional-networks/models/LoRA folder.

Open "Additional Networks" panel from the left bottom of Web UI.

Press "Refresh models" to update the models list.

Select "LoRA" for "Network module 1".

Choose the name of the LoRA model file in "Model 1".

Set the weight of the model (negative weight might be working but unexpected.)

Repeat them for the module/model/weight 2 to 5 if you have other models. Models are applied in the order of 1 to 5.

You can generate images with the model with these additional networks.

X/Y plot

If you use LoRA models to plot, put the comma separated list of the model names into AddNet Model X

image

You can get the list of models with the button next to Values. Please select any model in Model ? at Additional Networks in order to make the button work. Models in the same folder as the model will be listed.

image

The metadata of the model can be drawn as legends. Move to Settings tab, select Additional Networks at left bottom, and set Metadata to show. Available values are in Network metadata textbox in Additional Networks tab.

image

Specify target region of LoRA by mask (experimental)

Open Extra args and drop a mask image to mask image.

By specifying with the mask image, each LoRA model can be applied only to the specified region of the image. Currently, only three models (Models 1 to 3) can be masked.

The mask image is RGB image, with each channel (R, G and B) corresponding to LoRA models 1 to 3. Each channel can be overlapped. For example, yellow area (R and G) is applied to LoRA model 1 and 2. The range of values is 0 to 255, corresponding to a LoRA weight of 0 to 1.

It can be combined with ControlNet.

without ControlNet with ControlNet
no LoRA
with LoRA, no mask
with Lora, with mask
pose mask

Sample images are generated with wd-1-5-beta2-aesthetic-fp16.safetensors and three LoRAs: two character LoRAs (model 1 and 2, masked, weight=1.0) and one style LoRA (model 4, not masked, weight=0.8). Used ControlNet is diff_control_wd15beta2_pose.safetensors.

Difference from 'Latent Couple extension' and 'Composable LoRA'

'Latent Couple extension' masks the output of U-Net for each sub-prompt (AND-separated prompts), while our implementation masks the output of LoRA at each layer of U-Net. The mask is resized according to the tensor shape of each layer, so the resolution is particularly coarse at the deeper layers.

'Composable LoRA' controls the area via 'Latent Couple extension' by switching LoRA on or off for each sub-prompt, but this implementation works alone.

This implementation does not work for all modules in LoRA (the modules associated with Text Encoder are not masked), and due to the coarse resolution, it is not possible to completely separate areas.

この Web UI 拡張について

LoRA などのネットワークを元の Stable Diffusion に追加し、画像生成を行うための拡張です。現在は LoRA のみ対応しています。

この拡張で使えるのはsd-scriptsリポジトリで学習した LoRA のモデル(*.ckpt または *.safetensors)です。他の LoRA リポジトリで学習したモデルは対応していません。

この拡張単体では学習はできません。

将来的に LoRA 以外のネットワークについてもサポートするかもしれません。

インストール

  1. Web UI で "Extensions" タブを開きます。
  2. さらに "Install from URL" タブを開きます。
  3. "URL for extension's git repository" 欄にこのリポジトリの URL を入れます。
  4. "Install"ボタンを押してインストールします。
  5. Web UI を再起動してください。

使用法