Skip to content

Commit e26360f

Browse files
author
Lincoln Stein
committed
merged multi-gpu support into new session_processor architecture
2 parents debef24 + 6b24424 commit e26360f

File tree

449 files changed

+20779
-13504
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

449 files changed

+20779
-13504
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ help:
1818
@echo "frontend-typegen Generate types for the frontend from the OpenAPI schema"
1919
@echo "installer-zip Build the installer .zip file for the current version"
2020
@echo "tag-release Tag the GitHub repository with the current version (use at release time only!)"
21+
@echo "openapi Generate the OpenAPI schema for the app, outputting to stdout"
2122

2223
# Runs ruff, fixing any safely-fixable errors and formatting
2324
ruff:
@@ -70,3 +71,6 @@ installer-zip:
7071
tag-release:
7172
cd installer && ./tag_release.sh
7273

74+
# Generate the OpenAPI Schema for the app
75+
openapi:
76+
python scripts/generate_openapi_schema.py

docker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ GPU_DRIVER=nvidia
6464

6565
Any environment variables supported by InvokeAI can be set here - please see the [Configuration docs](https://invoke-ai.github.io/InvokeAI/features/CONFIGURATION/) for further detail.
6666

67-
## Even Moar Customizing!
67+
## Even More Customizing!
6868

6969
See the `docker-compose.yml` file. The `command` instruction can be uncommented and used to run arbitrary startup commands. Some examples below.
7070

docs/contributing/frontend/WORKFLOWS.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ Stateless fields do not store their value in the node, so their field instances
117117

118118
"Custom" fields will always be treated as stateless fields.
119119

120-
##### Collection and Scalar Fields
120+
##### Single and Collection Fields
121121

122-
Field types have a name and two flags which may identify it as a **collection** or **collection or scalar** field.
122+
Field types have a name and cardinality property which may identify it as a **SINGLE**, **COLLECTION** or **SINGLE_OR_COLLECTION** field.
123123

124-
If a field is annotated in python as a list, its field type is parsed and flagged as a **collection** type (e.g. `list[int]`).
125-
126-
If it is annotated as a union of a type and list, the type will be flagged as a **collection or scalar** type (e.g. `Union[int, list[int]]`). Fields may not be unions of different types (e.g. `Union[int, list[str]]` and `Union[int, str]` are not allowed).
124+
- If a field is annotated in python as a singular value or class, its field type is parsed as a **SINGLE** type (e.g. `int`, `ImageField`, `str`).
125+
- If a field is annotated in python as a list, its field type is parsed as a **COLLECTION** type (e.g. `list[int]`).
126+
- If it is annotated as a union of a type and list, the type will be parsed as a **SINGLE_OR_COLLECTION** type (e.g. `Union[int, list[int]]`). Fields may not be unions of different types (e.g. `Union[int, list[str]]` and `Union[int, str]` are not allowed).
127127

128128
## Implementation
129129

@@ -173,8 +173,7 @@ Field types are represented as structured objects:
173173
```ts
174174
type FieldType = {
175175
name: string;
176-
isCollection: boolean;
177-
isCollectionOrScalar: boolean;
176+
cardinality: 'SINGLE' | 'COLLECTION' | 'SINGLE_OR_COLLECTION';
178177
};
179178
```
180179

@@ -186,7 +185,7 @@ There are 4 general cases for field type parsing.
186185

187186
When a field is annotated as a primitive values (e.g. `int`, `str`, `float`), the field type parsing is fairly straightforward. The field is represented by a simple OpenAPI **schema object**, which has a `type` property.
188187

189-
We create a field type name from this `type` string (e.g. `string` -> `StringField`).
188+
We create a field type name from this `type` string (e.g. `string` -> `StringField`). The cardinality is `"SINGLE"`.
190189

191190
##### Complex Types
192191

@@ -200,13 +199,13 @@ We need to **dereference** the schema to pull these out. Dereferencing may requi
200199

201200
When a field is annotated as a list of a single type, the schema object has an `items` property. They may be a schema object or reference object and must be parsed to determine the item type.
202201

203-
We use the item type for field type name, adding `isCollection: true` to the field type.
202+
We use the item type for field type name. The cardinality is `"COLLECTION"`.
204203

205-
##### Collection or Scalar Types
204+
##### Single or Collection Types
206205

207206
When a field is annotated as a union of a type and list of that type, the schema object has an `anyOf` property, which holds a list of valid types for the union.
208207

209-
After verifying that the union has two members (a type and list of the same type), we use the type for field type name, adding `isCollectionOrScalar: true` to the field type.
208+
After verifying that the union has two members (a type and list of the same type), we use the type for field type name, with cardinality `"SINGLE_OR_COLLECTION"`.
210209

211210
##### Optional Fields
212211

docs/features/CONTROLNET.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ Additionally, each section can be expanded with the "Show Advanced" button in o
165165
There are several ways to install IP-Adapter models with an existing InvokeAI installation:
166166

167167
1. Through the command line interface launched from the invoke.sh / invoke.bat scripts, option [4] to download models.
168-
2. Through the Model Manager UI with models from the *Tools* section of [www.models.invoke.ai](https://www.models.invoke.ai). To do this, copy the repo ID from the desired model page, and paste it in the Add Model field of the model manager. **Note** Both the IP-Adapter and the Image Encoder must be installed for IP-Adapter to work. For example, the [SD 1.5 IP-Adapter](https://models.invoke.ai/InvokeAI/ip_adapter_plus_sd15) and [SD1.5 Image Encoder](https://models.invoke.ai/InvokeAI/ip_adapter_sd_image_encoder) must be installed to use IP-Adapter with SD1.5 based models.
168+
2. Through the Model Manager UI with models from the *Tools* section of [models.invoke.ai](https://models.invoke.ai). To do this, copy the repo ID from the desired model page, and paste it in the Add Model field of the model manager. **Note** Both the IP-Adapter and the Image Encoder must be installed for IP-Adapter to work. For example, the [SD 1.5 IP-Adapter](https://models.invoke.ai/InvokeAI/ip_adapter_plus_sd15) and [SD1.5 Image Encoder](https://models.invoke.ai/InvokeAI/ip_adapter_sd_image_encoder) must be installed to use IP-Adapter with SD1.5 based models.
169169
3. **Advanced -- Not recommended ** Manually downloading the IP-Adapter and Image Encoder files - Image Encoder folders shouid be placed in the `models\any\clip_vision` folders. IP Adapter Model folders should be placed in the relevant `ip-adapter` folder of relevant base model folder of Invoke root directory. For example, for the SDXL IP-Adapter, files should be added to the `model/sdxl/ip_adapter/` folder.
170170

171171
#### Using IP-Adapter

docs/help/FAQ.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,18 @@ This is caused by an invalid setting in the `invokeai.yaml` configuration file.
154154

155155
Check the [configuration docs] for more detail about the settings and how to specify them.
156156

157+
## `ModuleNotFoundError: No module named 'controlnet_aux'`
158+
159+
`controlnet_aux` is a dependency of Invoke and appears to have been packaged or distributed strangely. Sometimes, it doesn't install correctly. This is outside our control.
160+
161+
If you encounter this error, the solution is to remove the package from the `pip` cache and re-run the Invoke installer so a fresh, working version of `controlnet_aux` can be downloaded and installed:
162+
163+
- Run the Invoke launcher
164+
- Choose the developer console option
165+
- Run this command: `pip cache remove controlnet_aux`
166+
- Close the terminal window
167+
- Download and run the [installer](https://github.com/invoke-ai/InvokeAI/releases/latest), selecting your current install location
168+
157169
## Out of Memory Issues
158170

159171
The models are large, VRAM is expensive, and you may find yourself

docs/help/diffusion.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ When you generate an image using text-to-image, multiple steps occur in latent s
2020
4. The VAE decodes the final latent image from latent space into image space.
2121

2222
Image-to-image is a similar process, with only step 1 being different:
23-
1. The input image is encoded from image space into latent space by the VAE. Noise is then added to the input latent image. Denoising Strength dictates how may noise steps are added, and the amount of noise added at each step. A Denoising Strength of 0 means there are 0 steps and no noise added, resulting in an unchanged image, while a Denoising Strength of 1 results in the image being completely replaced with noise and a full set of denoising steps are performance. The process is then the same as steps 2-4 in the text-to-image process.
23+
1. The input image is encoded from image space into latent space by the VAE. Noise is then added to the input latent image. Denoising Strength dictates how many noise steps are added, and the amount of noise added at each step. A Denoising Strength of 0 means there are 0 steps and no noise added, resulting in an unchanged image, while a Denoising Strength of 1 results in the image being completely replaced with noise and a full set of denoising steps are performance. The process is then the same as steps 2-4 in the text-to-image process.
2424

2525
Furthermore, a model provides the CLIP prompt tokenizer, the VAE, and a U-Net (where noise prediction occurs given a prompt and initial noise tensor).
2626

docs/installation/010_INSTALL_AUTOMATED.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Updating is exactly the same as installing - download the latest installer, choo
9898

9999
If you have installation issues, please review the [FAQ]. You can also [create an issue] or ask for help on [discord].
100100

101-
[installation requirements]: INSTALLATION.md#installation-requirements
101+
[installation requirements]: INSTALL_REQUIREMENTS.md
102102
[FAQ]: ../help/FAQ.md
103103
[install some models]: 050_INSTALLING_MODELS.md
104104
[configuration docs]: ../features/CONFIGURATION.md

docs/installation/020_INSTALL_MANUAL.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ InvokeAI is distributed as a python package on PyPI, installable with `pip`. The
1010

1111
### Requirements
1212

13-
Before you start, go through the [installation requirements].
13+
Before you start, go through the [installation requirements](./INSTALL_REQUIREMENTS.md).
1414

1515
### Installation Walkthrough
1616

@@ -79,7 +79,7 @@ Before you start, go through the [installation requirements].
7979
8080
1. Install the InvokeAI Package. The base command is `pip install InvokeAI --use-pep517`, but you may need to change this depending on your system and the desired features.
8181
82-
- You may need to provide an [extra index URL]. Select your platform configuration using [this tool on the PyTorch website]. Copy the `--extra-index-url` string from this and append it to your install command.
82+
- You may need to provide an [extra index URL](https://pip.pypa.io/en/stable/cli/pip_install/#cmdoption-extra-index-url). Select your platform configuration using [this tool on the PyTorch website](https://pytorch.org/get-started/locally/). Copy the `--extra-index-url` string from this and append it to your install command.
8383
8484
!!! example "Install with an extra index URL"
8585
@@ -116,4 +116,4 @@ Before you start, go through the [installation requirements].
116116
117117
!!! warning
118118
119-
If the virtual environment is _not_ inside the root directory, then you _must_ specify the path to the root directory with `--root_dir \path\to\invokeai` or the `INVOKEAI_ROOT` environment variable.
119+
If the virtual environment is _not_ inside the root directory, then you _must_ specify the path to the root directory with `--root \path\to\invokeai` or the `INVOKEAI_ROOT` environment variable.

docs/installation/INSTALL_REQUIREMENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ Invoke runs best with a dedicated GPU, but will fall back to running on CPU, alb
3737
=== "Nvidia"
3838

3939
```
40-
Any GPU with at least 8GB VRAM. Linux only.
40+
Any GPU with at least 8GB VRAM.
4141
```
4242

4343
=== "AMD"
4444

4545
```
46-
Any GPU with at least 16GB VRAM.
46+
Any GPU with at least 16GB VRAM. Linux only.
4747
```
4848

4949
=== "Mac"

installer/templates/invoke.bat.in

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ set INVOKEAI_ROOT=.
1010
echo Desired action:
1111
echo 1. Generate images with the browser-based interface
1212
echo 2. Open the developer console
13-
echo 3. Run the InvokeAI image database maintenance script
14-
echo 4. Command-line help
13+
echo 3. Command-line help
1514
echo Q - Quit
1615
echo.
1716
echo To update, download and run the installer from https://github.com/invoke-ai/InvokeAI/releases/latest.
@@ -34,9 +33,6 @@ IF /I "%choice%" == "1" (
3433
echo *** Type `exit` to quit this shell and deactivate the Python virtual environment ***
3534
call cmd /k
3635
) ELSE IF /I "%choice%" == "3" (
37-
echo Running the db maintenance script...
38-
python .venv\Scripts\invokeai-db-maintenance.exe
39-
) ELSE IF /I "%choice%" == "4" (
4036
echo Displaying command line help...
4137
python .venv\Scripts\invokeai-web.exe --help %*
4238
pause

installer/templates/invoke.sh.in

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ do_choice() {
4747
bash --init-file "$file_name"
4848
;;
4949
3)
50-
clear
51-
printf "Running the db maintenance script\n"
52-
invokeai-db-maintenance --root ${INVOKEAI_ROOT}
53-
;;
54-
4)
5550
clear
5651
printf "Command-line help\n"
5752
invokeai-web --help
@@ -71,8 +66,7 @@ do_line_input() {
7166
printf "What would you like to do?\n"
7267
printf "1: Generate images using the browser-based interface\n"
7368
printf "2: Open the developer console\n"
74-
printf "3: Run the InvokeAI image database maintenance script\n"
75-
printf "4: Command-line help\n"
69+
printf "3: Command-line help\n"
7670
printf "Q: Quit\n\n"
7771
printf "To update, download and run the installer from https://github.com/invoke-ai/InvokeAI/releases/latest.\n\n"
7872
read -p "Please enter 1-4, Q: [1] " yn

invokeai/app/api/dependencies.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,22 @@
1919
from ..services.bulk_download.bulk_download_default import BulkDownloadService
2020
from ..services.config import InvokeAIAppConfig
2121
from ..services.download import DownloadQueueService
22+
from ..services.events.events_fastapievents import FastAPIEventService
2223
from ..services.image_files.image_files_disk import DiskImageFileStorage
2324
from ..services.image_records.image_records_sqlite import SqliteImageRecordStorage
2425
from ..services.images.images_default import ImageService
2526
from ..services.invocation_cache.invocation_cache_memory import MemoryInvocationCache
2627
from ..services.invocation_services import InvocationServices
28+
from ..services.invocation_stats.invocation_stats_default import InvocationStatsService
2729
from ..services.invoker import Invoker
2830
from ..services.model_images.model_images_default import ModelImageFileStorageDisk
2931
from ..services.model_manager.model_manager_default import ModelManagerService
3032
from ..services.model_records import ModelRecordServiceSQL
3133
from ..services.names.names_default import SimpleNameService
32-
from ..services.session_processor.session_processor_default import DefaultSessionProcessor
34+
from ..services.session_processor.session_processor_default import DefaultSessionProcessor, DefaultSessionRunner
3335
from ..services.session_queue.session_queue_sqlite import SqliteSessionQueue
3436
from ..services.urls.urls_default import LocalUrlService
3537
from ..services.workflow_records.workflow_records_sqlite import SqliteWorkflowRecordsStorage
36-
from .events import FastAPIEventService
3738

3839

3940
# TODO: is there a better way to achieve this?
@@ -101,11 +102,9 @@ def initialize(config: InvokeAIAppConfig, event_handler_id: int, logger: Logger
101102
download_queue=download_queue_service,
102103
events=events,
103104
)
104-
# horrible hack - remove
105-
invokeai.backend.util.devices.RAM_CACHE = model_manager.load.ram_cache
106-
107105
names = SimpleNameService()
108-
session_processor = DefaultSessionProcessor()
106+
performance_statistics = InvocationStatsService()
107+
session_processor = DefaultSessionProcessor(session_runner=DefaultSessionRunner())
109108
session_queue = SqliteSessionQueue(db=db)
110109
urls = LocalUrlService()
111110
workflow_records = SqliteWorkflowRecordsStorage(db=db)
@@ -127,6 +126,7 @@ def initialize(config: InvokeAIAppConfig, event_handler_id: int, logger: Logger
127126
model_manager=model_manager,
128127
download_queue=download_queue_service,
129128
names=names,
129+
performance_statistics=performance_statistics,
130130
session_processor=session_processor,
131131
session_queue=session_queue,
132132
urls=urls,

invokeai/app/api/events.py

Lines changed: 0 additions & 52 deletions
This file was deleted.

invokeai/app/api/routers/app_info.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from invokeai.app.invocations.upscale import ESRGAN_MODELS
1414
from invokeai.app.services.invocation_cache.invocation_cache_common import InvocationCacheStatus
1515
from invokeai.backend.image_util.infill_methods.patchmatch import PatchMatch
16-
from invokeai.backend.image_util.safety_checker import SafetyChecker
1716
from invokeai.backend.util.logging import logging
1817
from invokeai.version import __version__
1918

@@ -109,9 +108,7 @@ async def get_config() -> AppConfig:
109108
upscaling_models.append(str(Path(model).stem))
110109
upscaler = Upscaler(upscaling_method="esrgan", upscaling_models=upscaling_models)
111110

112-
nsfw_methods = []
113-
if SafetyChecker.safety_checker_available():
114-
nsfw_methods.append("nsfw_checker")
111+
nsfw_methods = ["nsfw_checker"]
115112

116113
watermarking_methods = ["invisible_watermark"]
117114

0 commit comments

Comments
 (0)