update INSTALLING_MODELS.md

This commit is contained in:
mauwii 2022-11-06 16:15:06 +01:00 committed by Lincoln Stein
parent f91fd27624
commit 1780618543

View File

@ -6,81 +6,77 @@ title: Installing Models
## Model Weight Files ## Model Weight Files
The model weight files ('*.ckpt') are the Stable Diffusion "secret The model weight files ('\*.ckpt') are the Stable Diffusion "secret sauce". They
sauce". They are the product of training the AI on millions of are the product of training the AI on millions of captioned images gathered from
captioned images gathered from multiple sources. multiple sources.
Originally there was only a single Stable Diffusion weights file, Originally there was only a single Stable Diffusion weights file, which many
which many people named `model.ckpt`. Now there are dozens or more people named `model.ckpt`. Now there are dozens or more that have been "fine
that have been "fine tuned" to provide particulary styles, genres, or tuned" to provide particulary styles, genres, or other features. InvokeAI allows
other features. InvokeAI allows you to install and run multiple model you to install and run multiple model weight files and switch between them
weight files and switch between them quickly in the command-line and quickly in the command-line and web interfaces.
web interfaces.
This manual will guide you through installing and configuring model This manual will guide you through installing and configuring model weight
weight files. files.
## Base Models ## Base Models
InvokeAI comes with support for a good initial set of models listed in InvokeAI comes with support for a good initial set of models listed in the model
the model configuration file `configs/models.yaml`. They are: configuration file `configs/models.yaml`. They are:
| Model | Weight File | Description | DOWNLOAD FROM | | Model | Weight File | Description | DOWNLOAD FROM |
| ---------------------- | ----------------------------- |--------------------------------- | ----------------| | -------------------- | --------------------------------- | ---------------------------------------------------------- | -------------------------------------------------------------- |
| stable-diffusion-1.5 | v1-5-pruned-emaonly.ckpt | Most recent version of base Stable Diffusion model | https://huggingface.co/runwayml/stable-diffusion-v1-5 | | stable-diffusion-1.5 | v1-5-pruned-emaonly.ckpt | Most recent version of base Stable Diffusion model | https://huggingface.co/runwayml/stable-diffusion-v1-5 |
| stable-diffusion-1.4 | sd-v1-4.ckpt | Previous version of base Stable Diffusion model | https://huggingface.co/CompVis/stable-diffusion-v-1-4-original | | stable-diffusion-1.4 | sd-v1-4.ckpt | Previous version of base Stable Diffusion model | https://huggingface.co/CompVis/stable-diffusion-v-1-4-original |
| inpainting-1.5 | sd-v1-5-inpainting.ckpt | Stable Diffusion 1.5 model specialized for inpainting | https://huggingface.co/runwayml/stable-diffusion-inpainting | | inpainting-1.5 | sd-v1-5-inpainting.ckpt | Stable Diffusion 1.5 model specialized for inpainting | https://huggingface.co/runwayml/stable-diffusion-inpainting |
| waifu-diffusion-1.3 | model-epoch09-float32.ckpt | Stable Diffusion 1.4 trained to produce anime images | https://huggingface.co/hakurei/waifu-diffusion-v1-3 | | waifu-diffusion-1.3 | model-epoch09-float32.ckpt | Stable Diffusion 1.4 trained to produce anime images | https://huggingface.co/hakurei/waifu-diffusion-v1-3 |
| <all models> | vae-ft-mse-840000-ema-pruned.ckpt | A fine-tune file add-on file that improves face generation | https://huggingface.co/stabilityai/sd-vae-ft-mse-original/ | | `<all models>` | vae-ft-mse-840000-ema-pruned.ckpt | A fine-tune file add-on file that improves face generation | https://huggingface.co/stabilityai/sd-vae-ft-mse-original/ |
Note that these files are covered by an "Ethical AI" license which forbids
Note that these files are covered by an "Ethical AI" license which certain uses. You will need to create an account on the Hugging Face website and
forbids certain uses. You will need to create an account on the accept the license terms before you can access the files.
Hugging Face website and accept the license terms before you can
access the files.
The predefined configuration file for InvokeAI (located at The predefined configuration file for InvokeAI (located at
`configs/models.yaml`) provides entries for each of these weights `configs/models.yaml`) provides entries for each of these weights files.
files. `stable-diffusion-1.5` is the default model used, and we `stable-diffusion-1.5` is the default model used, and we strongly recommend that
strongly recommend that you install this weights file if nothing else. you install this weights file if nothing else.
## Community-Contributed Models ## Community-Contributed Models
There are too many to list here and more are being contributed every There are too many to list here and more are being contributed every day.
day. Hugging Face maintains a [fast-growing Hugging Face maintains a
repository](https://huggingface.co/sd-concepts-library) of fine-tune [fast-growing repository](https://huggingface.co/sd-concepts-library) of
(".bin") models that can be imported into InvokeAI by passing the fine-tune (".bin") models that can be imported into InvokeAI by passing the
`--embedding_path` option to the `invoke.py` command. `--embedding_path` option to the `invoke.py` command.
[This page](https://rentry.org/sdmodels) hosts a large list of [This page](https://rentry.org/sdmodels) hosts a large list of official and
official and unofficial Stable Diffusion models and where they can be unofficial Stable Diffusion models and where they can be obtained.
obtained.
## Installation ## Installation
There are three ways to install weights files: There are three ways to install weights files:
1. During InvokeAI installation, the `preload_models.py` script can 1. During InvokeAI installation, the `preload_models.py` script can download
download them for you. them for you.
2. You can use the command-line interface (CLI) to import, configure 2. You can use the command-line interface (CLI) to import, configure and modify
and modify new models files. new models files.
3. You can download the files manually and add the appropriate entries 3. You can download the files manually and add the appropriate entries to
to `models.yaml`. `models.yaml`.
### Installation via `preload_models.py` ### Installation via `preload_models.py`
This is the most automatic way. Run `scripts/preload_models.py` from This is the most automatic way. Run `scripts/preload_models.py` from the
the console. It will ask you to select which models to download and console. It will ask you to select which models to download and lead you through
lead you through the steps of setting up a Hugging Face account if you the steps of setting up a Hugging Face account if you haven't done so already.
haven't done so already.
To start, from within the InvokeAI directory run the command `python To start, run `python scripts/preload_models.py` from within the InvokeAI:
scripts/preload_models.py` (Linux/MacOS) or `python directory
scripts\preload_models.py` (Windows):
``` !!! example ""
```text
Loading Python libraries... Loading Python libraries...
** INTRODUCTION ** ** INTRODUCTION **
@ -136,46 +132,50 @@ Press <enter> when you are ready to continue:
... ...
``` ```
When the script is complete, you will find the downloaded weights When the script is complete, you will find the downloaded weights files in
files in `models/ldm/stable-diffusion-v1` and a matching configuration `models/ldm/stable-diffusion-v1` and a matching configuration file in
file in `configs/models.yaml`. `configs/models.yaml`.
You can run the script again to add any models you didn't select the You can run the script again to add any models you didn't select the first time.
first time. Note that as a safety measure the script will _never_ Note that as a safety measure the script will _never_ remove a
remove a previously-installed weights file. You will have to do this previously-installed weights file. You will have to do this manually.
manually.
### Installation via the CLI ### Installation via the CLI
You can install a new model, including any of the community-supported You can install a new model, including any of the community-supported ones, via
ones, via the command-line client's `!import_model` command. the command-line client's `!import_model` command.
1. First download the desired model weights file and place it under `models/ldm/stable-diffusion-v1/`. 1. First download the desired model weights file and place it under
You may rename the weights file to something more memorable if you wish. Record the path of the `models/ldm/stable-diffusion-v1/`. You may rename the weights file to
weights file (e.g. `models/ldm/stable-diffusion-v1/arabian-nights-1.0.ckpt`) something more memorable if you wish. Record the path of the weights file
(e.g. `models/ldm/stable-diffusion-v1/arabian-nights-1.0.ckpt`)
2. Launch the `invoke.py` CLI with `python scripts/invoke.py`. 2. Launch the `invoke.py` CLI with `python scripts/invoke.py`.
3. At the `invoke>` command-line, enter the command `!import_model <path to model>`. 3. At the `invoke>` command-line, enter the command
For example: `!import_model <path to model>`. For example:
`invoke> !import_model models/ldm/stable-diffusion-v1/arabian-nights-1.0.ckpt` `invoke> !import_model models/ldm/stable-diffusion-v1/arabian-nights-1.0.ckpt`
(Hint - the CLI supports file path autocompletion. Type a bit of the path !!! tip "the CLI supports file path autocompletion"
name and hit <tab> in order to get a choice of possible completions.)
4. Follow the wizard's instructions to complete installation as shown in the example Type a bit of the path name and hit ++tab++ in order to get a choice of
here: possible completions.
``` 4. Follow the wizard's instructions to complete installation as shown in the
invoke> <b>!import_model models/ldm/stable-diffusion-v1/arabian-nights-1.0.ckpt</b> example here:
!!! example ""
```text
invoke> !import_model models/ldm/stable-diffusion-v1/arabian-nights-1.0.ckpt
>> Model import in process. Please enter the values needed to configure this model: >> Model import in process. Please enter the values needed to configure this model:
Name for this model: <b>arabian-nights</b> Name for this model: arabian-nights
Description of this model: <b>Arabian Nights Fine Tune v1.0</b> Description of this model: Arabian Nights Fine Tune v1.0
Configuration file for this model: <b>configs/stable-diffusion/v1-inference.yaml</b> Configuration file for this model: configs/stable-diffusion/v1-inference.yaml
Default image width: <b>512</b> Default image width: 512
Default image height: <b>512</b> Default image height: 512
>> New configuration: >> New configuration:
arabian-nights: arabian-nights:
config: configs/stable-diffusion/v1-inference.yaml config: configs/stable-diffusion/v1-inference.yaml
@ -183,7 +183,7 @@ arabian-nights:
height: 512 height: 512
weights: models/ldm/stable-diffusion-v1/arabian-nights-1.0.ckpt weights: models/ldm/stable-diffusion-v1/arabian-nights-1.0.ckpt
width: 512 width: 512
OK to import [n]? <b>y</b> OK to import [n]? y
>> Caching model stable-diffusion-1.4 in system RAM >> Caching model stable-diffusion-1.4 in system RAM
>> Loading waifu-diffusion from models/ldm/stable-diffusion-v1/arabian-nights-1.0.ckpt >> Loading waifu-diffusion from models/ldm/stable-diffusion-v1/arabian-nights-1.0.ckpt
| LatentDiffusion: Running in eps-prediction mode | LatentDiffusion: Running in eps-prediction mode
@ -192,38 +192,37 @@ OK to import [n]? <b>y</b>
| Working with z of shape (1, 4, 32, 32) = 4096 dimensions. | Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
| Making attention of type 'vanilla' with 512 in_channels | Making attention of type 'vanilla' with 512 in_channels
| Using faster float16 precision | Using faster float16 precision
``` ```
If you've previously installed the fine-tune VAE file `vae-ft-mse-840000-ema-pruned.ckpt`, If you've previously installed the fine-tune VAE file
the wizard will also ask you if you want to add this VAE to the model. `vae-ft-mse-840000-ema-pruned.ckpt`, the wizard will also ask you if you want to
add this VAE to the model.
The appropriate entry for this model will be added to `configs/models.yaml` and it will The appropriate entry for this model will be added to `configs/models.yaml` and
be available to use in the CLI immediately. it will be available to use in the CLI immediately.
The CLI has additional commands for switching among, viewing, editing, The CLI has additional commands for switching among, viewing, editing, deleting
deleting the available models. These are described in [Command Line the available models. These are described in
Client](../features/CLI.md#model-selection-and-importation), but the two most [Command Line Client](../features/CLI.md#model-selection-and-importation), but
frequently-used are `!models` and `!switch <name of model>`. The first the two most frequently-used are `!models` and `!switch <name of model>`. The
prints a table of models that InvokeAI knows about and their load first prints a table of models that InvokeAI knows about and their load status.
status. The second will load the requested model and lets you switch The second will load the requested model and lets you switch back and forth
back and forth quickly among loaded models. quickly among loaded models.
### Manually editing of `configs/models.yaml` ### Manually editing of `configs/models.yaml`
If you are comfortable with a text editor then you may simply edit If you are comfortable with a text editor then you may simply edit `models.yaml`
`models.yaml` directly. directly.
First you need to download the desired .ckpt file and place it in First you need to download the desired .ckpt file and place it in
`models/ldm/stable-diffusion-v1` as descirbed in step #1 in the `models/ldm/stable-diffusion-v1` as descirbed in step #1 in the previous
previous section. Record the path to the weights file, section. Record the path to the weights file, e.g.
e.g. `models/ldm/stable-diffusion-v1/arabian-nights-1.0.ckpt` `models/ldm/stable-diffusion-v1/arabian-nights-1.0.ckpt`
Then using a **text** editor (e.g. the Windows Notepad application), Then using a **text** editor (e.g. the Windows Notepad application), open the
open the file `configs/models.yaml`, and add a new stanza that follows file `configs/models.yaml`, and add a new stanza that follows this model:
this model:
``` ```yaml
arabian-nights-1.0: arabian-nights-1.0:
description: A great fine-tune in Arabian Nights style description: A great fine-tune in Arabian Nights style
weights: ./models/ldm/stable-diffusion-v1/arabian-nights-1.0.ckpt weights: ./models/ldm/stable-diffusion-v1/arabian-nights-1.0.ckpt
@ -234,34 +233,14 @@ arabian-nights-1.0:
default: false default: false
``` ```
* arabian-nights-1.0 | name | description |
- This is the name of the model that you will refer to from within the | :----------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
CLI and the WebGUI when you need to load and use the model. | arabian-nights-1.0 | This is the name of the model that you will refer to from within the CLI and the WebGUI when you need to load and use the model. |
| description | Any description that you want to add to the model to remind you what it is. |
* description | weights | Relative path to the .ckpt weights file for this model. |
- Any description that you want to add to the model to remind you what | config | This is the confusingly-named configuration file for the model itself. Use `./configs/stable-diffusion/v1-inference.yaml` unless the model happens to need a custom configuration, in which case the place you downloaded it from will tell you what to use instead. For example, the runwayML custom inpainting model requires the file `configs/stable-diffusion/v1-inpainting-inference.yaml`. This is already inclued in the InvokeAI distribution and is configured automatically for you by the `preload_models.py` script. |
it is. | vae | If you want to add a VAE file to the model, then enter its path here. |
| width, height | This is the width and height of the images used to train the model. Currently they are always 512 and 512. |
* weights
- Relative path to the .ckpt weights file for this model.
* config
- This is the confusingly-named configuration file for the model itself.
Use `./configs/stable-diffusion/v1-inference.yaml` unless the model happens
to need a custom configuration, in which case the place you downloaded it
from will tell you what to use instead. For example, the runwayML custom
inpainting model requires the file `configs/stable-diffusion/v1-inpainting-inference.yaml`.
This is already inclued in the InvokeAI distribution and is configured automatically
for you by the `preload_models.py` script.
* vae
- If you want to add a VAE file to the model, then enter its path here.
* width, height
- This is the width and height of the images used to train the model.
Currently they are always 512 and 512.
Save the `models.yaml` and relaunch InvokeAI. The new model should now be Save the `models.yaml` and relaunch InvokeAI. The new model should now be
available for your use. available for your use.