mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Compare commits
47 Commits
feat/diffu
...
test
Author | SHA1 | Date | |
---|---|---|---|
ad786130ff | |||
77a444f3bc | |||
24209b60a4 | |||
cf2b847e33 | |||
5f35ad078d | |||
43266b18c7 | |||
d521145c36 | |||
bf359bd91f | |||
25ad74922e | |||
d8c31e9ed5 | |||
fc958217eb | |||
5010412341 | |||
0e93c4e856 | |||
98e6c62214 | |||
e1d2d382cf | |||
d349e00965 | |||
bbe1097c05 | |||
a10acde5eb | |||
171532ec44 | |||
54cbadeffa | |||
a76e58017c | |||
17be3e1234 | |||
73ba6b03ab | |||
6f37fbdee4 | |||
1928d1af29 | |||
f6127a1b6b | |||
7f457ca03d | |||
2b972cda6c | |||
47b0e1d7b4 | |||
fe0a16c846 | |||
f19c6069a9 | |||
6f45931711 | |||
278392d52c | |||
b2f942d714 | |||
6bc2253894 | |||
97d6f207d8 | |||
dc9a9d7bec | |||
15a3e49a40 | |||
7ccfc499dc | |||
56d0d80a39 | |||
2d64ee7f9e | |||
10ada84404 | |||
7744e01e2c | |||
ce8e5f9adf | |||
fc1021b6be | |||
fadfe1dfe9 | |||
2716ae353b |
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -2,4 +2,3 @@
|
|||||||
# Only affects text files and ignores other file types.
|
# Only affects text files and ignores other file types.
|
||||||
# For more info see: https://www.aleksandrhovhannisyan.com/blog/crlf-vs-lf-normalizing-line-endings-in-git/
|
# For more info see: https://www.aleksandrhovhannisyan.com/blog/crlf-vs-lf-normalizing-line-endings-in-git/
|
||||||
* text=auto
|
* text=auto
|
||||||
docker/** text eol=lf
|
|
15
.github/pull_request_template.md
vendored
15
.github/pull_request_template.md
vendored
@ -42,21 +42,6 @@ Please provide steps on how to test changes, any hardware or
|
|||||||
software specifications as well as any other pertinent information.
|
software specifications as well as any other pertinent information.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
## Merge Plan
|
|
||||||
|
|
||||||
<!--
|
|
||||||
A merge plan describes how this PR should be handled after it is approved.
|
|
||||||
|
|
||||||
Example merge plans:
|
|
||||||
- "This PR can be merged when approved"
|
|
||||||
- "This must be squash-merged when approved"
|
|
||||||
- "DO NOT MERGE - I will rebase and tidy commits before merging"
|
|
||||||
- "#dev-chat on discord needs to be advised of this change when it is merged"
|
|
||||||
|
|
||||||
A merge plan is particularly important for large PRs or PRs that touch the
|
|
||||||
database in any way.
|
|
||||||
-->
|
|
||||||
|
|
||||||
## Added/updated tests?
|
## Added/updated tests?
|
||||||
|
|
||||||
- [ ] Yes
|
- [ ] Yes
|
||||||
|
24
.github/workflows/lint-frontend.yml
vendored
24
.github/workflows/lint-frontend.yml
vendored
@ -22,22 +22,12 @@ jobs:
|
|||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Node 18
|
- name: Setup Node 18
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '18'
|
node-version: '18'
|
||||||
- name: Checkout
|
- uses: actions/checkout@v3
|
||||||
uses: actions/checkout@v4
|
- run: 'yarn install --frozen-lockfile'
|
||||||
- name: Setup pnpm
|
- run: 'yarn run lint:tsc'
|
||||||
uses: pnpm/action-setup@v2
|
- run: 'yarn run lint:madge'
|
||||||
with:
|
- run: 'yarn run lint:eslint'
|
||||||
version: '8.12.1'
|
- run: 'yarn run lint:prettier'
|
||||||
- name: Install dependencies
|
|
||||||
run: 'pnpm install --prefer-frozen-lockfile'
|
|
||||||
- name: Typescript
|
|
||||||
run: 'pnpm run lint:tsc'
|
|
||||||
- name: Madge
|
|
||||||
run: 'pnpm run lint:madge'
|
|
||||||
- name: ESLint
|
|
||||||
run: 'pnpm run lint:eslint'
|
|
||||||
- name: Prettier
|
|
||||||
run: 'pnpm run lint:prettier'
|
|
||||||
|
20
.github/workflows/pyflakes.yml
vendored
Normal file
20
.github/workflows/pyflakes.yml
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- development
|
||||||
|
- 'release-candidate-*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pyflakes:
|
||||||
|
name: runner / pyflakes
|
||||||
|
if: github.event.pull_request.draft == false
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: pyflakes
|
||||||
|
uses: reviewdog/action-pyflakes@v1
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
reporter: github-pr-review
|
50
.github/workflows/pypi-release.yml
vendored
50
.github/workflows/pypi-release.yml
vendored
@ -1,15 +1,13 @@
|
|||||||
name: PyPI Release
|
name: PyPI Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- 'invokeai/version/invokeai_version.py'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
|
||||||
publish_package:
|
|
||||||
description: 'Publish build on PyPi? [true/false]'
|
|
||||||
required: true
|
|
||||||
default: 'false'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-release:
|
release:
|
||||||
if: github.repository == 'invoke-ai/InvokeAI'
|
if: github.repository == 'invoke-ai/InvokeAI'
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
env:
|
env:
|
||||||
@ -17,43 +15,19 @@ jobs:
|
|||||||
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
|
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
|
||||||
TWINE_NON_INTERACTIVE: 1
|
TWINE_NON_INTERACTIVE: 1
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: checkout sources
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup Node 18
|
- name: install deps
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '18'
|
|
||||||
|
|
||||||
- name: Setup pnpm
|
|
||||||
uses: pnpm/action-setup@v2
|
|
||||||
with:
|
|
||||||
version: '8.12.1'
|
|
||||||
|
|
||||||
- name: Install frontend dependencies
|
|
||||||
run: pnpm install --prefer-frozen-lockfile
|
|
||||||
working-directory: invokeai/frontend/web
|
|
||||||
|
|
||||||
- name: Build frontend
|
|
||||||
run: pnpm run build
|
|
||||||
working-directory: invokeai/frontend/web
|
|
||||||
|
|
||||||
- name: Install python dependencies
|
|
||||||
run: pip install --upgrade build twine
|
run: pip install --upgrade build twine
|
||||||
|
|
||||||
- name: Build python package
|
- name: build package
|
||||||
run: python3 -m build
|
run: python3 -m build
|
||||||
|
|
||||||
- name: Upload build as workflow artifact
|
- name: check distribution
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: dist
|
|
||||||
path: dist
|
|
||||||
|
|
||||||
- name: Check distribution
|
|
||||||
run: twine check dist/*
|
run: twine check dist/*
|
||||||
|
|
||||||
- name: Check PyPI versions
|
- name: check PyPI versions
|
||||||
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')
|
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')
|
||||||
run: |
|
run: |
|
||||||
pip install --upgrade requests
|
pip install --upgrade requests
|
||||||
@ -62,6 +36,6 @@ jobs:
|
|||||||
EXISTS=scripts.pypi_helper.local_on_pypi(); \
|
EXISTS=scripts.pypi_helper.local_on_pypi(); \
|
||||||
print(f'PACKAGE_EXISTS={EXISTS}')" >> $GITHUB_ENV
|
print(f'PACKAGE_EXISTS={EXISTS}')" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Publish build on PyPi
|
- name: upload package
|
||||||
if: env.PACKAGE_EXISTS == 'False' && env.TWINE_PASSWORD != '' && github.event.inputs.publish_package == 'true'
|
if: env.PACKAGE_EXISTS == 'False' && env.TWINE_PASSWORD != ''
|
||||||
run: twine upload dist/*
|
run: twine upload dist/*
|
||||||
|
9
.github/workflows/style-checks.yml
vendored
9
.github/workflows/style-checks.yml
vendored
@ -6,7 +6,7 @@ on:
|
|||||||
branches: main
|
branches: main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ruff:
|
black:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@ -18,7 +18,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Install dependencies with pip
|
- name: Install dependencies with pip
|
||||||
run: |
|
run: |
|
||||||
pip install ruff
|
pip install black flake8 Flake8-pyproject isort
|
||||||
|
|
||||||
- run: ruff check --output-format=github .
|
- run: isort --check-only .
|
||||||
- run: ruff format --check .
|
- run: black --check .
|
||||||
|
- run: flake8
|
||||||
|
15
.gitignore
vendored
15
.gitignore
vendored
@ -1,5 +1,8 @@
|
|||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
|
# ignore the Anaconda/Miniconda installer used while building Docker image
|
||||||
|
anaconda.sh
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
@ -16,7 +19,7 @@ __pycache__/
|
|||||||
.Python
|
.Python
|
||||||
build/
|
build/
|
||||||
develop-eggs/
|
develop-eggs/
|
||||||
dist/
|
# dist/
|
||||||
downloads/
|
downloads/
|
||||||
eggs/
|
eggs/
|
||||||
.eggs/
|
.eggs/
|
||||||
@ -133,10 +136,12 @@ celerybeat.pid
|
|||||||
|
|
||||||
# Environments
|
# Environments
|
||||||
.env
|
.env
|
||||||
.venv*
|
.venv
|
||||||
env/
|
env/
|
||||||
venv/
|
venv/
|
||||||
ENV/
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
# Spyder project settings
|
# Spyder project settings
|
||||||
.spyderproject
|
.spyderproject
|
||||||
@ -181,10 +186,14 @@ cython_debug/
|
|||||||
.scratch/
|
.scratch/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
|
# ignore environment.yml and requirements.txt
|
||||||
|
# these are links to the real files in environments-and-requirements
|
||||||
|
environment.yml
|
||||||
|
requirements.txt
|
||||||
|
|
||||||
# source installer files
|
# source installer files
|
||||||
installer/*zip
|
installer/*zip
|
||||||
installer/install.bat
|
installer/install.bat
|
||||||
installer/install.sh
|
installer/install.sh
|
||||||
installer/update.bat
|
installer/update.bat
|
||||||
installer/update.sh
|
installer/update.sh
|
||||||
installer/InvokeAI-Installer/
|
|
||||||
|
52
Makefile
52
Makefile
@ -1,52 +0,0 @@
|
|||||||
# simple Makefile with scripts that are otherwise hard to remember
|
|
||||||
# to use, run from the repo root `make <command>`
|
|
||||||
|
|
||||||
default: help
|
|
||||||
|
|
||||||
help:
|
|
||||||
@echo Developer commands:
|
|
||||||
@echo
|
|
||||||
@echo "ruff Run ruff, fixing any safely-fixable errors and formatting"
|
|
||||||
@echo "ruff-unsafe Run ruff, fixing all fixable errors and formatting"
|
|
||||||
@echo "mypy Run mypy using the config in pyproject.toml to identify type mismatches and other coding errors"
|
|
||||||
@echo "mypy-all Run mypy ignoring the config in pyproject.tom but still ignoring missing imports"
|
|
||||||
@echo "frontend-build Build the frontend in order to run on localhost:9090"
|
|
||||||
@echo "frontend-dev Run the frontend in developer mode on localhost:5173"
|
|
||||||
@echo "installer-zip Build the installer .zip file for the current version"
|
|
||||||
@echo "tag-release Tag the GitHub repository with the current version (use at release time only!)"
|
|
||||||
|
|
||||||
# Runs ruff, fixing any safely-fixable errors and formatting
|
|
||||||
ruff:
|
|
||||||
ruff check . --fix
|
|
||||||
ruff format .
|
|
||||||
|
|
||||||
# Runs ruff, fixing all errors it can fix and formatting
|
|
||||||
ruff-unsafe:
|
|
||||||
ruff check . --fix --unsafe-fixes
|
|
||||||
ruff format .
|
|
||||||
|
|
||||||
# Runs mypy, using the config in pyproject.toml
|
|
||||||
mypy:
|
|
||||||
mypy scripts/invokeai-web.py
|
|
||||||
|
|
||||||
# Runs mypy, ignoring the config in pyproject.toml but still ignoring missing (untyped) imports
|
|
||||||
# (many files are ignored by the config, so this is useful for checking all files)
|
|
||||||
mypy-all:
|
|
||||||
mypy scripts/invokeai-web.py --config-file= --ignore-missing-imports
|
|
||||||
|
|
||||||
# Build the frontend
|
|
||||||
frontend-build:
|
|
||||||
cd invokeai/frontend/web && pnpm build
|
|
||||||
|
|
||||||
# Run the frontend in dev mode
|
|
||||||
frontend-dev:
|
|
||||||
cd invokeai/frontend/web && pnpm dev
|
|
||||||
|
|
||||||
# Installer zip file
|
|
||||||
installer-zip:
|
|
||||||
cd installer && ./create_installer.sh
|
|
||||||
|
|
||||||
# Tag the release
|
|
||||||
tag-release:
|
|
||||||
cd installer && ./tag_release.sh
|
|
||||||
|
|
14
README.md
14
README.md
@ -123,10 +123,10 @@ and go to http://localhost:9090.
|
|||||||
|
|
||||||
### Command-Line Installation (for developers and users familiar with Terminals)
|
### Command-Line Installation (for developers and users familiar with Terminals)
|
||||||
|
|
||||||
You must have Python 3.10 through 3.11 installed on your machine. Earlier or
|
You must have Python 3.9 through 3.11 installed on your machine. Earlier or
|
||||||
later versions are not supported.
|
later versions are not supported.
|
||||||
Node.js also needs to be installed along with `pnpm` (can be installed with
|
Node.js also needs to be installed along with yarn (can be installed with
|
||||||
the command `npm install -g pnpm` if needed)
|
the command `npm install -g yarn` if needed)
|
||||||
|
|
||||||
1. Open a command-line window on your machine. The PowerShell is recommended for Windows.
|
1. Open a command-line window on your machine. The PowerShell is recommended for Windows.
|
||||||
2. Create a directory to install InvokeAI into. You'll need at least 15 GB of free space:
|
2. Create a directory to install InvokeAI into. You'll need at least 15 GB of free space:
|
||||||
@ -161,7 +161,7 @@ the command `npm install -g pnpm` if needed)
|
|||||||
_For Windows/Linux with an NVIDIA GPU:_
|
_For Windows/Linux with an NVIDIA GPU:_
|
||||||
|
|
||||||
```terminal
|
```terminal
|
||||||
pip install "InvokeAI[xformers]" --use-pep517 --extra-index-url https://download.pytorch.org/whl/cu121
|
pip install "InvokeAI[xformers]" --use-pep517 --extra-index-url https://download.pytorch.org/whl/cu118
|
||||||
```
|
```
|
||||||
|
|
||||||
_For Linux with an AMD GPU:_
|
_For Linux with an AMD GPU:_
|
||||||
@ -175,7 +175,7 @@ the command `npm install -g pnpm` if needed)
|
|||||||
pip install InvokeAI --use-pep517 --extra-index-url https://download.pytorch.org/whl/cpu
|
pip install InvokeAI --use-pep517 --extra-index-url https://download.pytorch.org/whl/cpu
|
||||||
```
|
```
|
||||||
|
|
||||||
_For Macintoshes, either Intel or M1/M2/M3:_
|
_For Macintoshes, either Intel or M1/M2:_
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pip install InvokeAI --use-pep517
|
pip install InvokeAI --use-pep517
|
||||||
@ -270,7 +270,7 @@ upgrade script.** See the next section for a Windows recipe.
|
|||||||
3. Select option [1] to upgrade to the latest release.
|
3. Select option [1] to upgrade to the latest release.
|
||||||
|
|
||||||
4. Once the upgrade is finished you will be returned to the launcher
|
4. Once the upgrade is finished you will be returned to the launcher
|
||||||
menu. Select option [6] "Re-run the configure script to fix a broken
|
menu. Select option [7] "Re-run the configure script to fix a broken
|
||||||
install or to complete a major upgrade".
|
install or to complete a major upgrade".
|
||||||
|
|
||||||
This will run the configure script against the v2.3 directory and
|
This will run the configure script against the v2.3 directory and
|
||||||
@ -395,7 +395,7 @@ Notes](https://github.com/invoke-ai/InvokeAI/releases) and the
|
|||||||
|
|
||||||
### Troubleshooting
|
### Troubleshooting
|
||||||
|
|
||||||
Please check out our **[Troubleshooting Guide](https://invoke-ai.github.io/InvokeAI/installation/010_INSTALL_AUTOMATED/#troubleshooting)** to get solutions for common installation
|
Please check out our **[Q&A](https://invoke-ai.github.io/InvokeAI/help/TROUBLESHOOT/#faq)** to get solutions for common installation
|
||||||
problems and other issues. For more help, please join our [Discord][discord link]
|
problems and other issues. For more help, please join our [Discord][discord link]
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
## Make a copy of this file named `.env` and fill in the values below.
|
## Make a copy of this file named `.env` and fill in the values below.
|
||||||
## Any environment variables supported by InvokeAI can be specified here,
|
## Any environment variables supported by InvokeAI can be specified here.
|
||||||
## in addition to the examples below.
|
|
||||||
|
|
||||||
# INVOKEAI_ROOT is the path to a path on the local filesystem where InvokeAI will store data.
|
# INVOKEAI_ROOT is the path to a path on the local filesystem where InvokeAI will store data.
|
||||||
# Outputs will also be stored here by default.
|
# Outputs will also be stored here by default.
|
||||||
# This **must** be an absolute path.
|
# This **must** be an absolute path.
|
||||||
INVOKEAI_ROOT=
|
INVOKEAI_ROOT=
|
||||||
|
|
||||||
# Get this value from your HuggingFace account settings page.
|
HUGGINGFACE_TOKEN=
|
||||||
# HUGGING_FACE_HUB_TOKEN=
|
|
||||||
|
|
||||||
## optional variables specific to the docker setup.
|
## optional variables specific to the docker setup
|
||||||
# GPU_DRIVER=nvidia #| rocm
|
# GPU_DRIVER=cuda
|
||||||
# CONTAINER_UID=1000
|
# CONTAINER_UID=1000
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Builder stage
|
## Builder stage
|
||||||
|
|
||||||
FROM library/ubuntu:23.04 AS builder
|
FROM library/ubuntu:22.04 AS builder
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
|
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
|
||||||
@ -10,7 +10,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
|||||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||||
apt update && apt-get install -y \
|
apt update && apt-get install -y \
|
||||||
git \
|
git \
|
||||||
python3-venv \
|
python3.10-venv \
|
||||||
python3-pip \
|
python3-pip \
|
||||||
build-essential
|
build-essential
|
||||||
|
|
||||||
@ -18,8 +18,8 @@ ENV INVOKEAI_SRC=/opt/invokeai
|
|||||||
ENV VIRTUAL_ENV=/opt/venv/invokeai
|
ENV VIRTUAL_ENV=/opt/venv/invokeai
|
||||||
|
|
||||||
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||||
ARG TORCH_VERSION=2.1.0
|
ARG TORCH_VERSION=2.0.1
|
||||||
ARG TORCHVISION_VERSION=0.16
|
ARG TORCHVISION_VERSION=0.15.2
|
||||||
ARG GPU_DRIVER=cuda
|
ARG GPU_DRIVER=cuda
|
||||||
ARG TARGETPLATFORM="linux/amd64"
|
ARG TARGETPLATFORM="linux/amd64"
|
||||||
# unused but available
|
# unused but available
|
||||||
@ -35,9 +35,9 @@ RUN --mount=type=cache,target=/root/.cache/pip \
|
|||||||
if [ "$TARGETPLATFORM" = "linux/arm64" ] || [ "$GPU_DRIVER" = "cpu" ]; then \
|
if [ "$TARGETPLATFORM" = "linux/arm64" ] || [ "$GPU_DRIVER" = "cpu" ]; then \
|
||||||
extra_index_url_arg="--extra-index-url https://download.pytorch.org/whl/cpu"; \
|
extra_index_url_arg="--extra-index-url https://download.pytorch.org/whl/cpu"; \
|
||||||
elif [ "$GPU_DRIVER" = "rocm" ]; then \
|
elif [ "$GPU_DRIVER" = "rocm" ]; then \
|
||||||
extra_index_url_arg="--index-url https://download.pytorch.org/whl/rocm5.6"; \
|
extra_index_url_arg="--extra-index-url https://download.pytorch.org/whl/rocm5.4.2"; \
|
||||||
else \
|
else \
|
||||||
extra_index_url_arg="--extra-index-url https://download.pytorch.org/whl/cu121"; \
|
extra_index_url_arg="--extra-index-url https://download.pytorch.org/whl/cu118"; \
|
||||||
fi &&\
|
fi &&\
|
||||||
pip install $extra_index_url_arg \
|
pip install $extra_index_url_arg \
|
||||||
torch==$TORCH_VERSION \
|
torch==$TORCH_VERSION \
|
||||||
@ -59,20 +59,18 @@ RUN --mount=type=cache,target=/root/.cache/pip \
|
|||||||
|
|
||||||
# #### Build the Web UI ------------------------------------
|
# #### Build the Web UI ------------------------------------
|
||||||
|
|
||||||
FROM node:18-slim AS web-builder
|
FROM node:18 AS web-builder
|
||||||
ENV PNPM_HOME="/pnpm"
|
|
||||||
ENV PATH="$PNPM_HOME:$PATH"
|
|
||||||
RUN corepack enable
|
|
||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
COPY invokeai/frontend/web/ ./
|
COPY invokeai/frontend/web/ ./
|
||||||
RUN --mount=type=cache,target=/pnpm/store \
|
RUN --mount=type=cache,target=/usr/lib/node_modules \
|
||||||
pnpm install --frozen-lockfile
|
npm install --include dev
|
||||||
RUN pnpm run build
|
RUN --mount=type=cache,target=/usr/lib/node_modules \
|
||||||
|
yarn vite build
|
||||||
|
|
||||||
|
|
||||||
#### Runtime stage ---------------------------------------
|
#### Runtime stage ---------------------------------------
|
||||||
|
|
||||||
FROM library/ubuntu:23.04 AS runtime
|
FROM library/ubuntu:22.04 AS runtime
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
@ -87,7 +85,6 @@ RUN apt update && apt install -y --no-install-recommends \
|
|||||||
iotop \
|
iotop \
|
||||||
bzip2 \
|
bzip2 \
|
||||||
gosu \
|
gosu \
|
||||||
magic-wormhole \
|
|
||||||
libglib2.0-0 \
|
libglib2.0-0 \
|
||||||
libgl1-mesa-glx \
|
libgl1-mesa-glx \
|
||||||
python3-venv \
|
python3-venv \
|
||||||
@ -97,13 +94,15 @@ RUN apt update && apt install -y --no-install-recommends \
|
|||||||
libstdc++-10-dev &&\
|
libstdc++-10-dev &&\
|
||||||
apt-get clean && apt-get autoclean
|
apt-get clean && apt-get autoclean
|
||||||
|
|
||||||
|
# globally add magic-wormhole
|
||||||
|
# for ease of transferring data to and from the container
|
||||||
|
# when running in sandboxed cloud environments; e.g. Runpod etc.
|
||||||
|
RUN pip install magic-wormhole
|
||||||
|
|
||||||
ENV INVOKEAI_SRC=/opt/invokeai
|
ENV INVOKEAI_SRC=/opt/invokeai
|
||||||
ENV VIRTUAL_ENV=/opt/venv/invokeai
|
ENV VIRTUAL_ENV=/opt/venv/invokeai
|
||||||
ENV INVOKEAI_ROOT=/invokeai
|
ENV INVOKEAI_ROOT=/invokeai
|
||||||
ENV PATH="$VIRTUAL_ENV/bin:$INVOKEAI_SRC:$PATH"
|
ENV PATH="$VIRTUAL_ENV/bin:$INVOKEAI_SRC:$PATH"
|
||||||
ENV CONTAINER_UID=${CONTAINER_UID:-1000}
|
|
||||||
ENV CONTAINER_GID=${CONTAINER_GID:-1000}
|
|
||||||
|
|
||||||
# --link requires buldkit w/ dockerfile syntax 1.4
|
# --link requires buldkit w/ dockerfile syntax 1.4
|
||||||
COPY --link --from=builder ${INVOKEAI_SRC} ${INVOKEAI_SRC}
|
COPY --link --from=builder ${INVOKEAI_SRC} ${INVOKEAI_SRC}
|
||||||
@ -121,7 +120,9 @@ WORKDIR ${INVOKEAI_SRC}
|
|||||||
RUN cd /usr/lib/$(uname -p)-linux-gnu/pkgconfig/ && ln -sf opencv4.pc opencv.pc
|
RUN cd /usr/lib/$(uname -p)-linux-gnu/pkgconfig/ && ln -sf opencv4.pc opencv.pc
|
||||||
RUN python3 -c "from patchmatch import patch_match"
|
RUN python3 -c "from patchmatch import patch_match"
|
||||||
|
|
||||||
RUN mkdir -p ${INVOKEAI_ROOT} && chown -R ${CONTAINER_UID}:${CONTAINER_GID} ${INVOKEAI_ROOT}
|
# Create unprivileged user and make the local dir
|
||||||
|
RUN useradd --create-home --shell /bin/bash -u 1000 --comment "container local user" invoke
|
||||||
|
RUN mkdir -p ${INVOKEAI_ROOT} && chown -R invoke:invoke ${INVOKEAI_ROOT}
|
||||||
|
|
||||||
COPY docker/docker-entrypoint.sh ./
|
COPY docker/docker-entrypoint.sh ./
|
||||||
ENTRYPOINT ["/opt/invokeai/docker-entrypoint.sh"]
|
ENTRYPOINT ["/opt/invokeai/docker-entrypoint.sh"]
|
||||||
|
@ -1,19 +1,11 @@
|
|||||||
# InvokeAI Containerized
|
# InvokeAI Containerized
|
||||||
|
|
||||||
All commands should be run within the `docker` directory: `cd docker`
|
All commands are to be run from the `docker` directory: `cd docker`
|
||||||
|
|
||||||
## Quickstart :rocket:
|
|
||||||
|
|
||||||
On a known working Linux+Docker+CUDA (Nvidia) system, execute `./run.sh` in this directory. It will take a few minutes - depending on your internet speed - to install the core models. Once the application starts up, open `http://localhost:9090` in your browser to Invoke!
|
|
||||||
|
|
||||||
For more configuration options (using an AMD GPU, custom root directory location, etc): read on.
|
|
||||||
|
|
||||||
## Detailed setup
|
|
||||||
|
|
||||||
#### Linux
|
#### Linux
|
||||||
|
|
||||||
1. Ensure builkit is enabled in the Docker daemon settings (`/etc/docker/daemon.json`)
|
1. Ensure builkit is enabled in the Docker daemon settings (`/etc/docker/daemon.json`)
|
||||||
2. Install the `docker compose` plugin using your package manager, or follow a [tutorial](https://docs.docker.com/compose/install/linux/#install-using-the-repository).
|
2. Install the `docker compose` plugin using your package manager, or follow a [tutorial](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-ubuntu-22-04).
|
||||||
- The deprecated `docker-compose` (hyphenated) CLI continues to work for now.
|
- The deprecated `docker-compose` (hyphenated) CLI continues to work for now.
|
||||||
3. Ensure docker daemon is able to access the GPU.
|
3. Ensure docker daemon is able to access the GPU.
|
||||||
- You may need to install [nvidia-container-toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html)
|
- You may need to install [nvidia-container-toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html)
|
||||||
@ -26,12 +18,13 @@ For more configuration options (using an AMD GPU, custom root directory location
|
|||||||
|
|
||||||
This is done via Docker Desktop preferences
|
This is done via Docker Desktop preferences
|
||||||
|
|
||||||
### Configure Invoke environment
|
## Quickstart
|
||||||
|
|
||||||
|
|
||||||
1. Make a copy of `env.sample` and name it `.env` (`cp env.sample .env` (Mac/Linux) or `copy example.env .env` (Windows)). Make changes as necessary. Set `INVOKEAI_ROOT` to an absolute path to:
|
1. Make a copy of `env.sample` and name it `.env` (`cp env.sample .env` (Mac/Linux) or `copy example.env .env` (Windows)). Make changes as necessary. Set `INVOKEAI_ROOT` to an absolute path to:
|
||||||
a. the desired location of the InvokeAI runtime directory, or
|
a. the desired location of the InvokeAI runtime directory, or
|
||||||
b. an existing, v3.0.0 compatible runtime directory.
|
b. an existing, v3.0.0 compatible runtime directory.
|
||||||
1. Execute `run.sh`
|
1. `docker compose up`
|
||||||
|
|
||||||
The image will be built automatically if needed.
|
The image will be built automatically if needed.
|
||||||
|
|
||||||
@ -45,28 +38,24 @@ The runtime directory (holding models and outputs) will be created in the locati
|
|||||||
|
|
||||||
The Docker daemon on the system must be already set up to use the GPU. In case of Linux, this involves installing `nvidia-docker-runtime` and configuring the `nvidia` runtime as default. Steps will be different for AMD. Please see Docker documentation for the most up-to-date instructions for using your GPU with Docker.
|
The Docker daemon on the system must be already set up to use the GPU. In case of Linux, this involves installing `nvidia-docker-runtime` and configuring the `nvidia` runtime as default. Steps will be different for AMD. Please see Docker documentation for the most up-to-date instructions for using your GPU with Docker.
|
||||||
|
|
||||||
To use an AMD GPU, set `GPU_DRIVER=rocm` in your `.env` file.
|
|
||||||
|
|
||||||
## Customize
|
## Customize
|
||||||
|
|
||||||
Check the `.env.sample` file. It contains some environment variables for running in Docker. Copy it, name it `.env`, and fill it in with your own values. Next time you run `run.sh`, your custom values will be used.
|
Check the `.env.sample` file. It contains some environment variables for running in Docker. Copy it, name it `.env`, and fill it in with your own values. Next time you run `docker compose up`, your custom values will be used.
|
||||||
|
|
||||||
You can also set these values in `docker-compose.yml` directly, but `.env` will help avoid conflicts when code is updated.
|
You can also set these values in `docker compose.yml` directly, but `.env` will help avoid conflicts when code is updated.
|
||||||
|
|
||||||
Values are optional, but setting `INVOKEAI_ROOT` is highly recommended. The default is `~/invokeai`. Example:
|
Example (most values are optional):
|
||||||
|
|
||||||
```bash
|
```
|
||||||
INVOKEAI_ROOT=/Volumes/WorkDrive/invokeai
|
INVOKEAI_ROOT=/Volumes/WorkDrive/invokeai
|
||||||
HUGGINGFACE_TOKEN=the_actual_token
|
HUGGINGFACE_TOKEN=the_actual_token
|
||||||
CONTAINER_UID=1000
|
CONTAINER_UID=1000
|
||||||
GPU_DRIVER=nvidia
|
GPU_DRIVER=cuda
|
||||||
```
|
```
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
## Even Moar Customizing!
|
## Even Moar Customizing!
|
||||||
|
|
||||||
See the `docker-compose.yml` file. The `command` instruction can be uncommented and used to run arbitrary startup commands. Some examples below.
|
See the `docker compose.yaml` file. The `command` instruction can be uncommented and used to run arbitrary startup commands. Some examples below.
|
||||||
|
|
||||||
### Reconfigure the runtime directory
|
### Reconfigure the runtime directory
|
||||||
|
|
||||||
@ -74,7 +63,7 @@ Can be used to download additional models from the supported model list
|
|||||||
|
|
||||||
In conjunction with `INVOKEAI_ROOT` can be also used to initialize a runtime directory
|
In conjunction with `INVOKEAI_ROOT` can be also used to initialize a runtime directory
|
||||||
|
|
||||||
```yaml
|
```
|
||||||
command:
|
command:
|
||||||
- invokeai-configure
|
- invokeai-configure
|
||||||
- --yes
|
- --yes
|
||||||
@ -82,7 +71,7 @@ command:
|
|||||||
|
|
||||||
Or install models:
|
Or install models:
|
||||||
|
|
||||||
```yaml
|
```
|
||||||
command:
|
command:
|
||||||
- invokeai-model-install
|
- invokeai-model-install
|
||||||
```
|
```
|
11
docker/build.sh
Executable file
11
docker/build.sh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
build_args=""
|
||||||
|
|
||||||
|
[[ -f ".env" ]] && build_args=$(awk '$1 ~ /\=[^$]/ {print "--build-arg " $0 " "}' .env)
|
||||||
|
|
||||||
|
echo "docker-compose build args:"
|
||||||
|
echo $build_args
|
||||||
|
|
||||||
|
docker-compose build $build_args
|
@ -2,8 +2,19 @@
|
|||||||
|
|
||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
x-invokeai: &invokeai
|
services:
|
||||||
|
invokeai:
|
||||||
image: "local/invokeai:latest"
|
image: "local/invokeai:latest"
|
||||||
|
# edit below to run on a container runtime other than nvidia-container-runtime.
|
||||||
|
# not yet tested with rocm/AMD GPUs
|
||||||
|
# Comment out the "deploy" section to run on CPU only
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
reservations:
|
||||||
|
devices:
|
||||||
|
- driver: nvidia
|
||||||
|
count: 1
|
||||||
|
capabilities: [gpu]
|
||||||
build:
|
build:
|
||||||
context: ..
|
context: ..
|
||||||
dockerfile: docker/Dockerfile
|
dockerfile: docker/Dockerfile
|
||||||
@ -35,27 +46,3 @@ x-invokeai: &invokeai
|
|||||||
# - |
|
# - |
|
||||||
# invokeai-model-install --yes --default-only --config_file ${INVOKEAI_ROOT}/config_custom.yaml
|
# invokeai-model-install --yes --default-only --config_file ${INVOKEAI_ROOT}/config_custom.yaml
|
||||||
# invokeai-nodes-web --host 0.0.0.0
|
# invokeai-nodes-web --host 0.0.0.0
|
||||||
|
|
||||||
services:
|
|
||||||
invokeai-nvidia:
|
|
||||||
<<: *invokeai
|
|
||||||
deploy:
|
|
||||||
resources:
|
|
||||||
reservations:
|
|
||||||
devices:
|
|
||||||
- driver: nvidia
|
|
||||||
count: 1
|
|
||||||
capabilities: [gpu]
|
|
||||||
|
|
||||||
invokeai-cpu:
|
|
||||||
<<: *invokeai
|
|
||||||
profiles:
|
|
||||||
- cpu
|
|
||||||
|
|
||||||
invokeai-rocm:
|
|
||||||
<<: *invokeai
|
|
||||||
devices:
|
|
||||||
- /dev/kfd:/dev/kfd
|
|
||||||
- /dev/dri:/dev/dri
|
|
||||||
profiles:
|
|
||||||
- rocm
|
|
||||||
|
@ -19,7 +19,7 @@ set -e -o pipefail
|
|||||||
# Default UID: 1000 chosen due to popularity on Linux systems. Possibly 501 on MacOS.
|
# Default UID: 1000 chosen due to popularity on Linux systems. Possibly 501 on MacOS.
|
||||||
|
|
||||||
USER_ID=${CONTAINER_UID:-1000}
|
USER_ID=${CONTAINER_UID:-1000}
|
||||||
USER=ubuntu
|
USER=invoke
|
||||||
usermod -u ${USER_ID} ${USER} 1>/dev/null
|
usermod -u ${USER_ID} ${USER} 1>/dev/null
|
||||||
|
|
||||||
configure() {
|
configure() {
|
||||||
|
@ -1,32 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e -o pipefail
|
set -e
|
||||||
|
|
||||||
run() {
|
SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}")
|
||||||
local scriptdir=$(dirname "${BASH_SOURCE[0]}")
|
cd "$SCRIPTDIR" || exit 1
|
||||||
cd "$scriptdir" || exit 1
|
|
||||||
|
|
||||||
local build_args=""
|
docker-compose up --build -d
|
||||||
local profile=""
|
docker-compose logs -f
|
||||||
|
|
||||||
touch .env
|
|
||||||
build_args=$(awk '$1 ~ /=[^$]/ && $0 !~ /^#/ {print "--build-arg " $0 " "}' .env) &&
|
|
||||||
profile="$(awk -F '=' '/GPU_DRIVER/ {print $2}' .env)"
|
|
||||||
|
|
||||||
[[ -z "$profile" ]] && profile="nvidia"
|
|
||||||
|
|
||||||
local service_name="invokeai-$profile"
|
|
||||||
|
|
||||||
if [[ ! -z "$build_args" ]]; then
|
|
||||||
printf "%s\n" "docker compose build args:"
|
|
||||||
printf "%s\n" "$build_args"
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker compose build $build_args
|
|
||||||
unset build_args
|
|
||||||
|
|
||||||
printf "%s\n" "starting service $service_name"
|
|
||||||
docker compose --profile "$profile" up -d "$service_name"
|
|
||||||
docker compose logs -f
|
|
||||||
}
|
|
||||||
|
|
||||||
run
|
|
||||||
|
@ -488,7 +488,7 @@ sections describe what's new for InvokeAI.
|
|||||||
|
|
||||||
- A choice of installer scripts that automate installation and configuration.
|
- A choice of installer scripts that automate installation and configuration.
|
||||||
See
|
See
|
||||||
[Installation](installation/INSTALLATION.md).
|
[Installation](installation/index.md).
|
||||||
- A streamlined manual installation process that works for both Conda and
|
- A streamlined manual installation process that works for both Conda and
|
||||||
PIP-only installs. See
|
PIP-only installs. See
|
||||||
[Manual Installation](installation/020_INSTALL_MANUAL.md).
|
[Manual Installation](installation/020_INSTALL_MANUAL.md).
|
||||||
@ -657,7 +657,7 @@ sections describe what's new for InvokeAI.
|
|||||||
|
|
||||||
## v1.13 <small>(3 September 2022)</small>
|
## v1.13 <small>(3 September 2022)</small>
|
||||||
|
|
||||||
- Support image variations (see [VARIATIONS](deprecated/VARIATIONS.md)
|
- Support image variations (see [VARIATIONS](features/VARIATIONS.md)
|
||||||
([Kevin Gibbons](https://github.com/bakkot) and many contributors and
|
([Kevin Gibbons](https://github.com/bakkot) and many contributors and
|
||||||
reviewers)
|
reviewers)
|
||||||
- Supports a Google Colab notebook for a standalone server running on Google
|
- Supports a Google Colab notebook for a standalone server running on Google
|
||||||
|
@ -1,277 +0,0 @@
|
|||||||
# The InvokeAI Download Queue
|
|
||||||
|
|
||||||
The DownloadQueueService provides a multithreaded parallel download
|
|
||||||
queue for arbitrary URLs, with queue prioritization, event handling,
|
|
||||||
and restart capabilities.
|
|
||||||
|
|
||||||
## Simple Example
|
|
||||||
|
|
||||||
```
|
|
||||||
from invokeai.app.services.download import DownloadQueueService, TqdmProgress
|
|
||||||
|
|
||||||
download_queue = DownloadQueueService()
|
|
||||||
for url in ['https://github.com/invoke-ai/InvokeAI/blob/main/invokeai/assets/a-painting-of-a-fire.png?raw=true',
|
|
||||||
'https://github.com/invoke-ai/InvokeAI/blob/main/invokeai/assets/birdhouse.png?raw=true',
|
|
||||||
'https://github.com/invoke-ai/InvokeAI/blob/main/invokeai/assets/missing.png',
|
|
||||||
'https://civitai.com/api/download/models/152309?type=Model&format=SafeTensor',
|
|
||||||
]:
|
|
||||||
|
|
||||||
# urls start downloading as soon as download() is called
|
|
||||||
download_queue.download(source=url,
|
|
||||||
dest='/tmp/downloads',
|
|
||||||
on_progress=TqdmProgress().update
|
|
||||||
)
|
|
||||||
|
|
||||||
download_queue.join() # wait for all downloads to finish
|
|
||||||
for job in download_queue.list_jobs():
|
|
||||||
print(job.model_dump_json(exclude_none=True, indent=4),"\n")
|
|
||||||
```
|
|
||||||
|
|
||||||
Output:
|
|
||||||
|
|
||||||
```
|
|
||||||
{
|
|
||||||
"source": "https://github.com/invoke-ai/InvokeAI/blob/main/invokeai/assets/a-painting-of-a-fire.png?raw=true",
|
|
||||||
"dest": "/tmp/downloads",
|
|
||||||
"id": 0,
|
|
||||||
"priority": 10,
|
|
||||||
"status": "completed",
|
|
||||||
"download_path": "/tmp/downloads/a-painting-of-a-fire.png",
|
|
||||||
"job_started": "2023-12-04T05:34:41.742174",
|
|
||||||
"job_ended": "2023-12-04T05:34:42.592035",
|
|
||||||
"bytes": 666734,
|
|
||||||
"total_bytes": 666734
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
"source": "https://github.com/invoke-ai/InvokeAI/blob/main/invokeai/assets/birdhouse.png?raw=true",
|
|
||||||
"dest": "/tmp/downloads",
|
|
||||||
"id": 1,
|
|
||||||
"priority": 10,
|
|
||||||
"status": "completed",
|
|
||||||
"download_path": "/tmp/downloads/birdhouse.png",
|
|
||||||
"job_started": "2023-12-04T05:34:41.741975",
|
|
||||||
"job_ended": "2023-12-04T05:34:42.652841",
|
|
||||||
"bytes": 774949,
|
|
||||||
"total_bytes": 774949
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
"source": "https://github.com/invoke-ai/InvokeAI/blob/main/invokeai/assets/missing.png",
|
|
||||||
"dest": "/tmp/downloads",
|
|
||||||
"id": 2,
|
|
||||||
"priority": 10,
|
|
||||||
"status": "error",
|
|
||||||
"job_started": "2023-12-04T05:34:41.742079",
|
|
||||||
"job_ended": "2023-12-04T05:34:42.147625",
|
|
||||||
"bytes": 0,
|
|
||||||
"total_bytes": 0,
|
|
||||||
"error_type": "HTTPError(Not Found)",
|
|
||||||
"error": "Traceback (most recent call last):\n File \"/home/lstein/Projects/InvokeAI/invokeai/app/services/download/download_default.py\", line 182, in _download_next_item\n self._do_download(job)\n File \"/home/lstein/Projects/InvokeAI/invokeai/app/services/download/download_default.py\", line 206, in _do_download\n raise HTTPError(resp.reason)\nrequests.exceptions.HTTPError: Not Found\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
"source": "https://civitai.com/api/download/models/152309?type=Model&format=SafeTensor",
|
|
||||||
"dest": "/tmp/downloads",
|
|
||||||
"id": 3,
|
|
||||||
"priority": 10,
|
|
||||||
"status": "completed",
|
|
||||||
"download_path": "/tmp/downloads/xl_more_art-full_v1.safetensors",
|
|
||||||
"job_started": "2023-12-04T05:34:42.147645",
|
|
||||||
"job_ended": "2023-12-04T05:34:43.735990",
|
|
||||||
"bytes": 719020768,
|
|
||||||
"total_bytes": 719020768
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## The API
|
|
||||||
|
|
||||||
The default download queue is `DownloadQueueService`, an
|
|
||||||
implementation of ABC `DownloadQueueServiceBase`. It juggles multiple
|
|
||||||
background download requests and provides facilities for interrogating
|
|
||||||
and cancelling the requests. Access to a current or past download task
|
|
||||||
is mediated via `DownloadJob` objects which report the current status
|
|
||||||
of a job request
|
|
||||||
|
|
||||||
### The Queue Object
|
|
||||||
|
|
||||||
A default download queue is located in
|
|
||||||
`ApiDependencies.invoker.services.download_queue`. However, you can
|
|
||||||
create additional instances if you need to isolate your queue from the
|
|
||||||
main one.
|
|
||||||
|
|
||||||
```
|
|
||||||
queue = DownloadQueueService(event_bus=events)
|
|
||||||
```
|
|
||||||
|
|
||||||
`DownloadQueueService()` takes three optional arguments:
|
|
||||||
|
|
||||||
| **Argument** | **Type** | **Default** | **Description** |
|
|
||||||
|----------------|-----------------|---------------|-----------------|
|
|
||||||
| `max_parallel_dl` | int | 5 | Maximum number of simultaneous downloads allowed |
|
|
||||||
| `event_bus` | EventServiceBase | None | System-wide FastAPI event bus for reporting download events |
|
|
||||||
| `requests_session` | requests.sessions.Session | None | An alternative requests Session object to use for the download |
|
|
||||||
|
|
||||||
`max_parallel_dl` specifies how many download jobs are allowed to run
|
|
||||||
simultaneously. Each will run in a different thread of execution.
|
|
||||||
|
|
||||||
`event_bus` is an EventServiceBase, typically the one created at
|
|
||||||
InvokeAI startup. If present, download events are periodically emitted
|
|
||||||
on this bus to allow clients to follow download progress.
|
|
||||||
|
|
||||||
`requests_session` is a url library requests Session object. It is
|
|
||||||
used for testing.
|
|
||||||
|
|
||||||
### The Job object
|
|
||||||
|
|
||||||
The queue operates on a series of download job objects. These objects
|
|
||||||
specify the source and destination of the download, and keep track of
|
|
||||||
the progress of the download.
|
|
||||||
|
|
||||||
The only job type currently implemented is `DownloadJob`, a pydantic object with the
|
|
||||||
following fields:
|
|
||||||
|
|
||||||
| **Field** | **Type** | **Default** | **Description** |
|
|
||||||
|----------------|-----------------|---------------|-----------------|
|
|
||||||
| _Fields passed in at job creation time_ |
|
|
||||||
| `source` | AnyHttpUrl | | Where to download from |
|
|
||||||
| `dest` | Path | | Where to download to |
|
|
||||||
| `access_token` | str | | [optional] string containing authentication token for access |
|
|
||||||
| `on_start` | Callable | | [optional] callback when the download starts |
|
|
||||||
| `on_progress` | Callable | | [optional] callback called at intervals during download progress |
|
|
||||||
| `on_complete` | Callable | | [optional] callback called after successful download completion |
|
|
||||||
| `on_error` | Callable | | [optional] callback called after an error occurs |
|
|
||||||
| `id` | int | auto assigned | Job ID, an integer >= 0 |
|
|
||||||
| `priority` | int | 10 | Job priority. Lower priorities run before higher priorities |
|
|
||||||
| |
|
|
||||||
| _Fields updated over the course of the download task_
|
|
||||||
| `status` | DownloadJobStatus| | Status code |
|
|
||||||
| `download_path` | Path | | Path to the location of the downloaded file |
|
|
||||||
| `job_started` | float | | Timestamp for when the job started running |
|
|
||||||
| `job_ended` | float | | Timestamp for when the job completed or errored out |
|
|
||||||
| `job_sequence` | int | | A counter that is incremented each time a model is dequeued |
|
|
||||||
| `bytes` | int | 0 | Bytes downloaded so far |
|
|
||||||
| `total_bytes` | int | 0 | Total size of the file at the remote site |
|
|
||||||
| `error_type` | str | | String version of the exception that caused an error during download |
|
|
||||||
| `error` | str | | String version of the traceback associated with an error |
|
|
||||||
| `cancelled` | bool | False | Set to true if the job was cancelled by the caller|
|
|
||||||
|
|
||||||
When you create a job, you can assign it a `priority`. If multiple
|
|
||||||
jobs are queued, the job with the lowest priority runs first.
|
|
||||||
|
|
||||||
Every job has a `source` and a `dest`. `source` is a pydantic.networks AnyHttpUrl object.
|
|
||||||
The `dest` is a path on the local filesystem that specifies the
|
|
||||||
destination for the downloaded object. Its semantics are
|
|
||||||
described below.
|
|
||||||
|
|
||||||
When the job is submitted, it is assigned a numeric `id`. The id can
|
|
||||||
then be used to fetch the job object from the queue.
|
|
||||||
|
|
||||||
The `status` field is updated by the queue to indicate where the job
|
|
||||||
is in its lifecycle. Values are defined in the string enum
|
|
||||||
`DownloadJobStatus`, a symbol available from
|
|
||||||
`invokeai.app.services.download_manager`. Possible values are:
|
|
||||||
|
|
||||||
| **Value** | **String Value** | ** Description ** |
|
|
||||||
|--------------|---------------------|-------------------|
|
|
||||||
| `WAITING` | waiting | Job is on the queue but not yet running|
|
|
||||||
| `RUNNING` | running | The download is started |
|
|
||||||
| `COMPLETED` | completed | Job has finished its work without an error |
|
|
||||||
| `ERROR` | error | Job encountered an error and will not run again|
|
|
||||||
|
|
||||||
`job_started` and `job_ended` indicate when the job
|
|
||||||
was started (using a python timestamp) and when it completed.
|
|
||||||
|
|
||||||
In case of an error, the job's status will be set to `DownloadJobStatus.ERROR`, the text of the
|
|
||||||
Exception that caused the error will be placed in the `error_type`
|
|
||||||
field and the traceback that led to the error will be in `error`.
|
|
||||||
|
|
||||||
A cancelled job will have status `DownloadJobStatus.ERROR` and an
|
|
||||||
`error_type` field of "DownloadJobCancelledException". In addition,
|
|
||||||
the job's `cancelled` property will be set to True.
|
|
||||||
|
|
||||||
### Callbacks
|
|
||||||
|
|
||||||
Download jobs can be associated with a series of callbacks, each with
|
|
||||||
the signature `Callable[["DownloadJob"], None]`. The callbacks are assigned
|
|
||||||
using optional arguments `on_start`, `on_progress`, `on_complete` and
|
|
||||||
`on_error`. When the corresponding event occurs, the callback wil be
|
|
||||||
invoked and passed the job. The callback will be run in a `try:`
|
|
||||||
context in the same thread as the download job. Any exceptions that
|
|
||||||
occur during execution of the callback will be caught and converted
|
|
||||||
into a log error message, thereby allowing the download to continue.
|
|
||||||
|
|
||||||
#### `TqdmProgress`
|
|
||||||
|
|
||||||
The `invokeai.app.services.download.download_default` module defines a
|
|
||||||
class named `TqdmProgress` which can be used as an `on_progress`
|
|
||||||
handler to display a completion bar in the console. Use as follows:
|
|
||||||
|
|
||||||
```
|
|
||||||
from invokeai.app.services.download import TqdmProgress
|
|
||||||
|
|
||||||
download_queue.download(source='http://some.server.somewhere/some_file',
|
|
||||||
dest='/tmp/downloads',
|
|
||||||
on_progress=TqdmProgress().update
|
|
||||||
)
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
### Events
|
|
||||||
|
|
||||||
If the queue was initialized with the InvokeAI event bus (the case
|
|
||||||
when using `ApiDependencies.invoker.services.download_queue`), then
|
|
||||||
download events will also be issued on the bus. The events are:
|
|
||||||
|
|
||||||
* `download_started` -- This is issued when a job is taken off the
|
|
||||||
queue and a request is made to the remote server for the URL headers, but before any data
|
|
||||||
has been downloaded. The event payload will contain the keys `source`
|
|
||||||
and `download_path`. The latter contains the path that the URL will be
|
|
||||||
downloaded to.
|
|
||||||
|
|
||||||
* `download_progress -- This is issued periodically as the download
|
|
||||||
runs. The payload contains the keys `source`, `download_path`,
|
|
||||||
`current_bytes` and `total_bytes`. The latter two fields can be
|
|
||||||
used to display the percent complete.
|
|
||||||
|
|
||||||
* `download_complete` -- This is issued when the download completes
|
|
||||||
successfully. The payload contains the keys `source`, `download_path`
|
|
||||||
and `total_bytes`.
|
|
||||||
|
|
||||||
* `download_error` -- This is issued when the download stops because
|
|
||||||
of an error condition. The payload contains the fields `error_type`
|
|
||||||
and `error`. The former is the text representation of the exception,
|
|
||||||
and the latter is a traceback showing where the error occurred.
|
|
||||||
|
|
||||||
### Job control
|
|
||||||
|
|
||||||
To create a job call the queue's `download()` method. You can list all
|
|
||||||
jobs using `list_jobs()`, fetch a single job by its with
|
|
||||||
`id_to_job()`, cancel a running job with `cancel_job()`, cancel all
|
|
||||||
running jobs with `cancel_all_jobs()`, and wait for all jobs to finish
|
|
||||||
with `join()`.
|
|
||||||
|
|
||||||
#### job = queue.download(source, dest, priority, access_token)
|
|
||||||
|
|
||||||
Create a new download job and put it on the queue, returning the
|
|
||||||
DownloadJob object.
|
|
||||||
|
|
||||||
#### jobs = queue.list_jobs()
|
|
||||||
|
|
||||||
Return a list of all active and inactive `DownloadJob`s.
|
|
||||||
|
|
||||||
#### job = queue.id_to_job(id)
|
|
||||||
|
|
||||||
Return the job corresponding to given ID.
|
|
||||||
|
|
||||||
Return a list of all active and inactive `DownloadJob`s.
|
|
||||||
|
|
||||||
#### queue.prune_jobs()
|
|
||||||
|
|
||||||
Remove inactive (complete or errored) jobs from the listing returned
|
|
||||||
by `list_jobs()`.
|
|
||||||
|
|
||||||
#### queue.join()
|
|
||||||
|
|
||||||
Block until all pending jobs have run to completion or errored out.
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
# Nodes
|
# Invocations
|
||||||
|
|
||||||
Features in InvokeAI are added in the form of modular nodes systems called
|
Features in InvokeAI are added in the form of modular node-like systems called
|
||||||
**Invocations**.
|
**Invocations**.
|
||||||
|
|
||||||
An Invocation is simply a single operation that takes in some inputs and gives
|
An Invocation is simply a single operation that takes in some inputs and gives
|
||||||
@ -9,34 +9,13 @@ complex functionality.
|
|||||||
|
|
||||||
## Invocations Directory
|
## Invocations Directory
|
||||||
|
|
||||||
InvokeAI Nodes can be found in the `invokeai/app/invocations` directory. These can be used as examples to create your own nodes.
|
InvokeAI Invocations can be found in the `invokeai/app/invocations` directory.
|
||||||
|
|
||||||
New nodes should be added to a subfolder in `nodes` direction found at the root level of the InvokeAI installation location. Nodes added to this folder will be able to be used upon application startup.
|
You can add your new functionality to one of the existing Invocations in this
|
||||||
|
directory or create a new file in this directory as per your needs.
|
||||||
Example `nodes` subfolder structure:
|
|
||||||
```py
|
|
||||||
├── __init__.py # Invoke-managed custom node loader
|
|
||||||
│
|
|
||||||
├── cool_node
|
|
||||||
│ ├── __init__.py # see example below
|
|
||||||
│ └── cool_node.py
|
|
||||||
│
|
|
||||||
└── my_node_pack
|
|
||||||
├── __init__.py # see example below
|
|
||||||
├── tasty_node.py
|
|
||||||
├── bodacious_node.py
|
|
||||||
├── utils.py
|
|
||||||
└── extra_nodes
|
|
||||||
└── fancy_node.py
|
|
||||||
```
|
|
||||||
|
|
||||||
Each node folder must have an `__init__.py` file that imports its nodes. Only nodes imported in the `__init__.py` file are loaded.
|
|
||||||
See the README in the nodes folder for more examples:
|
|
||||||
|
|
||||||
```py
|
|
||||||
from .cool_node import CoolInvocation
|
|
||||||
```
|
|
||||||
|
|
||||||
|
**Note:** _All Invocations must be inside this directory for InvokeAI to
|
||||||
|
recognize them as valid Invocations._
|
||||||
|
|
||||||
## Creating A New Invocation
|
## Creating A New Invocation
|
||||||
|
|
||||||
@ -65,7 +44,7 @@ The first set of things we need to do when creating a new Invocation are -
|
|||||||
So let us do that.
|
So let us do that.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from invokeai.app.invocations.baseinvocation import BaseInvocation, invocation
|
from .baseinvocation import BaseInvocation, invocation
|
||||||
|
|
||||||
@invocation('resize')
|
@invocation('resize')
|
||||||
class ResizeInvocation(BaseInvocation):
|
class ResizeInvocation(BaseInvocation):
|
||||||
@ -99,8 +78,8 @@ create your own custom field types later in this guide. For now, let's go ahead
|
|||||||
and use it.
|
and use it.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from invokeai.app.invocations.baseinvocation import BaseInvocation, InputField, invocation
|
from .baseinvocation import BaseInvocation, InputField, invocation
|
||||||
from invokeai.app.invocations.primitives import ImageField
|
from .primitives import ImageField
|
||||||
|
|
||||||
@invocation('resize')
|
@invocation('resize')
|
||||||
class ResizeInvocation(BaseInvocation):
|
class ResizeInvocation(BaseInvocation):
|
||||||
@ -124,8 +103,8 @@ image: ImageField = InputField(description="The input image")
|
|||||||
Great. Now let us create our other inputs for `width` and `height`
|
Great. Now let us create our other inputs for `width` and `height`
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from invokeai.app.invocations.baseinvocation import BaseInvocation, InputField, invocation
|
from .baseinvocation import BaseInvocation, InputField, invocation
|
||||||
from invokeai.app.invocations.primitives import ImageField
|
from .primitives import ImageField
|
||||||
|
|
||||||
@invocation('resize')
|
@invocation('resize')
|
||||||
class ResizeInvocation(BaseInvocation):
|
class ResizeInvocation(BaseInvocation):
|
||||||
@ -160,8 +139,8 @@ that are provided by it by InvokeAI.
|
|||||||
Let us create this function first.
|
Let us create this function first.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from invokeai.app.invocations.baseinvocation import BaseInvocation, InputField, invocation, InvocationContext
|
from .baseinvocation import BaseInvocation, InputField, invocation
|
||||||
from invokeai.app.invocations.primitives import ImageField
|
from .primitives import ImageField
|
||||||
|
|
||||||
@invocation('resize')
|
@invocation('resize')
|
||||||
class ResizeInvocation(BaseInvocation):
|
class ResizeInvocation(BaseInvocation):
|
||||||
@ -189,9 +168,9 @@ all the necessary info related to image outputs. So let us use that.
|
|||||||
We will cover how to create your own output types later in this guide.
|
We will cover how to create your own output types later in this guide.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from invokeai.app.invocations.baseinvocation import BaseInvocation, InputField, invocation, InvocationContext
|
from .baseinvocation import BaseInvocation, InputField, invocation
|
||||||
from invokeai.app.invocations.primitives import ImageField
|
from .primitives import ImageField
|
||||||
from invokeai.app.invocations.image import ImageOutput
|
from .image import ImageOutput
|
||||||
|
|
||||||
@invocation('resize')
|
@invocation('resize')
|
||||||
class ResizeInvocation(BaseInvocation):
|
class ResizeInvocation(BaseInvocation):
|
||||||
@ -216,9 +195,9 @@ Perfect. Now that we have our Invocation setup, let us do what we want to do.
|
|||||||
So let's do that.
|
So let's do that.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from invokeai.app.invocations.baseinvocation import BaseInvocation, InputField, invocation, InvocationContext
|
from .baseinvocation import BaseInvocation, InputField, invocation
|
||||||
from invokeai.app.invocations.primitives import ImageField
|
from .primitives import ImageField
|
||||||
from invokeai.app.invocations.image import ImageOutput, ResourceOrigin, ImageCategory
|
from .image import ImageOutput
|
||||||
|
|
||||||
@invocation("resize")
|
@invocation("resize")
|
||||||
class ResizeInvocation(BaseInvocation):
|
class ResizeInvocation(BaseInvocation):
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -46,18 +46,17 @@ We encourage you to ping @psychedelicious and @blessedcoolant on [Discord](http
|
|||||||
```bash
|
```bash
|
||||||
node --version
|
node --version
|
||||||
```
|
```
|
||||||
|
2. Install [yarn classic](https://classic.yarnpkg.com/lang/en/) and confirm it is installed by running this:
|
||||||
2. Install [pnpm](https://pnpm.io/) and confirm it is installed by running this:
|
|
||||||
```bash
|
```bash
|
||||||
npm install --global pnpm
|
npm install --global yarn
|
||||||
pnpm --version
|
yarn --version
|
||||||
```
|
```
|
||||||
|
|
||||||
From `invokeai/frontend/web/` run `pnpm install` to get everything set up.
|
From `invokeai/frontend/web/` run `yarn install` to get everything set up.
|
||||||
|
|
||||||
Start everything in dev mode:
|
Start everything in dev mode:
|
||||||
1. Ensure your virtual environment is running
|
1. Ensure your virtual environment is running
|
||||||
2. Start the dev server: `pnpm dev`
|
2. Start the dev server: `yarn dev`
|
||||||
3. Start the InvokeAI Nodes backend: `python scripts/invokeai-web.py # run from the repo root`
|
3. Start the InvokeAI Nodes backend: `python scripts/invokeai-web.py # run from the repo root`
|
||||||
4. Point your browser to the dev server address e.g. [http://localhost:5173/](http://localhost:5173/)
|
4. Point your browser to the dev server address e.g. [http://localhost:5173/](http://localhost:5173/)
|
||||||
|
|
||||||
@ -73,4 +72,4 @@ For a number of technical and logistical reasons, we need to commit UI build art
|
|||||||
|
|
||||||
If you submit a PR, there is a good chance we will ask you to include a separate commit with a build of the app.
|
If you submit a PR, there is a good chance we will ask you to include a separate commit with a build of the app.
|
||||||
|
|
||||||
To build for production, run `pnpm build`.
|
To build for production, run `yarn build`.
|
@ -45,5 +45,5 @@ For backend related work, please reach out to **@blessedcoolant**, **@lstein**,
|
|||||||
|
|
||||||
## **What does the Code of Conduct mean for me?**
|
## **What does the Code of Conduct mean for me?**
|
||||||
|
|
||||||
Our [Code of Conduct](../../CODE_OF_CONDUCT.md) means that you are responsible for treating everyone on the project with respect and courtesy regardless of their identity. If you are the victim of any inappropriate behavior or comments as described in our Code of Conduct, we are here for you and will do the best to ensure that the abuser is reprimanded appropriately, per our code.
|
Our [Code of Conduct](CODE_OF_CONDUCT.md) means that you are responsible for treating everyone on the project with respect and courtesy regardless of their identity. If you are the victim of any inappropriate behavior or comments as described in our Code of Conduct, we are here for you and will do the best to ensure that the abuser is reprimanded appropriately, per our code.
|
||||||
|
|
||||||
|
@ -211,8 +211,8 @@ Here are the invoke> command that apply to txt2img:
|
|||||||
| `--facetool <name>` | `-ft <name>` | `-ft gfpgan` | Select face restoration algorithm to use: gfpgan, codeformer |
|
| `--facetool <name>` | `-ft <name>` | `-ft gfpgan` | Select face restoration algorithm to use: gfpgan, codeformer |
|
||||||
| `--codeformer_fidelity` | `-cf <float>` | `0.75` | Used along with CodeFormer. Takes values between 0 and 1. 0 produces high quality but low accuracy. 1 produces high accuracy but low quality |
|
| `--codeformer_fidelity` | `-cf <float>` | `0.75` | Used along with CodeFormer. Takes values between 0 and 1. 0 produces high quality but low accuracy. 1 produces high accuracy but low quality |
|
||||||
| `--save_original` | `-save_orig` | `False` | When upscaling or fixing faces, this will cause the original image to be saved rather than replaced. |
|
| `--save_original` | `-save_orig` | `False` | When upscaling or fixing faces, this will cause the original image to be saved rather than replaced. |
|
||||||
| `--variation <float>` | `-v<float>` | `0.0` | Add a bit of noise (0.0=none, 1.0=high) to the image in order to generate a series of variations. Usually used in combination with `-S<seed>` and `-n<int>` to generate a series a riffs on a starting image. See [Variations](VARIATIONS.md). |
|
| `--variation <float>` | `-v<float>` | `0.0` | Add a bit of noise (0.0=none, 1.0=high) to the image in order to generate a series of variations. Usually used in combination with `-S<seed>` and `-n<int>` to generate a series a riffs on a starting image. See [Variations](../features/VARIATIONS.md). |
|
||||||
| `--with_variations <pattern>` | | `None` | Combine two or more variations. See [Variations](VARIATIONS.md) for now to use this. |
|
| `--with_variations <pattern>` | | `None` | Combine two or more variations. See [Variations](../features/VARIATIONS.md) for now to use this. |
|
||||||
| `--save_intermediates <n>` | | `None` | Save the image from every nth step into an "intermediates" folder inside the output directory |
|
| `--save_intermediates <n>` | | `None` | Save the image from every nth step into an "intermediates" folder inside the output directory |
|
||||||
| `--h_symmetry_time_pct <float>` | | `None` | Create symmetry along the X axis at the desired percent complete of the generation process. (Must be between 0.0 and 1.0; set to a very small number like 0.0001 for just after the first step of generation.) |
|
| `--h_symmetry_time_pct <float>` | | `None` | Create symmetry along the X axis at the desired percent complete of the generation process. (Must be between 0.0 and 1.0; set to a very small number like 0.0001 for just after the first step of generation.) |
|
||||||
| `--v_symmetry_time_pct <float>` | | `None` | Create symmetry along the Y axis at the desired percent complete of the generation process. (Must be between 0.0 and 1.0; set to a very small number like 0.0001 for just after the first step of generation.) |
|
| `--v_symmetry_time_pct <float>` | | `None` | Create symmetry along the Y axis at the desired percent complete of the generation process. (Must be between 0.0 and 1.0; set to a very small number like 0.0001 for just after the first step of generation.) |
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
---
|
||||||
|
title: Textual Inversion Embeddings and LoRAs
|
||||||
|
---
|
||||||
|
|
||||||
|
# :material-library-shelves: Textual Inversions and LoRAs
|
||||||
|
|
||||||
|
With the advances in research, many new capabilities are available to customize the knowledge and understanding of novel concepts not originally contained in the base model.
|
||||||
|
|
||||||
|
|
||||||
## Using Textual Inversion Files
|
## Using Textual Inversion Files
|
||||||
|
|
||||||
Textual inversion (TI) files are small models that customize the output of
|
Textual inversion (TI) files are small models that customize the output of
|
||||||
@ -19,9 +28,8 @@ by placing them in the designated directory for the compatible model type
|
|||||||
|
|
||||||
### An Example
|
### An Example
|
||||||
|
|
||||||
Here are a few examples to illustrate how it works. All these images
|
Here are a few examples to illustrate how it works. All these images were
|
||||||
were generated using the legacy command-line client and the Stable
|
generated using the command-line client and the Stable Diffusion 1.5 model:
|
||||||
Diffusion 1.5 model:
|
|
||||||
|
|
||||||
| Japanese gardener | Japanese gardener <ghibli-face> | Japanese gardener <hoi4-leaders> | Japanese gardener <cartoona-animals> |
|
| Japanese gardener | Japanese gardener <ghibli-face> | Japanese gardener <hoi4-leaders> | Japanese gardener <cartoona-animals> |
|
||||||
| :--------------------------------: | :-----------------------------------: | :------------------------------------: | :----------------------------------------: |
|
| :--------------------------------: | :-----------------------------------: | :------------------------------------: | :----------------------------------------: |
|
||||||
@ -52,4 +60,29 @@ files it finds there for compatible models. At startup you will see a message si
|
|||||||
>> Current embedding manager terms: <HOI4-Leader>, <princess-knight>
|
>> Current embedding manager terms: <HOI4-Leader>, <princess-knight>
|
||||||
```
|
```
|
||||||
To use these when generating, simply type the `<` key in your prompt to open the Textual Inversion WebUI and
|
To use these when generating, simply type the `<` key in your prompt to open the Textual Inversion WebUI and
|
||||||
select the embedding you'd like to use. This UI has type-ahead support, so you can easily find supported embeddings.
|
select the embedding you'd like to use. This UI has type-ahead support, so you can easily find supported embeddings.
|
||||||
|
|
||||||
|
## Using LoRAs
|
||||||
|
|
||||||
|
LoRA files are models that customize the output of Stable Diffusion
|
||||||
|
image generation. Larger than embeddings, but much smaller than full
|
||||||
|
models, they augment SD with improved understanding of subjects and
|
||||||
|
artistic styles.
|
||||||
|
|
||||||
|
Unlike TI files, LoRAs do not introduce novel vocabulary into the
|
||||||
|
model's known tokens. Instead, LoRAs augment the model's weights that
|
||||||
|
are applied to generate imagery. LoRAs may be supplied with a
|
||||||
|
"trigger" word that they have been explicitly trained on, or may
|
||||||
|
simply apply their effect without being triggered.
|
||||||
|
|
||||||
|
LoRAs are typically stored in .safetensors files, which are the most
|
||||||
|
secure way to store and transmit these types of weights. You may
|
||||||
|
install any number of `.safetensors` LoRA files simply by copying them
|
||||||
|
into the `autoimport/lora` directory of the corresponding InvokeAI models
|
||||||
|
directory (usually `invokeai` in your home directory).
|
||||||
|
|
||||||
|
To use these when generating, open the LoRA menu item in the options
|
||||||
|
panel, select the LoRAs you want to apply and ensure that they have
|
||||||
|
the appropriate weight recommended by the model provider. Typically,
|
||||||
|
most LoRAs perform best at a weight of .75-1.
|
||||||
|
|
@ -82,7 +82,7 @@ format of YAML files can be found
|
|||||||
[here](https://circleci.com/blog/what-is-yaml-a-beginner-s-guide/).
|
[here](https://circleci.com/blog/what-is-yaml-a-beginner-s-guide/).
|
||||||
|
|
||||||
You can fix a broken `invokeai.yaml` by deleting it and running the
|
You can fix a broken `invokeai.yaml` by deleting it and running the
|
||||||
configuration script again -- option [6] in the launcher, "Re-run the
|
configuration script again -- option [7] in the launcher, "Re-run the
|
||||||
configure script".
|
configure script".
|
||||||
|
|
||||||
#### Reading Environment Variables
|
#### Reading Environment Variables
|
||||||
@ -154,16 +154,14 @@ groups in `invokeia.yaml`:
|
|||||||
|
|
||||||
### Web Server
|
### Web Server
|
||||||
|
|
||||||
| Setting | Default Value | Description |
|
| Setting | Default Value | Description |
|
||||||
|---------------------|---------------|----------------------------------------------------------------------------------------------------------------------------|
|
|----------|----------------|--------------|
|
||||||
| `host` | `localhost` | Name or IP address of the network interface that the web server will listen on |
|
| `host` | `localhost` | Name or IP address of the network interface that the web server will listen on |
|
||||||
| `port` | `9090` | Network port number that the web server will listen on |
|
| `port` | `9090` | Network port number that the web server will listen on |
|
||||||
| `allow_origins` | `[]` | A list of host names or IP addresses that are allowed to connect to the InvokeAI API in the format `['host1','host2',...]` |
|
| `allow_origins` | `[]` | A list of host names or IP addresses that are allowed to connect to the InvokeAI API in the format `['host1','host2',...]` |
|
||||||
| `allow_credentials` | `true` | Require credentials for a foreign host to access the InvokeAI API (don't change this) |
|
| `allow_credentials` | `true` | Require credentials for a foreign host to access the InvokeAI API (don't change this) |
|
||||||
| `allow_methods` | `*` | List of HTTP methods ("GET", "POST") that the web server is allowed to use when accessing the API |
|
| `allow_methods` | `*` | List of HTTP methods ("GET", "POST") that the web server is allowed to use when accessing the API |
|
||||||
| `allow_headers` | `*` | List of HTTP headers that the web server will accept when accessing the API |
|
| `allow_headers` | `*` | List of HTTP headers that the web server will accept when accessing the API |
|
||||||
| `ssl_certfile` | null | Path to an SSL certificate file, used to enable HTTPS. |
|
|
||||||
| `ssl_keyfile` | null | Path to an SSL keyfile, if the key is not included in the certificate file. |
|
|
||||||
|
|
||||||
The documentation for InvokeAI's API can be accessed by browsing to the following URL: [http://localhost:9090/docs].
|
The documentation for InvokeAI's API can be accessed by browsing to the following URL: [http://localhost:9090/docs].
|
||||||
|
|
||||||
|
@ -17,6 +17,9 @@ image generation, providing you with a way to direct the network
|
|||||||
towards generating images that better fit your desired style or
|
towards generating images that better fit your desired style or
|
||||||
outcome.
|
outcome.
|
||||||
|
|
||||||
|
|
||||||
|
#### How it works
|
||||||
|
|
||||||
ControlNet works by analyzing an input image, pre-processing that
|
ControlNet works by analyzing an input image, pre-processing that
|
||||||
image to identify relevant information that can be interpreted by each
|
image to identify relevant information that can be interpreted by each
|
||||||
specific ControlNet model, and then inserting that control information
|
specific ControlNet model, and then inserting that control information
|
||||||
@ -24,21 +27,35 @@ into the generation process. This can be used to adjust the style,
|
|||||||
composition, or other aspects of the image to better achieve a
|
composition, or other aspects of the image to better achieve a
|
||||||
specific result.
|
specific result.
|
||||||
|
|
||||||
#### Installation
|
|
||||||
|
#### Models
|
||||||
|
|
||||||
InvokeAI provides access to a series of ControlNet models that provide
|
InvokeAI provides access to a series of ControlNet models that provide
|
||||||
different effects or styles in your generated images.
|
different effects or styles in your generated images. Currently
|
||||||
|
InvokeAI only supports "diffuser" style ControlNet models. These are
|
||||||
|
folders that contain the files `config.json` and/or
|
||||||
|
`diffusion_pytorch_model.safetensors` and
|
||||||
|
`diffusion_pytorch_model.fp16.safetensors`. The name of the folder is
|
||||||
|
the name of the model.
|
||||||
|
|
||||||
To install ControlNet Models:
|
***InvokeAI does not currently support checkpoint-format
|
||||||
|
ControlNets. These come in the form of a single file with the
|
||||||
|
extension `.safetensors`.***
|
||||||
|
|
||||||
1. The easiest way to install them is
|
Diffuser-style ControlNet models are available at HuggingFace
|
||||||
|
(http://huggingface.co) and accessed via their repo IDs (identifiers
|
||||||
|
in the format "author/modelname"). The easiest way to install them is
|
||||||
to use the InvokeAI model installer application. Use the
|
to use the InvokeAI model installer application. Use the
|
||||||
`invoke.sh`/`invoke.bat` launcher to select item [4] and then navigate
|
`invoke.sh`/`invoke.bat` launcher to select item [5] and then navigate
|
||||||
to the CONTROLNETS section. Select the models you wish to install and
|
to the CONTROLNETS section. Select the models you wish to install and
|
||||||
press "APPLY CHANGES". You may also enter additional HuggingFace
|
press "APPLY CHANGES". You may also enter additional HuggingFace
|
||||||
repo_ids in the "Additional models" textbox.
|
repo_ids in the "Additional models" textbox:
|
||||||
2. Using the "Add Model" function of the model manager, enter the HuggingFace Repo ID of the ControlNet. The ID is in the format "author/repoName"
|
|
||||||
|
|
||||||
|
{:width="640px"}
|
||||||
|
|
||||||
|
Command-line users can launch the model installer using the command
|
||||||
|
`invokeai-model-install`.
|
||||||
|
|
||||||
_Be aware that some ControlNet models require additional code
|
_Be aware that some ControlNet models require additional code
|
||||||
functionality in order to work properly, so just installing a
|
functionality in order to work properly, so just installing a
|
||||||
@ -46,17 +63,6 @@ third-party ControlNet model may not have the desired effect._ Please
|
|||||||
read and follow the documentation for installing a third party model
|
read and follow the documentation for installing a third party model
|
||||||
not currently included among InvokeAI's default list.
|
not currently included among InvokeAI's default list.
|
||||||
|
|
||||||
Currently InvokeAI **only** supports 🤗 Diffusers-format ControlNet models. These are
|
|
||||||
folders that contain the files `config.json` and/or
|
|
||||||
`diffusion_pytorch_model.safetensors` and
|
|
||||||
`diffusion_pytorch_model.fp16.safetensors`. The name of the folder is
|
|
||||||
the name of the model.
|
|
||||||
|
|
||||||
🤗 Diffusers-format ControlNet models are available at HuggingFace
|
|
||||||
(http://huggingface.co) and accessed via their repo IDs (identifiers
|
|
||||||
in the format "author/modelname").
|
|
||||||
|
|
||||||
#### ControlNet Models
|
|
||||||
The models currently supported include:
|
The models currently supported include:
|
||||||
|
|
||||||
**Canny**:
|
**Canny**:
|
||||||
@ -127,29 +133,6 @@ Start/End - 0 represents the start of the generation, 1 represents the end. The
|
|||||||
|
|
||||||
Additionally, each ControlNet section can be expanded in order to manipulate settings for the image pre-processor that adjusts your uploaded image before using it in when you Invoke.
|
Additionally, each ControlNet section can be expanded in order to manipulate settings for the image pre-processor that adjusts your uploaded image before using it in when you Invoke.
|
||||||
|
|
||||||
## T2I-Adapter
|
|
||||||
[T2I-Adapter](https://github.com/TencentARC/T2I-Adapter) is a tool similar to ControlNet that allows for control over the generation process by providing control information during the generation process. T2I-Adapter models tend to be smaller and more efficient than ControlNets.
|
|
||||||
|
|
||||||
##### Installation
|
|
||||||
To install T2I-Adapter Models:
|
|
||||||
|
|
||||||
1. The easiest way to install models is
|
|
||||||
to use the InvokeAI model installer application. Use the
|
|
||||||
`invoke.sh`/`invoke.bat` launcher to select item [5] and then navigate
|
|
||||||
to the T2I-Adapters section. Select the models you wish to install and
|
|
||||||
press "APPLY CHANGES". You may also enter additional HuggingFace
|
|
||||||
repo_ids in the "Additional models" textbox.
|
|
||||||
2. Using the "Add Model" function of the model manager, enter the HuggingFace Repo ID of the T2I-Adapter. The ID is in the format "author/repoName"
|
|
||||||
|
|
||||||
#### Usage
|
|
||||||
Each T2I Adapter has two settings that are applied.
|
|
||||||
|
|
||||||
Weight - Strength of the model applied to the generation for the section, defined by start/end.
|
|
||||||
|
|
||||||
Start/End - 0 represents the start of the generation, 1 represents the end. The Start/end setting controls what steps during the generation process have the ControlNet applied.
|
|
||||||
|
|
||||||
Additionally, each section can be expanded with the "Show Advanced" button in order to manipulate settings for the image pre-processor that adjusts your uploaded image before using it in during the generation process.
|
|
||||||
|
|
||||||
|
|
||||||
## IP-Adapter
|
## IP-Adapter
|
||||||
|
|
||||||
@ -157,13 +140,13 @@ Additionally, each section can be expanded with the "Show Advanced" button in o
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
#### Installation
|
#### Installation
|
||||||
There are several ways to install IP-Adapter models with an existing InvokeAI installation:
|
There are several ways to install IP-Adapter models with an existing InvokeAI installation:
|
||||||
|
|
||||||
1. Through the command line interface launched from the invoke.sh / invoke.bat scripts, option [4] to download models.
|
1. Through the command line interface launched from the invoke.sh / invoke.bat scripts, option [5] to download models.
|
||||||
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.
|
2. Through the Model Manager UI with models from the *Tools* section of [www.models.invoke.ai](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.
|
||||||
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.
|
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.
|
||||||
|
|
||||||
#### Using IP-Adapter
|
#### Using IP-Adapter
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
---
|
|
||||||
title: LoRAs & LCM-LoRAs
|
|
||||||
---
|
|
||||||
|
|
||||||
# :material-library-shelves: LoRAs & LCM-LoRAs
|
|
||||||
|
|
||||||
With the advances in research, many new capabilities are available to customize the knowledge and understanding of novel concepts not originally contained in the base model.
|
|
||||||
|
|
||||||
## LoRAs
|
|
||||||
|
|
||||||
Low-Rank Adaptation (LoRA) files are models that customize the output of Stable Diffusion
|
|
||||||
image generation. Larger than embeddings, but much smaller than full
|
|
||||||
models, they augment SD with improved understanding of subjects and
|
|
||||||
artistic styles.
|
|
||||||
|
|
||||||
Unlike TI files, LoRAs do not introduce novel vocabulary into the
|
|
||||||
model's known tokens. Instead, LoRAs augment the model's weights that
|
|
||||||
are applied to generate imagery. LoRAs may be supplied with a
|
|
||||||
"trigger" word that they have been explicitly trained on, or may
|
|
||||||
simply apply their effect without being triggered.
|
|
||||||
|
|
||||||
LoRAs are typically stored in .safetensors files, which are the most
|
|
||||||
secure way to store and transmit these types of weights. You may
|
|
||||||
install any number of `.safetensors` LoRA files simply by copying them
|
|
||||||
into the `autoimport/lora` directory of the corresponding InvokeAI models
|
|
||||||
directory (usually `invokeai` in your home directory).
|
|
||||||
|
|
||||||
To use these when generating, open the LoRA menu item in the options
|
|
||||||
panel, select the LoRAs you want to apply and ensure that they have
|
|
||||||
the appropriate weight recommended by the model provider. Typically,
|
|
||||||
most LoRAs perform best at a weight of .75-1.
|
|
||||||
|
|
||||||
|
|
||||||
## LCM-LoRAs
|
|
||||||
Latent Consistency Models (LCMs) allowed a reduced number of steps to be used to generate images with Stable Diffusion. These are created by distilling base models, creating models that only require a small number of steps to generate images. However, LCMs require that any fine-tune of a base model be distilled to be used as an LCM.
|
|
||||||
|
|
||||||
LCM-LoRAs are models that provide the benefit of LCMs but are able to be used as LoRAs and applied to any fine tune of a base model. LCM-LoRAs are created by training a small number of adapters, rather than distilling the entire fine-tuned base model. The resulting LoRA can be used the same way as a standard LoRA, but with a greatly reduced step count. This enables SDXL images to be generated up to 10x faster than without the use of LCM-LoRAs.
|
|
||||||
|
|
||||||
|
|
||||||
**Using LCM-LoRAs**
|
|
||||||
|
|
||||||
LCM-LoRAs are natively supported in InvokeAI throughout the application. To get started, install any diffusers format LCM-LoRAs using the model manager and select it in the LoRA field.
|
|
||||||
|
|
||||||
There are a number parameter differences when using LCM-LoRAs and standard generation:
|
|
||||||
|
|
||||||
- When using LCM-LoRAs, the LoRA strength should be lower than if using a standard LoRA, with 0.35 recommended as a starting point.
|
|
||||||
- The LCM scheduler should be used for generation
|
|
||||||
- CFG-Scale should be reduced to ~1
|
|
||||||
- Steps should be reduced in the range of 4-8
|
|
||||||
|
|
||||||
Standard LoRAs can also be used alongside LCM-LoRAs, but will also require a lower strength, with 0.45 being recommended as a starting point.
|
|
||||||
|
|
||||||
More information can be found here: https://huggingface.co/blog/lcm_lora#fast-inference-with-sdxl-lcm-loras
|
|
@ -16,10 +16,9 @@ Model Merging can be be done by navigating to the Model Manager and clicking the
|
|||||||
display all the diffusers-style models that InvokeAI knows about.
|
display all the diffusers-style models that InvokeAI knows about.
|
||||||
If you do not see the model you are looking for, then it is probably
|
If you do not see the model you are looking for, then it is probably
|
||||||
a legacy checkpoint model and needs to be converted using the
|
a legacy checkpoint model and needs to be converted using the
|
||||||
"Convert" option in the Web-based Model Manager tab.
|
`invoke` command-line client and its `!optimize` command. You
|
||||||
|
must select at least two models to merge. The third can be left at
|
||||||
You must select at least two models to merge. The third can be left
|
"None" if you desire.
|
||||||
at "None" if you desire.
|
|
||||||
|
|
||||||
* Alpha: This is the ratio to use when combining models. It ranges
|
* Alpha: This is the ratio to use when combining models. It ranges
|
||||||
from 0 to 1. The higher the value, the more weight is given to the
|
from 0 to 1. The higher the value, the more weight is given to the
|
||||||
|
@ -120,7 +120,7 @@ Generate an image with a given prompt, record the seed of the image, and then
|
|||||||
use the `prompt2prompt` syntax to substitute words in the original prompt for
|
use the `prompt2prompt` syntax to substitute words in the original prompt for
|
||||||
words in a new prompt. This works for `img2img` as well.
|
words in a new prompt. This works for `img2img` as well.
|
||||||
|
|
||||||
For example, consider the prompt `a cat.swap(dog) playing with a ball in the forest`. Normally, because the words interact with each other when doing a stable diffusion image generation, these two prompts would generate different compositions:
|
For example, consider the prompt `a cat.swap(dog) playing with a ball in the forest`. Normally, because of the word words interact with each other when doing a stable diffusion image generation, these two prompts would generate different compositions:
|
||||||
- `a cat playing with a ball in the forest`
|
- `a cat playing with a ball in the forest`
|
||||||
- `a dog playing with a ball in the forest`
|
- `a dog playing with a ball in the forest`
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ title: Command-line Utilities
|
|||||||
|
|
||||||
InvokeAI comes with several scripts that are accessible via the
|
InvokeAI comes with several scripts that are accessible via the
|
||||||
command line. To access these commands, start the "developer's
|
command line. To access these commands, start the "developer's
|
||||||
console" from the launcher (`invoke.bat` menu item [7]). Users who are
|
console" from the launcher (`invoke.bat` menu item [8]). Users who are
|
||||||
familiar with Python can alternatively activate InvokeAI's virtual
|
familiar with Python can alternatively activate InvokeAI's virtual
|
||||||
environment (typically, but not necessarily `invokeai/.venv`).
|
environment (typically, but not necessarily `invokeai/.venv`).
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ invokeai-web --ram 7
|
|||||||
|
|
||||||
## **invokeai-merge**
|
## **invokeai-merge**
|
||||||
|
|
||||||
This is the model merge script, the same as launcher option [3]. Call
|
This is the model merge script, the same as launcher option [4]. Call
|
||||||
it with the `--gui` command-line argument to start the interactive
|
it with the `--gui` command-line argument to start the interactive
|
||||||
console-based GUI. Alternatively, you can run it non-interactively
|
console-based GUI. Alternatively, you can run it non-interactively
|
||||||
using command-line arguments as illustrated in the example below which
|
using command-line arguments as illustrated in the example below which
|
||||||
@ -48,7 +48,7 @@ invokeai-merge --force --base-model sd-1 --models stable-diffusion-1.5 inkdiffus
|
|||||||
## **invokeai-ti**
|
## **invokeai-ti**
|
||||||
|
|
||||||
This is the textual inversion training script that is run by launcher
|
This is the textual inversion training script that is run by launcher
|
||||||
option [2]. Call it with `--gui` to run the interactive console-based
|
option [3]. Call it with `--gui` to run the interactive console-based
|
||||||
front end. It can also be run non-interactively. It has about a
|
front end. It can also be run non-interactively. It has about a
|
||||||
zillion arguments, but a typical training session can be launched
|
zillion arguments, but a typical training session can be launched
|
||||||
with:
|
with:
|
||||||
@ -68,7 +68,7 @@ in Windows).
|
|||||||
## **invokeai-install**
|
## **invokeai-install**
|
||||||
|
|
||||||
This is the console-based model install script that is run by launcher
|
This is the console-based model install script that is run by launcher
|
||||||
option [4]. If called without arguments, it will launch the
|
option [5]. If called without arguments, it will launch the
|
||||||
interactive console-based interface. It can also be used
|
interactive console-based interface. It can also be used
|
||||||
non-interactively to list, add and remove models as shown by these
|
non-interactively to list, add and remove models as shown by these
|
||||||
examples:
|
examples:
|
||||||
@ -148,7 +148,7 @@ launch the web server against it with `invokeai-web --root InvokeAI-New`.
|
|||||||
## **invokeai-update**
|
## **invokeai-update**
|
||||||
|
|
||||||
This is the interactive console-based script that is run by launcher
|
This is the interactive console-based script that is run by launcher
|
||||||
menu item [8] to update to a new version of InvokeAI. It takes no
|
menu item [9] to update to a new version of InvokeAI. It takes no
|
||||||
command-line arguments.
|
command-line arguments.
|
||||||
|
|
||||||
## **invokeai-metadata**
|
## **invokeai-metadata**
|
||||||
|
@ -126,6 +126,6 @@ amounts of image-to-image variation even when the seed is fixed and the
|
|||||||
`-v` argument is very low. Others are more deterministic. Feel free to
|
`-v` argument is very low. Others are more deterministic. Feel free to
|
||||||
experiment until you find the combination that you like.
|
experiment until you find the combination that you like.
|
||||||
|
|
||||||
Also be aware of the [Perlin Noise](../features/OTHER.md#thresholding-and-perlin-noise-initialization-options)
|
Also be aware of the [Perlin Noise](OTHER.md#thresholding-and-perlin-noise-initialization-options)
|
||||||
feature, which provides another way of introducing variability into your
|
feature, which provides another way of introducing variability into your
|
||||||
image generation requests.
|
image generation requests.
|
@ -20,7 +20,7 @@ a single convenient digital artist-optimized user interface.
|
|||||||
### * [Prompt Engineering](PROMPTS.md)
|
### * [Prompt Engineering](PROMPTS.md)
|
||||||
Get the images you want with the InvokeAI prompt engineering language.
|
Get the images you want with the InvokeAI prompt engineering language.
|
||||||
|
|
||||||
### * The [LoRA, LyCORIS, LCM-LoRA Models](CONCEPTS.md)
|
### * The [LoRA, LyCORIS and Textual Inversion Models](CONCEPTS.md)
|
||||||
Add custom subjects and styles using a variety of fine-tuned models.
|
Add custom subjects and styles using a variety of fine-tuned models.
|
||||||
|
|
||||||
### * [ControlNet](CONTROLNET.md)
|
### * [ControlNet](CONTROLNET.md)
|
||||||
@ -28,7 +28,7 @@ Learn how to install and use ControlNet models for fine control over
|
|||||||
image output.
|
image output.
|
||||||
|
|
||||||
### * [Image-to-Image Guide](IMG2IMG.md)
|
### * [Image-to-Image Guide](IMG2IMG.md)
|
||||||
Use a seed image to build new creations.
|
Use a seed image to build new creations in the CLI.
|
||||||
|
|
||||||
## Model Management
|
## Model Management
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ guide also covers optimizing models to load quickly.
|
|||||||
Teach an old model new tricks. Merge 2-3 models together to create a
|
Teach an old model new tricks. Merge 2-3 models together to create a
|
||||||
new model that combines characteristics of the originals.
|
new model that combines characteristics of the originals.
|
||||||
|
|
||||||
### * [Textual Inversion](TEXTUAL_INVERSIONS.md)
|
### * [Textual Inversion](TRAINING.md)
|
||||||
Personalize models by adding your own style or subjects.
|
Personalize models by adding your own style or subjects.
|
||||||
|
|
||||||
## Other Features
|
## Other Features
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
# FAQs
|
|
||||||
|
|
||||||
**Where do I get started? How can I install Invoke?**
|
|
||||||
|
|
||||||
- You can download the latest installers [here](https://github.com/invoke-ai/InvokeAI/releases) - Note that any releases marked as *pre-release* are in a beta state. You may experience some issues, but we appreciate your help testing those! For stable/reliable installations, please install the **[Latest Release](https://github.com/invoke-ai/InvokeAI/releases/latest)**
|
|
||||||
|
|
||||||
**How can I download models? Can I use models I already have downloaded?**
|
|
||||||
|
|
||||||
- Models can be downloaded through the model manager, or through option [4] in the invoke.bat/invoke.sh launcher script. To download a model through the Model Manager, use the HuggingFace Repo ID by pressing the “Copy” button next to the repository name. Alternatively, to download a model from CivitAi, use the download link in the Model Manager.
|
|
||||||
- Models that are already downloaded can be used by creating a symlink to the model location in the `autoimport` folder or by using the Model Manger’s “Scan for Models” function.
|
|
||||||
|
|
||||||
**My images are taking a long time to generate. How can I speed up generation?**
|
|
||||||
|
|
||||||
- A common solution is to reduce the size of your RAM & VRAM cache to 0.25. This ensures your system has enough memory to generate images.
|
|
||||||
- Additionally, check the [hardware requirements](https://invoke-ai.github.io/InvokeAI/#hardware-requirements) to ensure that your system is capable of generating images.
|
|
||||||
- Lastly, double check your generations are happening on your GPU (if you have one). InvokeAI will log what is being used for generation upon startup.
|
|
||||||
|
|
||||||
**I’ve installed Python on Windows but the installer says it can’t find it?**
|
|
||||||
|
|
||||||
- Then ensure that you checked **'Add python.exe to PATH'** when installing Python. This can be found at the bottom of the Python Installer window. If you already have Python installed, this can be done with the modify / repair feature of the installer.
|
|
||||||
|
|
||||||
**I’ve installed everything successfully but I still get an error about Triton when starting Invoke?**
|
|
||||||
|
|
||||||
- This can be safely ignored. InvokeAI doesn't use Triton, but if you are on Linux and wish to dismiss the error, you can install Triton.
|
|
||||||
|
|
||||||
**I updated to 3.4.0 and now xFormers can’t load C++/CUDA?**
|
|
||||||
|
|
||||||
- An issue occurred with your PyTorch update. Follow these steps to fix :
|
|
||||||
1. Launch your invoke.bat / invoke.sh and select the option to open the developer console
|
|
||||||
2. Run:`pip install ".[xformers]" --upgrade --force-reinstall --extra-index-url https://download.pytorch.org/whl/cu121`
|
|
||||||
- If you run into an error with `typing_extensions`, re-open the developer console and run: `pip install -U typing-extensions`
|
|
||||||
|
|
||||||
**It says my pip is out of date - is that why my install isn't working?**
|
|
||||||
- An out of date won't cause an installation to fail. The cause of the error can likely be found above the message that says pip is out of date.
|
|
||||||
- If you saw that warning but the install went well, don't worry about it (but you can update pip afterwards if you'd like).
|
|
||||||
|
|
||||||
**How can I generate the exact same that I found on the internet?**
|
|
||||||
Most example images with prompts that you'll find on the internet have been generated using different software, so you can't expect to get identical results. In order to reproduce an image, you need to replicate the exact settings and processing steps, including (but not limited to) the model, the positive and negative prompts, the seed, the sampler, the exact image size, any upscaling steps, etc.
|
|
||||||
|
|
||||||
|
|
||||||
**Where can I get more help?**
|
|
||||||
|
|
||||||
- Create an issue on [GitHub](https://github.com/invoke-ai/InvokeAI/issues) or post in the [#help channel](https://discord.com/channels/1020123559063990373/1149510134058471514) of the InvokeAI Discord
|
|
@ -57,9 +57,7 @@ Prompts provide the models directions on what to generate. As a general rule of
|
|||||||
|
|
||||||
Models are the magic that power InvokeAI. These files represent the output of training a machine on understanding massive amounts of images - providing them with the capability to generate new images using just a text description of what you’d like to see. (Like Stable Diffusion!)
|
Models are the magic that power InvokeAI. These files represent the output of training a machine on understanding massive amounts of images - providing them with the capability to generate new images using just a text description of what you’d like to see. (Like Stable Diffusion!)
|
||||||
|
|
||||||
Invoke offers a simple way to download several different models upon installation, but many more can be discovered online, including at https://models.invoke.ai
|
Invoke offers a simple way to download several different models upon installation, but many more can be discovered online, including at ****. Each model can produce a unique style of output, based on the images it was trained on - Try out different models to see which best fits your creative vision!
|
||||||
|
|
||||||
Each model can produce a unique style of output, based on the images it was trained on - Try out different models to see which best fits your creative vision!
|
|
||||||
|
|
||||||
- *Models that contain “inpainting” in the name are designed for use with the inpainting feature of the Unified Canvas*
|
- *Models that contain “inpainting” in the name are designed for use with the inpainting feature of the Unified Canvas*
|
||||||
|
|
||||||
|
@ -101,13 +101,16 @@ Mac and Linux machines, and runs on GPU cards with as little as 4 GB of RAM.
|
|||||||
|
|
||||||
<div align="center"><img src="assets/invoke-web-server-1.png" width=640></div>
|
<div align="center"><img src="assets/invoke-web-server-1.png" width=640></div>
|
||||||
|
|
||||||
|
!!! Note
|
||||||
|
|
||||||
|
This project is rapidly evolving. Please use the [Issues tab](https://github.com/invoke-ai/InvokeAI/issues) to report bugs and make feature requests. Be sure to use the provided templates as it will help aid response time.
|
||||||
|
|
||||||
## :octicons-link-24: Quick Links
|
## :octicons-link-24: Quick Links
|
||||||
|
|
||||||
<div class="button-container">
|
<div class="button-container">
|
||||||
<a href="installation/INSTALLATION"> <button class="button">Installation</button> </a>
|
<a href="installation/INSTALLATION"> <button class="button">Installation</button> </a>
|
||||||
<a href="features/"> <button class="button">Features</button> </a>
|
<a href="features/"> <button class="button">Features</button> </a>
|
||||||
<a href="help/gettingStartedWithAI/"> <button class="button">Getting Started</button> </a>
|
<a href="help/gettingStartedWithAI/"> <button class="button">Getting Started</button> </a>
|
||||||
<a href="help/FAQ/"> <button class="button">FAQ</button> </a>
|
|
||||||
<a href="contributing/CONTRIBUTING/"> <button class="button">Contributing</button> </a>
|
<a href="contributing/CONTRIBUTING/"> <button class="button">Contributing</button> </a>
|
||||||
<a href="https://github.com/invoke-ai/InvokeAI/"> <button class="button">Code and Downloads</button> </a>
|
<a href="https://github.com/invoke-ai/InvokeAI/"> <button class="button">Code and Downloads</button> </a>
|
||||||
<a href="https://github.com/invoke-ai/InvokeAI/issues"> <button class="button">Bug Reports </button> </a>
|
<a href="https://github.com/invoke-ai/InvokeAI/issues"> <button class="button">Bug Reports </button> </a>
|
||||||
@ -140,6 +143,7 @@ Mac and Linux machines, and runs on GPU cards with as little as 4 GB of RAM.
|
|||||||
<!-- seperator -->
|
<!-- seperator -->
|
||||||
### Prompt Engineering
|
### Prompt Engineering
|
||||||
- [Prompt Syntax](features/PROMPTS.md)
|
- [Prompt Syntax](features/PROMPTS.md)
|
||||||
|
- [Generating Variations](features/VARIATIONS.md)
|
||||||
|
|
||||||
### InvokeAI Configuration
|
### InvokeAI Configuration
|
||||||
- [Guide to InvokeAI Runtime Settings](features/CONFIGURATION.md)
|
- [Guide to InvokeAI Runtime Settings](features/CONFIGURATION.md)
|
||||||
@ -162,8 +166,10 @@ still a work in progress, but coming soon.
|
|||||||
|
|
||||||
### Command-Line Interface Retired
|
### Command-Line Interface Retired
|
||||||
|
|
||||||
All "invokeai" command-line interfaces have been retired as of version
|
The original "invokeai" command-line interface has been retired. The
|
||||||
3.4.
|
`invokeai` command will now launch a new command-line client that can
|
||||||
|
be used by developers to create and test nodes. It is not intended to
|
||||||
|
be used for routine image generation or manipulation.
|
||||||
|
|
||||||
To launch the Web GUI from the command-line, use the command
|
To launch the Web GUI from the command-line, use the command
|
||||||
`invokeai-web` rather than the traditional `invokeai --web`.
|
`invokeai-web` rather than the traditional `invokeai --web`.
|
||||||
@ -195,7 +201,6 @@ The list of schedulers has been completely revamped and brought up to date:
|
|||||||
| **dpmpp_2m** | DPMSolverMultistepScheduler | original noise scnedule |
|
| **dpmpp_2m** | DPMSolverMultistepScheduler | original noise scnedule |
|
||||||
| **dpmpp_2m_k** | DPMSolverMultistepScheduler | using karras noise schedule |
|
| **dpmpp_2m_k** | DPMSolverMultistepScheduler | using karras noise schedule |
|
||||||
| **unipc** | UniPCMultistepScheduler | CPU only |
|
| **unipc** | UniPCMultistepScheduler | CPU only |
|
||||||
| **lcm** | LCMScheduler | |
|
|
||||||
|
|
||||||
Please see [3.0.0 Release Notes](https://github.com/invoke-ai/InvokeAI/releases/tag/v3.0.0) for further details.
|
Please see [3.0.0 Release Notes](https://github.com/invoke-ai/InvokeAI/releases/tag/v3.0.0) for further details.
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ experimental versions later.
|
|||||||
this, open up a command-line window ("Terminal" on Linux and
|
this, open up a command-line window ("Terminal" on Linux and
|
||||||
Macintosh, "Command" or "Powershell" on Windows) and type `python
|
Macintosh, "Command" or "Powershell" on Windows) and type `python
|
||||||
--version`. If Python is installed, it will print out the version
|
--version`. If Python is installed, it will print out the version
|
||||||
number. If it is version `3.10.*` or `3.11.*` you meet
|
number. If it is version `3.9.*`, `3.10.*` or `3.11.*` you meet
|
||||||
requirements.
|
requirements.
|
||||||
|
|
||||||
!!! warning "What to do if you have an unsupported version"
|
!!! warning "What to do if you have an unsupported version"
|
||||||
@ -48,7 +48,7 @@ experimental versions later.
|
|||||||
Go to [Python Downloads](https://www.python.org/downloads/)
|
Go to [Python Downloads](https://www.python.org/downloads/)
|
||||||
and download the appropriate installer package for your
|
and download the appropriate installer package for your
|
||||||
platform. We recommend [Version
|
platform. We recommend [Version
|
||||||
3.10.12](https://www.python.org/downloads/release/python-3109/),
|
3.10.9](https://www.python.org/downloads/release/python-3109/),
|
||||||
which has been extensively tested with InvokeAI.
|
which has been extensively tested with InvokeAI.
|
||||||
|
|
||||||
_Please select your platform in the section below for platform-specific
|
_Please select your platform in the section below for platform-specific
|
||||||
@ -179,7 +179,7 @@ experimental versions later.
|
|||||||
you will have the choice of CUDA (NVidia cards), ROCm (AMD cards),
|
you will have the choice of CUDA (NVidia cards), ROCm (AMD cards),
|
||||||
or CPU (no graphics acceleration). On Windows, you'll have the
|
or CPU (no graphics acceleration). On Windows, you'll have the
|
||||||
choice of CUDA vs CPU, and on Macs you'll be offered CPU only. When
|
choice of CUDA vs CPU, and on Macs you'll be offered CPU only. When
|
||||||
you select CPU on M1/M2/M3 Macintoshes, you will get MPS-based
|
you select CPU on M1 or M2 Macintoshes, you will get MPS-based
|
||||||
graphics acceleration without installing additional drivers. If you
|
graphics acceleration without installing additional drivers. If you
|
||||||
are unsure what GPU you are using, you can ask the installer to
|
are unsure what GPU you are using, you can ask the installer to
|
||||||
guess.
|
guess.
|
||||||
@ -471,7 +471,7 @@ Then type the following commands:
|
|||||||
|
|
||||||
=== "NVIDIA System"
|
=== "NVIDIA System"
|
||||||
```bash
|
```bash
|
||||||
pip install torch torchvision --force-reinstall --extra-index-url https://download.pytorch.org/whl/cu121
|
pip install torch torchvision --force-reinstall --extra-index-url https://download.pytorch.org/whl/cu118
|
||||||
pip install xformers
|
pip install xformers
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ gaming):
|
|||||||
|
|
||||||
* **Python**
|
* **Python**
|
||||||
|
|
||||||
version 3.10 through 3.11
|
version 3.9 through 3.11
|
||||||
|
|
||||||
* **CUDA Tools**
|
* **CUDA Tools**
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ gaming):
|
|||||||
To install InvokeAI with virtual environments and the PIP package
|
To install InvokeAI with virtual environments and the PIP package
|
||||||
manager, please follow these steps:
|
manager, please follow these steps:
|
||||||
|
|
||||||
1. Please make sure you are using Python 3.10 through 3.11. The rest of the install
|
1. Please make sure you are using Python 3.9 through 3.11. The rest of the install
|
||||||
procedure depends on this and will not work with other versions:
|
procedure depends on this and will not work with other versions:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -148,7 +148,7 @@ manager, please follow these steps:
|
|||||||
=== "CUDA (NVidia)"
|
=== "CUDA (NVidia)"
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install "InvokeAI[xformers]" --use-pep517 --extra-index-url https://download.pytorch.org/whl/cu121
|
pip install "InvokeAI[xformers]" --use-pep517 --extra-index-url https://download.pytorch.org/whl/cu118
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "ROCm (AMD)"
|
=== "ROCm (AMD)"
|
||||||
@ -293,19 +293,6 @@ manager, please follow these steps:
|
|||||||
|
|
||||||
## Developer Install
|
## Developer Install
|
||||||
|
|
||||||
!!! warning
|
|
||||||
|
|
||||||
InvokeAI uses a SQLite database. By running on `main`, you accept responsibility for your database. This
|
|
||||||
means making regular backups (especially before pulling) and/or fixing it yourself in the event that a
|
|
||||||
PR introduces a schema change.
|
|
||||||
|
|
||||||
If you don't need persistent backend storage, you can use an ephemeral in-memory database by setting
|
|
||||||
`use_memory_db: true` under `Path:` in your `invokeai.yaml` file.
|
|
||||||
|
|
||||||
If this is untenable, you should run the application via the official installer or a manual install of the
|
|
||||||
python package from pypi. These releases will not break your database.
|
|
||||||
|
|
||||||
|
|
||||||
If you have an interest in how InvokeAI works, or you would like to
|
If you have an interest in how InvokeAI works, or you would like to
|
||||||
add features or bugfixes, you are encouraged to install the source
|
add features or bugfixes, you are encouraged to install the source
|
||||||
code for InvokeAI. For this to work, you will need to install the
|
code for InvokeAI. For this to work, you will need to install the
|
||||||
@ -340,7 +327,7 @@ installation protocol (important!)
|
|||||||
|
|
||||||
=== "CUDA (NVidia)"
|
=== "CUDA (NVidia)"
|
||||||
```bash
|
```bash
|
||||||
pip install -e .[xformers] --use-pep517 --extra-index-url https://download.pytorch.org/whl/cu121
|
pip install -e .[xformers] --use-pep517 --extra-index-url https://download.pytorch.org/whl/cu118
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "ROCm (AMD)"
|
=== "ROCm (AMD)"
|
||||||
@ -388,7 +375,7 @@ you can do so using this unsupported recipe:
|
|||||||
mkdir ~/invokeai
|
mkdir ~/invokeai
|
||||||
conda create -n invokeai python=3.10
|
conda create -n invokeai python=3.10
|
||||||
conda activate invokeai
|
conda activate invokeai
|
||||||
pip install InvokeAI[xformers] --use-pep517 --extra-index-url https://download.pytorch.org/whl/cu121
|
pip install InvokeAI[xformers] --use-pep517 --extra-index-url https://download.pytorch.org/whl/cu118
|
||||||
invokeai-configure --root ~/invokeai
|
invokeai-configure --root ~/invokeai
|
||||||
invokeai --root ~/invokeai --web
|
invokeai --root ~/invokeai --web
|
||||||
```
|
```
|
||||||
@ -401,5 +388,3 @@ environment variable INVOKEAI_ROOT to point to the installation directory.
|
|||||||
|
|
||||||
Note that if you run into problems with the Conda installation, the InvokeAI
|
Note that if you run into problems with the Conda installation, the InvokeAI
|
||||||
staff will **not** be able to help you out. Caveat Emptor!
|
staff will **not** be able to help you out. Caveat Emptor!
|
||||||
|
|
||||||
[dev-chat]: https://discord.com/channels/1020123559063990373/1049495067846524939
|
|
@ -85,7 +85,7 @@ You can find which version you should download from [this link](https://docs.nvi
|
|||||||
|
|
||||||
When installing torch and torchvision manually with `pip`, remember to provide
|
When installing torch and torchvision manually with `pip`, remember to provide
|
||||||
the argument `--extra-index-url
|
the argument `--extra-index-url
|
||||||
https://download.pytorch.org/whl/cu121` as described in the [Manual
|
https://download.pytorch.org/whl/cu118` as described in the [Manual
|
||||||
Installation Guide](020_INSTALL_MANUAL.md).
|
Installation Guide](020_INSTALL_MANUAL.md).
|
||||||
|
|
||||||
## :simple-amd: ROCm
|
## :simple-amd: ROCm
|
||||||
|
@ -4,49 +4,38 @@ title: Installing with Docker
|
|||||||
|
|
||||||
# :fontawesome-brands-docker: Docker
|
# :fontawesome-brands-docker: Docker
|
||||||
|
|
||||||
!!! warning "macOS and AMD GPU Users"
|
!!! warning "For most users"
|
||||||
|
|
||||||
We highly recommend to Install InvokeAI locally using [these instructions](INSTALLATION.md),
|
We highly recommend to Install InvokeAI locally using [these instructions](INSTALLATION.md)
|
||||||
because Docker containers can not access the GPU on macOS.
|
|
||||||
|
|
||||||
!!! warning "AMD GPU Users"
|
!!! tip "For developers"
|
||||||
|
|
||||||
Container support for AMD GPUs has been reported to work by the community, but has not received
|
For container-related development tasks or for enabling easy
|
||||||
extensive testing. Please make sure to set the `GPU_DRIVER=rocm` environment variable (see below), and
|
deployment to other environments (on-premises or cloud), follow these
|
||||||
use the `build.sh` script to build the image for this to take effect at build time.
|
instructions.
|
||||||
|
|
||||||
!!! tip "Linux and Windows Users"
|
For general use, install locally to leverage your machine's GPU.
|
||||||
|
|
||||||
For optimal performance, configure your Docker daemon to access your machine's GPU.
|
|
||||||
Docker Desktop on Windows [includes GPU support](https://www.docker.com/blog/wsl-2-gpu-support-for-docker-desktop-on-nvidia-gpus/).
|
|
||||||
Linux users should install and configure the [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html)
|
|
||||||
|
|
||||||
## Why containers?
|
## Why containers?
|
||||||
|
|
||||||
They provide a flexible, reliable way to build and deploy InvokeAI.
|
They provide a flexible, reliable way to build and deploy InvokeAI. You'll also
|
||||||
See [Processes](https://12factor.net/processes) under the Twelve-Factor App
|
use a Docker volume to store the largest model files and image outputs as a
|
||||||
methodology for details on why running applications in such a stateless fashion is important.
|
first step in decoupling storage and compute. Future enhancements can do this
|
||||||
|
for other assets. See [Processes](https://12factor.net/processes) under the
|
||||||
|
Twelve-Factor App methodology for details on why running applications in such a
|
||||||
|
stateless fashion is important.
|
||||||
|
|
||||||
The container is configured for CUDA by default, but can be built to support AMD GPUs
|
You can specify the target platform when building the image and running the
|
||||||
by setting the `GPU_DRIVER=rocm` environment variable at Docker image build time.
|
container. You'll also need to specify the InvokeAI requirements file that
|
||||||
|
matches the container's OS and the architecture it will run on.
|
||||||
|
|
||||||
Developers on Apple silicon (M1/M2/M3): You
|
Developers on Apple silicon (M1/M2): You
|
||||||
[can't access your GPU cores from Docker containers](https://github.com/pytorch/pytorch/issues/81224)
|
[can't access your GPU cores from Docker containers](https://github.com/pytorch/pytorch/issues/81224)
|
||||||
and performance is reduced compared with running it directly on macOS but for
|
and performance is reduced compared with running it directly on macOS but for
|
||||||
development purposes it's fine. Once you're done with development tasks on your
|
development purposes it's fine. Once you're done with development tasks on your
|
||||||
laptop you can build for the target platform and architecture and deploy to
|
laptop you can build for the target platform and architecture and deploy to
|
||||||
another environment with NVIDIA GPUs on-premises or in the cloud.
|
another environment with NVIDIA GPUs on-premises or in the cloud.
|
||||||
|
|
||||||
## TL;DR
|
|
||||||
|
|
||||||
This assumes properly configured Docker on Linux or Windows/WSL2. Read on for detailed customization options.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# docker compose commands should be run from the `docker` directory
|
|
||||||
cd docker
|
|
||||||
docker compose up
|
|
||||||
```
|
|
||||||
|
|
||||||
## Installation in a Linux container (desktop)
|
## Installation in a Linux container (desktop)
|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
@ -69,44 +58,222 @@ a token and copy it, since you will need in for the next step.
|
|||||||
|
|
||||||
### Setup
|
### Setup
|
||||||
|
|
||||||
Set up your environmnent variables. In the `docker` directory, make a copy of `env.sample` and name it `.env`. Make changes as necessary.
|
Set the fork you want to use and other variables.
|
||||||
|
|
||||||
Any environment variables supported by InvokeAI can be set here - please see the [CONFIGURATION](../features/CONFIGURATION.md) for further detail.
|
!!! tip
|
||||||
|
|
||||||
At a minimum, you might want to set the `INVOKEAI_ROOT` environment variable
|
I preffer to save my env vars
|
||||||
to point to the location where you wish to store your InvokeAI models, configuration, and outputs.
|
in the repository root in a `.env` (or `.envrc`) file to automatically re-apply
|
||||||
|
them when I come back.
|
||||||
|
|
||||||
|
The build- and run- scripts contain default values for almost everything,
|
||||||
|
besides the [Hugging Face Token](https://huggingface.co/settings/tokens) you
|
||||||
|
created in the last step.
|
||||||
|
|
||||||
|
Some Suggestions of variables you may want to change besides the Token:
|
||||||
|
|
||||||
<figure markdown>
|
<figure markdown>
|
||||||
|
|
||||||
| Environment-Variable <img width="220" align="right"/> | Default value <img width="360" align="right"/> | Description |
|
| Environment-Variable <img width="220" align="right"/> | Default value <img width="360" align="right"/> | Description |
|
||||||
| ----------------------------------------------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ----------------------------------------------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `INVOKEAI_ROOT` | `~/invokeai` | **Required** - the location of your InvokeAI root directory. It will be created if it does not exist.
|
| `HUGGING_FACE_HUB_TOKEN` | No default, but **required**! | This is the only **required** variable, without it you can't download the huggingface models |
|
||||||
| `HUGGING_FACE_HUB_TOKEN` | | InvokeAI will work without it, but some of the integrations with HuggingFace (like downloading from models from private repositories) may not work|
|
| `REPOSITORY_NAME` | The Basename of the Repo folder | This name will used as the container repository/image name |
|
||||||
| `GPU_DRIVER` | `cuda` | Optionally change this to `rocm` to build the image for AMD GPUs. NOTE: Use the `build.sh` script to build the image for this to take effect.
|
| `VOLUMENAME` | `${REPOSITORY_NAME,,}_data` | Name of the Docker Volume where model files will be stored |
|
||||||
|
| `ARCH` | arch of the build machine | Can be changed if you want to build the image for another arch |
|
||||||
|
| `CONTAINER_REGISTRY` | ghcr.io | Name of the Container Registry to use for the full tag |
|
||||||
|
| `CONTAINER_REPOSITORY` | `$(whoami)/${REPOSITORY_NAME}` | Name of the Container Repository |
|
||||||
|
| `CONTAINER_FLAVOR` | `cuda` | The flavor of the image to built, available options are `cuda`, `rocm` and `cpu`. If you choose `rocm` or `cpu`, the extra-index-url will be selected automatically, unless you set one yourself. |
|
||||||
|
| `CONTAINER_TAG` | `${INVOKEAI_BRANCH##*/}-${CONTAINER_FLAVOR}` | The Container Repository / Tag which will be used |
|
||||||
|
| `INVOKE_DOCKERFILE` | `Dockerfile` | The Dockerfile which should be built, handy for development |
|
||||||
|
| `PIP_EXTRA_INDEX_URL` | | If you want to use a custom pip-extra-index-url |
|
||||||
|
|
||||||
</figure>
|
</figure>
|
||||||
|
|
||||||
#### Build the Image
|
#### Build the Image
|
||||||
|
|
||||||
Use the standard `docker compose build` command from within the `docker` directory.
|
I provided a build script, which is located next to the Dockerfile in
|
||||||
|
`docker/build.sh`. It can be executed from repository root like this:
|
||||||
|
|
||||||
If using an AMD GPU:
|
```bash
|
||||||
a: set the `GPU_DRIVER=rocm` environment variable in `docker-compose.yml` and continue using `docker compose build` as usual, or
|
./docker/build.sh
|
||||||
b: set `GPU_DRIVER=rocm` in the `.env` file and use the `build.sh` script, provided for convenience
|
```
|
||||||
|
|
||||||
|
The build Script not only builds the container, but also creates the docker
|
||||||
|
volume if not existing yet.
|
||||||
|
|
||||||
#### Run the Container
|
#### Run the Container
|
||||||
|
|
||||||
Use the standard `docker compose up` command, and generally the `docker compose` [CLI](https://docs.docker.com/compose/reference/) as usual.
|
After the build process is done, you can run the container via the provided
|
||||||
|
`docker/run.sh` script
|
||||||
|
|
||||||
Once the container starts up (and configures the InvokeAI root directory if this is a new installation), you can access InvokeAI at [http://localhost:9090](http://localhost:9090)
|
```bash
|
||||||
|
./docker/run.sh
|
||||||
|
```
|
||||||
|
|
||||||
## Troubleshooting / FAQ
|
When used without arguments, the container will start the webserver and provide
|
||||||
|
you the link to open it. But if you want to use some other parameters you can
|
||||||
|
also do so.
|
||||||
|
|
||||||
- Q: I am running on Windows under WSL2, and am seeing a "no such file or directory" error.
|
!!! example "run script example"
|
||||||
- A: Your `docker-entrypoint.sh` file likely has Windows (CRLF) as opposed to Unix (LF) line endings,
|
|
||||||
and you may have cloned this repository before the issue was fixed. To solve this, please change
|
```bash
|
||||||
the line endings in the `docker-entrypoint.sh` file to `LF`. You can do this in VSCode
|
./docker/run.sh "banana sushi" -Ak_lms -S42 -s10
|
||||||
(`Ctrl+P` and search for "line endings"), or by using the `dos2unix` utility in WSL.
|
```
|
||||||
Finally, you may delete `docker-entrypoint.sh` followed by `git pull; git checkout docker/docker-entrypoint.sh`
|
|
||||||
to reset the file to its most recent version.
|
This would generate the legendary "banana sushi" with Seed 42, k_lms Sampler and 10 steps.
|
||||||
For more information on this issue, please see the [Docker Desktop documentation](https://docs.docker.com/desktop/troubleshoot/topics/#avoid-unexpected-syntax-errors-use-unix-style-line-endings-for-files-in-containers)
|
|
||||||
|
Find out more about available CLI-Parameters at [features/CLI.md](../../features/CLI/#arguments)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Running the container on your GPU
|
||||||
|
|
||||||
|
If you have an Nvidia GPU, you can enable InvokeAI to run on the GPU by running
|
||||||
|
the container with an extra environment variable to enable GPU usage and have
|
||||||
|
the process run much faster:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GPU_FLAGS=all ./docker/run.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
This passes the `--gpus all` to docker and uses the GPU.
|
||||||
|
|
||||||
|
If you don't have a GPU (or your host is not yet setup to use it) you will see a
|
||||||
|
message like this:
|
||||||
|
|
||||||
|
`docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].`
|
||||||
|
|
||||||
|
You can use the full set of GPU combinations documented here:
|
||||||
|
|
||||||
|
https://docs.docker.com/config/containers/resource_constraints/#gpu
|
||||||
|
|
||||||
|
For example, use `GPU_FLAGS=device=GPU-3a23c669-1f69-c64e-cf85-44e9b07e7a2a` to
|
||||||
|
choose a specific device identified by a UUID.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
!!! warning "Deprecated"
|
||||||
|
|
||||||
|
From here on you will find the the previous Docker-Docs, which will still
|
||||||
|
provide some usefull informations.
|
||||||
|
|
||||||
|
## Usage (time to have fun)
|
||||||
|
|
||||||
|
### Startup
|
||||||
|
|
||||||
|
If you're on a **Linux container** the `invoke` script is **automatically
|
||||||
|
started** and the output dir set to the Docker volume you created earlier.
|
||||||
|
|
||||||
|
If you're **directly on macOS follow these startup instructions**. With the
|
||||||
|
Conda environment activated (`conda activate ldm`), run the interactive
|
||||||
|
interface that combines the functionality of the original scripts `txt2img` and
|
||||||
|
`img2img`: Use the more accurate but VRAM-intensive full precision math because
|
||||||
|
half-precision requires autocast and won't work. By default the images are saved
|
||||||
|
in `outputs/img-samples/`.
|
||||||
|
|
||||||
|
```Shell
|
||||||
|
python3 scripts/invoke.py --full_precision
|
||||||
|
```
|
||||||
|
|
||||||
|
You'll get the script's prompt. You can see available options or quit.
|
||||||
|
|
||||||
|
```Shell
|
||||||
|
invoke> -h
|
||||||
|
invoke> q
|
||||||
|
```
|
||||||
|
|
||||||
|
### Text to Image
|
||||||
|
|
||||||
|
For quick (but bad) image results test with 5 steps (default 50) and 1 sample
|
||||||
|
image. This will let you know that everything is set up correctly. Then increase
|
||||||
|
steps to 100 or more for good (but slower) results. The prompt can be in quotes
|
||||||
|
or not.
|
||||||
|
|
||||||
|
```Shell
|
||||||
|
invoke> The hulk fighting with sheldon cooper -s5 -n1
|
||||||
|
invoke> "woman closeup highly detailed" -s 150
|
||||||
|
# Reuse previous seed and apply face restoration
|
||||||
|
invoke> "woman closeup highly detailed" --steps 150 --seed -1 -G 0.75
|
||||||
|
```
|
||||||
|
|
||||||
|
You'll need to experiment to see if face restoration is making it better or
|
||||||
|
worse for your specific prompt.
|
||||||
|
|
||||||
|
If you're on a container the output is set to the Docker volume. You can copy it
|
||||||
|
wherever you want. You can download it from the Docker Desktop app, Volumes,
|
||||||
|
my-vol, data. Or you can copy it from your Mac terminal. Keep in mind
|
||||||
|
`docker cp` can't expand `*.png` so you'll need to specify the image file name.
|
||||||
|
|
||||||
|
On your host Mac (you can use the name of any container that mounted the
|
||||||
|
volume):
|
||||||
|
|
||||||
|
```Shell
|
||||||
|
docker cp dummy:/data/000001.928403745.png /Users/<your-user>/Pictures
|
||||||
|
```
|
||||||
|
|
||||||
|
### Image to Image
|
||||||
|
|
||||||
|
You can also do text-guided image-to-image translation. For example, turning a
|
||||||
|
sketch into a detailed drawing.
|
||||||
|
|
||||||
|
`strength` is a value between 0.0 and 1.0 that controls the amount of noise that
|
||||||
|
is added to the input image. Values that approach 1.0 allow for lots of
|
||||||
|
variations but will also produce images that are not semantically consistent
|
||||||
|
with the input. 0.0 preserves image exactly, 1.0 replaces it completely.
|
||||||
|
|
||||||
|
Make sure your input image size dimensions are multiples of 64 e.g. 512x512.
|
||||||
|
Otherwise you'll get `Error: product of dimension sizes > 2**31'`. If you still
|
||||||
|
get the error
|
||||||
|
[try a different size](https://support.apple.com/guide/preview/resize-rotate-or-flip-an-image-prvw2015/mac#:~:text=image's%20file%20size-,In%20the%20Preview%20app%20on%20your%20Mac%2C%20open%20the%20file,is%20shown%20at%20the%20bottom.)
|
||||||
|
like 512x256.
|
||||||
|
|
||||||
|
If you're on a Docker container, copy your input image into the Docker volume
|
||||||
|
|
||||||
|
```Shell
|
||||||
|
docker cp /Users/<your-user>/Pictures/sketch-mountains-input.jpg dummy:/data/
|
||||||
|
```
|
||||||
|
|
||||||
|
Try it out generating an image (or more). The `invoke` script needs absolute
|
||||||
|
paths to find the image so don't use `~`.
|
||||||
|
|
||||||
|
If you're on your Mac
|
||||||
|
|
||||||
|
```Shell
|
||||||
|
invoke> "A fantasy landscape, trending on artstation" -I /Users/<your-user>/Pictures/sketch-mountains-input.jpg --strength 0.75 --steps 100 -n4
|
||||||
|
```
|
||||||
|
|
||||||
|
If you're on a Linux container on your Mac
|
||||||
|
|
||||||
|
```Shell
|
||||||
|
invoke> "A fantasy landscape, trending on artstation" -I /data/sketch-mountains-input.jpg --strength 0.75 --steps 50 -n1
|
||||||
|
```
|
||||||
|
|
||||||
|
### Web Interface
|
||||||
|
|
||||||
|
You can use the `invoke` script with a graphical web interface. Start the web
|
||||||
|
server with:
|
||||||
|
|
||||||
|
```Shell
|
||||||
|
python3 scripts/invoke.py --full_precision --web
|
||||||
|
```
|
||||||
|
|
||||||
|
If it's running on your Mac point your Mac web browser to
|
||||||
|
<http://127.0.0.1:9090>
|
||||||
|
|
||||||
|
Press Control-C at the command line to stop the web server.
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
|
||||||
|
Some text you can add at the end of the prompt to make it very pretty:
|
||||||
|
|
||||||
|
```Shell
|
||||||
|
cinematic photo, highly detailed, cinematic lighting, ultra-detailed, ultrarealistic, photorealism, Octane Rendering, cyberpunk lights, Hyper Detail, 8K, HD, Unreal Engine, V-Ray, full hd, cyberpunk, abstract, 3d octane render + 4k UHD + immense detail + dramatic lighting + well lit + black, purple, blue, pink, cerulean, teal, metallic colours, + fine details, ultra photoreal, photographic, concept art, cinematic composition, rule of thirds, mysterious, eerie, photorealism, breathtaking detailed, painting art deco pattern, by hsiao, ron cheng, john james audubon, bizarre compositions, exquisite detail, extremely moody lighting, painted by greg rutkowski makoto shinkai takashi takeuchi studio ghibli, akihiko yoshida
|
||||||
|
```
|
||||||
|
|
||||||
|
The original scripts should work as well.
|
||||||
|
|
||||||
|
```Shell
|
||||||
|
python3 scripts/orig_scripts/txt2img.py --help
|
||||||
|
python3 scripts/orig_scripts/txt2img.py --ddim_steps 100 --n_iter 1 --n_samples 1 --plms --prompt "new born baby kitten. Hyper Detail, Octane Rendering, Unreal Engine, V-Ray"
|
||||||
|
python3 scripts/orig_scripts/txt2img.py --ddim_steps 5 --n_iter 1 --n_samples 1 --plms --prompt "ocean" # or --klms
|
||||||
|
```
|
||||||
|
@ -84,7 +84,7 @@ InvokeAI root directory's `autoimport` folder.
|
|||||||
|
|
||||||
### Installation via `invokeai-model-install`
|
### Installation via `invokeai-model-install`
|
||||||
|
|
||||||
From the `invoke` launcher, choose option [4] "Download and install
|
From the `invoke` launcher, choose option [5] "Download and install
|
||||||
models." This will launch the same script that prompted you to select
|
models." This will launch the same script that prompted you to select
|
||||||
models at install time. You can use this to add models that you
|
models at install time. You can use this to add models that you
|
||||||
skipped the first time around. It is all right to specify a model that
|
skipped the first time around. It is all right to specify a model that
|
||||||
|
@ -59,7 +59,8 @@ Prior to installing PyPatchMatch, you need to take the following steps:
|
|||||||
`from patchmatch import patch_match`: It should look like the following:
|
`from patchmatch import patch_match`: It should look like the following:
|
||||||
|
|
||||||
```py
|
```py
|
||||||
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
|
Python 3.9.5 (default, Nov 23 2021, 15:27:38)
|
||||||
|
[GCC 9.3.0] on linux
|
||||||
Type "help", "copyright", "credits" or "license" for more information.
|
Type "help", "copyright", "credits" or "license" for more information.
|
||||||
>>> from patchmatch import patch_match
|
>>> from patchmatch import patch_match
|
||||||
Compiling and loading c extensions from "/home/lstein/Projects/InvokeAI/.invokeai-env/src/pypatchmatch/patchmatch".
|
Compiling and loading c extensions from "/home/lstein/Projects/InvokeAI/.invokeai-env/src/pypatchmatch/patchmatch".
|
||||||
|
@ -28,7 +28,7 @@ command line, then just be sure to activate it's virtual environment.
|
|||||||
Then run the following three commands:
|
Then run the following three commands:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pip install xformers~=0.0.22
|
pip install xformers~=0.0.19
|
||||||
pip install triton # WON'T WORK ON WINDOWS
|
pip install triton # WON'T WORK ON WINDOWS
|
||||||
python -m xformers.info output
|
python -m xformers.info output
|
||||||
```
|
```
|
||||||
@ -42,7 +42,7 @@ If all goes well, you'll see a report like the
|
|||||||
following:
|
following:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
xFormers 0.0.22
|
xFormers 0.0.20
|
||||||
memory_efficient_attention.cutlassF: available
|
memory_efficient_attention.cutlassF: available
|
||||||
memory_efficient_attention.cutlassB: available
|
memory_efficient_attention.cutlassB: available
|
||||||
memory_efficient_attention.flshattF: available
|
memory_efficient_attention.flshattF: available
|
||||||
@ -59,14 +59,14 @@ swiglu.gemm_fused_operand_sum: available
|
|||||||
swiglu.fused.p.cpp: available
|
swiglu.fused.p.cpp: available
|
||||||
is_triton_available: True
|
is_triton_available: True
|
||||||
is_functorch_available: False
|
is_functorch_available: False
|
||||||
pytorch.version: 2.1.0+cu121
|
pytorch.version: 2.0.1+cu118
|
||||||
pytorch.cuda: available
|
pytorch.cuda: available
|
||||||
gpu.compute_capability: 8.9
|
gpu.compute_capability: 8.9
|
||||||
gpu.name: NVIDIA GeForce RTX 4070
|
gpu.name: NVIDIA GeForce RTX 4070
|
||||||
build.info: available
|
build.info: available
|
||||||
build.cuda_version: 1108
|
build.cuda_version: 1108
|
||||||
build.python_version: 3.10.11
|
build.python_version: 3.10.11
|
||||||
build.torch_version: 2.1.0+cu121
|
build.torch_version: 2.0.1+cu118
|
||||||
build.env.TORCH_CUDA_ARCH_LIST: 5.0+PTX 6.0 6.1 7.0 7.5 8.0 8.6
|
build.env.TORCH_CUDA_ARCH_LIST: 5.0+PTX 6.0 6.1 7.0 7.5 8.0 8.6
|
||||||
build.env.XFORMERS_BUILD_TYPE: Release
|
build.env.XFORMERS_BUILD_TYPE: Release
|
||||||
build.env.XFORMERS_ENABLE_DEBUG_ASSERTIONS: None
|
build.env.XFORMERS_ENABLE_DEBUG_ASSERTIONS: None
|
||||||
@ -92,22 +92,33 @@ installed from source. These instructions were written for a system
|
|||||||
running Ubuntu 22.04, but other Linux distributions should be able to
|
running Ubuntu 22.04, but other Linux distributions should be able to
|
||||||
adapt this recipe.
|
adapt this recipe.
|
||||||
|
|
||||||
#### 1. Install CUDA Toolkit 12.1
|
#### 1. Install CUDA Toolkit 11.8
|
||||||
|
|
||||||
You will need the CUDA developer's toolkit in order to compile and
|
You will need the CUDA developer's toolkit in order to compile and
|
||||||
install xFormers. **Do not try to install Ubuntu's nvidia-cuda-toolkit
|
install xFormers. **Do not try to install Ubuntu's nvidia-cuda-toolkit
|
||||||
package.** It is out of date and will cause conflicts among the NVIDIA
|
package.** It is out of date and will cause conflicts among the NVIDIA
|
||||||
driver and binaries. Instead install the CUDA Toolkit package provided
|
driver and binaries. Instead install the CUDA Toolkit package provided
|
||||||
by NVIDIA itself. Go to [CUDA Toolkit 12.1
|
by NVIDIA itself. Go to [CUDA Toolkit 11.8
|
||||||
Downloads](https://developer.nvidia.com/cuda-12-1-0-download-archive)
|
Downloads](https://developer.nvidia.com/cuda-11-8-0-download-archive)
|
||||||
and use the target selection wizard to choose your platform and Linux
|
and use the target selection wizard to choose your platform and Linux
|
||||||
distribution. Select an installer type of "runfile (local)" at the
|
distribution. Select an installer type of "runfile (local)" at the
|
||||||
last step.
|
last step.
|
||||||
|
|
||||||
This will provide you with a recipe for downloading and running a
|
This will provide you with a recipe for downloading and running a
|
||||||
install shell script that will install the toolkit and drivers.
|
install shell script that will install the toolkit and drivers. For
|
||||||
|
example, the install script recipe for Ubuntu 22.04 running on a
|
||||||
|
x86_64 system is:
|
||||||
|
|
||||||
#### 2. Confirm/Install pyTorch 2.1.0 with CUDA 12.1 support
|
```
|
||||||
|
wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run
|
||||||
|
sudo sh cuda_11.8.0_520.61.05_linux.run
|
||||||
|
```
|
||||||
|
|
||||||
|
Rather than cut-and-paste this example, We recommend that you walk
|
||||||
|
through the toolkit wizard in order to get the most up to date
|
||||||
|
installer for your system.
|
||||||
|
|
||||||
|
#### 2. Confirm/Install pyTorch 2.01 with CUDA 11.8 support
|
||||||
|
|
||||||
If you are using InvokeAI 3.0.2 or higher, these will already be
|
If you are using InvokeAI 3.0.2 or higher, these will already be
|
||||||
installed. If not, you can check whether you have the needed libraries
|
installed. If not, you can check whether you have the needed libraries
|
||||||
@ -122,7 +133,7 @@ Then run the command:
|
|||||||
python -c 'exec("import torch\nprint(torch.__version__)")'
|
python -c 'exec("import torch\nprint(torch.__version__)")'
|
||||||
```
|
```
|
||||||
|
|
||||||
If it prints __2.1.0+cu121__ you're good. If not, you can install the
|
If it prints __1.13.1+cu118__ you're good. If not, you can install the
|
||||||
most up to date libraries with this command:
|
most up to date libraries with this command:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
@ -79,7 +79,7 @@ title: Manual Installation, Linux
|
|||||||
and obtaining an access token for downloading. It will then download and
|
and obtaining an access token for downloading. It will then download and
|
||||||
install the weights files for you.
|
install the weights files for you.
|
||||||
|
|
||||||
Please look [here](../020_INSTALL_MANUAL.md) for a manual process for doing
|
Please look [here](../INSTALL_MANUAL.md) for a manual process for doing
|
||||||
the same thing.
|
the same thing.
|
||||||
|
|
||||||
7. Start generating images!
|
7. Start generating images!
|
||||||
@ -112,7 +112,7 @@ title: Manual Installation, Linux
|
|||||||
To use an alternative model you may invoke the `!switch` command in
|
To use an alternative model you may invoke the `!switch` command in
|
||||||
the CLI, or pass `--model <model_name>` during `invoke.py` launch for
|
the CLI, or pass `--model <model_name>` during `invoke.py` launch for
|
||||||
either the CLI or the Web UI. See [Command Line
|
either the CLI or the Web UI. See [Command Line
|
||||||
Client](../../deprecated/CLI.md#model-selection-and-importation). The
|
Client](../../features/CLI.md#model-selection-and-importation). The
|
||||||
model names are defined in `configs/models.yaml`.
|
model names are defined in `configs/models.yaml`.
|
||||||
|
|
||||||
8. Subsequently, to relaunch the script, be sure to run "conda activate
|
8. Subsequently, to relaunch the script, be sure to run "conda activate
|
||||||
|
@ -150,7 +150,7 @@ will do our best to help.
|
|||||||
To use an alternative model you may invoke the `!switch` command in
|
To use an alternative model you may invoke the `!switch` command in
|
||||||
the CLI, or pass `--model <model_name>` during `invoke.py` launch for
|
the CLI, or pass `--model <model_name>` during `invoke.py` launch for
|
||||||
either the CLI or the Web UI. See [Command Line
|
either the CLI or the Web UI. See [Command Line
|
||||||
Client](../../deprecated/CLI.md#model-selection-and-importation). The
|
Client](../../features/CLI.md#model-selection-and-importation). The
|
||||||
model names are defined in `configs/models.yaml`.
|
model names are defined in `configs/models.yaml`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -128,7 +128,7 @@ python scripts/invoke.py --web --max_load_models=3 \
|
|||||||
```
|
```
|
||||||
|
|
||||||
These options are described in detail in the
|
These options are described in detail in the
|
||||||
[Command-Line Interface](../../deprecated/CLI.md) documentation.
|
[Command-Line Interface](../../features/CLI.md) documentation.
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ Note that you will need NVIDIA drivers, Python 3.10, and Git installed beforehan
|
|||||||
obtaining an access token for downloading. It will then download and install the
|
obtaining an access token for downloading. It will then download and install the
|
||||||
weights files for you.
|
weights files for you.
|
||||||
|
|
||||||
Please look [here](../020_INSTALL_MANUAL.md) for a manual process for doing the
|
Please look [here](../INSTALL_MANUAL.md) for a manual process for doing the
|
||||||
same thing.
|
same thing.
|
||||||
|
|
||||||
8. Start generating images!
|
8. Start generating images!
|
||||||
@ -108,7 +108,7 @@ Note that you will need NVIDIA drivers, Python 3.10, and Git installed beforehan
|
|||||||
To use an alternative model you may invoke the `!switch` command in
|
To use an alternative model you may invoke the `!switch` command in
|
||||||
the CLI, or pass `--model <model_name>` during `invoke.py` launch for
|
the CLI, or pass `--model <model_name>` during `invoke.py` launch for
|
||||||
either the CLI or the Web UI. See [Command Line
|
either the CLI or the Web UI. See [Command Line
|
||||||
Client](../../deprecated/CLI.md#model-selection-and-importation). The
|
Client](../../features/CLI.md#model-selection-and-importation). The
|
||||||
model names are defined in `configs/models.yaml`.
|
model names are defined in `configs/models.yaml`.
|
||||||
|
|
||||||
9. Subsequently, to relaunch the script, first activate the Anaconda
|
9. Subsequently, to relaunch the script, first activate the Anaconda
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
document.addEventListener("DOMContentLoaded", function () {
|
|
||||||
var script = document.createElement("script");
|
|
||||||
script.src = "https://widget.kapa.ai/kapa-widget.bundle.js";
|
|
||||||
script.setAttribute("data-website-id", "b5973bb1-476b-451e-8cf4-98de86745a10");
|
|
||||||
script.setAttribute("data-project-name", "Invoke.AI");
|
|
||||||
script.setAttribute("data-project-color", "#11213C");
|
|
||||||
script.setAttribute("data-project-logo", "https://avatars.githubusercontent.com/u/113954515?s=280&v=4");
|
|
||||||
script.async = true;
|
|
||||||
document.head.appendChild(script);
|
|
||||||
});
|
|
@ -4,21 +4,11 @@ These are nodes that have been developed by the community, for the community. If
|
|||||||
|
|
||||||
If you'd like to submit a node for the community, please refer to the [node creation overview](contributingNodes.md).
|
If you'd like to submit a node for the community, please refer to the [node creation overview](contributingNodes.md).
|
||||||
|
|
||||||
To use a node, add the node to the `nodes` folder found in your InvokeAI install location.
|
To download a node, simply download the `.py` node file from the link and add it to the `invokeai/app/invocations` folder in your Invoke AI install location. If you used the automated installation, this can be found inside the `.venv` folder. Along with the node, an example node graph should be provided to help you get started with the node.
|
||||||
|
|
||||||
The suggested method is to use `git clone` to clone the repository the node is found in. This allows for easy updates of the node in the future.
|
|
||||||
|
|
||||||
If you'd prefer, you can also just download the whole node folder from the linked repository and add it to the `nodes` folder.
|
|
||||||
|
|
||||||
To use a community workflow, download the the `.json` node graph file and load it into Invoke AI via the **Load Workflow** button in the Workflow Editor.
|
To use a community workflow, download the the `.json` node graph file and load it into Invoke AI via the **Load Workflow** button in the Workflow Editor.
|
||||||
|
|
||||||
- Community Nodes
|
- Community Nodes
|
||||||
+ [Adapters-Linked](#adapters-linked-nodes)
|
|
||||||
+ [Average Images](#average-images)
|
|
||||||
+ [Clean Image Artifacts After Cut](#clean-image-artifacts-after-cut)
|
|
||||||
+ [Close Color Mask](#close-color-mask)
|
|
||||||
+ [Clothing Mask](#clothing-mask)
|
|
||||||
+ [Contrast Limited Adaptive Histogram Equalization](#contrast-limited-adaptive-histogram-equalization)
|
|
||||||
+ [Depth Map from Wavefront OBJ](#depth-map-from-wavefront-obj)
|
+ [Depth Map from Wavefront OBJ](#depth-map-from-wavefront-obj)
|
||||||
+ [Film Grain](#film-grain)
|
+ [Film Grain](#film-grain)
|
||||||
+ [Generative Grammar-Based Prompt Nodes](#generative-grammar-based-prompt-nodes)
|
+ [Generative Grammar-Based Prompt Nodes](#generative-grammar-based-prompt-nodes)
|
||||||
@ -27,92 +17,22 @@ To use a community workflow, download the the `.json` node graph file and load i
|
|||||||
+ [Halftone](#halftone)
|
+ [Halftone](#halftone)
|
||||||
+ [Ideal Size](#ideal-size)
|
+ [Ideal Size](#ideal-size)
|
||||||
+ [Image and Mask Composition Pack](#image-and-mask-composition-pack)
|
+ [Image and Mask Composition Pack](#image-and-mask-composition-pack)
|
||||||
+ [Image Dominant Color](#image-dominant-color)
|
|
||||||
+ [Image to Character Art Image Nodes](#image-to-character-art-image-nodes)
|
+ [Image to Character Art Image Nodes](#image-to-character-art-image-nodes)
|
||||||
+ [Image Picker](#image-picker)
|
+ [Image Picker](#image-picker)
|
||||||
+ [Image Resize Plus](#image-resize-plus)
|
|
||||||
+ [Load Video Frame](#load-video-frame)
|
+ [Load Video Frame](#load-video-frame)
|
||||||
+ [Make 3D](#make-3d)
|
+ [Make 3D](#make-3d)
|
||||||
+ [Mask Operations](#mask-operations)
|
|
||||||
+ [Match Histogram](#match-histogram)
|
|
||||||
+ [Metadata-Linked](#metadata-linked-nodes)
|
|
||||||
+ [Negative Image](#negative-image)
|
|
||||||
+ [Oobabooga](#oobabooga)
|
+ [Oobabooga](#oobabooga)
|
||||||
+ [Prompt Tools](#prompt-tools)
|
+ [Prompt Tools](#prompt-tools)
|
||||||
+ [Remote Image](#remote-image)
|
|
||||||
+ [Remove Background](#remove-background)
|
|
||||||
+ [Retroize](#retroize)
|
+ [Retroize](#retroize)
|
||||||
+ [Size Stepper Nodes](#size-stepper-nodes)
|
+ [Size Stepper Nodes](#size-stepper-nodes)
|
||||||
+ [Simple Skin Detection](#simple-skin-detection)
|
|
||||||
+ [Text font to Image](#text-font-to-image)
|
+ [Text font to Image](#text-font-to-image)
|
||||||
+ [Thresholding](#thresholding)
|
+ [Thresholding](#thresholding)
|
||||||
+ [Unsharp Mask](#unsharp-mask)
|
|
||||||
+ [XY Image to Grid and Images to Grids nodes](#xy-image-to-grid-and-images-to-grids-nodes)
|
+ [XY Image to Grid and Images to Grids nodes](#xy-image-to-grid-and-images-to-grids-nodes)
|
||||||
- [Example Node Template](#example-node-template)
|
- [Example Node Template](#example-node-template)
|
||||||
- [Disclaimer](#disclaimer)
|
- [Disclaimer](#disclaimer)
|
||||||
- [Help](#help)
|
- [Help](#help)
|
||||||
|
|
||||||
|
|
||||||
--------------------------------
|
|
||||||
### Adapters Linked Nodes
|
|
||||||
|
|
||||||
**Description:** A set of nodes for linked adapters (ControlNet, IP-Adaptor & T2I-Adapter). This allows multiple adapters to be chained together without using a `collect` node which means it can be used inside an `iterate` node without any collecting on every iteration issues.
|
|
||||||
|
|
||||||
- `ControlNet-Linked` - Collects ControlNet info to pass to other nodes.
|
|
||||||
- `IP-Adapter-Linked` - Collects IP-Adapter info to pass to other nodes.
|
|
||||||
- `T2I-Adapter-Linked` - Collects T2I-Adapter info to pass to other nodes.
|
|
||||||
|
|
||||||
Note: These are inherited from the core nodes so any update to the core nodes should be reflected in these.
|
|
||||||
|
|
||||||
**Node Link:** https://github.com/skunkworxdark/adapters-linked-nodes
|
|
||||||
|
|
||||||
--------------------------------
|
|
||||||
### Average Images
|
|
||||||
|
|
||||||
**Description:** This node takes in a collection of images of the same size and averages them as output. It converts everything to RGB mode first.
|
|
||||||
|
|
||||||
**Node Link:** https://github.com/JPPhoto/average-images-node
|
|
||||||
|
|
||||||
--------------------------------
|
|
||||||
### Clean Image Artifacts After Cut
|
|
||||||
|
|
||||||
Description: Removes residual artifacts after an image is separated from its background.
|
|
||||||
|
|
||||||
Node Link: https://github.com/VeyDlin/clean-artifact-after-cut-node
|
|
||||||
|
|
||||||
View:
|
|
||||||
</br><img src="https://raw.githubusercontent.com/VeyDlin/clean-artifact-after-cut-node/master/.readme/node.png" width="500" />
|
|
||||||
|
|
||||||
--------------------------------
|
|
||||||
### Close Color Mask
|
|
||||||
|
|
||||||
Description: Generates a mask for images based on a closely matching color, useful for color-based selections.
|
|
||||||
|
|
||||||
Node Link: https://github.com/VeyDlin/close-color-mask-node
|
|
||||||
|
|
||||||
View:
|
|
||||||
</br><img src="https://raw.githubusercontent.com/VeyDlin/close-color-mask-node/master/.readme/node.png" width="500" />
|
|
||||||
|
|
||||||
--------------------------------
|
|
||||||
### Clothing Mask
|
|
||||||
|
|
||||||
Description: Employs a U2NET neural network trained for the segmentation of clothing items in images.
|
|
||||||
|
|
||||||
Node Link: https://github.com/VeyDlin/clothing-mask-node
|
|
||||||
|
|
||||||
View:
|
|
||||||
</br><img src="https://raw.githubusercontent.com/VeyDlin/clothing-mask-node/master/.readme/node.png" width="500" />
|
|
||||||
|
|
||||||
--------------------------------
|
|
||||||
### Contrast Limited Adaptive Histogram Equalization
|
|
||||||
|
|
||||||
Description: Enhances local image contrast using adaptive histogram equalization with contrast limiting.
|
|
||||||
|
|
||||||
Node Link: https://github.com/VeyDlin/clahe-node
|
|
||||||
|
|
||||||
View:
|
|
||||||
</br><img src="https://raw.githubusercontent.com/VeyDlin/clahe-node/master/.readme/node.png" width="500" />
|
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
### Depth Map from Wavefront OBJ
|
### Depth Map from Wavefront OBJ
|
||||||
|
|
||||||
@ -229,16 +149,6 @@ This includes 15 Nodes:
|
|||||||
|
|
||||||
</br><img src="https://raw.githubusercontent.com/dwringer/composition-nodes/main/composition_pack_overview.jpg" width="500" />
|
</br><img src="https://raw.githubusercontent.com/dwringer/composition-nodes/main/composition_pack_overview.jpg" width="500" />
|
||||||
|
|
||||||
--------------------------------
|
|
||||||
### Image Dominant Color
|
|
||||||
|
|
||||||
Description: Identifies and extracts the dominant color from an image using k-means clustering.
|
|
||||||
|
|
||||||
Node Link: https://github.com/VeyDlin/image-dominant-color-node
|
|
||||||
|
|
||||||
View:
|
|
||||||
</br><img src="https://raw.githubusercontent.com/VeyDlin/image-dominant-color-node/master/.readme/node.png" width="500" />
|
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
### Image to Character Art Image Nodes
|
### Image to Character Art Image Nodes
|
||||||
|
|
||||||
@ -260,17 +170,6 @@ View:
|
|||||||
|
|
||||||
**Node Link:** https://github.com/JPPhoto/image-picker-node
|
**Node Link:** https://github.com/JPPhoto/image-picker-node
|
||||||
|
|
||||||
--------------------------------
|
|
||||||
### Image Resize Plus
|
|
||||||
|
|
||||||
Description: Provides various image resizing options such as fill, stretch, fit, center, and crop.
|
|
||||||
|
|
||||||
Node Link: https://github.com/VeyDlin/image-resize-plus-node
|
|
||||||
|
|
||||||
View:
|
|
||||||
</br><img src="https://raw.githubusercontent.com/VeyDlin/image-resize-plus-node/master/.readme/node.png" width="500" />
|
|
||||||
|
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
### Load Video Frame
|
### Load Video Frame
|
||||||
|
|
||||||
@ -278,8 +177,12 @@ View:
|
|||||||
|
|
||||||
**Node Link:** https://github.com/helix4u/load_video_frame
|
**Node Link:** https://github.com/helix4u/load_video_frame
|
||||||
|
|
||||||
|
**Example Node Graph:** https://github.com/helix4u/load_video_frame/blob/main/Example_Workflow.json
|
||||||
|
|
||||||
**Output Example:**
|
**Output Example:**
|
||||||
<img src="https://raw.githubusercontent.com/helix4u/load_video_frame/main/_git_assets/testmp4_embed_converted.gif" width="500" />
|
|
||||||
|
<img src="https://github.com/helix4u/load_video_frame/blob/main/testmp4_embed_converted.gif" width="500" />
|
||||||
|
[Full mp4 of Example Output test.mp4](https://github.com/helix4u/load_video_frame/blob/main/test.mp4)
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
### Make 3D
|
### Make 3D
|
||||||
@ -295,57 +198,6 @@ View:
|
|||||||
<img src="https://gitlab.com/srcrr/shift3d/-/raw/main/example-1.png" width="300" />
|
<img src="https://gitlab.com/srcrr/shift3d/-/raw/main/example-1.png" width="300" />
|
||||||
<img src="https://gitlab.com/srcrr/shift3d/-/raw/main/example-2.png" width="300" />
|
<img src="https://gitlab.com/srcrr/shift3d/-/raw/main/example-2.png" width="300" />
|
||||||
|
|
||||||
--------------------------------
|
|
||||||
### Mask Operations
|
|
||||||
|
|
||||||
Description: Offers logical operations (OR, SUB, AND) for combining and manipulating image masks.
|
|
||||||
|
|
||||||
Node Link: https://github.com/VeyDlin/mask-operations-node
|
|
||||||
|
|
||||||
View:
|
|
||||||
</br><img src="https://raw.githubusercontent.com/VeyDlin/mask-operations-node/master/.readme/node.png" width="500" />
|
|
||||||
|
|
||||||
--------------------------------
|
|
||||||
### Match Histogram
|
|
||||||
|
|
||||||
**Description:** An InvokeAI node to match a histogram from one image to another. This is a bit like the `color correct` node in the main InvokeAI but this works in the YCbCr colourspace and can handle images of different sizes. Also does not require a mask input.
|
|
||||||
- Option to only transfer luminance channel.
|
|
||||||
- Option to save output as grayscale
|
|
||||||
|
|
||||||
A good use case for this node is to normalize the colors of an image that has been through the tiled scaling workflow of my XYGrid Nodes.
|
|
||||||
|
|
||||||
See full docs here: https://github.com/skunkworxdark/Prompt-tools-nodes/edit/main/README.md
|
|
||||||
|
|
||||||
**Node Link:** https://github.com/skunkworxdark/match_histogram
|
|
||||||
|
|
||||||
**Output Examples**
|
|
||||||
|
|
||||||
<img src="https://github.com/skunkworxdark/match_histogram/assets/21961335/ed12f329-a0ef-444a-9bae-129ed60d6097" width="300" />
|
|
||||||
|
|
||||||
--------------------------------
|
|
||||||
### Metadata Linked Nodes
|
|
||||||
|
|
||||||
**Description:** A set of nodes for Metadata. Collect Metadata from within an `iterate` node & extract metadata from an image.
|
|
||||||
|
|
||||||
- `Metadata Item Linked` - Allows collecting of metadata while within an iterate node with no need for a collect node or conversion to metadata node.
|
|
||||||
- `Metadata From Image` - Provides Metadata from an image.
|
|
||||||
- `Metadata To String` - Extracts a String value of a label from metadata.
|
|
||||||
- `Metadata To Integer` - Extracts an Integer value of a label from metadata.
|
|
||||||
- `Metadata To Float` - Extracts a Float value of a label from metadata.
|
|
||||||
- `Metadata To Scheduler` - Extracts a Scheduler value of a label from metadata.
|
|
||||||
|
|
||||||
**Node Link:** https://github.com/skunkworxdark/metadata-linked-nodes
|
|
||||||
|
|
||||||
--------------------------------
|
|
||||||
### Negative Image
|
|
||||||
|
|
||||||
Description: Creates a negative version of an image, effective for visual effects and mask inversion.
|
|
||||||
|
|
||||||
Node Link: https://github.com/VeyDlin/negative-image-node
|
|
||||||
|
|
||||||
View:
|
|
||||||
</br><img src="https://raw.githubusercontent.com/VeyDlin/negative-image-node/master/.readme/node.png" width="500" />
|
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
### Oobabooga
|
### Oobabooga
|
||||||
|
|
||||||
@ -375,50 +227,22 @@ This node works best with SDXL models, especially as the style can be described
|
|||||||
--------------------------------
|
--------------------------------
|
||||||
### Prompt Tools
|
### Prompt Tools
|
||||||
|
|
||||||
**Description:** A set of InvokeAI nodes that add general prompt (string) manipulation tools. Designed to accompany the `Prompts From File` node and other prompt generation nodes.
|
**Description:** A set of InvokeAI nodes that add general prompt manipulation tools. These were written to accompany the PromptsFromFile node and other prompt generation nodes.
|
||||||
|
|
||||||
1. `Prompt To File` - saves a prompt or collection of prompts to a file. one per line. There is an append/overwrite option.
|
|
||||||
2. `PTFields Collect` - Converts image generation fields into a Json format string that can be passed to Prompt to file.
|
|
||||||
3. `PTFields Expand` - Takes Json string and converts it to individual generation parameters. This can be fed from the Prompts to file node.
|
|
||||||
4. `Prompt Strength` - Formats prompt with strength like the weighted format of compel
|
|
||||||
5. `Prompt Strength Combine` - Combines weighted prompts for .and()/.blend()
|
|
||||||
6. `CSV To Index String` - Gets a string from a CSV by index. Includes a Random index option
|
|
||||||
|
|
||||||
The following Nodes are now included in v3.2 of Invoke and are nolonger in this set of tools.<br>
|
|
||||||
- `Prompt Join` -> `String Join`
|
|
||||||
- `Prompt Join Three` -> `String Join Three`
|
|
||||||
- `Prompt Replace` -> `String Replace`
|
|
||||||
- `Prompt Split Neg` -> `String Split Neg`
|
|
||||||
|
|
||||||
|
1. PromptJoin - Joins to prompts into one.
|
||||||
|
2. PromptReplace - performs a search and replace on a prompt. With the option of using regex.
|
||||||
|
3. PromptSplitNeg - splits a prompt into positive and negative using the old V2 method of [] for negative.
|
||||||
|
4. PromptToFile - saves a prompt or collection of prompts to a file. one per line. There is an append/overwrite option.
|
||||||
|
5. PTFieldsCollect - Converts image generation fields into a Json format string that can be passed to Prompt to file.
|
||||||
|
6. PTFieldsExpand - Takes Json string and converts it to individual generation parameters This can be fed from the Prompts to file node.
|
||||||
|
7. PromptJoinThree - Joins 3 prompt together.
|
||||||
|
8. PromptStrength - This take a string and float and outputs another string in the format of (string)strength like the weighted format of compel.
|
||||||
|
9. PromptStrengthCombine - This takes a collection of prompt strength strings and outputs a string in the .and() or .blend() format that can be fed into a proper prompt node.
|
||||||
|
|
||||||
See full docs here: https://github.com/skunkworxdark/Prompt-tools-nodes/edit/main/README.md
|
See full docs here: https://github.com/skunkworxdark/Prompt-tools-nodes/edit/main/README.md
|
||||||
|
|
||||||
**Node Link:** https://github.com/skunkworxdark/Prompt-tools-nodes
|
**Node Link:** https://github.com/skunkworxdark/Prompt-tools-nodes
|
||||||
|
|
||||||
**Workflow Examples**
|
|
||||||
|
|
||||||
<img src="https://github.com/skunkworxdark/prompt-tools/blob/main/images/CSVToIndexStringNode.png" width="300" />
|
|
||||||
|
|
||||||
--------------------------------
|
|
||||||
### Remote Image
|
|
||||||
|
|
||||||
**Description:** This is a pack of nodes to interoperate with other services, be they public websites or bespoke local servers. The pack consists of these nodes:
|
|
||||||
|
|
||||||
- *Load Remote Image* - Lets you load remote images such as a realtime webcam image, an image of the day, or dynamically created images.
|
|
||||||
- *Post Image to Remote Server* - Lets you upload an image to a remote server using an HTTP POST request, eg for storage, display or further processing.
|
|
||||||
|
|
||||||
**Node Link:** https://github.com/fieldOfView/InvokeAI-remote_image
|
|
||||||
|
|
||||||
--------------------------------
|
|
||||||
### Remove Background
|
|
||||||
|
|
||||||
Description: An integration of the rembg package to remove backgrounds from images using multiple U2NET models.
|
|
||||||
|
|
||||||
Node Link: https://github.com/VeyDlin/remove-background-node
|
|
||||||
|
|
||||||
View:
|
|
||||||
</br><img src="https://raw.githubusercontent.com/VeyDlin/remove-background-node/master/.readme/node.png" width="500" />
|
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
### Retroize
|
### Retroize
|
||||||
|
|
||||||
@ -430,17 +254,6 @@ View:
|
|||||||
|
|
||||||
<img src="https://github.com/Ar7ific1al/InvokeAI_nodes_retroize/assets/2306586/de8b4fa6-324c-4c2d-b36c-297600c73974" width="500" />
|
<img src="https://github.com/Ar7ific1al/InvokeAI_nodes_retroize/assets/2306586/de8b4fa6-324c-4c2d-b36c-297600c73974" width="500" />
|
||||||
|
|
||||||
--------------------------------
|
|
||||||
### Simple Skin Detection
|
|
||||||
|
|
||||||
Description: Detects skin in images based on predefined color thresholds.
|
|
||||||
|
|
||||||
Node Link: https://github.com/VeyDlin/simple-skin-detection-node
|
|
||||||
|
|
||||||
View:
|
|
||||||
</br><img src="https://raw.githubusercontent.com/VeyDlin/simple-skin-detection-node/master/.readme/node.png" width="500" />
|
|
||||||
|
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
### Size Stepper Nodes
|
### Size Stepper Nodes
|
||||||
|
|
||||||
@ -495,46 +308,26 @@ Highlights/Midtones/Shadows (with LUT blur enabled):
|
|||||||
<img src="https://github.com/invoke-ai/InvokeAI/assets/34005131/0a440e43-697f-4d17-82ee-f287467df0a5" width="300" />
|
<img src="https://github.com/invoke-ai/InvokeAI/assets/34005131/0a440e43-697f-4d17-82ee-f287467df0a5" width="300" />
|
||||||
<img src="https://github.com/invoke-ai/InvokeAI/assets/34005131/0701fd0f-2ca7-4fe2-8613-2b52547bafce" width="300" />
|
<img src="https://github.com/invoke-ai/InvokeAI/assets/34005131/0701fd0f-2ca7-4fe2-8613-2b52547bafce" width="300" />
|
||||||
|
|
||||||
--------------------------------
|
|
||||||
### Unsharp Mask
|
|
||||||
|
|
||||||
**Description:** Applies an unsharp mask filter to an image, preserving its alpha channel in the process.
|
|
||||||
|
|
||||||
**Node Link:** https://github.com/JPPhoto/unsharp-mask-node
|
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
### XY Image to Grid and Images to Grids nodes
|
### XY Image to Grid and Images to Grids nodes
|
||||||
|
|
||||||
**Description:** These nodes add the following to InvokeAI:
|
**Description:** Image to grid nodes and supporting tools.
|
||||||
- Generate grids of images from multiple input images
|
|
||||||
- Create XY grid images with labels from parameters
|
|
||||||
- Split images into overlapping tiles for processing (for super-resolution workflows)
|
|
||||||
- Recombine image tiles into a single output image blending the seams
|
|
||||||
|
|
||||||
The nodes include:
|
1. "Images To Grids" node - Takes a collection of images and creates a grid(s) of images. If there are more images than the size of a single grid then multiple grids will be created until it runs out of images.
|
||||||
1. `Images To Grids` - Combine multiple images into a grid of images
|
2. "XYImage To Grid" node - Converts a collection of XYImages into a labeled Grid of images. The XYImages collection has to be built using the supporting nodes. See example node setups for more details.
|
||||||
2. `XYImage To Grid` - Take X & Y params and creates a labeled image grid.
|
|
||||||
3. `XYImage Tiles` - Super-resolution (embiggen) style tiled resizing
|
|
||||||
4. `Image Tot XYImages` - Takes an image and cuts it up into a number of columns and rows.
|
|
||||||
5. Multiple supporting nodes - Helper nodes for data wrangling and building `XYImage` collections
|
|
||||||
|
|
||||||
See full docs here: https://github.com/skunkworxdark/XYGrid_nodes/edit/main/README.md
|
See full docs here: https://github.com/skunkworxdark/XYGrid_nodes/edit/main/README.md
|
||||||
|
|
||||||
**Node Link:** https://github.com/skunkworxdark/XYGrid_nodes
|
**Node Link:** https://github.com/skunkworxdark/XYGrid_nodes
|
||||||
|
|
||||||
**Output Examples**
|
|
||||||
|
|
||||||
<img src="https://github.com/skunkworxdark/XYGrid_nodes/blob/main/images/collage.png" width="300" />
|
|
||||||
|
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
### Example Node Template
|
### Example Node Template
|
||||||
|
|
||||||
**Description:** This node allows you to do super cool things with InvokeAI.
|
**Description:** This node allows you to do super cool things with InvokeAI.
|
||||||
|
|
||||||
**Node Link:** https://github.com/invoke-ai/InvokeAI/blob/main/invokeai/app/invocations/prompt.py
|
**Node Link:** https://github.com/invoke-ai/InvokeAI/fake_node.py
|
||||||
|
|
||||||
**Example Workflow:** https://github.com/invoke-ai/InvokeAI/blob/docs/main/docs/workflows/Prompt_from_File.json
|
**Example Node Graph:** https://github.com/invoke-ai/InvokeAI/fake_node_graph.json
|
||||||
|
|
||||||
**Output Examples**
|
**Output Examples**
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ To learn about the specifics of creating a new node, please visit our [Node crea
|
|||||||
|
|
||||||
Once you’ve created a node and confirmed that it behaves as expected locally, follow these steps:
|
Once you’ve created a node and confirmed that it behaves as expected locally, follow these steps:
|
||||||
|
|
||||||
- Make sure the node is contained in a new Python (.py) file. Preferably, the node is in a repo with a README detailing the nodes usage & examples to help others more easily use your node. Including the tag "invokeai-node" in your repository's README can also help other users find it more easily.
|
- Make sure the node is contained in a new Python (.py) file. Preferrably, the node is in a repo with a README detaling the nodes usage & examples to help others more easily use your node.
|
||||||
- Submit a pull request with a link to your node(s) repo in GitHub against the `main` branch to add the node to the [Community Nodes](communityNodes.md) list
|
- Submit a pull request with a link to your node(s) repo in GitHub against the `main` branch to add the node to the [Community Nodes](communityNodes.md) list
|
||||||
- Make sure you are following the template below and have provided all relevant details about the node and what it does. Example output images and workflows are very helpful for other users looking to use your node.
|
- Make sure you are following the template below and have provided all relevant details about the node and what it does. Example output images and workflows are very helpful for other users looking to use your node.
|
||||||
- A maintainer will review the pull request and node. If the node is aligned with the direction of the project, you may be asked for permission to include it in the core project.
|
- A maintainer will review the pull request and node. If the node is aligned with the direction of the project, you may be asked for permission to include it in the core project.
|
||||||
|
@ -1,106 +1,104 @@
|
|||||||
# List of Default Nodes
|
# List of Default Nodes
|
||||||
|
|
||||||
The table below contains a list of the default nodes shipped with InvokeAI and
|
The table below contains a list of the default nodes shipped with InvokeAI and their descriptions.
|
||||||
their descriptions.
|
|
||||||
|
|
||||||
| Node <img width=160 align="right"> | Function |
|
| Node <img width=160 align="right"> | Function |
|
||||||
| :------------------------------------------------------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|: ---------------------------------- | :--------------------------------------------------------------------------------------|
|
||||||
| Add Integers | Adds two numbers |
|
|Add Integers | Adds two numbers|
|
||||||
| Boolean Primitive Collection | A collection of boolean primitive values |
|
|Boolean Primitive Collection | A collection of boolean primitive values|
|
||||||
| Boolean Primitive | A boolean primitive value |
|
|Boolean Primitive | A boolean primitive value|
|
||||||
| Canny Processor | Canny edge detection for ControlNet |
|
|Canny Processor | Canny edge detection for ControlNet|
|
||||||
| CenterPadCrop | Pad or crop an image's sides from the center by specified pixels. Positive values are outside of the image. |
|
|CLIP Skip | Skip layers in clip text_encoder model.|
|
||||||
| CLIP Skip | Skip layers in clip text_encoder model. |
|
|Collect | Collects values into a collection|
|
||||||
| Collect | Collects values into a collection |
|
|Color Correct | Shifts the colors of a target image to match the reference image, optionally using a mask to only color-correct certain regions of the target image.|
|
||||||
| Color Correct | Shifts the colors of a target image to match the reference image, optionally using a mask to only color-correct certain regions of the target image. |
|
|Color Primitive | A color primitive value|
|
||||||
| Color Primitive | A color primitive value |
|
|Compel Prompt | Parse prompt using compel package to conditioning.|
|
||||||
| Compel Prompt | Parse prompt using compel package to conditioning. |
|
|Conditioning Primitive Collection | A collection of conditioning tensor primitive values|
|
||||||
| Conditioning Primitive Collection | A collection of conditioning tensor primitive values |
|
|Conditioning Primitive | A conditioning tensor primitive value|
|
||||||
| Conditioning Primitive | A conditioning tensor primitive value |
|
|Content Shuffle Processor | Applies content shuffle processing to image|
|
||||||
| Content Shuffle Processor | Applies content shuffle processing to image |
|
|ControlNet | Collects ControlNet info to pass to other nodes|
|
||||||
| ControlNet | Collects ControlNet info to pass to other nodes |
|
|Denoise Latents | Denoises noisy latents to decodable images|
|
||||||
| Denoise Latents | Denoises noisy latents to decodable images |
|
|Divide Integers | Divides two numbers|
|
||||||
| Divide Integers | Divides two numbers |
|
|Dynamic Prompt | Parses a prompt using adieyal/dynamicprompts' random or combinatorial generator|
|
||||||
| Dynamic Prompt | Parses a prompt using adieyal/dynamicprompts' random or combinatorial generator |
|
|[FaceMask](./detailedNodes/faceTools.md#facemask) | Generates masks for faces in an image to use with Inpainting|
|
||||||
| [FaceMask](./detailedNodes/faceTools.md#facemask) | Generates masks for faces in an image to use with Inpainting |
|
|[FaceIdentifier](./detailedNodes/faceTools.md#faceidentifier) | Identifies and labels faces in an image|
|
||||||
| [FaceIdentifier](./detailedNodes/faceTools.md#faceidentifier) | Identifies and labels faces in an image |
|
|[FaceOff](./detailedNodes/faceTools.md#faceoff) | Creates a new image that is a scaled bounding box with a mask on the face for Inpainting|
|
||||||
| [FaceOff](./detailedNodes/faceTools.md#faceoff) | Creates a new image that is a scaled bounding box with a mask on the face for Inpainting |
|
|Float Math | Perform basic math operations on two floats|
|
||||||
| Float Math | Perform basic math operations on two floats |
|
|Float Primitive Collection | A collection of float primitive values|
|
||||||
| Float Primitive Collection | A collection of float primitive values |
|
|Float Primitive | A float primitive value|
|
||||||
| Float Primitive | A float primitive value |
|
|Float Range | Creates a range|
|
||||||
| Float Range | Creates a range |
|
|HED (softedge) Processor | Applies HED edge detection to image|
|
||||||
| HED (softedge) Processor | Applies HED edge detection to image |
|
|Blur Image | Blurs an image|
|
||||||
| Blur Image | Blurs an image |
|
|Extract Image Channel | Gets a channel from an image.|
|
||||||
| Extract Image Channel | Gets a channel from an image. |
|
|Image Primitive Collection | A collection of image primitive values|
|
||||||
| Image Primitive Collection | A collection of image primitive values |
|
|Integer Math | Perform basic math operations on two integers|
|
||||||
| Integer Math | Perform basic math operations on two integers |
|
|Convert Image Mode | Converts an image to a different mode.|
|
||||||
| Convert Image Mode | Converts an image to a different mode. |
|
|Crop Image | Crops an image to a specified box. The box can be outside of the image.|
|
||||||
| Crop Image | Crops an image to a specified box. The box can be outside of the image. |
|
|Image Hue Adjustment | Adjusts the Hue of an image.|
|
||||||
| Image Hue Adjustment | Adjusts the Hue of an image. |
|
|Inverse Lerp Image | Inverse linear interpolation of all pixels of an image|
|
||||||
| Inverse Lerp Image | Inverse linear interpolation of all pixels of an image |
|
|Image Primitive | An image primitive value|
|
||||||
| Image Primitive | An image primitive value |
|
|Lerp Image | Linear interpolation of all pixels of an image|
|
||||||
| Lerp Image | Linear interpolation of all pixels of an image |
|
|Offset Image Channel | Add to or subtract from an image color channel by a uniform value.|
|
||||||
| Offset Image Channel | Add to or subtract from an image color channel by a uniform value. |
|
|Multiply Image Channel | Multiply or Invert an image color channel by a scalar value.|
|
||||||
| Multiply Image Channel | Multiply or Invert an image color channel by a scalar value. |
|
|Multiply Images | Multiplies two images together using `PIL.ImageChops.multiply()`.|
|
||||||
| Multiply Images | Multiplies two images together using `PIL.ImageChops.multiply()`. |
|
|Blur NSFW Image | Add blur to NSFW-flagged images|
|
||||||
| Blur NSFW Image | Add blur to NSFW-flagged images |
|
|Paste Image | Pastes an image into another image.|
|
||||||
| Paste Image | Pastes an image into another image. |
|
|ImageProcessor | Base class for invocations that preprocess images for ControlNet|
|
||||||
| ImageProcessor | Base class for invocations that preprocess images for ControlNet |
|
|Resize Image | Resizes an image to specific dimensions|
|
||||||
| Resize Image | Resizes an image to specific dimensions |
|
|Round Float | Rounds a float to a specified number of decimal places|
|
||||||
| Round Float | Rounds a float to a specified number of decimal places |
|
|Float to Integer | Converts a float to an integer. Optionally rounds to an even multiple of a input number.|
|
||||||
| Float to Integer | Converts a float to an integer. Optionally rounds to an even multiple of a input number. |
|
|Scale Image | Scales an image by a factor|
|
||||||
| Scale Image | Scales an image by a factor |
|
|Image to Latents | Encodes an image into latents.|
|
||||||
| Image to Latents | Encodes an image into latents. |
|
|Add Invisible Watermark | Add an invisible watermark to an image|
|
||||||
| Add Invisible Watermark | Add an invisible watermark to an image |
|
|Solid Color Infill | Infills transparent areas of an image with a solid color|
|
||||||
| Solid Color Infill | Infills transparent areas of an image with a solid color |
|
|PatchMatch Infill | Infills transparent areas of an image using the PatchMatch algorithm|
|
||||||
| PatchMatch Infill | Infills transparent areas of an image using the PatchMatch algorithm |
|
|Tile Infill | Infills transparent areas of an image with tiles of the image|
|
||||||
| Tile Infill | Infills transparent areas of an image with tiles of the image |
|
|Integer Primitive Collection | A collection of integer primitive values|
|
||||||
| Integer Primitive Collection | A collection of integer primitive values |
|
|Integer Primitive | An integer primitive value|
|
||||||
| Integer Primitive | An integer primitive value |
|
|Iterate | Iterates over a list of items|
|
||||||
| Iterate | Iterates over a list of items |
|
|Latents Primitive Collection | A collection of latents tensor primitive values|
|
||||||
| Latents Primitive Collection | A collection of latents tensor primitive values |
|
|Latents Primitive | A latents tensor primitive value|
|
||||||
| Latents Primitive | A latents tensor primitive value |
|
|Latents to Image | Generates an image from latents.|
|
||||||
| Latents to Image | Generates an image from latents. |
|
|Leres (Depth) Processor | Applies leres processing to image|
|
||||||
| Leres (Depth) Processor | Applies leres processing to image |
|
|Lineart Anime Processor | Applies line art anime processing to image|
|
||||||
| Lineart Anime Processor | Applies line art anime processing to image |
|
|Lineart Processor | Applies line art processing to image|
|
||||||
| Lineart Processor | Applies line art processing to image |
|
|LoRA Loader | Apply selected lora to unet and text_encoder.|
|
||||||
| LoRA Loader | Apply selected lora to unet and text_encoder. |
|
|Main Model Loader | Loads a main model, outputting its submodels.|
|
||||||
| Main Model Loader | Loads a main model, outputting its submodels. |
|
|Combine Mask | Combine two masks together by multiplying them using `PIL.ImageChops.multiply()`.|
|
||||||
| Combine Mask | Combine two masks together by multiplying them using `PIL.ImageChops.multiply()`. |
|
|Mask Edge | Applies an edge mask to an image|
|
||||||
| Mask Edge | Applies an edge mask to an image |
|
|Mask from Alpha | Extracts the alpha channel of an image as a mask.|
|
||||||
| Mask from Alpha | Extracts the alpha channel of an image as a mask. |
|
|Mediapipe Face Processor | Applies mediapipe face processing to image|
|
||||||
| Mediapipe Face Processor | Applies mediapipe face processing to image |
|
|Midas (Depth) Processor | Applies Midas depth processing to image|
|
||||||
| Midas (Depth) Processor | Applies Midas depth processing to image |
|
|MLSD Processor | Applies MLSD processing to image|
|
||||||
| MLSD Processor | Applies MLSD processing to image |
|
|Multiply Integers | Multiplies two numbers|
|
||||||
| Multiply Integers | Multiplies two numbers |
|
|Noise | Generates latent noise.|
|
||||||
| Noise | Generates latent noise. |
|
|Normal BAE Processor | Applies NormalBae processing to image|
|
||||||
| Normal BAE Processor | Applies NormalBae processing to image |
|
|ONNX Latents to Image | Generates an image from latents.|
|
||||||
| ONNX Latents to Image | Generates an image from latents. |
|
|ONNX Prompt (Raw) | A node to process inputs and produce outputs. May use dependency injection in __init__ to receive providers.|
|
||||||
| ONNX Prompt (Raw) | A node to process inputs and produce outputs. May use dependency injection in **init** to receive providers. |
|
|ONNX Text to Latents | Generates latents from conditionings.|
|
||||||
| ONNX Text to Latents | Generates latents from conditionings. |
|
|ONNX Model Loader | Loads a main model, outputting its submodels.|
|
||||||
| ONNX Model Loader | Loads a main model, outputting its submodels. |
|
|OpenCV Inpaint | Simple inpaint using opencv.|
|
||||||
| OpenCV Inpaint | Simple inpaint using opencv. |
|
|Openpose Processor | Applies Openpose processing to image|
|
||||||
| Openpose Processor | Applies Openpose processing to image |
|
|PIDI Processor | Applies PIDI processing to image|
|
||||||
| PIDI Processor | Applies PIDI processing to image |
|
|Prompts from File | Loads prompts from a text file|
|
||||||
| Prompts from File | Loads prompts from a text file |
|
|Random Integer | Outputs a single random integer.|
|
||||||
| Random Integer | Outputs a single random integer. |
|
|Random Range | Creates a collection of random numbers|
|
||||||
| Random Range | Creates a collection of random numbers |
|
|Integer Range | Creates a range of numbers from start to stop with step|
|
||||||
| Integer Range | Creates a range of numbers from start to stop with step |
|
|Integer Range of Size | Creates a range from start to start + size with step|
|
||||||
| Integer Range of Size | Creates a range from start to start + size with step |
|
|Resize Latents | Resizes latents to explicit width/height (in pixels). Provided dimensions are floor-divided by 8.|
|
||||||
| Resize Latents | Resizes latents to explicit width/height (in pixels). Provided dimensions are floor-divided by 8. |
|
|SDXL Compel Prompt | Parse prompt using compel package to conditioning.|
|
||||||
| SDXL Compel Prompt | Parse prompt using compel package to conditioning. |
|
|SDXL LoRA Loader | Apply selected lora to unet and text_encoder.|
|
||||||
| SDXL LoRA Loader | Apply selected lora to unet and text_encoder. |
|
|SDXL Main Model Loader | Loads an sdxl base model, outputting its submodels.|
|
||||||
| SDXL Main Model Loader | Loads an sdxl base model, outputting its submodels. |
|
|SDXL Refiner Compel Prompt | Parse prompt using compel package to conditioning.|
|
||||||
| SDXL Refiner Compel Prompt | Parse prompt using compel package to conditioning. |
|
|SDXL Refiner Model Loader | Loads an sdxl refiner model, outputting its submodels.|
|
||||||
| SDXL Refiner Model Loader | Loads an sdxl refiner model, outputting its submodels. |
|
|Scale Latents | Scales latents by a given factor.|
|
||||||
| Scale Latents | Scales latents by a given factor. |
|
|Segment Anything Processor | Applies segment anything processing to image|
|
||||||
| Segment Anything Processor | Applies segment anything processing to image |
|
|Show Image | Displays a provided image, and passes it forward in the pipeline.|
|
||||||
| Show Image | Displays a provided image, and passes it forward in the pipeline. |
|
|Step Param Easing | Experimental per-step parameter easing for denoising steps|
|
||||||
| Step Param Easing | Experimental per-step parameter easing for denoising steps |
|
|String Primitive Collection | A collection of string primitive values|
|
||||||
| String Primitive Collection | A collection of string primitive values |
|
|String Primitive | A string primitive value|
|
||||||
| String Primitive | A string primitive value |
|
|Subtract Integers | Subtracts two numbers|
|
||||||
| Subtract Integers | Subtracts two numbers |
|
|Tile Resample Processor | Tile resampler processor|
|
||||||
| Tile Resample Processor | Tile resampler processor |
|
|Upscale (RealESRGAN) | Upscales an image using RealESRGAN.|
|
||||||
| Upscale (RealESRGAN) | Upscales an image using RealESRGAN. |
|
|VAE Loader | Loads a VAE model, outputting a VaeLoaderOutput|
|
||||||
| VAE Loader | Loads a VAE model, outputting a VaeLoaderOutput |
|
|Zoe (Depth) Processor | Applies Zoe depth processing to image|
|
||||||
| Zoe (Depth) Processor | Applies Zoe depth processing to image |
|
|
@ -2,17 +2,13 @@
|
|||||||
|
|
||||||
We've curated some example workflows for you to get started with Workflows in InvokeAI
|
We've curated some example workflows for you to get started with Workflows in InvokeAI
|
||||||
|
|
||||||
To use them, right click on your desired workflow, follow the link to GitHub and click the "⬇" button to download the raw file. You can then use the "Load Workflow" functionality in InvokeAI to load the workflow and start generating images!
|
To use them, right click on your desired workflow, press "Download Linked File". You can then use the "Load Workflow" functionality in InvokeAI to load the workflow and start generating images!
|
||||||
|
|
||||||
If you're interested in finding more workflows, checkout the [#share-your-workflows](https://discord.com/channels/1020123559063990373/1130291608097661000) channel in the InvokeAI Discord.
|
If you're interested in finding more workflows, checkout the [#share-your-workflows](https://discord.com/channels/1020123559063990373/1130291608097661000) channel in the InvokeAI Discord.
|
||||||
|
|
||||||
* [SD1.5 / SD2 Text to Image](https://github.com/invoke-ai/InvokeAI/blob/main/docs/workflows/Text_to_Image.json)
|
* [SD1.5 / SD2 Text to Image](https://github.com/invoke-ai/InvokeAI/blob/main/docs/workflows/Text_to_Image.json)
|
||||||
* [SDXL Text to Image](https://github.com/invoke-ai/InvokeAI/blob/main/docs/workflows/SDXL_Text_to_Image.json)
|
* [SDXL Text to Image](https://github.com/invoke-ai/InvokeAI/blob/main/docs/workflows/SDXL_Text_to_Image.json)
|
||||||
* [SDXL Text to Image with Refiner](https://github.com/invoke-ai/InvokeAI/blob/main/docs/workflows/SDXL_w_Refiner_Text_to_Image.json)
|
* [SDXL (with Refiner) Text to Image](https://github.com/invoke-ai/InvokeAI/blob/main/docs/workflows/SDXL_Text_to_Image.json)
|
||||||
* [Multi ControlNet (Canny & Depth)](https://github.com/invoke-ai/InvokeAI/blob/main/docs/workflows/Multi_ControlNet_Canny_and_Depth.json)
|
* [Tiled Upscaling with ControlNet](https://github.com/invoke-ai/InvokeAI/blob/main/docs/workflows/ESRGAN_img2img_upscale w_Canny_ControlNet.json)
|
||||||
* [Tiled Upscaling with ControlNet](https://github.com/invoke-ai/InvokeAI/blob/main/docs/workflows/ESRGAN_img2img_upscale_w_Canny_ControlNet.json)
|
|
||||||
* [Prompt From File](https://github.com/invoke-ai/InvokeAI/blob/main/docs/workflows/Prompt_from_File.json)
|
|
||||||
* [Face Detailer with IP-Adapter & ControlNet](https://github.com/invoke-ai/InvokeAI/blob/main/docs/workflows/Face_Detailer_with_IP-Adapter_and_Canny.json)
|
|
||||||
* [FaceMask](https://github.com/invoke-ai/InvokeAI/blob/main/docs/workflows/FaceMask.json)
|
* [FaceMask](https://github.com/invoke-ai/InvokeAI/blob/main/docs/workflows/FaceMask.json)
|
||||||
* [FaceOff with 2x Face Scaling](https://github.com/invoke-ai/InvokeAI/blob/main/docs/workflows/FaceOff_FaceScale2x.json)
|
* [FaceOff with 2x Face Scaling](https://github.com/invoke-ai/InvokeAI/blob/main/docs/workflows/FaceOff_FaceScale2x.json)
|
||||||
* [QR Code Monster](https://github.com/invoke-ai/InvokeAI/blob/main/docs/workflows/QR_Code_Monster.json)
|
|
||||||
|
1010
docs/workflows/ESRGAN_img2img_upscale w_Canny_ControlNet.json
Normal file
1010
docs/workflows/ESRGAN_img2img_upscale w_Canny_ControlNet.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,975 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "Prompt from File",
|
|
||||||
"author": "InvokeAI",
|
|
||||||
"description": "Sample workflow using Prompt from File node",
|
|
||||||
"version": "0.1.0",
|
|
||||||
"contact": "invoke@invoke.ai",
|
|
||||||
"tags": "text2image, prompt from file, default",
|
|
||||||
"notes": "",
|
|
||||||
"exposedFields": [
|
|
||||||
{
|
|
||||||
"nodeId": "d6353b7f-b447-4e17-8f2e-80a88c91d426",
|
|
||||||
"fieldName": "model"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"nodeId": "1b7e0df8-8589-4915-a4ea-c0088f15d642",
|
|
||||||
"fieldName": "file_path"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"meta": {
|
|
||||||
"category": "default",
|
|
||||||
"version": "2.0.0"
|
|
||||||
},
|
|
||||||
"id": "d1609af5-eb0a-4f73-b573-c9af96a8d6bf",
|
|
||||||
"nodes": [
|
|
||||||
{
|
|
||||||
"id": "c2eaf1ba-5708-4679-9e15-945b8b432692",
|
|
||||||
"type": "invocation",
|
|
||||||
"data": {
|
|
||||||
"id": "c2eaf1ba-5708-4679-9e15-945b8b432692",
|
|
||||||
"type": "compel",
|
|
||||||
"label": "",
|
|
||||||
"isOpen": false,
|
|
||||||
"notes": "",
|
|
||||||
"isIntermediate": true,
|
|
||||||
"useCache": true,
|
|
||||||
"version": "1.0.0",
|
|
||||||
"nodePack": "invokeai",
|
|
||||||
"inputs": {
|
|
||||||
"prompt": {
|
|
||||||
"id": "dcdf3f6d-9b96-4bcd-9b8d-f992fefe4f62",
|
|
||||||
"name": "prompt",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "StringField"
|
|
||||||
},
|
|
||||||
"value": ""
|
|
||||||
},
|
|
||||||
"clip": {
|
|
||||||
"id": "3f1981c9-d8a9-42eb-a739-4f120eb80745",
|
|
||||||
"name": "clip",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "ClipField"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": {
|
|
||||||
"conditioning": {
|
|
||||||
"id": "46205e6c-c5e2-44cb-9c82-1cd20b95674a",
|
|
||||||
"name": "conditioning",
|
|
||||||
"fieldKind": "output",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "ConditioningField"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"width": 320,
|
|
||||||
"height": 32,
|
|
||||||
"position": {
|
|
||||||
"x": 925,
|
|
||||||
"y": -200
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "1b7e0df8-8589-4915-a4ea-c0088f15d642",
|
|
||||||
"type": "invocation",
|
|
||||||
"data": {
|
|
||||||
"id": "1b7e0df8-8589-4915-a4ea-c0088f15d642",
|
|
||||||
"type": "prompt_from_file",
|
|
||||||
"label": "Prompts from File",
|
|
||||||
"isOpen": true,
|
|
||||||
"notes": "",
|
|
||||||
"isIntermediate": true,
|
|
||||||
"useCache": true,
|
|
||||||
"version": "1.0.1",
|
|
||||||
"nodePack": "invokeai",
|
|
||||||
"inputs": {
|
|
||||||
"file_path": {
|
|
||||||
"id": "37e37684-4f30-4ec8-beae-b333e550f904",
|
|
||||||
"name": "file_path",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "Prompts File Path",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "StringField"
|
|
||||||
},
|
|
||||||
"value": ""
|
|
||||||
},
|
|
||||||
"pre_prompt": {
|
|
||||||
"id": "7de02feb-819a-4992-bad3-72a30920ddea",
|
|
||||||
"name": "pre_prompt",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "StringField"
|
|
||||||
},
|
|
||||||
"value": ""
|
|
||||||
},
|
|
||||||
"post_prompt": {
|
|
||||||
"id": "95f191d8-a282-428e-bd65-de8cb9b7513a",
|
|
||||||
"name": "post_prompt",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "StringField"
|
|
||||||
},
|
|
||||||
"value": ""
|
|
||||||
},
|
|
||||||
"start_line": {
|
|
||||||
"id": "efee9a48-05ab-4829-8429-becfa64a0782",
|
|
||||||
"name": "start_line",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "IntegerField"
|
|
||||||
},
|
|
||||||
"value": 1
|
|
||||||
},
|
|
||||||
"max_prompts": {
|
|
||||||
"id": "abebb428-3d3d-49fd-a482-4e96a16fff08",
|
|
||||||
"name": "max_prompts",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "IntegerField"
|
|
||||||
},
|
|
||||||
"value": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": {
|
|
||||||
"collection": {
|
|
||||||
"id": "77d5d7f1-9877-4ab1-9a8c-33e9ffa9abf3",
|
|
||||||
"name": "collection",
|
|
||||||
"fieldKind": "output",
|
|
||||||
"type": {
|
|
||||||
"isCollection": true,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "StringField"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"width": 320,
|
|
||||||
"height": 580,
|
|
||||||
"position": {
|
|
||||||
"x": 475,
|
|
||||||
"y": -400
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "1b89067c-3f6b-42c8-991f-e3055789b251",
|
|
||||||
"type": "invocation",
|
|
||||||
"data": {
|
|
||||||
"id": "1b89067c-3f6b-42c8-991f-e3055789b251",
|
|
||||||
"type": "iterate",
|
|
||||||
"label": "",
|
|
||||||
"isOpen": false,
|
|
||||||
"notes": "",
|
|
||||||
"isIntermediate": true,
|
|
||||||
"useCache": true,
|
|
||||||
"version": "1.1.0",
|
|
||||||
"inputs": {
|
|
||||||
"collection": {
|
|
||||||
"id": "4c564bf8-5ed6-441e-ad2c-dda265d5785f",
|
|
||||||
"name": "collection",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": true,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "CollectionField"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": {
|
|
||||||
"item": {
|
|
||||||
"id": "36340f9a-e7a5-4afa-b4b5-313f4e292380",
|
|
||||||
"name": "item",
|
|
||||||
"fieldKind": "output",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "CollectionItemField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"index": {
|
|
||||||
"id": "1beca95a-2159-460f-97ff-c8bab7d89336",
|
|
||||||
"name": "index",
|
|
||||||
"fieldKind": "output",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "IntegerField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"total": {
|
|
||||||
"id": "ead597b8-108e-4eda-88a8-5c29fa2f8df9",
|
|
||||||
"name": "total",
|
|
||||||
"fieldKind": "output",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "IntegerField"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"width": 320,
|
|
||||||
"height": 32,
|
|
||||||
"position": {
|
|
||||||
"x": 925,
|
|
||||||
"y": -400
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "d6353b7f-b447-4e17-8f2e-80a88c91d426",
|
|
||||||
"type": "invocation",
|
|
||||||
"data": {
|
|
||||||
"id": "d6353b7f-b447-4e17-8f2e-80a88c91d426",
|
|
||||||
"type": "main_model_loader",
|
|
||||||
"label": "",
|
|
||||||
"isOpen": true,
|
|
||||||
"notes": "",
|
|
||||||
"isIntermediate": true,
|
|
||||||
"useCache": true,
|
|
||||||
"version": "1.0.0",
|
|
||||||
"nodePack": "invokeai",
|
|
||||||
"inputs": {
|
|
||||||
"model": {
|
|
||||||
"id": "3f264259-3418-47d5-b90d-b6600e36ae46",
|
|
||||||
"name": "model",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "MainModelField"
|
|
||||||
},
|
|
||||||
"value": {
|
|
||||||
"model_name": "stable-diffusion-v1-5",
|
|
||||||
"base_model": "sd-1",
|
|
||||||
"model_type": "main"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": {
|
|
||||||
"unet": {
|
|
||||||
"id": "8e182ea2-9d0a-4c02-9407-27819288d4b5",
|
|
||||||
"name": "unet",
|
|
||||||
"fieldKind": "output",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "UNetField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"clip": {
|
|
||||||
"id": "d67d9d30-058c-46d5-bded-3d09d6d1aa39",
|
|
||||||
"name": "clip",
|
|
||||||
"fieldKind": "output",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "ClipField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"vae": {
|
|
||||||
"id": "89641601-0429-4448-98d5-190822d920d8",
|
|
||||||
"name": "vae",
|
|
||||||
"fieldKind": "output",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "VaeField"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"width": 320,
|
|
||||||
"height": 227,
|
|
||||||
"position": {
|
|
||||||
"x": 0,
|
|
||||||
"y": -375
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "fc9d0e35-a6de-4a19-84e1-c72497c823f6",
|
|
||||||
"type": "invocation",
|
|
||||||
"data": {
|
|
||||||
"id": "fc9d0e35-a6de-4a19-84e1-c72497c823f6",
|
|
||||||
"type": "compel",
|
|
||||||
"label": "",
|
|
||||||
"isOpen": false,
|
|
||||||
"notes": "",
|
|
||||||
"isIntermediate": true,
|
|
||||||
"useCache": true,
|
|
||||||
"version": "1.0.0",
|
|
||||||
"nodePack": "invokeai",
|
|
||||||
"inputs": {
|
|
||||||
"prompt": {
|
|
||||||
"id": "dcdf3f6d-9b96-4bcd-9b8d-f992fefe4f62",
|
|
||||||
"name": "prompt",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "StringField"
|
|
||||||
},
|
|
||||||
"value": ""
|
|
||||||
},
|
|
||||||
"clip": {
|
|
||||||
"id": "3f1981c9-d8a9-42eb-a739-4f120eb80745",
|
|
||||||
"name": "clip",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "ClipField"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": {
|
|
||||||
"conditioning": {
|
|
||||||
"id": "46205e6c-c5e2-44cb-9c82-1cd20b95674a",
|
|
||||||
"name": "conditioning",
|
|
||||||
"fieldKind": "output",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "ConditioningField"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"width": 320,
|
|
||||||
"height": 32,
|
|
||||||
"position": {
|
|
||||||
"x": 925,
|
|
||||||
"y": -275
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "0eb5f3f5-1b91-49eb-9ef0-41d67c7eae77",
|
|
||||||
"type": "invocation",
|
|
||||||
"data": {
|
|
||||||
"id": "0eb5f3f5-1b91-49eb-9ef0-41d67c7eae77",
|
|
||||||
"type": "noise",
|
|
||||||
"label": "",
|
|
||||||
"isOpen": false,
|
|
||||||
"notes": "",
|
|
||||||
"isIntermediate": true,
|
|
||||||
"useCache": true,
|
|
||||||
"version": "1.0.1",
|
|
||||||
"nodePack": "invokeai",
|
|
||||||
"inputs": {
|
|
||||||
"seed": {
|
|
||||||
"id": "b722d84a-eeee-484f-bef2-0250c027cb67",
|
|
||||||
"name": "seed",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "IntegerField"
|
|
||||||
},
|
|
||||||
"value": 0
|
|
||||||
},
|
|
||||||
"width": {
|
|
||||||
"id": "d5f8ce11-0502-4bfc-9a30-5757dddf1f94",
|
|
||||||
"name": "width",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "IntegerField"
|
|
||||||
},
|
|
||||||
"value": 512
|
|
||||||
},
|
|
||||||
"height": {
|
|
||||||
"id": "f187d5ff-38a5-4c3f-b780-fc5801ef34af",
|
|
||||||
"name": "height",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "IntegerField"
|
|
||||||
},
|
|
||||||
"value": 512
|
|
||||||
},
|
|
||||||
"use_cpu": {
|
|
||||||
"id": "12f112b8-8b76-4816-b79e-662edc9f9aa5",
|
|
||||||
"name": "use_cpu",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "BooleanField"
|
|
||||||
},
|
|
||||||
"value": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": {
|
|
||||||
"noise": {
|
|
||||||
"id": "08576ad1-96d9-42d2-96ef-6f5c1961933f",
|
|
||||||
"name": "noise",
|
|
||||||
"fieldKind": "output",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "LatentsField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"width": {
|
|
||||||
"id": "f3e1f94a-258d-41ff-9789-bd999bd9f40d",
|
|
||||||
"name": "width",
|
|
||||||
"fieldKind": "output",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "IntegerField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"height": {
|
|
||||||
"id": "6cefc357-4339-415e-a951-49b9c2be32f4",
|
|
||||||
"name": "height",
|
|
||||||
"fieldKind": "output",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "IntegerField"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"width": 320,
|
|
||||||
"height": 32,
|
|
||||||
"position": {
|
|
||||||
"x": 925,
|
|
||||||
"y": 25
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "dfc20e07-7aef-4fc0-a3a1-7bf68ec6a4e5",
|
|
||||||
"type": "invocation",
|
|
||||||
"data": {
|
|
||||||
"id": "dfc20e07-7aef-4fc0-a3a1-7bf68ec6a4e5",
|
|
||||||
"type": "rand_int",
|
|
||||||
"label": "",
|
|
||||||
"isOpen": false,
|
|
||||||
"notes": "",
|
|
||||||
"isIntermediate": true,
|
|
||||||
"useCache": false,
|
|
||||||
"version": "1.0.0",
|
|
||||||
"nodePack": "invokeai",
|
|
||||||
"inputs": {
|
|
||||||
"low": {
|
|
||||||
"id": "b9fc6cf1-469c-4037-9bf0-04836965826f",
|
|
||||||
"name": "low",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "IntegerField"
|
|
||||||
},
|
|
||||||
"value": 0
|
|
||||||
},
|
|
||||||
"high": {
|
|
||||||
"id": "06eac725-0f60-4ba2-b8cd-7ad9f757488c",
|
|
||||||
"name": "high",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "IntegerField"
|
|
||||||
},
|
|
||||||
"value": 2147483647
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": {
|
|
||||||
"value": {
|
|
||||||
"id": "df08c84e-7346-4e92-9042-9e5cb773aaff",
|
|
||||||
"name": "value",
|
|
||||||
"fieldKind": "output",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "IntegerField"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"width": 320,
|
|
||||||
"height": 32,
|
|
||||||
"position": {
|
|
||||||
"x": 925,
|
|
||||||
"y": -50
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "491ec988-3c77-4c37-af8a-39a0c4e7a2a1",
|
|
||||||
"type": "invocation",
|
|
||||||
"data": {
|
|
||||||
"id": "491ec988-3c77-4c37-af8a-39a0c4e7a2a1",
|
|
||||||
"type": "l2i",
|
|
||||||
"label": "",
|
|
||||||
"isOpen": true,
|
|
||||||
"notes": "",
|
|
||||||
"isIntermediate": true,
|
|
||||||
"useCache": true,
|
|
||||||
"version": "1.2.0",
|
|
||||||
"nodePack": "invokeai",
|
|
||||||
"inputs": {
|
|
||||||
"metadata": {
|
|
||||||
"id": "022e4b33-562b-438d-b7df-41c3fd931f40",
|
|
||||||
"name": "metadata",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "MetadataField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"latents": {
|
|
||||||
"id": "67cb6c77-a394-4a66-a6a9-a0a7dcca69ec",
|
|
||||||
"name": "latents",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "LatentsField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"vae": {
|
|
||||||
"id": "7b3fd9ad-a4ef-4e04-89fa-3832a9902dbd",
|
|
||||||
"name": "vae",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "VaeField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tiled": {
|
|
||||||
"id": "5ac5680d-3add-4115-8ec0-9ef5bb87493b",
|
|
||||||
"name": "tiled",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "BooleanField"
|
|
||||||
},
|
|
||||||
"value": false
|
|
||||||
},
|
|
||||||
"fp32": {
|
|
||||||
"id": "db8297f5-55f8-452f-98cf-6572c2582152",
|
|
||||||
"name": "fp32",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "BooleanField"
|
|
||||||
},
|
|
||||||
"value": false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": {
|
|
||||||
"image": {
|
|
||||||
"id": "d8778d0c-592a-4960-9280-4e77e00a7f33",
|
|
||||||
"name": "image",
|
|
||||||
"fieldKind": "output",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "ImageField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"width": {
|
|
||||||
"id": "c8b0a75a-f5de-4ff2-9227-f25bb2b97bec",
|
|
||||||
"name": "width",
|
|
||||||
"fieldKind": "output",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "IntegerField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"height": {
|
|
||||||
"id": "83c05fbf-76b9-49ab-93c4-fa4b10e793e4",
|
|
||||||
"name": "height",
|
|
||||||
"fieldKind": "output",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "IntegerField"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"width": 320,
|
|
||||||
"height": 267,
|
|
||||||
"position": {
|
|
||||||
"x": 2037.861329274915,
|
|
||||||
"y": -329.8393457509562
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "2fb1577f-0a56-4f12-8711-8afcaaaf1d5e",
|
|
||||||
"type": "invocation",
|
|
||||||
"data": {
|
|
||||||
"id": "2fb1577f-0a56-4f12-8711-8afcaaaf1d5e",
|
|
||||||
"type": "denoise_latents",
|
|
||||||
"label": "",
|
|
||||||
"isOpen": true,
|
|
||||||
"notes": "",
|
|
||||||
"isIntermediate": true,
|
|
||||||
"useCache": true,
|
|
||||||
"version": "1.5.0",
|
|
||||||
"nodePack": "invokeai",
|
|
||||||
"inputs": {
|
|
||||||
"positive_conditioning": {
|
|
||||||
"id": "751fb35b-3f23-45ce-af1c-053e74251337",
|
|
||||||
"name": "positive_conditioning",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "ConditioningField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"negative_conditioning": {
|
|
||||||
"id": "b9dc06b6-7481-4db1-a8c2-39d22a5eacff",
|
|
||||||
"name": "negative_conditioning",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "ConditioningField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"noise": {
|
|
||||||
"id": "6e15e439-3390-48a4-8031-01e0e19f0e1d",
|
|
||||||
"name": "noise",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "LatentsField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"steps": {
|
|
||||||
"id": "bfdfb3df-760b-4d51-b17b-0abb38b976c2",
|
|
||||||
"name": "steps",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "IntegerField"
|
|
||||||
},
|
|
||||||
"value": 10
|
|
||||||
},
|
|
||||||
"cfg_scale": {
|
|
||||||
"id": "47770858-322e-41af-8494-d8b63ed735f3",
|
|
||||||
"name": "cfg_scale",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": true,
|
|
||||||
"name": "FloatField"
|
|
||||||
},
|
|
||||||
"value": 7.5
|
|
||||||
},
|
|
||||||
"denoising_start": {
|
|
||||||
"id": "2ba78720-ee02-4130-a348-7bc3531f790b",
|
|
||||||
"name": "denoising_start",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "FloatField"
|
|
||||||
},
|
|
||||||
"value": 0
|
|
||||||
},
|
|
||||||
"denoising_end": {
|
|
||||||
"id": "a874dffb-d433-4d1a-9f59-af4367bb05e4",
|
|
||||||
"name": "denoising_end",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "FloatField"
|
|
||||||
},
|
|
||||||
"value": 1
|
|
||||||
},
|
|
||||||
"scheduler": {
|
|
||||||
"id": "36e021ad-b762-4fe4-ad4d-17f0291c40b2",
|
|
||||||
"name": "scheduler",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "SchedulerField"
|
|
||||||
},
|
|
||||||
"value": "euler"
|
|
||||||
},
|
|
||||||
"unet": {
|
|
||||||
"id": "98d3282d-f9f6-4b5e-b9e8-58658f1cac78",
|
|
||||||
"name": "unet",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "UNetField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"control": {
|
|
||||||
"id": "f2ea3216-43d5-42b4-887f-36e8f7166d53",
|
|
||||||
"name": "control",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": true,
|
|
||||||
"name": "ControlField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ip_adapter": {
|
|
||||||
"id": "d0780610-a298-47c8-a54e-70e769e0dfe2",
|
|
||||||
"name": "ip_adapter",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": true,
|
|
||||||
"name": "IPAdapterField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"t2i_adapter": {
|
|
||||||
"id": "fdb40970-185e-4ea8-8bb5-88f06f91f46a",
|
|
||||||
"name": "t2i_adapter",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": true,
|
|
||||||
"name": "T2IAdapterField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"cfg_rescale_multiplier": {
|
|
||||||
"id": "3af2d8c5-de83-425c-a100-49cb0f1f4385",
|
|
||||||
"name": "cfg_rescale_multiplier",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "FloatField"
|
|
||||||
},
|
|
||||||
"value": 0
|
|
||||||
},
|
|
||||||
"latents": {
|
|
||||||
"id": "e05b538a-1b5a-4aa5-84b1-fd2361289a81",
|
|
||||||
"name": "latents",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "LatentsField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"denoise_mask": {
|
|
||||||
"id": "463a419e-df30-4382-8ffb-b25b25abe425",
|
|
||||||
"name": "denoise_mask",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "DenoiseMaskField"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": {
|
|
||||||
"latents": {
|
|
||||||
"id": "559ee688-66cf-4139-8b82-3d3aa69995ce",
|
|
||||||
"name": "latents",
|
|
||||||
"fieldKind": "output",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "LatentsField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"width": {
|
|
||||||
"id": "0b4285c2-e8b9-48e5-98f6-0a49d3f98fd2",
|
|
||||||
"name": "width",
|
|
||||||
"fieldKind": "output",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "IntegerField"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"height": {
|
|
||||||
"id": "8b0881b9-45e5-47d5-b526-24b6661de0ee",
|
|
||||||
"name": "height",
|
|
||||||
"fieldKind": "output",
|
|
||||||
"type": {
|
|
||||||
"isCollection": false,
|
|
||||||
"isCollectionOrScalar": false,
|
|
||||||
"name": "IntegerField"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"width": 320,
|
|
||||||
"height": 705,
|
|
||||||
"position": {
|
|
||||||
"x": 1570.9941088179146,
|
|
||||||
"y": -407.6505491604564
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"edges": [
|
|
||||||
{
|
|
||||||
"id": "1b89067c-3f6b-42c8-991f-e3055789b251-fc9d0e35-a6de-4a19-84e1-c72497c823f6-collapsed",
|
|
||||||
"source": "1b89067c-3f6b-42c8-991f-e3055789b251",
|
|
||||||
"target": "fc9d0e35-a6de-4a19-84e1-c72497c823f6",
|
|
||||||
"type": "collapsed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "dfc20e07-7aef-4fc0-a3a1-7bf68ec6a4e5-0eb5f3f5-1b91-49eb-9ef0-41d67c7eae77-collapsed",
|
|
||||||
"source": "dfc20e07-7aef-4fc0-a3a1-7bf68ec6a4e5",
|
|
||||||
"target": "0eb5f3f5-1b91-49eb-9ef0-41d67c7eae77",
|
|
||||||
"type": "collapsed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "reactflow__edge-1b7e0df8-8589-4915-a4ea-c0088f15d642collection-1b89067c-3f6b-42c8-991f-e3055789b251collection",
|
|
||||||
"source": "1b7e0df8-8589-4915-a4ea-c0088f15d642",
|
|
||||||
"target": "1b89067c-3f6b-42c8-991f-e3055789b251",
|
|
||||||
"type": "default",
|
|
||||||
"sourceHandle": "collection",
|
|
||||||
"targetHandle": "collection"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "reactflow__edge-d6353b7f-b447-4e17-8f2e-80a88c91d426clip-fc9d0e35-a6de-4a19-84e1-c72497c823f6clip",
|
|
||||||
"source": "d6353b7f-b447-4e17-8f2e-80a88c91d426",
|
|
||||||
"target": "fc9d0e35-a6de-4a19-84e1-c72497c823f6",
|
|
||||||
"type": "default",
|
|
||||||
"sourceHandle": "clip",
|
|
||||||
"targetHandle": "clip"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "reactflow__edge-1b89067c-3f6b-42c8-991f-e3055789b251item-fc9d0e35-a6de-4a19-84e1-c72497c823f6prompt",
|
|
||||||
"source": "1b89067c-3f6b-42c8-991f-e3055789b251",
|
|
||||||
"target": "fc9d0e35-a6de-4a19-84e1-c72497c823f6",
|
|
||||||
"type": "default",
|
|
||||||
"sourceHandle": "item",
|
|
||||||
"targetHandle": "prompt"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "reactflow__edge-d6353b7f-b447-4e17-8f2e-80a88c91d426clip-c2eaf1ba-5708-4679-9e15-945b8b432692clip",
|
|
||||||
"source": "d6353b7f-b447-4e17-8f2e-80a88c91d426",
|
|
||||||
"target": "c2eaf1ba-5708-4679-9e15-945b8b432692",
|
|
||||||
"type": "default",
|
|
||||||
"sourceHandle": "clip",
|
|
||||||
"targetHandle": "clip"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "reactflow__edge-dfc20e07-7aef-4fc0-a3a1-7bf68ec6a4e5value-0eb5f3f5-1b91-49eb-9ef0-41d67c7eae77seed",
|
|
||||||
"source": "dfc20e07-7aef-4fc0-a3a1-7bf68ec6a4e5",
|
|
||||||
"target": "0eb5f3f5-1b91-49eb-9ef0-41d67c7eae77",
|
|
||||||
"type": "default",
|
|
||||||
"sourceHandle": "value",
|
|
||||||
"targetHandle": "seed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "reactflow__edge-fc9d0e35-a6de-4a19-84e1-c72497c823f6conditioning-2fb1577f-0a56-4f12-8711-8afcaaaf1d5epositive_conditioning",
|
|
||||||
"source": "fc9d0e35-a6de-4a19-84e1-c72497c823f6",
|
|
||||||
"target": "2fb1577f-0a56-4f12-8711-8afcaaaf1d5e",
|
|
||||||
"type": "default",
|
|
||||||
"sourceHandle": "conditioning",
|
|
||||||
"targetHandle": "positive_conditioning"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "reactflow__edge-c2eaf1ba-5708-4679-9e15-945b8b432692conditioning-2fb1577f-0a56-4f12-8711-8afcaaaf1d5enegative_conditioning",
|
|
||||||
"source": "c2eaf1ba-5708-4679-9e15-945b8b432692",
|
|
||||||
"target": "2fb1577f-0a56-4f12-8711-8afcaaaf1d5e",
|
|
||||||
"type": "default",
|
|
||||||
"sourceHandle": "conditioning",
|
|
||||||
"targetHandle": "negative_conditioning"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "reactflow__edge-0eb5f3f5-1b91-49eb-9ef0-41d67c7eae77noise-2fb1577f-0a56-4f12-8711-8afcaaaf1d5enoise",
|
|
||||||
"source": "0eb5f3f5-1b91-49eb-9ef0-41d67c7eae77",
|
|
||||||
"target": "2fb1577f-0a56-4f12-8711-8afcaaaf1d5e",
|
|
||||||
"type": "default",
|
|
||||||
"sourceHandle": "noise",
|
|
||||||
"targetHandle": "noise"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "reactflow__edge-d6353b7f-b447-4e17-8f2e-80a88c91d426unet-2fb1577f-0a56-4f12-8711-8afcaaaf1d5eunet",
|
|
||||||
"source": "d6353b7f-b447-4e17-8f2e-80a88c91d426",
|
|
||||||
"target": "2fb1577f-0a56-4f12-8711-8afcaaaf1d5e",
|
|
||||||
"type": "default",
|
|
||||||
"sourceHandle": "unet",
|
|
||||||
"targetHandle": "unet"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "reactflow__edge-2fb1577f-0a56-4f12-8711-8afcaaaf1d5elatents-491ec988-3c77-4c37-af8a-39a0c4e7a2a1latents",
|
|
||||||
"source": "2fb1577f-0a56-4f12-8711-8afcaaaf1d5e",
|
|
||||||
"target": "491ec988-3c77-4c37-af8a-39a0c4e7a2a1",
|
|
||||||
"type": "default",
|
|
||||||
"sourceHandle": "latents",
|
|
||||||
"targetHandle": "latents"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "reactflow__edge-d6353b7f-b447-4e17-8f2e-80a88c91d426vae-491ec988-3c77-4c37-af8a-39a0c4e7a2a1vae",
|
|
||||||
"source": "d6353b7f-b447-4e17-8f2e-80a88c91d426",
|
|
||||||
"target": "491ec988-3c77-4c37-af8a-39a0c4e7a2a1",
|
|
||||||
"type": "default",
|
|
||||||
"sourceHandle": "vae",
|
|
||||||
"targetHandle": "vae"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,758 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "QR Code Monster",
|
|
||||||
"author": "InvokeAI",
|
|
||||||
"description": "Sample workflow for create images with QR code Monster ControlNet",
|
|
||||||
"version": "1.0.1",
|
|
||||||
"contact": "invoke@invoke.ai",
|
|
||||||
"tags": "qrcode, controlnet, default",
|
|
||||||
"notes": "",
|
|
||||||
"exposedFields": [
|
|
||||||
{
|
|
||||||
"nodeId": "a6cc0986-f928-4a7e-8d44-ba2d4b36f54a",
|
|
||||||
"fieldName": "image"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"nodeId": "aca3b054-bfba-4392-bd20-6476f59504df",
|
|
||||||
"fieldName": "prompt"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"nodeId": "3db7cee0-31e2-4a3d-94a1-268cb16177dd",
|
|
||||||
"fieldName": "prompt"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"meta": {
|
|
||||||
"version": "1.0.0"
|
|
||||||
},
|
|
||||||
"nodes": [
|
|
||||||
{
|
|
||||||
"id": "3db7cee0-31e2-4a3d-94a1-268cb16177dd",
|
|
||||||
"type": "invocation",
|
|
||||||
"data": {
|
|
||||||
"id": "3db7cee0-31e2-4a3d-94a1-268cb16177dd",
|
|
||||||
"type": "compel",
|
|
||||||
"inputs": {
|
|
||||||
"prompt": {
|
|
||||||
"id": "6a1fe244-5656-4f8c-91d1-1fb474e28807",
|
|
||||||
"name": "prompt",
|
|
||||||
"type": "string",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "Negative Prompt",
|
|
||||||
"value": ""
|
|
||||||
},
|
|
||||||
"clip": {
|
|
||||||
"id": "f24688f3-29b8-4a2d-8603-046e5a5c7250",
|
|
||||||
"name": "clip",
|
|
||||||
"type": "ClipField",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": {
|
|
||||||
"conditioning": {
|
|
||||||
"id": "700528eb-3f8b-4745-b540-34f919b5b228",
|
|
||||||
"name": "conditioning",
|
|
||||||
"type": "ConditioningField",
|
|
||||||
"fieldKind": "output"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"label": "Prompt",
|
|
||||||
"isOpen": true,
|
|
||||||
"notes": "",
|
|
||||||
"embedWorkflow": false,
|
|
||||||
"isIntermediate": true,
|
|
||||||
"useCache": true,
|
|
||||||
"version": "1.0.0"
|
|
||||||
},
|
|
||||||
"width": 320,
|
|
||||||
"height": 261,
|
|
||||||
"position": {
|
|
||||||
"x": 773.0502679628016,
|
|
||||||
"y": 1622.4836086770556
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "610384f1-6f0c-4847-a9a2-37ce7f456ed1",
|
|
||||||
"type": "invocation",
|
|
||||||
"data": {
|
|
||||||
"id": "610384f1-6f0c-4847-a9a2-37ce7f456ed1",
|
|
||||||
"type": "main_model_loader",
|
|
||||||
"inputs": {
|
|
||||||
"model": {
|
|
||||||
"id": "cb36b6d3-6c1f-4911-a200-646745b0ff74",
|
|
||||||
"name": "model",
|
|
||||||
"type": "MainModelField",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": {
|
|
||||||
"model_name": "stable-diffusion-v1-5",
|
|
||||||
"base_model": "sd-1",
|
|
||||||
"model_type": "main"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": {
|
|
||||||
"unet": {
|
|
||||||
"id": "7246895b-b252-49bc-b952-8d801b4672f7",
|
|
||||||
"name": "unet",
|
|
||||||
"type": "UNetField",
|
|
||||||
"fieldKind": "output"
|
|
||||||
},
|
|
||||||
"clip": {
|
|
||||||
"id": "3c2aedb8-30d5-4d4b-99df-d06a0d7bedc6",
|
|
||||||
"name": "clip",
|
|
||||||
"type": "ClipField",
|
|
||||||
"fieldKind": "output"
|
|
||||||
},
|
|
||||||
"vae": {
|
|
||||||
"id": "b9743815-5501-4bbb-8bde-8bd6ba298a4e",
|
|
||||||
"name": "vae",
|
|
||||||
"type": "VaeField",
|
|
||||||
"fieldKind": "output"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"label": "",
|
|
||||||
"isOpen": true,
|
|
||||||
"notes": "",
|
|
||||||
"embedWorkflow": false,
|
|
||||||
"isIntermediate": true,
|
|
||||||
"useCache": true,
|
|
||||||
"version": "1.0.0"
|
|
||||||
},
|
|
||||||
"width": 320,
|
|
||||||
"height": 226,
|
|
||||||
"position": {
|
|
||||||
"x": 211.58866462619744,
|
|
||||||
"y": 1376.0542388105248
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "aca3b054-bfba-4392-bd20-6476f59504df",
|
|
||||||
"type": "invocation",
|
|
||||||
"data": {
|
|
||||||
"id": "aca3b054-bfba-4392-bd20-6476f59504df",
|
|
||||||
"type": "compel",
|
|
||||||
"inputs": {
|
|
||||||
"prompt": {
|
|
||||||
"id": "6a1fe244-5656-4f8c-91d1-1fb474e28807",
|
|
||||||
"name": "prompt",
|
|
||||||
"type": "string",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "Positive Prompt",
|
|
||||||
"value": ""
|
|
||||||
},
|
|
||||||
"clip": {
|
|
||||||
"id": "f24688f3-29b8-4a2d-8603-046e5a5c7250",
|
|
||||||
"name": "clip",
|
|
||||||
"type": "ClipField",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": {
|
|
||||||
"conditioning": {
|
|
||||||
"id": "700528eb-3f8b-4745-b540-34f919b5b228",
|
|
||||||
"name": "conditioning",
|
|
||||||
"type": "ConditioningField",
|
|
||||||
"fieldKind": "output"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"label": "",
|
|
||||||
"isOpen": true,
|
|
||||||
"notes": "",
|
|
||||||
"embedWorkflow": false,
|
|
||||||
"isIntermediate": true,
|
|
||||||
"useCache": true,
|
|
||||||
"version": "1.0.0"
|
|
||||||
},
|
|
||||||
"width": 320,
|
|
||||||
"height": 261,
|
|
||||||
"position": {
|
|
||||||
"x": 770.6491131680111,
|
|
||||||
"y": 1316.379247112241
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "a6cc0986-f928-4a7e-8d44-ba2d4b36f54a",
|
|
||||||
"type": "invocation",
|
|
||||||
"data": {
|
|
||||||
"id": "a6cc0986-f928-4a7e-8d44-ba2d4b36f54a",
|
|
||||||
"type": "image",
|
|
||||||
"inputs": {
|
|
||||||
"image": {
|
|
||||||
"id": "89ba5d58-28c9-4e04-a5df-79fb7a6f3531",
|
|
||||||
"name": "image",
|
|
||||||
"type": "ImageField",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "QR Code / Hidden Image"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": {
|
|
||||||
"image": {
|
|
||||||
"id": "54335653-0e17-42da-b9e8-83c5fb5af670",
|
|
||||||
"name": "image",
|
|
||||||
"type": "ImageField",
|
|
||||||
"fieldKind": "output"
|
|
||||||
},
|
|
||||||
"width": {
|
|
||||||
"id": "a3c65953-39ea-4d97-8858-d65154ff9d11",
|
|
||||||
"name": "width",
|
|
||||||
"type": "integer",
|
|
||||||
"fieldKind": "output"
|
|
||||||
},
|
|
||||||
"height": {
|
|
||||||
"id": "2c7db511-ebc9-4286-a46b-bc11e0fd779f",
|
|
||||||
"name": "height",
|
|
||||||
"type": "integer",
|
|
||||||
"fieldKind": "output"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"label": "",
|
|
||||||
"isOpen": true,
|
|
||||||
"notes": "",
|
|
||||||
"embedWorkflow": false,
|
|
||||||
"isIntermediate": true,
|
|
||||||
"useCache": true,
|
|
||||||
"version": "1.0.0"
|
|
||||||
},
|
|
||||||
"width": 320,
|
|
||||||
"height": 225,
|
|
||||||
"position": {
|
|
||||||
"x": 700.5034176864369,
|
|
||||||
"y": 1981.749600549388
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "280fd8a7-3b0c-49fe-8be4-6246e08b6c9a",
|
|
||||||
"type": "invocation",
|
|
||||||
"data": {
|
|
||||||
"id": "280fd8a7-3b0c-49fe-8be4-6246e08b6c9a",
|
|
||||||
"type": "noise",
|
|
||||||
"inputs": {
|
|
||||||
"seed": {
|
|
||||||
"id": "7c6c76dd-127b-4829-b1ec-430790cb7ed7",
|
|
||||||
"name": "seed",
|
|
||||||
"type": "integer",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": 0
|
|
||||||
},
|
|
||||||
"width": {
|
|
||||||
"id": "8ec6a525-a421-40d8-a17e-39e7b6836438",
|
|
||||||
"name": "width",
|
|
||||||
"type": "integer",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": 512
|
|
||||||
},
|
|
||||||
"height": {
|
|
||||||
"id": "6af1e58a-e2ee-4ec4-9f06-d8d0412922ca",
|
|
||||||
"name": "height",
|
|
||||||
"type": "integer",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": 512
|
|
||||||
},
|
|
||||||
"use_cpu": {
|
|
||||||
"id": "26662e99-5720-43a6-a5d8-06c9dab0e261",
|
|
||||||
"name": "use_cpu",
|
|
||||||
"type": "boolean",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": {
|
|
||||||
"noise": {
|
|
||||||
"id": "cb4c4dfc-a744-49eb-af4f-677448e28407",
|
|
||||||
"name": "noise",
|
|
||||||
"type": "LatentsField",
|
|
||||||
"fieldKind": "output"
|
|
||||||
},
|
|
||||||
"width": {
|
|
||||||
"id": "97e87be6-e81f-40a3-a522-28ebe4aad0ac",
|
|
||||||
"name": "width",
|
|
||||||
"type": "integer",
|
|
||||||
"fieldKind": "output"
|
|
||||||
},
|
|
||||||
"height": {
|
|
||||||
"id": "80784420-f1e1-47b0-bd1d-1d381a15e22d",
|
|
||||||
"name": "height",
|
|
||||||
"type": "integer",
|
|
||||||
"fieldKind": "output"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"label": "",
|
|
||||||
"isOpen": false,
|
|
||||||
"notes": "",
|
|
||||||
"embedWorkflow": false,
|
|
||||||
"isIntermediate": true,
|
|
||||||
"useCache": true,
|
|
||||||
"version": "1.0.0"
|
|
||||||
},
|
|
||||||
"width": 320,
|
|
||||||
"height": 32,
|
|
||||||
"position": {
|
|
||||||
"x": 1182.460291960481,
|
|
||||||
"y": 1759.592972960265
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "2ac03cf6-0326-454a-bed0-d8baef2bf30d",
|
|
||||||
"type": "invocation",
|
|
||||||
"data": {
|
|
||||||
"id": "2ac03cf6-0326-454a-bed0-d8baef2bf30d",
|
|
||||||
"type": "controlnet",
|
|
||||||
"inputs": {
|
|
||||||
"image": {
|
|
||||||
"id": "1f683889-9f14-40c8-af29-4b991b211a3a",
|
|
||||||
"name": "image",
|
|
||||||
"type": "ImageField",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": ""
|
|
||||||
},
|
|
||||||
"control_model": {
|
|
||||||
"id": "a933b21d-22c1-4e06-818f-15416b971282",
|
|
||||||
"name": "control_model",
|
|
||||||
"type": "ControlNetModelField",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": {
|
|
||||||
"model_name": "qrcode_monster",
|
|
||||||
"base_model": "sd-1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"control_weight": {
|
|
||||||
"id": "198a0825-e55e-4496-bc54-c3d7b02f3d75",
|
|
||||||
"name": "control_weight",
|
|
||||||
"type": "FloatPolymorphic",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": 1.4
|
|
||||||
},
|
|
||||||
"begin_step_percent": {
|
|
||||||
"id": "c85ce42f-22af-42a0-8993-676002fb275e",
|
|
||||||
"name": "begin_step_percent",
|
|
||||||
"type": "float",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": 0
|
|
||||||
},
|
|
||||||
"end_step_percent": {
|
|
||||||
"id": "a61a65c4-9e6f-4fe2-96a5-1294d17ec6e4",
|
|
||||||
"name": "end_step_percent",
|
|
||||||
"type": "float",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": 1
|
|
||||||
},
|
|
||||||
"control_mode": {
|
|
||||||
"id": "1aa45cfa-0249-46b7-bf24-3e38e92f5fa0",
|
|
||||||
"name": "control_mode",
|
|
||||||
"type": "enum",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": "balanced"
|
|
||||||
},
|
|
||||||
"resize_mode": {
|
|
||||||
"id": "a89d3cb9-a141-4cea-bb49-977bf267377b",
|
|
||||||
"name": "resize_mode",
|
|
||||||
"type": "enum",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": "just_resize"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": {
|
|
||||||
"control": {
|
|
||||||
"id": "c9a1fc7e-cb25-45a9-adff-1a97c9ff04d6",
|
|
||||||
"name": "control",
|
|
||||||
"type": "ControlField",
|
|
||||||
"fieldKind": "output"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"label": "",
|
|
||||||
"isOpen": true,
|
|
||||||
"notes": "",
|
|
||||||
"embedWorkflow": false,
|
|
||||||
"isIntermediate": true,
|
|
||||||
"useCache": true,
|
|
||||||
"version": "1.0.0"
|
|
||||||
},
|
|
||||||
"width": 320,
|
|
||||||
"height": 508,
|
|
||||||
"position": {
|
|
||||||
"x": 1165.434407461108,
|
|
||||||
"y": 1862.916856351665
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "28542b66-5a00-4780-a318-0a036d2df914",
|
|
||||||
"type": "invocation",
|
|
||||||
"data": {
|
|
||||||
"id": "28542b66-5a00-4780-a318-0a036d2df914",
|
|
||||||
"type": "l2i",
|
|
||||||
"inputs": {
|
|
||||||
"metadata": {
|
|
||||||
"id": "a38e8f55-7f2c-4fcc-a71f-d51e2eb0374a",
|
|
||||||
"name": "metadata",
|
|
||||||
"type": "MetadataField",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": ""
|
|
||||||
},
|
|
||||||
"latents": {
|
|
||||||
"id": "80e97bc8-e716-4175-9115-5b58495aa30c",
|
|
||||||
"name": "latents",
|
|
||||||
"type": "LatentsField",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": ""
|
|
||||||
},
|
|
||||||
"vae": {
|
|
||||||
"id": "5641bce6-ac2b-47eb-bb32-2f290026b7e1",
|
|
||||||
"name": "vae",
|
|
||||||
"type": "VaeField",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": ""
|
|
||||||
},
|
|
||||||
"tiled": {
|
|
||||||
"id": "9e75eb16-ae48-47ed-b180-e0409d377436",
|
|
||||||
"name": "tiled",
|
|
||||||
"type": "boolean",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": false
|
|
||||||
},
|
|
||||||
"fp32": {
|
|
||||||
"id": "0518b0ce-ee37-437b-8437-cc2976a3279f",
|
|
||||||
"name": "fp32",
|
|
||||||
"type": "boolean",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": {
|
|
||||||
"image": {
|
|
||||||
"id": "ec2ff985-a7eb-401f-92c4-1217cddad6a2",
|
|
||||||
"name": "image",
|
|
||||||
"type": "ImageField",
|
|
||||||
"fieldKind": "output"
|
|
||||||
},
|
|
||||||
"width": {
|
|
||||||
"id": "ba1d1720-6d67-4eca-9e9d-b97d08636774",
|
|
||||||
"name": "width",
|
|
||||||
"type": "integer",
|
|
||||||
"fieldKind": "output"
|
|
||||||
},
|
|
||||||
"height": {
|
|
||||||
"id": "10bcf8f4-6394-422f-b0c0-51680f3bfb25",
|
|
||||||
"name": "height",
|
|
||||||
"type": "integer",
|
|
||||||
"fieldKind": "output"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"label": "",
|
|
||||||
"isOpen": true,
|
|
||||||
"notes": "",
|
|
||||||
"embedWorkflow": false,
|
|
||||||
"isIntermediate": true,
|
|
||||||
"useCache": true,
|
|
||||||
"version": "1.0.0"
|
|
||||||
},
|
|
||||||
"width": 320,
|
|
||||||
"height": 267,
|
|
||||||
"position": {
|
|
||||||
"x": 2110.8415693683014,
|
|
||||||
"y": 1487.253341116115
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "9755ae4c-ef30-4db3-80f6-a31f98979a11",
|
|
||||||
"type": "invocation",
|
|
||||||
"data": {
|
|
||||||
"id": "9755ae4c-ef30-4db3-80f6-a31f98979a11",
|
|
||||||
"type": "denoise_latents",
|
|
||||||
"inputs": {
|
|
||||||
"positive_conditioning": {
|
|
||||||
"id": "8e6aceaa-a986-4ab2-9c04-5b1027b3daf6",
|
|
||||||
"name": "positive_conditioning",
|
|
||||||
"type": "ConditioningField",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": ""
|
|
||||||
},
|
|
||||||
"negative_conditioning": {
|
|
||||||
"id": "fbbaa712-ca1a-420b-9016-763f2a29d68c",
|
|
||||||
"name": "negative_conditioning",
|
|
||||||
"type": "ConditioningField",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": ""
|
|
||||||
},
|
|
||||||
"noise": {
|
|
||||||
"id": "a3b3d5d2-c0f9-4b89-a9b3-8de9418f7bb5",
|
|
||||||
"name": "noise",
|
|
||||||
"type": "LatentsField",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": ""
|
|
||||||
},
|
|
||||||
"steps": {
|
|
||||||
"id": "e491e664-2f8c-4f49-b3e4-57b051fbb9c5",
|
|
||||||
"name": "steps",
|
|
||||||
"type": "integer",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": 10
|
|
||||||
},
|
|
||||||
"cfg_scale": {
|
|
||||||
"id": "f0318abd-ed65-4cad-86a7-48d1c19a6d14",
|
|
||||||
"name": "cfg_scale",
|
|
||||||
"type": "FloatPolymorphic",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": 7.5
|
|
||||||
},
|
|
||||||
"denoising_start": {
|
|
||||||
"id": "f7c24c51-496f-44c4-836a-c734e529fec0",
|
|
||||||
"name": "denoising_start",
|
|
||||||
"type": "float",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": 0
|
|
||||||
},
|
|
||||||
"denoising_end": {
|
|
||||||
"id": "54f7656a-fb0d-4d9e-a459-f700f7dccd2e",
|
|
||||||
"name": "denoising_end",
|
|
||||||
"type": "float",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": 1
|
|
||||||
},
|
|
||||||
"scheduler": {
|
|
||||||
"id": "363ee440-040d-499b-bf84-bf5391b08681",
|
|
||||||
"name": "scheduler",
|
|
||||||
"type": "Scheduler",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": "euler"
|
|
||||||
},
|
|
||||||
"unet": {
|
|
||||||
"id": "5c93d4e5-1064-4700-ab1d-d12e1e9b5ba7",
|
|
||||||
"name": "unet",
|
|
||||||
"type": "UNetField",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": ""
|
|
||||||
},
|
|
||||||
"control": {
|
|
||||||
"id": "e1948eb3-7407-43b0-93e3-139470f186b7",
|
|
||||||
"name": "control",
|
|
||||||
"type": "ControlPolymorphic",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": ""
|
|
||||||
},
|
|
||||||
"ip_adapter": {
|
|
||||||
"id": "5675b2c3-adfb-49ee-b33c-26bdbfab1fed",
|
|
||||||
"name": "ip_adapter",
|
|
||||||
"type": "IPAdapterPolymorphic",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": ""
|
|
||||||
},
|
|
||||||
"t2i_adapter": {
|
|
||||||
"id": "89cd4ab3-3bfc-4063-9de5-91d42305c651",
|
|
||||||
"name": "t2i_adapter",
|
|
||||||
"type": "T2IAdapterPolymorphic",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": ""
|
|
||||||
},
|
|
||||||
"latents": {
|
|
||||||
"id": "ec01df90-5042-418d-b6d6-86b251c13770",
|
|
||||||
"name": "latents",
|
|
||||||
"type": "LatentsField",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": ""
|
|
||||||
},
|
|
||||||
"denoise_mask": {
|
|
||||||
"id": "561cde00-cb20-42ae-9bd3-4f477f73fbe1",
|
|
||||||
"name": "denoise_mask",
|
|
||||||
"type": "DenoiseMaskField",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": {
|
|
||||||
"latents": {
|
|
||||||
"id": "f9addefe-efcc-4e01-8945-6ebbc934b002",
|
|
||||||
"name": "latents",
|
|
||||||
"type": "LatentsField",
|
|
||||||
"fieldKind": "output"
|
|
||||||
},
|
|
||||||
"width": {
|
|
||||||
"id": "6d48f78b-d681-422a-8677-0111bd0625f1",
|
|
||||||
"name": "width",
|
|
||||||
"type": "integer",
|
|
||||||
"fieldKind": "output"
|
|
||||||
},
|
|
||||||
"height": {
|
|
||||||
"id": "f25997b8-6316-44ce-b696-b82e4ed51ae5",
|
|
||||||
"name": "height",
|
|
||||||
"type": "integer",
|
|
||||||
"fieldKind": "output"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"label": "",
|
|
||||||
"isOpen": true,
|
|
||||||
"notes": "",
|
|
||||||
"embedWorkflow": false,
|
|
||||||
"isIntermediate": true,
|
|
||||||
"useCache": true,
|
|
||||||
"version": "1.4.0"
|
|
||||||
},
|
|
||||||
"width": 320,
|
|
||||||
"height": 646,
|
|
||||||
"position": {
|
|
||||||
"x": 1597.9598293300219,
|
|
||||||
"y": 1420.4637727891632
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "59349822-af20-4e0e-a53f-3ba135d00c3f",
|
|
||||||
"type": "invocation",
|
|
||||||
"data": {
|
|
||||||
"id": "59349822-af20-4e0e-a53f-3ba135d00c3f",
|
|
||||||
"type": "rand_int",
|
|
||||||
"inputs": {
|
|
||||||
"low": {
|
|
||||||
"id": "051f22f9-2d4f-414f-bc51-84af2d626efa",
|
|
||||||
"name": "low",
|
|
||||||
"type": "integer",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": 0
|
|
||||||
},
|
|
||||||
"high": {
|
|
||||||
"id": "77206186-f264-4224-9589-f925cf903dc9",
|
|
||||||
"name": "high",
|
|
||||||
"type": "integer",
|
|
||||||
"fieldKind": "input",
|
|
||||||
"label": "",
|
|
||||||
"value": 2147483647
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": {
|
|
||||||
"value": {
|
|
||||||
"id": "a7ed9387-3a24-4d34-b7c5-f713bd544ab1",
|
|
||||||
"name": "value",
|
|
||||||
"type": "integer",
|
|
||||||
"fieldKind": "output"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"label": "",
|
|
||||||
"isOpen": false,
|
|
||||||
"notes": "",
|
|
||||||
"embedWorkflow": false,
|
|
||||||
"isIntermediate": true,
|
|
||||||
"useCache": false,
|
|
||||||
"version": "1.0.0"
|
|
||||||
},
|
|
||||||
"width": 320,
|
|
||||||
"height": 32,
|
|
||||||
"position": {
|
|
||||||
"x": 1178.16746986153,
|
|
||||||
"y": 1663.9433412808876
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"edges": [
|
|
||||||
{
|
|
||||||
"source": "59349822-af20-4e0e-a53f-3ba135d00c3f",
|
|
||||||
"target": "280fd8a7-3b0c-49fe-8be4-6246e08b6c9a",
|
|
||||||
"id": "59349822-af20-4e0e-a53f-3ba135d00c3f-280fd8a7-3b0c-49fe-8be4-6246e08b6c9a-collapsed",
|
|
||||||
"type": "collapsed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "610384f1-6f0c-4847-a9a2-37ce7f456ed1",
|
|
||||||
"sourceHandle": "clip",
|
|
||||||
"target": "aca3b054-bfba-4392-bd20-6476f59504df",
|
|
||||||
"targetHandle": "clip",
|
|
||||||
"id": "reactflow__edge-610384f1-6f0c-4847-a9a2-37ce7f456ed1clip-aca3b054-bfba-4392-bd20-6476f59504dfclip",
|
|
||||||
"type": "default"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "610384f1-6f0c-4847-a9a2-37ce7f456ed1",
|
|
||||||
"sourceHandle": "clip",
|
|
||||||
"target": "3db7cee0-31e2-4a3d-94a1-268cb16177dd",
|
|
||||||
"targetHandle": "clip",
|
|
||||||
"id": "reactflow__edge-610384f1-6f0c-4847-a9a2-37ce7f456ed1clip-3db7cee0-31e2-4a3d-94a1-268cb16177ddclip",
|
|
||||||
"type": "default"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "a6cc0986-f928-4a7e-8d44-ba2d4b36f54a",
|
|
||||||
"sourceHandle": "image",
|
|
||||||
"target": "2ac03cf6-0326-454a-bed0-d8baef2bf30d",
|
|
||||||
"targetHandle": "image",
|
|
||||||
"id": "reactflow__edge-a6cc0986-f928-4a7e-8d44-ba2d4b36f54aimage-2ac03cf6-0326-454a-bed0-d8baef2bf30dimage",
|
|
||||||
"type": "default"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "610384f1-6f0c-4847-a9a2-37ce7f456ed1",
|
|
||||||
"sourceHandle": "vae",
|
|
||||||
"target": "28542b66-5a00-4780-a318-0a036d2df914",
|
|
||||||
"targetHandle": "vae",
|
|
||||||
"id": "reactflow__edge-610384f1-6f0c-4847-a9a2-37ce7f456ed1vae-28542b66-5a00-4780-a318-0a036d2df914vae",
|
|
||||||
"type": "default"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "280fd8a7-3b0c-49fe-8be4-6246e08b6c9a",
|
|
||||||
"sourceHandle": "noise",
|
|
||||||
"target": "9755ae4c-ef30-4db3-80f6-a31f98979a11",
|
|
||||||
"targetHandle": "noise",
|
|
||||||
"id": "reactflow__edge-280fd8a7-3b0c-49fe-8be4-6246e08b6c9anoise-9755ae4c-ef30-4db3-80f6-a31f98979a11noise",
|
|
||||||
"type": "default"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "3db7cee0-31e2-4a3d-94a1-268cb16177dd",
|
|
||||||
"sourceHandle": "conditioning",
|
|
||||||
"target": "9755ae4c-ef30-4db3-80f6-a31f98979a11",
|
|
||||||
"targetHandle": "negative_conditioning",
|
|
||||||
"id": "reactflow__edge-3db7cee0-31e2-4a3d-94a1-268cb16177ddconditioning-9755ae4c-ef30-4db3-80f6-a31f98979a11negative_conditioning",
|
|
||||||
"type": "default"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "aca3b054-bfba-4392-bd20-6476f59504df",
|
|
||||||
"sourceHandle": "conditioning",
|
|
||||||
"target": "9755ae4c-ef30-4db3-80f6-a31f98979a11",
|
|
||||||
"targetHandle": "positive_conditioning",
|
|
||||||
"id": "reactflow__edge-aca3b054-bfba-4392-bd20-6476f59504dfconditioning-9755ae4c-ef30-4db3-80f6-a31f98979a11positive_conditioning",
|
|
||||||
"type": "default"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "610384f1-6f0c-4847-a9a2-37ce7f456ed1",
|
|
||||||
"sourceHandle": "unet",
|
|
||||||
"target": "9755ae4c-ef30-4db3-80f6-a31f98979a11",
|
|
||||||
"targetHandle": "unet",
|
|
||||||
"id": "reactflow__edge-610384f1-6f0c-4847-a9a2-37ce7f456ed1unet-9755ae4c-ef30-4db3-80f6-a31f98979a11unet",
|
|
||||||
"type": "default"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "2ac03cf6-0326-454a-bed0-d8baef2bf30d",
|
|
||||||
"sourceHandle": "control",
|
|
||||||
"target": "9755ae4c-ef30-4db3-80f6-a31f98979a11",
|
|
||||||
"targetHandle": "control",
|
|
||||||
"id": "reactflow__edge-2ac03cf6-0326-454a-bed0-d8baef2bf30dcontrol-9755ae4c-ef30-4db3-80f6-a31f98979a11control",
|
|
||||||
"type": "default"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "9755ae4c-ef30-4db3-80f6-a31f98979a11",
|
|
||||||
"sourceHandle": "latents",
|
|
||||||
"target": "28542b66-5a00-4780-a318-0a036d2df914",
|
|
||||||
"targetHandle": "latents",
|
|
||||||
"id": "reactflow__edge-9755ae4c-ef30-4db3-80f6-a31f98979a11latents-28542b66-5a00-4780-a318-0a036d2df914latents",
|
|
||||||
"type": "default"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"source": "59349822-af20-4e0e-a53f-3ba135d00c3f",
|
|
||||||
"sourceHandle": "value",
|
|
||||||
"target": "280fd8a7-3b0c-49fe-8be4-6246e08b6c9a",
|
|
||||||
"targetHandle": "seed",
|
|
||||||
"id": "reactflow__edge-59349822-af20-4e0e-a53f-3ba135d00c3fvalue-280fd8a7-3b0c-49fe-8be4-6246e08b6c9aseed",
|
|
||||||
"type": "default"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -2,72 +2,43 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
BCYAN="\e[1;36m"
|
|
||||||
BYELLOW="\e[1;33m"
|
|
||||||
BGREEN="\e[1;32m"
|
|
||||||
BRED="\e[1;31m"
|
|
||||||
RED="\e[31m"
|
|
||||||
RESET="\e[0m"
|
|
||||||
|
|
||||||
function is_bin_in_path {
|
|
||||||
builtin type -P "$1" &>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
function git_show {
|
|
||||||
git show -s --format='%h %s' $1
|
|
||||||
}
|
|
||||||
|
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
echo -e "${BYELLOW}This script must be run from the installer directory!${RESET}"
|
|
||||||
echo "The current working directory is $(pwd)"
|
|
||||||
read -p "If that looks right, press any key to proceed, or CTRL-C to exit..."
|
|
||||||
echo
|
|
||||||
|
|
||||||
# Some machines only have `python3` in PATH, others have `python` - make an alias.
|
|
||||||
# We can use a function to approximate an alias within a non-interactive shell.
|
|
||||||
if ! is_bin_in_path python && is_bin_in_path python3; then
|
|
||||||
function python {
|
|
||||||
python3 "$@"
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -v "VIRTUAL_ENV" ]]; then
|
if [[ -v "VIRTUAL_ENV" ]]; then
|
||||||
# we can't just call 'deactivate' because this function is not exported
|
# we can't just call 'deactivate' because this function is not exported
|
||||||
# to the environment of this script from the bash process that runs the script
|
# to the environment of this script from the bash process that runs the script
|
||||||
echo -e "${BRED}A virtual environment is activated. Please deactivate it before proceeding.${RESET}"
|
echo "A virtual environment is activated. Please deactivate it before proceeding".
|
||||||
exit -1
|
exit -1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
VERSION=$(
|
VERSION=$(cd ..; python -c "from invokeai.version import __version__ as version; print(version)")
|
||||||
cd ..
|
|
||||||
python -c "from invokeai.version import __version__ as version; print(version)"
|
|
||||||
)
|
|
||||||
PATCH=""
|
PATCH=""
|
||||||
VERSION="v${VERSION}${PATCH}"
|
VERSION="v${VERSION}${PATCH}"
|
||||||
|
LATEST_TAG="v3-latest"
|
||||||
|
|
||||||
echo -e "${BGREEN}HEAD${RESET}:"
|
echo Building installer for version $VERSION
|
||||||
git_show
|
echo "Be certain that you're in the 'installer' directory before continuing."
|
||||||
echo
|
read -p "Press any key to continue, or CTRL-C to exit..."
|
||||||
|
|
||||||
# ---------------------- FRONTEND ----------------------
|
read -e -p "Tag this repo with '${VERSION}' and '${LATEST_TAG}'? [n]: " input
|
||||||
|
RESPONSE=${input:='n'}
|
||||||
|
if [ "$RESPONSE" == 'y' ]; then
|
||||||
|
|
||||||
pushd ../invokeai/frontend/web >/dev/null
|
git push origin :refs/tags/$VERSION
|
||||||
echo
|
if ! git tag -fa $VERSION ; then
|
||||||
echo "Installing frontend dependencies..."
|
echo "Existing/invalid tag"
|
||||||
echo
|
exit -1
|
||||||
pnpm i --frozen-lockfile
|
fi
|
||||||
echo
|
|
||||||
echo "Building frontend..."
|
|
||||||
echo
|
|
||||||
pnpm build
|
|
||||||
popd
|
|
||||||
|
|
||||||
# ---------------------- BACKEND ----------------------
|
git push origin :refs/tags/$LATEST_TAG
|
||||||
|
git tag -fa $LATEST_TAG
|
||||||
|
|
||||||
echo
|
echo "remember to push --tags!"
|
||||||
echo "Building wheel..."
|
fi
|
||||||
echo
|
|
||||||
|
# ----------------------
|
||||||
|
|
||||||
|
echo Building the wheel
|
||||||
|
|
||||||
# install the 'build' package in the user site packages, if needed
|
# install the 'build' package in the user site packages, if needed
|
||||||
# could be improved by using a temporary venv, but it's tiny and harmless
|
# could be improved by using a temporary venv, but it's tiny and harmless
|
||||||
@ -75,15 +46,12 @@ if [[ $(python -c 'from importlib.util import find_spec; print(find_spec("build"
|
|||||||
pip install --user build
|
pip install --user build
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf ../build
|
rm -r ../build
|
||||||
|
|
||||||
python -m build --wheel --outdir dist/ ../.
|
python -m build --wheel --outdir dist/ ../.
|
||||||
|
|
||||||
# ----------------------
|
# ----------------------
|
||||||
|
|
||||||
echo
|
echo Building installer zip fles for InvokeAI $VERSION
|
||||||
echo "Building installer zip files for InvokeAI ${VERSION}..."
|
|
||||||
echo
|
|
||||||
|
|
||||||
# get rid of any old ones
|
# get rid of any old ones
|
||||||
rm -f *.zip
|
rm -f *.zip
|
||||||
@ -91,11 +59,9 @@ rm -rf InvokeAI-Installer
|
|||||||
|
|
||||||
# copy content
|
# copy content
|
||||||
mkdir InvokeAI-Installer
|
mkdir InvokeAI-Installer
|
||||||
for f in templates *.txt *.reg; do
|
for f in templates lib *.txt *.reg; do
|
||||||
cp -r ${f} InvokeAI-Installer/
|
cp -r ${f} InvokeAI-Installer/
|
||||||
done
|
done
|
||||||
mkdir InvokeAI-Installer/lib
|
|
||||||
cp lib/*.py InvokeAI-Installer/lib
|
|
||||||
|
|
||||||
# Move the wheel
|
# Move the wheel
|
||||||
mv dist/*.whl InvokeAI-Installer/lib/
|
mv dist/*.whl InvokeAI-Installer/lib/
|
||||||
@ -106,13 +72,13 @@ cp install.sh.in InvokeAI-Installer/install.sh
|
|||||||
chmod a+x InvokeAI-Installer/install.sh
|
chmod a+x InvokeAI-Installer/install.sh
|
||||||
|
|
||||||
# Windows
|
# Windows
|
||||||
perl -p -e "s/^set INVOKEAI_VERSION=.*/set INVOKEAI_VERSION=$VERSION/" install.bat.in >InvokeAI-Installer/install.bat
|
perl -p -e "s/^set INVOKEAI_VERSION=.*/set INVOKEAI_VERSION=$VERSION/" install.bat.in > InvokeAI-Installer/install.bat
|
||||||
cp WinLongPathsEnabled.reg InvokeAI-Installer/
|
cp WinLongPathsEnabled.reg InvokeAI-Installer/
|
||||||
|
|
||||||
# Zip everything up
|
# Zip everything up
|
||||||
zip -r InvokeAI-installer-$VERSION.zip InvokeAI-Installer
|
zip -r InvokeAI-installer-$VERSION.zip InvokeAI-Installer
|
||||||
|
|
||||||
# clean up
|
# clean up
|
||||||
rm -rf InvokeAI-Installer tmp dist ../invokeai/frontend/web/dist/
|
rm -rf InvokeAI-Installer tmp dist
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
@echo off
|
@echo off
|
||||||
setlocal EnableExtensions EnableDelayedExpansion
|
setlocal EnableExtensions EnableDelayedExpansion
|
||||||
|
|
||||||
@rem This script requires the user to install Python 3.10 or higher. All other
|
@rem This script requires the user to install Python 3.9 or higher. All other
|
||||||
@rem requirements are downloaded as needed.
|
@rem requirements are downloaded as needed.
|
||||||
|
|
||||||
@rem change to the script's directory
|
@rem change to the script's directory
|
||||||
@ -19,7 +19,7 @@ set INVOKEAI_VERSION=latest
|
|||||||
set INSTRUCTIONS=https://invoke-ai.github.io/InvokeAI/installation/INSTALL_AUTOMATED/
|
set INSTRUCTIONS=https://invoke-ai.github.io/InvokeAI/installation/INSTALL_AUTOMATED/
|
||||||
set TROUBLESHOOTING=https://invoke-ai.github.io/InvokeAI/installation/INSTALL_AUTOMATED/#troubleshooting
|
set TROUBLESHOOTING=https://invoke-ai.github.io/InvokeAI/installation/INSTALL_AUTOMATED/#troubleshooting
|
||||||
set PYTHON_URL=https://www.python.org/downloads/windows/
|
set PYTHON_URL=https://www.python.org/downloads/windows/
|
||||||
set MINIMUM_PYTHON_VERSION=3.10.0
|
set MINIMUM_PYTHON_VERSION=3.9.0
|
||||||
set PYTHON_URL=https://www.python.org/downloads/release/python-3109/
|
set PYTHON_URL=https://www.python.org/downloads/release/python-3109/
|
||||||
|
|
||||||
set err_msg=An error has occurred and the script could not continue.
|
set err_msg=An error has occurred and the script could not continue.
|
||||||
@ -28,7 +28,8 @@ set err_msg=An error has occurred and the script could not continue.
|
|||||||
echo This script will install InvokeAI and its dependencies.
|
echo This script will install InvokeAI and its dependencies.
|
||||||
echo.
|
echo.
|
||||||
echo BEFORE YOU START PLEASE MAKE SURE TO DO THE FOLLOWING
|
echo BEFORE YOU START PLEASE MAKE SURE TO DO THE FOLLOWING
|
||||||
echo 1. Install python 3.10 or 3.11. Python version 3.9 is no longer supported.
|
echo 1. Install python 3.9 or 3.10. Python version 3.11 and above are
|
||||||
|
echo not supported at the moment.
|
||||||
echo 2. Double-click on the file WinLongPathsEnabled.reg in order to
|
echo 2. Double-click on the file WinLongPathsEnabled.reg in order to
|
||||||
echo enable long path support on your system.
|
echo enable long path support on your system.
|
||||||
echo 3. Install the Visual C++ core libraries.
|
echo 3. Install the Visual C++ core libraries.
|
||||||
@ -45,19 +46,19 @@ echo ***** Checking and Updating Python *****
|
|||||||
|
|
||||||
call python --version >.tmp1 2>.tmp2
|
call python --version >.tmp1 2>.tmp2
|
||||||
if %errorlevel% == 1 (
|
if %errorlevel% == 1 (
|
||||||
set err_msg=Please install Python 3.10-11. See %INSTRUCTIONS% for details.
|
set err_msg=Please install Python 3.10. See %INSTRUCTIONS% for details.
|
||||||
goto err_exit
|
goto err_exit
|
||||||
)
|
)
|
||||||
|
|
||||||
for /f "tokens=2" %%i in (.tmp1) do set python_version=%%i
|
for /f "tokens=2" %%i in (.tmp1) do set python_version=%%i
|
||||||
if "%python_version%" == "" (
|
if "%python_version%" == "" (
|
||||||
set err_msg=No python was detected on your system. Please install Python version %MINIMUM_PYTHON_VERSION% or higher. We recommend Python 3.10.12 from %PYTHON_URL%
|
set err_msg=No python was detected on your system. Please install Python version %MINIMUM_PYTHON_VERSION% or higher. We recommend Python 3.10.9 from %PYTHON_URL%
|
||||||
goto err_exit
|
goto err_exit
|
||||||
)
|
)
|
||||||
|
|
||||||
call :compareVersions %MINIMUM_PYTHON_VERSION% %python_version%
|
call :compareVersions %MINIMUM_PYTHON_VERSION% %python_version%
|
||||||
if %errorlevel% == 1 (
|
if %errorlevel% == 1 (
|
||||||
set err_msg=Your version of Python is too low. You need at least %MINIMUM_PYTHON_VERSION% but you have %python_version%. We recommend Python 3.10.12 from %PYTHON_URL%
|
set err_msg=Your version of Python is too low. You need at least %MINIMUM_PYTHON_VERSION% but you have %python_version%. We recommend Python 3.10.9 from %PYTHON_URL%
|
||||||
goto err_exit
|
goto err_exit
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -8,10 +8,10 @@ cd $scriptdir
|
|||||||
|
|
||||||
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
|
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
|
||||||
|
|
||||||
MINIMUM_PYTHON_VERSION=3.10.0
|
MINIMUM_PYTHON_VERSION=3.9.0
|
||||||
MAXIMUM_PYTHON_VERSION=3.11.100
|
MAXIMUM_PYTHON_VERSION=3.11.100
|
||||||
PYTHON=""
|
PYTHON=""
|
||||||
for candidate in python3.11 python3.10 python3 python ; do
|
for candidate in python3.11 python3.10 python3.9 python3 python ; do
|
||||||
if ppath=`which $candidate`; then
|
if ppath=`which $candidate`; then
|
||||||
# when using `pyenv`, the executable for an inactive Python version will exist but will not be operational
|
# when using `pyenv`, the executable for an inactive Python version will exist but will not be operational
|
||||||
# we check that this found executable can actually run
|
# we check that this found executable can actually run
|
||||||
|
@ -13,7 +13,7 @@ from pathlib import Path
|
|||||||
from tempfile import TemporaryDirectory
|
from tempfile import TemporaryDirectory
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
SUPPORTED_PYTHON = ">=3.10.0,<=3.11.100"
|
SUPPORTED_PYTHON = ">=3.9.0,<=3.11.100"
|
||||||
INSTALLER_REQS = ["rich", "semver", "requests", "plumbum", "prompt-toolkit"]
|
INSTALLER_REQS = ["rich", "semver", "requests", "plumbum", "prompt-toolkit"]
|
||||||
BOOTSTRAP_VENV_PREFIX = "invokeai-installer-tmp"
|
BOOTSTRAP_VENV_PREFIX = "invokeai-installer-tmp"
|
||||||
|
|
||||||
@ -67,6 +67,7 @@ class Installer:
|
|||||||
# Cleaning up temporary directories on Windows results in a race condition
|
# Cleaning up temporary directories on Windows results in a race condition
|
||||||
# and a stack trace.
|
# and a stack trace.
|
||||||
# `ignore_cleanup_errors` was only added in Python 3.10
|
# `ignore_cleanup_errors` was only added in Python 3.10
|
||||||
|
# users of Python 3.9 will see a gnarly stack trace on installer exit
|
||||||
if OS == "Windows" and int(platform.python_version_tuple()[1]) >= 10:
|
if OS == "Windows" and int(platform.python_version_tuple()[1]) >= 10:
|
||||||
venv_dir = TemporaryDirectory(prefix=BOOTSTRAP_VENV_PREFIX, ignore_cleanup_errors=True)
|
venv_dir = TemporaryDirectory(prefix=BOOTSTRAP_VENV_PREFIX, ignore_cleanup_errors=True)
|
||||||
else:
|
else:
|
||||||
@ -138,6 +139,13 @@ class Installer:
|
|||||||
except shutil.SameFileError:
|
except shutil.SameFileError:
|
||||||
venv.create(venv_dir, with_pip=True, symlinks=True)
|
venv.create(venv_dir, with_pip=True, symlinks=True)
|
||||||
|
|
||||||
|
# upgrade pip in Python 3.9 environments
|
||||||
|
if int(platform.python_version_tuple()[1]) == 9:
|
||||||
|
from plumbum import FG, local
|
||||||
|
|
||||||
|
pip = local[get_pip_from_venv(venv_dir)]
|
||||||
|
pip["install", "--upgrade", "pip"] & FG
|
||||||
|
|
||||||
return venv_dir
|
return venv_dir
|
||||||
|
|
||||||
def install(
|
def install(
|
||||||
@ -244,9 +252,9 @@ class InvokeAiInstance:
|
|||||||
"numpy~=1.24.0", # choose versions that won't be uninstalled during phase 2
|
"numpy~=1.24.0", # choose versions that won't be uninstalled during phase 2
|
||||||
"urllib3~=1.26.0",
|
"urllib3~=1.26.0",
|
||||||
"requests~=2.28.0",
|
"requests~=2.28.0",
|
||||||
"torch==2.1.2",
|
"torch~=2.0.0",
|
||||||
"torchmetrics==0.11.4",
|
"torchmetrics==0.11.4",
|
||||||
"torchvision>=0.16.2",
|
"torchvision>=0.14.1",
|
||||||
"--force-reinstall",
|
"--force-reinstall",
|
||||||
"--find-links" if find_links is not None else None,
|
"--find-links" if find_links is not None else None,
|
||||||
find_links,
|
find_links,
|
||||||
@ -460,10 +468,10 @@ def get_torch_source() -> (Union[str, None], str):
|
|||||||
url = "https://download.pytorch.org/whl/cpu"
|
url = "https://download.pytorch.org/whl/cpu"
|
||||||
|
|
||||||
if device == "cuda":
|
if device == "cuda":
|
||||||
url = "https://download.pytorch.org/whl/cu121"
|
url = "https://download.pytorch.org/whl/cu118"
|
||||||
optional_modules = "[xformers,onnx-cuda]"
|
optional_modules = "[xformers,onnx-cuda]"
|
||||||
if device == "cuda_and_dml":
|
if device == "cuda_and_dml":
|
||||||
url = "https://download.pytorch.org/whl/cu121"
|
url = "https://download.pytorch.org/whl/cu118"
|
||||||
optional_modules = "[xformers,onnx-directml]"
|
optional_modules = "[xformers,onnx-directml]"
|
||||||
|
|
||||||
# in all other cases, Torch wheels should be coming from PyPi as of Torch 1.13
|
# in all other cases, Torch wheels should be coming from PyPi as of Torch 1.13
|
||||||
|
@ -137,7 +137,7 @@ def dest_path(dest=None) -> Path:
|
|||||||
path_completer = PathCompleter(
|
path_completer = PathCompleter(
|
||||||
only_directories=True,
|
only_directories=True,
|
||||||
expanduser=True,
|
expanduser=True,
|
||||||
get_paths=lambda: [browse_start], # noqa: B023
|
get_paths=lambda: [browse_start],
|
||||||
# get_paths=lambda: [".."].extend(list(browse_start.iterdir()))
|
# get_paths=lambda: [".."].extend(list(browse_start.iterdir()))
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ def dest_path(dest=None) -> Path:
|
|||||||
completer=path_completer,
|
completer=path_completer,
|
||||||
default=str(browse_start) + os.sep,
|
default=str(browse_start) + os.sep,
|
||||||
vi_mode=True,
|
vi_mode=True,
|
||||||
complete_while_typing=True,
|
complete_while_typing=True
|
||||||
# Test that this is not needed on Windows
|
# Test that this is not needed on Windows
|
||||||
# complete_style=CompleteStyle.READLINE_LIKE,
|
# complete_style=CompleteStyle.READLINE_LIKE,
|
||||||
)
|
)
|
||||||
|
@ -4,7 +4,7 @@ Project homepage: https://github.com/invoke-ai/InvokeAI
|
|||||||
|
|
||||||
Preparations:
|
Preparations:
|
||||||
|
|
||||||
You will need to install Python 3.10 or higher for this installer
|
You will need to install Python 3.9 or higher for this installer
|
||||||
to work. Instructions are given here:
|
to work. Instructions are given here:
|
||||||
https://invoke-ai.github.io/InvokeAI/installation/INSTALL_AUTOMATED/
|
https://invoke-ai.github.io/InvokeAI/installation/INSTALL_AUTOMATED/
|
||||||
|
|
||||||
@ -14,15 +14,15 @@ Preparations:
|
|||||||
python --version
|
python --version
|
||||||
|
|
||||||
If all is well, it will print "Python 3.X.X", where the version number
|
If all is well, it will print "Python 3.X.X", where the version number
|
||||||
is at least 3.10.*, and not higher than 3.11.*.
|
is at least 3.9.*, and not higher than 3.11.*.
|
||||||
|
|
||||||
If this works, check the version of the Python package manager, pip:
|
If this works, check the version of the Python package manager, pip:
|
||||||
|
|
||||||
pip --version
|
pip --version
|
||||||
|
|
||||||
You should get a message that indicates that the pip package
|
You should get a message that indicates that the pip package
|
||||||
installer was derived from Python 3.10 or 3.11. For example:
|
installer was derived from Python 3.9 or 3.10. For example:
|
||||||
"pip 22.0.1 from /usr/bin/pip (python 3.10)"
|
"pip 22.3.1 from /usr/bin/pip (python 3.9)"
|
||||||
|
|
||||||
Long Paths on Windows:
|
Long Paths on Windows:
|
||||||
|
|
||||||
|
@ -1,71 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
BCYAN="\e[1;36m"
|
|
||||||
BYELLOW="\e[1;33m"
|
|
||||||
BGREEN="\e[1;32m"
|
|
||||||
BRED="\e[1;31m"
|
|
||||||
RED="\e[31m"
|
|
||||||
RESET="\e[0m"
|
|
||||||
|
|
||||||
function does_tag_exist {
|
|
||||||
git rev-parse --quiet --verify "refs/tags/$1" >/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
function git_show_ref {
|
|
||||||
git show-ref --dereference $1 --abbrev 7
|
|
||||||
}
|
|
||||||
|
|
||||||
function git_show {
|
|
||||||
git show -s --format='%h %s' $1
|
|
||||||
}
|
|
||||||
|
|
||||||
VERSION=$(
|
|
||||||
cd ..
|
|
||||||
python -c "from invokeai.version import __version__ as version; print(version)"
|
|
||||||
)
|
|
||||||
PATCH=""
|
|
||||||
MAJOR_VERSION=$(echo $VERSION | sed 's/\..*$//')
|
|
||||||
VERSION="v${VERSION}${PATCH}"
|
|
||||||
LATEST_TAG="v${MAJOR_VERSION}-latest"
|
|
||||||
|
|
||||||
if does_tag_exist $VERSION; then
|
|
||||||
echo -e "${BCYAN}${VERSION}${RESET} already exists:"
|
|
||||||
git_show_ref tags/$VERSION
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
if does_tag_exist $LATEST_TAG; then
|
|
||||||
echo -e "${BCYAN}${LATEST_TAG}${RESET} already exists:"
|
|
||||||
git_show_ref tags/$LATEST_TAG
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "${BGREEN}HEAD${RESET}:"
|
|
||||||
git_show
|
|
||||||
echo
|
|
||||||
|
|
||||||
echo -e -n "Create tags ${BCYAN}${VERSION}${RESET} and ${BCYAN}${LATEST_TAG}${RESET} @ ${BGREEN}HEAD${RESET}, ${RED}deleting existing tags on remote${RESET}? "
|
|
||||||
read -e -p 'y/n [n]: ' input
|
|
||||||
RESPONSE=${input:='n'}
|
|
||||||
if [ "$RESPONSE" == 'y' ]; then
|
|
||||||
echo
|
|
||||||
echo -e "Deleting ${BCYAN}${VERSION}${RESET} tag on remote..."
|
|
||||||
git push --delete origin $VERSION
|
|
||||||
|
|
||||||
echo -e "Tagging ${BGREEN}HEAD${RESET} with ${BCYAN}${VERSION}${RESET} locally..."
|
|
||||||
if ! git tag -fa $VERSION; then
|
|
||||||
echo "Existing/invalid tag"
|
|
||||||
exit -1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "Deleting ${BCYAN}${LATEST_TAG}${RESET} tag on remote..."
|
|
||||||
git push --delete origin $LATEST_TAG
|
|
||||||
|
|
||||||
echo -e "Tagging ${BGREEN}HEAD${RESET} with ${BCYAN}${LATEST_TAG}${RESET} locally..."
|
|
||||||
git tag -fa $LATEST_TAG
|
|
||||||
|
|
||||||
echo -e "Pushing updated tags to remote..."
|
|
||||||
git push origin --tags
|
|
||||||
fi
|
|
||||||
exit 0
|
|
@ -9,37 +9,41 @@ set INVOKEAI_ROOT=.
|
|||||||
:start
|
:start
|
||||||
echo Desired action:
|
echo Desired action:
|
||||||
echo 1. Generate images with the browser-based interface
|
echo 1. Generate images with the browser-based interface
|
||||||
echo 2. Run textual inversion training
|
echo 2. Explore InvokeAI nodes using a command-line interface
|
||||||
echo 3. Merge models (diffusers type only)
|
echo 3. Run textual inversion training
|
||||||
echo 4. Download and install models
|
echo 4. Merge models (diffusers type only)
|
||||||
echo 5. Change InvokeAI startup options
|
echo 5. Download and install models
|
||||||
echo 6. Re-run the configure script to fix a broken install or to complete a major upgrade
|
echo 6. Change InvokeAI startup options
|
||||||
echo 7. Open the developer console
|
echo 7. Re-run the configure script to fix a broken install or to complete a major upgrade
|
||||||
echo 8. Update InvokeAI
|
echo 8. Open the developer console
|
||||||
echo 9. Run the InvokeAI image database maintenance script
|
echo 9. Update InvokeAI
|
||||||
echo 10. Command-line help
|
echo 10. Run the InvokeAI image database maintenance script
|
||||||
|
echo 11. Command-line help
|
||||||
echo Q - Quit
|
echo Q - Quit
|
||||||
set /P choice="Please enter 1-10, Q: [1] "
|
set /P choice="Please enter 1-11, Q: [1] "
|
||||||
if not defined choice set choice=1
|
if not defined choice set choice=1
|
||||||
IF /I "%choice%" == "1" (
|
IF /I "%choice%" == "1" (
|
||||||
echo Starting the InvokeAI browser-based UI..
|
echo Starting the InvokeAI browser-based UI..
|
||||||
python .venv\Scripts\invokeai-web.exe %*
|
python .venv\Scripts\invokeai-web.exe %*
|
||||||
) ELSE IF /I "%choice%" == "2" (
|
) ELSE IF /I "%choice%" == "2" (
|
||||||
|
echo Starting the InvokeAI command-line..
|
||||||
|
python .venv\Scripts\invokeai.exe %*
|
||||||
|
) ELSE IF /I "%choice%" == "3" (
|
||||||
echo Starting textual inversion training..
|
echo Starting textual inversion training..
|
||||||
python .venv\Scripts\invokeai-ti.exe --gui
|
python .venv\Scripts\invokeai-ti.exe --gui
|
||||||
) ELSE IF /I "%choice%" == "3" (
|
) ELSE IF /I "%choice%" == "4" (
|
||||||
echo Starting model merging script..
|
echo Starting model merging script..
|
||||||
python .venv\Scripts\invokeai-merge.exe --gui
|
python .venv\Scripts\invokeai-merge.exe --gui
|
||||||
) ELSE IF /I "%choice%" == "4" (
|
) ELSE IF /I "%choice%" == "5" (
|
||||||
echo Running invokeai-model-install...
|
echo Running invokeai-model-install...
|
||||||
python .venv\Scripts\invokeai-model-install.exe
|
python .venv\Scripts\invokeai-model-install.exe
|
||||||
) ELSE IF /I "%choice%" == "5" (
|
|
||||||
echo Running invokeai-configure...
|
|
||||||
python .venv\Scripts\invokeai-configure.exe --skip-sd-weight --skip-support-models
|
|
||||||
) ELSE IF /I "%choice%" == "6" (
|
) ELSE IF /I "%choice%" == "6" (
|
||||||
echo Running invokeai-configure...
|
echo Running invokeai-configure...
|
||||||
python .venv\Scripts\invokeai-configure.exe --yes --skip-sd-weight
|
python .venv\Scripts\invokeai-configure.exe --skip-sd-weight --skip-support-models
|
||||||
) ELSE IF /I "%choice%" == "7" (
|
) ELSE IF /I "%choice%" == "7" (
|
||||||
|
echo Running invokeai-configure...
|
||||||
|
python .venv\Scripts\invokeai-configure.exe --yes --skip-sd-weight
|
||||||
|
) ELSE IF /I "%choice%" == "8" (
|
||||||
echo Developer Console
|
echo Developer Console
|
||||||
echo Python command is:
|
echo Python command is:
|
||||||
where python
|
where python
|
||||||
@ -51,13 +55,13 @@ IF /I "%choice%" == "1" (
|
|||||||
echo *************************
|
echo *************************
|
||||||
echo *** Type `exit` to quit this shell and deactivate the Python virtual environment ***
|
echo *** Type `exit` to quit this shell and deactivate the Python virtual environment ***
|
||||||
call cmd /k
|
call cmd /k
|
||||||
) ELSE IF /I "%choice%" == "8" (
|
) ELSE IF /I "%choice%" == "9" (
|
||||||
echo Running invokeai-update...
|
echo Running invokeai-update...
|
||||||
python -m invokeai.frontend.install.invokeai_update
|
python -m invokeai.frontend.install.invokeai_update
|
||||||
) ELSE IF /I "%choice%" == "9" (
|
) ELSE IF /I "%choice%" == "10" (
|
||||||
echo Running the db maintenance script...
|
echo Running the db maintenance script...
|
||||||
python .venv\Scripts\invokeai-db-maintenance.exe
|
python .venv\Scripts\invokeai-db-maintenance.exe
|
||||||
) ELSE IF /I "%choice%" == "10" (
|
) ELSE IF /I "%choice%" == "11" (
|
||||||
echo Displaying command line help...
|
echo Displaying command line help...
|
||||||
python .venv\Scripts\invokeai-web.exe --help %*
|
python .venv\Scripts\invokeai-web.exe --help %*
|
||||||
pause
|
pause
|
||||||
|
@ -58,47 +58,52 @@ do_choice() {
|
|||||||
invokeai-web $PARAMS
|
invokeai-web $PARAMS
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
|
clear
|
||||||
|
printf "Explore InvokeAI nodes using a command-line interface\n"
|
||||||
|
invokeai $PARAMS
|
||||||
|
;;
|
||||||
|
3)
|
||||||
clear
|
clear
|
||||||
printf "Textual inversion training\n"
|
printf "Textual inversion training\n"
|
||||||
invokeai-ti --gui $PARAMS
|
invokeai-ti --gui $PARAMS
|
||||||
;;
|
;;
|
||||||
3)
|
4)
|
||||||
clear
|
clear
|
||||||
printf "Merge models (diffusers type only)\n"
|
printf "Merge models (diffusers type only)\n"
|
||||||
invokeai-merge --gui $PARAMS
|
invokeai-merge --gui $PARAMS
|
||||||
;;
|
;;
|
||||||
4)
|
5)
|
||||||
clear
|
clear
|
||||||
printf "Download and install models\n"
|
printf "Download and install models\n"
|
||||||
invokeai-model-install --root ${INVOKEAI_ROOT}
|
invokeai-model-install --root ${INVOKEAI_ROOT}
|
||||||
;;
|
;;
|
||||||
5)
|
6)
|
||||||
clear
|
clear
|
||||||
printf "Change InvokeAI startup options\n"
|
printf "Change InvokeAI startup options\n"
|
||||||
invokeai-configure --root ${INVOKEAI_ROOT} --skip-sd-weights --skip-support-models
|
invokeai-configure --root ${INVOKEAI_ROOT} --skip-sd-weights --skip-support-models
|
||||||
;;
|
;;
|
||||||
6)
|
7)
|
||||||
clear
|
clear
|
||||||
printf "Re-run the configure script to fix a broken install or to complete a major upgrade\n"
|
printf "Re-run the configure script to fix a broken install or to complete a major upgrade\n"
|
||||||
invokeai-configure --root ${INVOKEAI_ROOT} --yes --default_only --skip-sd-weights
|
invokeai-configure --root ${INVOKEAI_ROOT} --yes --default_only --skip-sd-weights
|
||||||
;;
|
;;
|
||||||
7)
|
8)
|
||||||
clear
|
clear
|
||||||
printf "Open the developer console\n"
|
printf "Open the developer console\n"
|
||||||
file_name=$(basename "${BASH_SOURCE[0]}")
|
file_name=$(basename "${BASH_SOURCE[0]}")
|
||||||
bash --init-file "$file_name"
|
bash --init-file "$file_name"
|
||||||
;;
|
;;
|
||||||
8)
|
9)
|
||||||
clear
|
clear
|
||||||
printf "Update InvokeAI\n"
|
printf "Update InvokeAI\n"
|
||||||
python -m invokeai.frontend.install.invokeai_update
|
python -m invokeai.frontend.install.invokeai_update
|
||||||
;;
|
;;
|
||||||
9)
|
10)
|
||||||
clear
|
clear
|
||||||
printf "Running the db maintenance script\n"
|
printf "Running the db maintenance script\n"
|
||||||
invokeai-db-maintenance --root ${INVOKEAI_ROOT}
|
invokeai-db-maintenance --root ${INVOKEAI_ROOT}
|
||||||
;;
|
;;
|
||||||
10)
|
11)
|
||||||
clear
|
clear
|
||||||
printf "Command-line help\n"
|
printf "Command-line help\n"
|
||||||
invokeai-web --help
|
invokeai-web --help
|
||||||
@ -116,15 +121,16 @@ do_choice() {
|
|||||||
do_dialog() {
|
do_dialog() {
|
||||||
options=(
|
options=(
|
||||||
1 "Generate images with a browser-based interface"
|
1 "Generate images with a browser-based interface"
|
||||||
2 "Textual inversion training"
|
2 "Explore InvokeAI nodes using a command-line interface"
|
||||||
3 "Merge models (diffusers type only)"
|
3 "Textual inversion training"
|
||||||
4 "Download and install models"
|
4 "Merge models (diffusers type only)"
|
||||||
5 "Change InvokeAI startup options"
|
5 "Download and install models"
|
||||||
6 "Re-run the configure script to fix a broken install or to complete a major upgrade"
|
6 "Change InvokeAI startup options"
|
||||||
7 "Open the developer console"
|
7 "Re-run the configure script to fix a broken install or to complete a major upgrade"
|
||||||
8 "Update InvokeAI"
|
8 "Open the developer console"
|
||||||
9 "Run the InvokeAI image database maintenance script"
|
9 "Update InvokeAI"
|
||||||
10 "Command-line help"
|
10 "Run the InvokeAI image database maintenance script"
|
||||||
|
11 "Command-line help"
|
||||||
)
|
)
|
||||||
|
|
||||||
choice=$(dialog --clear \
|
choice=$(dialog --clear \
|
||||||
@ -149,17 +155,18 @@ do_line_input() {
|
|||||||
printf " ** For a more attractive experience, please install the 'dialog' utility using your package manager. **\n\n"
|
printf " ** For a more attractive experience, please install the 'dialog' utility using your package manager. **\n\n"
|
||||||
printf "What would you like to do?\n"
|
printf "What would you like to do?\n"
|
||||||
printf "1: Generate images using the browser-based interface\n"
|
printf "1: Generate images using the browser-based interface\n"
|
||||||
printf "2: Run textual inversion training\n"
|
printf "2: Explore InvokeAI nodes using the command-line interface\n"
|
||||||
printf "3: Merge models (diffusers type only)\n"
|
printf "3: Run textual inversion training\n"
|
||||||
printf "4: Download and install models\n"
|
printf "4: Merge models (diffusers type only)\n"
|
||||||
printf "5: Change InvokeAI startup options\n"
|
printf "5: Download and install models\n"
|
||||||
printf "6: Re-run the configure script to fix a broken install\n"
|
printf "6: Change InvokeAI startup options\n"
|
||||||
printf "7: Open the developer console\n"
|
printf "7: Re-run the configure script to fix a broken install\n"
|
||||||
printf "8: Update InvokeAI\n"
|
printf "8: Open the developer console\n"
|
||||||
printf "9: Run the InvokeAI image database maintenance script\n"
|
printf "9: Update InvokeAI\n"
|
||||||
printf "10: Command-line help\n"
|
printf "10: Run the InvokeAI image database maintenance script\n"
|
||||||
|
printf "11: Command-line help\n"
|
||||||
printf "Q: Quit\n\n"
|
printf "Q: Quit\n\n"
|
||||||
read -p "Please enter 1-10, Q: [1] " yn
|
read -p "Please enter 1-11, Q: [1] " yn
|
||||||
choice=${yn:='1'}
|
choice=${yn:='1'}
|
||||||
do_choice $choice
|
do_choice $choice
|
||||||
clear
|
clear
|
||||||
|
@ -1,38 +1,35 @@
|
|||||||
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654)
|
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654)
|
||||||
|
|
||||||
|
import sqlite3
|
||||||
from logging import Logger
|
from logging import Logger
|
||||||
|
|
||||||
from invokeai.app.services.shared.sqlite.sqlite_util import init_db
|
from invokeai.app.services.board_image_record_storage import SqliteBoardImageRecordStorage
|
||||||
|
from invokeai.app.services.board_images import BoardImagesService, BoardImagesServiceDependencies
|
||||||
|
from invokeai.app.services.board_record_storage import SqliteBoardRecordStorage
|
||||||
|
from invokeai.app.services.boards import BoardService, BoardServiceDependencies
|
||||||
|
from invokeai.app.services.config import InvokeAIAppConfig
|
||||||
|
from invokeai.app.services.image_record_storage import SqliteImageRecordStorage
|
||||||
|
from invokeai.app.services.images import ImageService, ImageServiceDependencies
|
||||||
|
from invokeai.app.services.invocation_cache.invocation_cache_memory import MemoryInvocationCache
|
||||||
|
from invokeai.app.services.resource_name import SimpleNameService
|
||||||
|
from invokeai.app.services.session_processor.session_processor_default import DefaultSessionProcessor
|
||||||
|
from invokeai.app.services.session_queue.session_queue_sqlite import SqliteSessionQueue
|
||||||
|
from invokeai.app.services.urls import LocalUrlService
|
||||||
from invokeai.backend.util.logging import InvokeAILogger
|
from invokeai.backend.util.logging import InvokeAILogger
|
||||||
from invokeai.version.invokeai_version import __version__
|
from invokeai.version.invokeai_version import __version__
|
||||||
|
|
||||||
from ..services.board_image_records.board_image_records_sqlite import SqliteBoardImageRecordStorage
|
from ..services.default_graphs import create_system_graphs
|
||||||
from ..services.board_images.board_images_default import BoardImagesService
|
from ..services.graph import GraphExecutionState, LibraryGraph
|
||||||
from ..services.board_records.board_records_sqlite import SqliteBoardRecordStorage
|
from ..services.image_file_storage import DiskImageFileStorage
|
||||||
from ..services.boards.boards_default import BoardService
|
from ..services.invocation_queue import MemoryInvocationQueue
|
||||||
from ..services.config import InvokeAIAppConfig
|
|
||||||
from ..services.download import DownloadQueueService
|
|
||||||
from ..services.image_files.image_files_disk import DiskImageFileStorage
|
|
||||||
from ..services.image_records.image_records_sqlite import SqliteImageRecordStorage
|
|
||||||
from ..services.images.images_default import ImageService
|
|
||||||
from ..services.invocation_cache.invocation_cache_memory import MemoryInvocationCache
|
|
||||||
from ..services.invocation_processor.invocation_processor_default import DefaultInvocationProcessor
|
|
||||||
from ..services.invocation_queue.invocation_queue_memory import MemoryInvocationQueue
|
|
||||||
from ..services.invocation_services import InvocationServices
|
from ..services.invocation_services import InvocationServices
|
||||||
from ..services.invocation_stats.invocation_stats_default import InvocationStatsService
|
from ..services.invocation_stats import InvocationStatsService
|
||||||
from ..services.invoker import Invoker
|
from ..services.invoker import Invoker
|
||||||
from ..services.item_storage.item_storage_sqlite import SqliteItemStorage
|
from ..services.latent_storage import DiskLatentsStorage, ForwardCacheLatentsStorage
|
||||||
from ..services.latents_storage.latents_storage_disk import DiskLatentsStorage
|
from ..services.model_manager_service import ModelManagerService
|
||||||
from ..services.latents_storage.latents_storage_forward_cache import ForwardCacheLatentsStorage
|
from ..services.processor import DefaultInvocationProcessor
|
||||||
from ..services.model_install import ModelInstallService
|
from ..services.sqlite import SqliteItemStorage
|
||||||
from ..services.model_manager.model_manager_default import ModelManagerService
|
from ..services.thread import lock
|
||||||
from ..services.model_records import ModelRecordServiceSQL
|
|
||||||
from ..services.names.names_default import SimpleNameService
|
|
||||||
from ..services.session_processor.session_processor_default import DefaultSessionProcessor
|
|
||||||
from ..services.session_queue.session_queue_sqlite import SqliteSessionQueue
|
|
||||||
from ..services.shared.graph import GraphExecutionState
|
|
||||||
from ..services.urls.urls_default import LocalUrlService
|
|
||||||
from ..services.workflow_records.workflow_records_sqlite import SqliteWorkflowRecordsStorage
|
|
||||||
from .events import FastAPIEventService
|
from .events import FastAPIEventService
|
||||||
|
|
||||||
|
|
||||||
@ -66,69 +63,100 @@ class ApiDependencies:
|
|||||||
logger.info(f"Root directory = {str(config.root_path)}")
|
logger.info(f"Root directory = {str(config.root_path)}")
|
||||||
logger.debug(f"Internet connectivity is {config.internet_available}")
|
logger.debug(f"Internet connectivity is {config.internet_available}")
|
||||||
|
|
||||||
output_folder = config.output_path
|
|
||||||
image_files = DiskImageFileStorage(f"{output_folder}/images")
|
|
||||||
|
|
||||||
db = init_db(config=config, logger=logger, image_files=image_files)
|
|
||||||
|
|
||||||
configuration = config
|
|
||||||
logger = logger
|
|
||||||
|
|
||||||
board_image_records = SqliteBoardImageRecordStorage(db=db)
|
|
||||||
board_images = BoardImagesService()
|
|
||||||
board_records = SqliteBoardRecordStorage(db=db)
|
|
||||||
boards = BoardService()
|
|
||||||
events = FastAPIEventService(event_handler_id)
|
events = FastAPIEventService(event_handler_id)
|
||||||
graph_execution_manager = SqliteItemStorage[GraphExecutionState](db=db, table_name="graph_executions")
|
|
||||||
image_records = SqliteImageRecordStorage(db=db)
|
output_folder = config.output_path
|
||||||
images = ImageService()
|
|
||||||
invocation_cache = MemoryInvocationCache(max_cache_size=config.node_cache_size)
|
# TODO: build a file/path manager?
|
||||||
latents = ForwardCacheLatentsStorage(DiskLatentsStorage(f"{output_folder}/latents"))
|
if config.use_memory_db:
|
||||||
model_manager = ModelManagerService(config, logger)
|
db_location = ":memory:"
|
||||||
model_record_service = ModelRecordServiceSQL(db=db)
|
else:
|
||||||
download_queue_service = DownloadQueueService(event_bus=events)
|
db_path = config.db_path
|
||||||
model_install_service = ModelInstallService(
|
db_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
app_config=config, record_store=model_record_service, event_bus=events
|
db_location = str(db_path)
|
||||||
|
|
||||||
|
logger.info(f"Using database at {db_location}")
|
||||||
|
db_conn = sqlite3.connect(db_location, check_same_thread=False) # TODO: figure out a better threading solution
|
||||||
|
|
||||||
|
if config.log_sql:
|
||||||
|
db_conn.set_trace_callback(print)
|
||||||
|
db_conn.execute("PRAGMA foreign_keys = ON;")
|
||||||
|
|
||||||
|
graph_execution_manager = SqliteItemStorage[GraphExecutionState](
|
||||||
|
conn=db_conn, table_name="graph_executions", lock=lock
|
||||||
)
|
)
|
||||||
names = SimpleNameService()
|
|
||||||
performance_statistics = InvocationStatsService()
|
|
||||||
processor = DefaultInvocationProcessor()
|
|
||||||
queue = MemoryInvocationQueue()
|
|
||||||
session_processor = DefaultSessionProcessor()
|
|
||||||
session_queue = SqliteSessionQueue(db=db)
|
|
||||||
urls = LocalUrlService()
|
urls = LocalUrlService()
|
||||||
workflow_records = SqliteWorkflowRecordsStorage(db=db)
|
image_record_storage = SqliteImageRecordStorage(conn=db_conn, lock=lock)
|
||||||
|
image_file_storage = DiskImageFileStorage(f"{output_folder}/images")
|
||||||
|
names = SimpleNameService()
|
||||||
|
latents = ForwardCacheLatentsStorage(DiskLatentsStorage(f"{output_folder}/latents"))
|
||||||
|
|
||||||
|
board_record_storage = SqliteBoardRecordStorage(conn=db_conn, lock=lock)
|
||||||
|
board_image_record_storage = SqliteBoardImageRecordStorage(conn=db_conn, lock=lock)
|
||||||
|
|
||||||
|
boards = BoardService(
|
||||||
|
services=BoardServiceDependencies(
|
||||||
|
board_image_record_storage=board_image_record_storage,
|
||||||
|
board_record_storage=board_record_storage,
|
||||||
|
image_record_storage=image_record_storage,
|
||||||
|
url=urls,
|
||||||
|
logger=logger,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
board_images = BoardImagesService(
|
||||||
|
services=BoardImagesServiceDependencies(
|
||||||
|
board_image_record_storage=board_image_record_storage,
|
||||||
|
board_record_storage=board_record_storage,
|
||||||
|
image_record_storage=image_record_storage,
|
||||||
|
url=urls,
|
||||||
|
logger=logger,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
images = ImageService(
|
||||||
|
services=ImageServiceDependencies(
|
||||||
|
board_image_record_storage=board_image_record_storage,
|
||||||
|
image_record_storage=image_record_storage,
|
||||||
|
image_file_storage=image_file_storage,
|
||||||
|
url=urls,
|
||||||
|
logger=logger,
|
||||||
|
names=names,
|
||||||
|
graph_execution_manager=graph_execution_manager,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
services = InvocationServices(
|
services = InvocationServices(
|
||||||
board_image_records=board_image_records,
|
model_manager=ModelManagerService(config, logger),
|
||||||
board_images=board_images,
|
|
||||||
board_records=board_records,
|
|
||||||
boards=boards,
|
|
||||||
configuration=configuration,
|
|
||||||
events=events,
|
events=events,
|
||||||
graph_execution_manager=graph_execution_manager,
|
|
||||||
image_files=image_files,
|
|
||||||
image_records=image_records,
|
|
||||||
images=images,
|
|
||||||
invocation_cache=invocation_cache,
|
|
||||||
latents=latents,
|
latents=latents,
|
||||||
|
images=images,
|
||||||
|
boards=boards,
|
||||||
|
board_images=board_images,
|
||||||
|
queue=MemoryInvocationQueue(),
|
||||||
|
graph_library=SqliteItemStorage[LibraryGraph](conn=db_conn, lock=lock, table_name="graphs"),
|
||||||
|
graph_execution_manager=graph_execution_manager,
|
||||||
|
processor=DefaultInvocationProcessor(),
|
||||||
|
configuration=config,
|
||||||
|
performance_statistics=InvocationStatsService(graph_execution_manager),
|
||||||
logger=logger,
|
logger=logger,
|
||||||
model_manager=model_manager,
|
session_queue=SqliteSessionQueue(conn=db_conn, lock=lock),
|
||||||
model_records=model_record_service,
|
session_processor=DefaultSessionProcessor(),
|
||||||
download_queue=download_queue_service,
|
invocation_cache=MemoryInvocationCache(max_cache_size=config.node_cache_size),
|
||||||
model_install=model_install_service,
|
|
||||||
names=names,
|
|
||||||
performance_statistics=performance_statistics,
|
|
||||||
processor=processor,
|
|
||||||
queue=queue,
|
|
||||||
session_processor=session_processor,
|
|
||||||
session_queue=session_queue,
|
|
||||||
urls=urls,
|
|
||||||
workflow_records=workflow_records,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
create_system_graphs(services.graph_library)
|
||||||
|
|
||||||
ApiDependencies.invoker = Invoker(services)
|
ApiDependencies.invoker = Invoker(services)
|
||||||
db.clean()
|
|
||||||
|
try:
|
||||||
|
lock.acquire()
|
||||||
|
db_conn.execute("VACUUM;")
|
||||||
|
db_conn.commit()
|
||||||
|
logger.info("Cleaned database")
|
||||||
|
finally:
|
||||||
|
lock.release()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def shutdown():
|
def shutdown():
|
||||||
|
@ -7,7 +7,7 @@ from typing import Any
|
|||||||
|
|
||||||
from fastapi_events.dispatcher import dispatch
|
from fastapi_events.dispatcher import dispatch
|
||||||
|
|
||||||
from ..services.events.events_base import EventServiceBase
|
from ..services.events import EventServiceBase
|
||||||
|
|
||||||
|
|
||||||
class FastAPIEventService(EventServiceBase):
|
class FastAPIEventService(EventServiceBase):
|
||||||
@ -28,7 +28,7 @@ class FastAPIEventService(EventServiceBase):
|
|||||||
self.__queue.put(None)
|
self.__queue.put(None)
|
||||||
|
|
||||||
def dispatch(self, event_name: str, payload: Any) -> None:
|
def dispatch(self, event_name: str, payload: Any) -> None:
|
||||||
self.__queue.put({"event_name": event_name, "payload": payload})
|
self.__queue.put(dict(event_name=event_name, payload=payload))
|
||||||
|
|
||||||
async def __dispatch_from_queue(self, stop_event: threading.Event):
|
async def __dispatch_from_queue(self, stop_event: threading.Event):
|
||||||
"""Get events on from the queue and dispatch them, from the correct thread"""
|
"""Get events on from the queue and dispatch them, from the correct thread"""
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
import typing
|
import typing
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from importlib.metadata import PackageNotFoundError, version
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from platform import python_version
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
import torch
|
|
||||||
from fastapi import Body
|
from fastapi import Body
|
||||||
from fastapi.routing import APIRouter
|
from fastapi.routing import APIRouter
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
@ -44,24 +40,6 @@ class AppVersion(BaseModel):
|
|||||||
version: str = Field(description="App version")
|
version: str = Field(description="App version")
|
||||||
|
|
||||||
|
|
||||||
class AppDependencyVersions(BaseModel):
|
|
||||||
"""App depencency Versions Response"""
|
|
||||||
|
|
||||||
accelerate: str = Field(description="accelerate version")
|
|
||||||
compel: str = Field(description="compel version")
|
|
||||||
cuda: Optional[str] = Field(description="CUDA version")
|
|
||||||
diffusers: str = Field(description="diffusers version")
|
|
||||||
numpy: str = Field(description="Numpy version")
|
|
||||||
opencv: str = Field(description="OpenCV version")
|
|
||||||
onnx: str = Field(description="ONNX version")
|
|
||||||
pillow: str = Field(description="Pillow (PIL) version")
|
|
||||||
python: str = Field(description="Python version")
|
|
||||||
torch: str = Field(description="PyTorch version")
|
|
||||||
torchvision: str = Field(description="PyTorch Vision version")
|
|
||||||
transformers: str = Field(description="transformers version")
|
|
||||||
xformers: Optional[str] = Field(description="xformers version")
|
|
||||||
|
|
||||||
|
|
||||||
class AppConfig(BaseModel):
|
class AppConfig(BaseModel):
|
||||||
"""App Config Response"""
|
"""App Config Response"""
|
||||||
|
|
||||||
@ -76,29 +54,6 @@ async def get_version() -> AppVersion:
|
|||||||
return AppVersion(version=__version__)
|
return AppVersion(version=__version__)
|
||||||
|
|
||||||
|
|
||||||
@app_router.get("/app_deps", operation_id="get_app_deps", status_code=200, response_model=AppDependencyVersions)
|
|
||||||
async def get_app_deps() -> AppDependencyVersions:
|
|
||||||
try:
|
|
||||||
xformers = version("xformers")
|
|
||||||
except PackageNotFoundError:
|
|
||||||
xformers = None
|
|
||||||
return AppDependencyVersions(
|
|
||||||
accelerate=version("accelerate"),
|
|
||||||
compel=version("compel"),
|
|
||||||
cuda=torch.version.cuda,
|
|
||||||
diffusers=version("diffusers"),
|
|
||||||
numpy=version("numpy"),
|
|
||||||
opencv=version("opencv-python"),
|
|
||||||
onnx=version("onnx"),
|
|
||||||
pillow=version("pillow"),
|
|
||||||
python=python_version(),
|
|
||||||
torch=torch.version.__version__,
|
|
||||||
torchvision=version("torchvision"),
|
|
||||||
transformers=version("transformers"),
|
|
||||||
xformers=xformers,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@app_router.get("/config", operation_id="get_config", status_code=200, response_model=AppConfig)
|
@app_router.get("/config", operation_id="get_config", status_code=200, response_model=AppConfig)
|
||||||
async def get_config() -> AppConfig:
|
async def get_config() -> AppConfig:
|
||||||
infill_methods = ["tile", "lama", "cv2"]
|
infill_methods = ["tile", "lama", "cv2"]
|
||||||
|
@ -4,9 +4,9 @@ from fastapi import Body, HTTPException, Path, Query
|
|||||||
from fastapi.routing import APIRouter
|
from fastapi.routing import APIRouter
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
from invokeai.app.services.board_records.board_records_common import BoardChanges
|
from invokeai.app.services.board_record_storage import BoardChanges
|
||||||
from invokeai.app.services.boards.boards_common import BoardDTO
|
from invokeai.app.services.image_record_storage import OffsetPaginatedResults
|
||||||
from invokeai.app.services.shared.pagination import OffsetPaginatedResults
|
from invokeai.app.services.models.board_record import BoardDTO
|
||||||
|
|
||||||
from ..dependencies import ApiDependencies
|
from ..dependencies import ApiDependencies
|
||||||
|
|
||||||
|
@ -1,111 +0,0 @@
|
|||||||
# Copyright (c) 2023 Lincoln D. Stein
|
|
||||||
"""FastAPI route for the download queue."""
|
|
||||||
|
|
||||||
from typing import List, Optional
|
|
||||||
|
|
||||||
from fastapi import Body, Path, Response
|
|
||||||
from fastapi.routing import APIRouter
|
|
||||||
from pydantic.networks import AnyHttpUrl
|
|
||||||
from starlette.exceptions import HTTPException
|
|
||||||
|
|
||||||
from invokeai.app.services.download import (
|
|
||||||
DownloadJob,
|
|
||||||
UnknownJobIDException,
|
|
||||||
)
|
|
||||||
|
|
||||||
from ..dependencies import ApiDependencies
|
|
||||||
|
|
||||||
download_queue_router = APIRouter(prefix="/v1/download_queue", tags=["download_queue"])
|
|
||||||
|
|
||||||
|
|
||||||
@download_queue_router.get(
|
|
||||||
"/",
|
|
||||||
operation_id="list_downloads",
|
|
||||||
)
|
|
||||||
async def list_downloads() -> List[DownloadJob]:
|
|
||||||
"""Get a list of active and inactive jobs."""
|
|
||||||
queue = ApiDependencies.invoker.services.download_queue
|
|
||||||
return queue.list_jobs()
|
|
||||||
|
|
||||||
|
|
||||||
@download_queue_router.patch(
|
|
||||||
"/",
|
|
||||||
operation_id="prune_downloads",
|
|
||||||
responses={
|
|
||||||
204: {"description": "All completed jobs have been pruned"},
|
|
||||||
400: {"description": "Bad request"},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
async def prune_downloads():
|
|
||||||
"""Prune completed and errored jobs."""
|
|
||||||
queue = ApiDependencies.invoker.services.download_queue
|
|
||||||
queue.prune_jobs()
|
|
||||||
return Response(status_code=204)
|
|
||||||
|
|
||||||
|
|
||||||
@download_queue_router.post(
|
|
||||||
"/i/",
|
|
||||||
operation_id="download",
|
|
||||||
)
|
|
||||||
async def download(
|
|
||||||
source: AnyHttpUrl = Body(description="download source"),
|
|
||||||
dest: str = Body(description="download destination"),
|
|
||||||
priority: int = Body(default=10, description="queue priority"),
|
|
||||||
access_token: Optional[str] = Body(default=None, description="token for authorization to download"),
|
|
||||||
) -> DownloadJob:
|
|
||||||
"""Download the source URL to the file or directory indicted in dest."""
|
|
||||||
queue = ApiDependencies.invoker.services.download_queue
|
|
||||||
return queue.download(source, dest, priority, access_token)
|
|
||||||
|
|
||||||
|
|
||||||
@download_queue_router.get(
|
|
||||||
"/i/{id}",
|
|
||||||
operation_id="get_download_job",
|
|
||||||
responses={
|
|
||||||
200: {"description": "Success"},
|
|
||||||
404: {"description": "The requested download JobID could not be found"},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
async def get_download_job(
|
|
||||||
id: int = Path(description="ID of the download job to fetch."),
|
|
||||||
) -> DownloadJob:
|
|
||||||
"""Get a download job using its ID."""
|
|
||||||
try:
|
|
||||||
job = ApiDependencies.invoker.services.download_queue.id_to_job(id)
|
|
||||||
return job
|
|
||||||
except UnknownJobIDException as e:
|
|
||||||
raise HTTPException(status_code=404, detail=str(e))
|
|
||||||
|
|
||||||
|
|
||||||
@download_queue_router.delete(
|
|
||||||
"/i/{id}",
|
|
||||||
operation_id="cancel_download_job",
|
|
||||||
responses={
|
|
||||||
204: {"description": "Job has been cancelled"},
|
|
||||||
404: {"description": "The requested download JobID could not be found"},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
async def cancel_download_job(
|
|
||||||
id: int = Path(description="ID of the download job to cancel."),
|
|
||||||
):
|
|
||||||
"""Cancel a download job using its ID."""
|
|
||||||
try:
|
|
||||||
queue = ApiDependencies.invoker.services.download_queue
|
|
||||||
job = queue.id_to_job(id)
|
|
||||||
queue.cancel_job(job)
|
|
||||||
return Response(status_code=204)
|
|
||||||
except UnknownJobIDException as e:
|
|
||||||
raise HTTPException(status_code=404, detail=str(e))
|
|
||||||
|
|
||||||
|
|
||||||
@download_queue_router.delete(
|
|
||||||
"/i",
|
|
||||||
operation_id="cancel_all_download_jobs",
|
|
||||||
responses={
|
|
||||||
204: {"description": "Download jobs have been cancelled"},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
async def cancel_all_download_jobs():
|
|
||||||
"""Cancel all download jobs."""
|
|
||||||
ApiDependencies.invoker.services.download_queue.cancel_all_jobs()
|
|
||||||
return Response(status_code=204)
|
|
@ -1,18 +1,16 @@
|
|||||||
import io
|
import io
|
||||||
import traceback
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from fastapi import Body, HTTPException, Path, Query, Request, Response, UploadFile
|
from fastapi import Body, HTTPException, Path, Query, Request, Response, UploadFile
|
||||||
from fastapi.responses import FileResponse
|
from fastapi.responses import FileResponse
|
||||||
from fastapi.routing import APIRouter
|
from fastapi.routing import APIRouter
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from pydantic import BaseModel, Field, ValidationError
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
from invokeai.app.invocations.baseinvocation import MetadataField, MetadataFieldValidator
|
from invokeai.app.invocations.metadata import ImageMetadata
|
||||||
from invokeai.app.services.image_records.image_records_common import ImageCategory, ImageRecordChanges, ResourceOrigin
|
from invokeai.app.models.image import ImageCategory, ResourceOrigin
|
||||||
from invokeai.app.services.images.images_common import ImageDTO, ImageUrlsDTO
|
from invokeai.app.services.image_record_storage import OffsetPaginatedResults
|
||||||
from invokeai.app.services.shared.pagination import OffsetPaginatedResults
|
from invokeai.app.services.models.image_record import ImageDTO, ImageRecordChanges, ImageUrlsDTO
|
||||||
from invokeai.app.services.workflow_records.workflow_records_common import WorkflowWithoutID, WorkflowWithoutIDValidator
|
|
||||||
|
|
||||||
from ..dependencies import ApiDependencies
|
from ..dependencies import ApiDependencies
|
||||||
|
|
||||||
@ -44,41 +42,20 @@ async def upload_image(
|
|||||||
crop_visible: Optional[bool] = Query(default=False, description="Whether to crop the image"),
|
crop_visible: Optional[bool] = Query(default=False, description="Whether to crop the image"),
|
||||||
) -> ImageDTO:
|
) -> ImageDTO:
|
||||||
"""Uploads an image"""
|
"""Uploads an image"""
|
||||||
if not file.content_type or not file.content_type.startswith("image"):
|
if not file.content_type.startswith("image"):
|
||||||
raise HTTPException(status_code=415, detail="Not an image")
|
raise HTTPException(status_code=415, detail="Not an image")
|
||||||
|
|
||||||
metadata = None
|
|
||||||
workflow = None
|
|
||||||
|
|
||||||
contents = await file.read()
|
contents = await file.read()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pil_image = Image.open(io.BytesIO(contents))
|
pil_image = Image.open(io.BytesIO(contents))
|
||||||
if crop_visible:
|
if crop_visible:
|
||||||
bbox = pil_image.getbbox()
|
bbox = pil_image.getbbox()
|
||||||
pil_image = pil_image.crop(bbox)
|
pil_image = pil_image.crop(bbox)
|
||||||
except Exception:
|
except Exception:
|
||||||
ApiDependencies.invoker.services.logger.error(traceback.format_exc())
|
# Error opening the image
|
||||||
raise HTTPException(status_code=415, detail="Failed to read image")
|
raise HTTPException(status_code=415, detail="Failed to read image")
|
||||||
|
|
||||||
# TODO: retain non-invokeai metadata on upload?
|
|
||||||
# attempt to parse metadata from image
|
|
||||||
metadata_raw = pil_image.info.get("invokeai_metadata", None)
|
|
||||||
if metadata_raw:
|
|
||||||
try:
|
|
||||||
metadata = MetadataFieldValidator.validate_json(metadata_raw)
|
|
||||||
except ValidationError:
|
|
||||||
ApiDependencies.invoker.services.logger.warn("Failed to parse metadata for uploaded image")
|
|
||||||
pass
|
|
||||||
|
|
||||||
# attempt to parse workflow from image
|
|
||||||
workflow_raw = pil_image.info.get("invokeai_workflow", None)
|
|
||||||
if workflow_raw is not None:
|
|
||||||
try:
|
|
||||||
workflow = WorkflowWithoutIDValidator.validate_json(workflow_raw)
|
|
||||||
except ValidationError:
|
|
||||||
ApiDependencies.invoker.services.logger.warn("Failed to parse metadata for uploaded image")
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
image_dto = ApiDependencies.invoker.services.images.create(
|
image_dto = ApiDependencies.invoker.services.images.create(
|
||||||
image=pil_image,
|
image=pil_image,
|
||||||
@ -86,8 +63,6 @@ async def upload_image(
|
|||||||
image_category=image_category,
|
image_category=image_category,
|
||||||
session_id=session_id,
|
session_id=session_id,
|
||||||
board_id=board_id,
|
board_id=board_id,
|
||||||
metadata=metadata,
|
|
||||||
workflow=workflow,
|
|
||||||
is_intermediate=is_intermediate,
|
is_intermediate=is_intermediate,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -96,7 +71,6 @@ async def upload_image(
|
|||||||
|
|
||||||
return image_dto
|
return image_dto
|
||||||
except Exception:
|
except Exception:
|
||||||
ApiDependencies.invoker.services.logger.error(traceback.format_exc())
|
|
||||||
raise HTTPException(status_code=500, detail="Failed to create image")
|
raise HTTPException(status_code=500, detail="Failed to create image")
|
||||||
|
|
||||||
|
|
||||||
@ -113,7 +87,7 @@ async def delete_image(
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@images_router.delete("/intermediates", operation_id="clear_intermediates")
|
@images_router.post("/clear-intermediates", operation_id="clear_intermediates")
|
||||||
async def clear_intermediates() -> int:
|
async def clear_intermediates() -> int:
|
||||||
"""Clears all intermediates"""
|
"""Clears all intermediates"""
|
||||||
|
|
||||||
@ -125,17 +99,6 @@ async def clear_intermediates() -> int:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@images_router.get("/intermediates", operation_id="get_intermediates_count")
|
|
||||||
async def get_intermediates_count() -> int:
|
|
||||||
"""Gets the count of intermediate images"""
|
|
||||||
|
|
||||||
try:
|
|
||||||
return ApiDependencies.invoker.services.images.get_intermediates_count()
|
|
||||||
except Exception:
|
|
||||||
raise HTTPException(status_code=500, detail="Failed to get intermediates")
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@images_router.patch(
|
@images_router.patch(
|
||||||
"/i/{image_name}",
|
"/i/{image_name}",
|
||||||
operation_id="update_image",
|
operation_id="update_image",
|
||||||
@ -172,11 +135,11 @@ async def get_image_dto(
|
|||||||
@images_router.get(
|
@images_router.get(
|
||||||
"/i/{image_name}/metadata",
|
"/i/{image_name}/metadata",
|
||||||
operation_id="get_image_metadata",
|
operation_id="get_image_metadata",
|
||||||
response_model=Optional[MetadataField],
|
response_model=ImageMetadata,
|
||||||
)
|
)
|
||||||
async def get_image_metadata(
|
async def get_image_metadata(
|
||||||
image_name: str = Path(description="The name of image to get"),
|
image_name: str = Path(description="The name of image to get"),
|
||||||
) -> Optional[MetadataField]:
|
) -> ImageMetadata:
|
||||||
"""Gets an image's metadata"""
|
"""Gets an image's metadata"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -185,18 +148,6 @@ async def get_image_metadata(
|
|||||||
raise HTTPException(status_code=404)
|
raise HTTPException(status_code=404)
|
||||||
|
|
||||||
|
|
||||||
@images_router.get(
|
|
||||||
"/i/{image_name}/workflow", operation_id="get_image_workflow", response_model=Optional[WorkflowWithoutID]
|
|
||||||
)
|
|
||||||
async def get_image_workflow(
|
|
||||||
image_name: str = Path(description="The name of image whose workflow to get"),
|
|
||||||
) -> Optional[WorkflowWithoutID]:
|
|
||||||
try:
|
|
||||||
return ApiDependencies.invoker.services.images.get_workflow(image_name)
|
|
||||||
except Exception:
|
|
||||||
raise HTTPException(status_code=404)
|
|
||||||
|
|
||||||
|
|
||||||
@images_router.api_route(
|
@images_router.api_route(
|
||||||
"/i/{image_name}/full",
|
"/i/{image_name}/full",
|
||||||
methods=["GET", "HEAD"],
|
methods=["GET", "HEAD"],
|
||||||
|
@ -1,322 +0,0 @@
|
|||||||
# Copyright (c) 2023 Lincoln D. Stein
|
|
||||||
"""FastAPI route for model configuration records."""
|
|
||||||
|
|
||||||
|
|
||||||
from hashlib import sha1
|
|
||||||
from random import randbytes
|
|
||||||
from typing import Any, Dict, List, Optional
|
|
||||||
|
|
||||||
from fastapi import Body, Path, Query, Response
|
|
||||||
from fastapi.routing import APIRouter
|
|
||||||
from pydantic import BaseModel, ConfigDict
|
|
||||||
from starlette.exceptions import HTTPException
|
|
||||||
from typing_extensions import Annotated
|
|
||||||
|
|
||||||
from invokeai.app.services.model_install import ModelInstallJob, ModelSource
|
|
||||||
from invokeai.app.services.model_records import (
|
|
||||||
DuplicateModelException,
|
|
||||||
InvalidModelException,
|
|
||||||
UnknownModelException,
|
|
||||||
)
|
|
||||||
from invokeai.backend.model_manager.config import (
|
|
||||||
AnyModelConfig,
|
|
||||||
BaseModelType,
|
|
||||||
ModelType,
|
|
||||||
)
|
|
||||||
|
|
||||||
from ..dependencies import ApiDependencies
|
|
||||||
|
|
||||||
model_records_router = APIRouter(prefix="/v1/model/record", tags=["model_manager_v2_unstable"])
|
|
||||||
|
|
||||||
|
|
||||||
class ModelsList(BaseModel):
|
|
||||||
"""Return list of configs."""
|
|
||||||
|
|
||||||
models: list[AnyModelConfig]
|
|
||||||
|
|
||||||
model_config = ConfigDict(use_enum_values=True)
|
|
||||||
|
|
||||||
|
|
||||||
@model_records_router.get(
|
|
||||||
"/",
|
|
||||||
operation_id="list_model_records",
|
|
||||||
)
|
|
||||||
async def list_model_records(
|
|
||||||
base_models: Optional[List[BaseModelType]] = Query(default=None, description="Base models to include"),
|
|
||||||
model_type: Optional[ModelType] = Query(default=None, description="The type of model to get"),
|
|
||||||
model_name: Optional[str] = Query(default=None, description="Exact match on the name of the model"),
|
|
||||||
model_format: Optional[str] = Query(
|
|
||||||
default=None, description="Exact match on the format of the model (e.g. 'diffusers')"
|
|
||||||
),
|
|
||||||
) -> ModelsList:
|
|
||||||
"""Get a list of models."""
|
|
||||||
record_store = ApiDependencies.invoker.services.model_records
|
|
||||||
found_models: list[AnyModelConfig] = []
|
|
||||||
if base_models:
|
|
||||||
for base_model in base_models:
|
|
||||||
found_models.extend(
|
|
||||||
record_store.search_by_attr(
|
|
||||||
base_model=base_model, model_type=model_type, model_name=model_name, model_format=model_format
|
|
||||||
)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
found_models.extend(
|
|
||||||
record_store.search_by_attr(model_type=model_type, model_name=model_name, model_format=model_format)
|
|
||||||
)
|
|
||||||
return ModelsList(models=found_models)
|
|
||||||
|
|
||||||
|
|
||||||
@model_records_router.get(
|
|
||||||
"/i/{key}",
|
|
||||||
operation_id="get_model_record",
|
|
||||||
responses={
|
|
||||||
200: {"description": "Success"},
|
|
||||||
400: {"description": "Bad request"},
|
|
||||||
404: {"description": "The model could not be found"},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
async def get_model_record(
|
|
||||||
key: str = Path(description="Key of the model record to fetch."),
|
|
||||||
) -> AnyModelConfig:
|
|
||||||
"""Get a model record"""
|
|
||||||
record_store = ApiDependencies.invoker.services.model_records
|
|
||||||
try:
|
|
||||||
return record_store.get_model(key)
|
|
||||||
except UnknownModelException as e:
|
|
||||||
raise HTTPException(status_code=404, detail=str(e))
|
|
||||||
|
|
||||||
|
|
||||||
@model_records_router.patch(
|
|
||||||
"/i/{key}",
|
|
||||||
operation_id="update_model_record",
|
|
||||||
responses={
|
|
||||||
200: {"description": "The model was updated successfully"},
|
|
||||||
400: {"description": "Bad request"},
|
|
||||||
404: {"description": "The model could not be found"},
|
|
||||||
409: {"description": "There is already a model corresponding to the new name"},
|
|
||||||
},
|
|
||||||
status_code=200,
|
|
||||||
response_model=AnyModelConfig,
|
|
||||||
)
|
|
||||||
async def update_model_record(
|
|
||||||
key: Annotated[str, Path(description="Unique key of model")],
|
|
||||||
info: Annotated[AnyModelConfig, Body(description="Model config", discriminator="type")],
|
|
||||||
) -> AnyModelConfig:
|
|
||||||
"""Update model contents with a new config. If the model name or base fields are changed, then the model is renamed."""
|
|
||||||
logger = ApiDependencies.invoker.services.logger
|
|
||||||
record_store = ApiDependencies.invoker.services.model_records
|
|
||||||
try:
|
|
||||||
model_response = record_store.update_model(key, config=info)
|
|
||||||
logger.info(f"Updated model: {key}")
|
|
||||||
except UnknownModelException as e:
|
|
||||||
raise HTTPException(status_code=404, detail=str(e))
|
|
||||||
except ValueError as e:
|
|
||||||
logger.error(str(e))
|
|
||||||
raise HTTPException(status_code=409, detail=str(e))
|
|
||||||
return model_response
|
|
||||||
|
|
||||||
|
|
||||||
@model_records_router.delete(
|
|
||||||
"/i/{key}",
|
|
||||||
operation_id="del_model_record",
|
|
||||||
responses={
|
|
||||||
204: {"description": "Model deleted successfully"},
|
|
||||||
404: {"description": "Model not found"},
|
|
||||||
},
|
|
||||||
status_code=204,
|
|
||||||
)
|
|
||||||
async def del_model_record(
|
|
||||||
key: str = Path(description="Unique key of model to remove from model registry."),
|
|
||||||
) -> Response:
|
|
||||||
"""
|
|
||||||
Delete model record from database.
|
|
||||||
|
|
||||||
The configuration record will be removed. The corresponding weights files will be
|
|
||||||
deleted as well if they reside within the InvokeAI "models" directory.
|
|
||||||
"""
|
|
||||||
logger = ApiDependencies.invoker.services.logger
|
|
||||||
|
|
||||||
try:
|
|
||||||
installer = ApiDependencies.invoker.services.model_install
|
|
||||||
installer.delete(key)
|
|
||||||
logger.info(f"Deleted model: {key}")
|
|
||||||
return Response(status_code=204)
|
|
||||||
except UnknownModelException as e:
|
|
||||||
logger.error(str(e))
|
|
||||||
raise HTTPException(status_code=404, detail=str(e))
|
|
||||||
|
|
||||||
|
|
||||||
@model_records_router.post(
|
|
||||||
"/i/",
|
|
||||||
operation_id="add_model_record",
|
|
||||||
responses={
|
|
||||||
201: {"description": "The model added successfully"},
|
|
||||||
409: {"description": "There is already a model corresponding to this path or repo_id"},
|
|
||||||
415: {"description": "Unrecognized file/folder format"},
|
|
||||||
},
|
|
||||||
status_code=201,
|
|
||||||
)
|
|
||||||
async def add_model_record(
|
|
||||||
config: Annotated[AnyModelConfig, Body(description="Model config", discriminator="type")],
|
|
||||||
) -> AnyModelConfig:
|
|
||||||
"""
|
|
||||||
Add a model using the configuration information appropriate for its type.
|
|
||||||
"""
|
|
||||||
logger = ApiDependencies.invoker.services.logger
|
|
||||||
record_store = ApiDependencies.invoker.services.model_records
|
|
||||||
if config.key == "<NOKEY>":
|
|
||||||
config.key = sha1(randbytes(100)).hexdigest()
|
|
||||||
logger.info(f"Created model {config.key} for {config.name}")
|
|
||||||
try:
|
|
||||||
record_store.add_model(config.key, config)
|
|
||||||
except DuplicateModelException as e:
|
|
||||||
logger.error(str(e))
|
|
||||||
raise HTTPException(status_code=409, detail=str(e))
|
|
||||||
except InvalidModelException as e:
|
|
||||||
logger.error(str(e))
|
|
||||||
raise HTTPException(status_code=415)
|
|
||||||
|
|
||||||
# now fetch it out
|
|
||||||
return record_store.get_model(config.key)
|
|
||||||
|
|
||||||
|
|
||||||
@model_records_router.post(
|
|
||||||
"/import",
|
|
||||||
operation_id="import_model_record",
|
|
||||||
responses={
|
|
||||||
201: {"description": "The model imported successfully"},
|
|
||||||
415: {"description": "Unrecognized file/folder format"},
|
|
||||||
424: {"description": "The model appeared to import successfully, but could not be found in the model manager"},
|
|
||||||
409: {"description": "There is already a model corresponding to this path or repo_id"},
|
|
||||||
},
|
|
||||||
status_code=201,
|
|
||||||
)
|
|
||||||
async def import_model(
|
|
||||||
source: ModelSource,
|
|
||||||
config: Optional[Dict[str, Any]] = Body(
|
|
||||||
description="Dict of fields that override auto-probed values in the model config record, such as name, description and prediction_type ",
|
|
||||||
default=None,
|
|
||||||
),
|
|
||||||
) -> ModelInstallJob:
|
|
||||||
"""Add a model using its local path, repo_id, or remote URL.
|
|
||||||
|
|
||||||
Models will be downloaded, probed, configured and installed in a
|
|
||||||
series of background threads. The return object has `status` attribute
|
|
||||||
that can be used to monitor progress.
|
|
||||||
|
|
||||||
The source object is a discriminated Union of LocalModelSource,
|
|
||||||
HFModelSource and URLModelSource. Set the "type" field to the
|
|
||||||
appropriate value:
|
|
||||||
|
|
||||||
* To install a local path using LocalModelSource, pass a source of form:
|
|
||||||
`{
|
|
||||||
"type": "local",
|
|
||||||
"path": "/path/to/model",
|
|
||||||
"inplace": false
|
|
||||||
}`
|
|
||||||
The "inplace" flag, if true, will register the model in place in its
|
|
||||||
current filesystem location. Otherwise, the model will be copied
|
|
||||||
into the InvokeAI models directory.
|
|
||||||
|
|
||||||
* To install a HuggingFace repo_id using HFModelSource, pass a source of form:
|
|
||||||
`{
|
|
||||||
"type": "hf",
|
|
||||||
"repo_id": "stabilityai/stable-diffusion-2.0",
|
|
||||||
"variant": "fp16",
|
|
||||||
"subfolder": "vae",
|
|
||||||
"access_token": "f5820a918aaf01"
|
|
||||||
}`
|
|
||||||
The `variant`, `subfolder` and `access_token` fields are optional.
|
|
||||||
|
|
||||||
* To install a remote model using an arbitrary URL, pass:
|
|
||||||
`{
|
|
||||||
"type": "url",
|
|
||||||
"url": "http://www.civitai.com/models/123456",
|
|
||||||
"access_token": "f5820a918aaf01"
|
|
||||||
}`
|
|
||||||
The `access_token` field is optonal
|
|
||||||
|
|
||||||
The model's configuration record will be probed and filled in
|
|
||||||
automatically. To override the default guesses, pass "metadata"
|
|
||||||
with a Dict containing the attributes you wish to override.
|
|
||||||
|
|
||||||
Installation occurs in the background. Either use list_model_install_jobs()
|
|
||||||
to poll for completion, or listen on the event bus for the following events:
|
|
||||||
|
|
||||||
"model_install_started"
|
|
||||||
"model_install_completed"
|
|
||||||
"model_install_error"
|
|
||||||
|
|
||||||
On successful completion, the event's payload will contain the field "key"
|
|
||||||
containing the installed ID of the model. On an error, the event's payload
|
|
||||||
will contain the fields "error_type" and "error" describing the nature of the
|
|
||||||
error and its traceback, respectively.
|
|
||||||
|
|
||||||
"""
|
|
||||||
logger = ApiDependencies.invoker.services.logger
|
|
||||||
|
|
||||||
try:
|
|
||||||
installer = ApiDependencies.invoker.services.model_install
|
|
||||||
result: ModelInstallJob = installer.import_model(
|
|
||||||
source=source,
|
|
||||||
config=config,
|
|
||||||
)
|
|
||||||
logger.info(f"Started installation of {source}")
|
|
||||||
except UnknownModelException as e:
|
|
||||||
logger.error(str(e))
|
|
||||||
raise HTTPException(status_code=424, detail=str(e))
|
|
||||||
except InvalidModelException as e:
|
|
||||||
logger.error(str(e))
|
|
||||||
raise HTTPException(status_code=415)
|
|
||||||
except ValueError as e:
|
|
||||||
logger.error(str(e))
|
|
||||||
raise HTTPException(status_code=409, detail=str(e))
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
@model_records_router.get(
|
|
||||||
"/import",
|
|
||||||
operation_id="list_model_install_jobs",
|
|
||||||
)
|
|
||||||
async def list_model_install_jobs() -> List[ModelInstallJob]:
|
|
||||||
"""
|
|
||||||
Return list of model install jobs.
|
|
||||||
|
|
||||||
If the optional 'source' argument is provided, then the list will be filtered
|
|
||||||
for partial string matches against the install source.
|
|
||||||
"""
|
|
||||||
jobs: List[ModelInstallJob] = ApiDependencies.invoker.services.model_install.list_jobs()
|
|
||||||
return jobs
|
|
||||||
|
|
||||||
|
|
||||||
@model_records_router.patch(
|
|
||||||
"/import",
|
|
||||||
operation_id="prune_model_install_jobs",
|
|
||||||
responses={
|
|
||||||
204: {"description": "All completed and errored jobs have been pruned"},
|
|
||||||
400: {"description": "Bad request"},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
async def prune_model_install_jobs() -> Response:
|
|
||||||
"""
|
|
||||||
Prune all completed and errored jobs from the install job list.
|
|
||||||
"""
|
|
||||||
ApiDependencies.invoker.services.model_install.prune_jobs()
|
|
||||||
return Response(status_code=204)
|
|
||||||
|
|
||||||
|
|
||||||
@model_records_router.patch(
|
|
||||||
"/sync",
|
|
||||||
operation_id="sync_models_to_config",
|
|
||||||
responses={
|
|
||||||
204: {"description": "Model config record database resynced with files on disk"},
|
|
||||||
400: {"description": "Bad request"},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
async def sync_models_to_config() -> Response:
|
|
||||||
"""
|
|
||||||
Traverse the models and autoimport directories. Model files without a corresponding
|
|
||||||
record in the database are added. Orphan records without a models file are deleted.
|
|
||||||
"""
|
|
||||||
ApiDependencies.invoker.services.model_install.sync_to_config()
|
|
||||||
return Response(status_code=204)
|
|
@ -1,11 +1,12 @@
|
|||||||
# Copyright (c) 2023 Kyle Schouviller (https://github.com/kyle0654), 2023 Kent Keirsey (https://github.com/hipsterusername), 2023 Lincoln D. Stein
|
# Copyright (c) 2023 Kyle Schouviller (https://github.com/kyle0654), 2023 Kent Keirsey (https://github.com/hipsterusername), 2023 Lincoln D. Stein
|
||||||
|
|
||||||
|
|
||||||
import pathlib
|
import pathlib
|
||||||
from typing import Annotated, List, Literal, Optional, Union
|
from typing import List, Literal, Optional, Union
|
||||||
|
|
||||||
from fastapi import Body, Path, Query, Response
|
from fastapi import Body, Path, Query, Response
|
||||||
from fastapi.routing import APIRouter
|
from fastapi.routing import APIRouter
|
||||||
from pydantic import BaseModel, ConfigDict, Field, TypeAdapter
|
from pydantic import BaseModel, parse_obj_as
|
||||||
from starlette.exceptions import HTTPException
|
from starlette.exceptions import HTTPException
|
||||||
|
|
||||||
from invokeai.backend import BaseModelType, ModelType
|
from invokeai.backend import BaseModelType, ModelType
|
||||||
@ -22,14 +23,8 @@ from ..dependencies import ApiDependencies
|
|||||||
models_router = APIRouter(prefix="/v1/models", tags=["models"])
|
models_router = APIRouter(prefix="/v1/models", tags=["models"])
|
||||||
|
|
||||||
UpdateModelResponse = Union[tuple(OPENAPI_MODEL_CONFIGS)]
|
UpdateModelResponse = Union[tuple(OPENAPI_MODEL_CONFIGS)]
|
||||||
UpdateModelResponseValidator = TypeAdapter(UpdateModelResponse)
|
|
||||||
|
|
||||||
ImportModelResponse = Union[tuple(OPENAPI_MODEL_CONFIGS)]
|
ImportModelResponse = Union[tuple(OPENAPI_MODEL_CONFIGS)]
|
||||||
ImportModelResponseValidator = TypeAdapter(ImportModelResponse)
|
|
||||||
|
|
||||||
ConvertModelResponse = Union[tuple(OPENAPI_MODEL_CONFIGS)]
|
ConvertModelResponse = Union[tuple(OPENAPI_MODEL_CONFIGS)]
|
||||||
ConvertModelResponseValidator = TypeAdapter(ConvertModelResponse)
|
|
||||||
|
|
||||||
MergeModelResponse = Union[tuple(OPENAPI_MODEL_CONFIGS)]
|
MergeModelResponse = Union[tuple(OPENAPI_MODEL_CONFIGS)]
|
||||||
ImportModelAttributes = Union[tuple(OPENAPI_MODEL_CONFIGS)]
|
ImportModelAttributes = Union[tuple(OPENAPI_MODEL_CONFIGS)]
|
||||||
|
|
||||||
@ -37,11 +32,6 @@ ImportModelAttributes = Union[tuple(OPENAPI_MODEL_CONFIGS)]
|
|||||||
class ModelsList(BaseModel):
|
class ModelsList(BaseModel):
|
||||||
models: list[Union[tuple(OPENAPI_MODEL_CONFIGS)]]
|
models: list[Union[tuple(OPENAPI_MODEL_CONFIGS)]]
|
||||||
|
|
||||||
model_config = ConfigDict(use_enum_values=True)
|
|
||||||
|
|
||||||
|
|
||||||
ModelsListValidator = TypeAdapter(ModelsList)
|
|
||||||
|
|
||||||
|
|
||||||
@models_router.get(
|
@models_router.get(
|
||||||
"/",
|
"/",
|
||||||
@ -54,12 +44,12 @@ async def list_models(
|
|||||||
) -> ModelsList:
|
) -> ModelsList:
|
||||||
"""Gets a list of models"""
|
"""Gets a list of models"""
|
||||||
if base_models and len(base_models) > 0:
|
if base_models and len(base_models) > 0:
|
||||||
models_raw = []
|
models_raw = list()
|
||||||
for base_model in base_models:
|
for base_model in base_models:
|
||||||
models_raw.extend(ApiDependencies.invoker.services.model_manager.list_models(base_model, model_type))
|
models_raw.extend(ApiDependencies.invoker.services.model_manager.list_models(base_model, model_type))
|
||||||
else:
|
else:
|
||||||
models_raw = ApiDependencies.invoker.services.model_manager.list_models(None, model_type)
|
models_raw = ApiDependencies.invoker.services.model_manager.list_models(None, model_type)
|
||||||
models = ModelsListValidator.validate_python({"models": models_raw})
|
models = parse_obj_as(ModelsList, {"models": models_raw})
|
||||||
return models
|
return models
|
||||||
|
|
||||||
|
|
||||||
@ -115,14 +105,11 @@ async def update_model(
|
|||||||
info.path = new_info.get("path")
|
info.path = new_info.get("path")
|
||||||
|
|
||||||
# replace empty string values with None/null to avoid phenomenon of vae: ''
|
# replace empty string values with None/null to avoid phenomenon of vae: ''
|
||||||
info_dict = info.model_dump()
|
info_dict = info.dict()
|
||||||
info_dict = {x: info_dict[x] if info_dict[x] else None for x in info_dict.keys()}
|
info_dict = {x: info_dict[x] if info_dict[x] else None for x in info_dict.keys()}
|
||||||
|
|
||||||
ApiDependencies.invoker.services.model_manager.update_model(
|
ApiDependencies.invoker.services.model_manager.update_model(
|
||||||
model_name=model_name,
|
model_name=model_name, base_model=base_model, model_type=model_type, model_attributes=info_dict
|
||||||
base_model=base_model,
|
|
||||||
model_type=model_type,
|
|
||||||
model_attributes=info_dict,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
model_raw = ApiDependencies.invoker.services.model_manager.list_model(
|
model_raw = ApiDependencies.invoker.services.model_manager.list_model(
|
||||||
@ -130,7 +117,7 @@ async def update_model(
|
|||||||
base_model=base_model,
|
base_model=base_model,
|
||||||
model_type=model_type,
|
model_type=model_type,
|
||||||
)
|
)
|
||||||
model_response = UpdateModelResponseValidator.validate_python(model_raw)
|
model_response = parse_obj_as(UpdateModelResponse, model_raw)
|
||||||
except ModelNotFoundException as e:
|
except ModelNotFoundException as e:
|
||||||
raise HTTPException(status_code=404, detail=str(e))
|
raise HTTPException(status_code=404, detail=str(e))
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
@ -165,15 +152,13 @@ async def import_model(
|
|||||||
) -> ImportModelResponse:
|
) -> ImportModelResponse:
|
||||||
"""Add a model using its local path, repo_id, or remote URL. Model characteristics will be probed and configured automatically"""
|
"""Add a model using its local path, repo_id, or remote URL. Model characteristics will be probed and configured automatically"""
|
||||||
|
|
||||||
location = location.strip("\"' ")
|
|
||||||
items_to_import = {location}
|
items_to_import = {location}
|
||||||
prediction_types = {x.value: x for x in SchedulerPredictionType}
|
prediction_types = {x.value: x for x in SchedulerPredictionType}
|
||||||
logger = ApiDependencies.invoker.services.logger
|
logger = ApiDependencies.invoker.services.logger
|
||||||
|
|
||||||
try:
|
try:
|
||||||
installed_models = ApiDependencies.invoker.services.model_manager.heuristic_import(
|
installed_models = ApiDependencies.invoker.services.model_manager.heuristic_import(
|
||||||
items_to_import=items_to_import,
|
items_to_import=items_to_import, prediction_type_helper=lambda x: prediction_types.get(prediction_type)
|
||||||
prediction_type_helper=lambda x: prediction_types.get(prediction_type),
|
|
||||||
)
|
)
|
||||||
info = installed_models.get(location)
|
info = installed_models.get(location)
|
||||||
|
|
||||||
@ -185,7 +170,7 @@ async def import_model(
|
|||||||
model_raw = ApiDependencies.invoker.services.model_manager.list_model(
|
model_raw = ApiDependencies.invoker.services.model_manager.list_model(
|
||||||
model_name=info.name, base_model=info.base_model, model_type=info.model_type
|
model_name=info.name, base_model=info.base_model, model_type=info.model_type
|
||||||
)
|
)
|
||||||
return ImportModelResponseValidator.validate_python(model_raw)
|
return parse_obj_as(ImportModelResponse, model_raw)
|
||||||
|
|
||||||
except ModelNotFoundException as e:
|
except ModelNotFoundException as e:
|
||||||
logger.error(str(e))
|
logger.error(str(e))
|
||||||
@ -219,18 +204,13 @@ async def add_model(
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
ApiDependencies.invoker.services.model_manager.add_model(
|
ApiDependencies.invoker.services.model_manager.add_model(
|
||||||
info.model_name,
|
info.model_name, info.base_model, info.model_type, model_attributes=info.dict()
|
||||||
info.base_model,
|
|
||||||
info.model_type,
|
|
||||||
model_attributes=info.model_dump(),
|
|
||||||
)
|
)
|
||||||
logger.info(f"Successfully added {info.model_name}")
|
logger.info(f"Successfully added {info.model_name}")
|
||||||
model_raw = ApiDependencies.invoker.services.model_manager.list_model(
|
model_raw = ApiDependencies.invoker.services.model_manager.list_model(
|
||||||
model_name=info.model_name,
|
model_name=info.model_name, base_model=info.base_model, model_type=info.model_type
|
||||||
base_model=info.base_model,
|
|
||||||
model_type=info.model_type,
|
|
||||||
)
|
)
|
||||||
return ImportModelResponseValidator.validate_python(model_raw)
|
return parse_obj_as(ImportModelResponse, model_raw)
|
||||||
except ModelNotFoundException as e:
|
except ModelNotFoundException as e:
|
||||||
logger.error(str(e))
|
logger.error(str(e))
|
||||||
raise HTTPException(status_code=404, detail=str(e))
|
raise HTTPException(status_code=404, detail=str(e))
|
||||||
@ -242,10 +222,7 @@ async def add_model(
|
|||||||
@models_router.delete(
|
@models_router.delete(
|
||||||
"/{base_model}/{model_type}/{model_name}",
|
"/{base_model}/{model_type}/{model_name}",
|
||||||
operation_id="del_model",
|
operation_id="del_model",
|
||||||
responses={
|
responses={204: {"description": "Model deleted successfully"}, 404: {"description": "Model not found"}},
|
||||||
204: {"description": "Model deleted successfully"},
|
|
||||||
404: {"description": "Model not found"},
|
|
||||||
},
|
|
||||||
status_code=204,
|
status_code=204,
|
||||||
response_model=None,
|
response_model=None,
|
||||||
)
|
)
|
||||||
@ -301,7 +278,7 @@ async def convert_model(
|
|||||||
model_raw = ApiDependencies.invoker.services.model_manager.list_model(
|
model_raw = ApiDependencies.invoker.services.model_manager.list_model(
|
||||||
model_name, base_model=base_model, model_type=model_type
|
model_name, base_model=base_model, model_type=model_type
|
||||||
)
|
)
|
||||||
response = ConvertModelResponseValidator.validate_python(model_raw)
|
response = parse_obj_as(ConvertModelResponse, model_raw)
|
||||||
except ModelNotFoundException as e:
|
except ModelNotFoundException as e:
|
||||||
raise HTTPException(status_code=404, detail=f"Model '{model_name}' not found: {str(e)}")
|
raise HTTPException(status_code=404, detail=f"Model '{model_name}' not found: {str(e)}")
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
@ -324,8 +301,7 @@ async def search_for_models(
|
|||||||
) -> List[pathlib.Path]:
|
) -> List[pathlib.Path]:
|
||||||
if not search_path.is_dir():
|
if not search_path.is_dir():
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=404,
|
status_code=404, detail=f"The search path '{search_path}' does not exist or is not directory"
|
||||||
detail=f"The search path '{search_path}' does not exist or is not directory",
|
|
||||||
)
|
)
|
||||||
return ApiDependencies.invoker.services.model_manager.search_for_models(search_path)
|
return ApiDependencies.invoker.services.model_manager.search_for_models(search_path)
|
||||||
|
|
||||||
@ -360,26 +336,6 @@ async def sync_to_config() -> bool:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
# There's some weird pydantic-fastapi behaviour that requires this to be a separate class
|
|
||||||
# TODO: After a few updates, see if it works inside the route operation handler?
|
|
||||||
class MergeModelsBody(BaseModel):
|
|
||||||
model_names: List[str] = Field(description="model name", min_length=2, max_length=3)
|
|
||||||
merged_model_name: Optional[str] = Field(description="Name of destination model")
|
|
||||||
alpha: Optional[float] = Field(description="Alpha weighting strength to apply to 2d and 3d models", default=0.5)
|
|
||||||
interp: Optional[MergeInterpolationMethod] = Field(description="Interpolation method")
|
|
||||||
force: Optional[bool] = Field(
|
|
||||||
description="Force merging of models created with different versions of diffusers",
|
|
||||||
default=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
merge_dest_directory: Optional[str] = Field(
|
|
||||||
description="Save the merged model to the designated directory (with 'merged_model_name' appended)",
|
|
||||||
default=None,
|
|
||||||
)
|
|
||||||
|
|
||||||
model_config = ConfigDict(protected_namespaces=())
|
|
||||||
|
|
||||||
|
|
||||||
@models_router.put(
|
@models_router.put(
|
||||||
"/merge/{base_model}",
|
"/merge/{base_model}",
|
||||||
operation_id="merge_models",
|
operation_id="merge_models",
|
||||||
@ -392,23 +348,31 @@ class MergeModelsBody(BaseModel):
|
|||||||
response_model=MergeModelResponse,
|
response_model=MergeModelResponse,
|
||||||
)
|
)
|
||||||
async def merge_models(
|
async def merge_models(
|
||||||
body: Annotated[MergeModelsBody, Body(description="Model configuration", embed=True)],
|
|
||||||
base_model: BaseModelType = Path(description="Base model"),
|
base_model: BaseModelType = Path(description="Base model"),
|
||||||
|
model_names: List[str] = Body(description="model name", min_items=2, max_items=3),
|
||||||
|
merged_model_name: Optional[str] = Body(description="Name of destination model"),
|
||||||
|
alpha: Optional[float] = Body(description="Alpha weighting strength to apply to 2d and 3d models", default=0.5),
|
||||||
|
interp: Optional[MergeInterpolationMethod] = Body(description="Interpolation method"),
|
||||||
|
force: Optional[bool] = Body(
|
||||||
|
description="Force merging of models created with different versions of diffusers", default=False
|
||||||
|
),
|
||||||
|
merge_dest_directory: Optional[str] = Body(
|
||||||
|
description="Save the merged model to the designated directory (with 'merged_model_name' appended)",
|
||||||
|
default=None,
|
||||||
|
),
|
||||||
) -> MergeModelResponse:
|
) -> MergeModelResponse:
|
||||||
"""Convert a checkpoint model into a diffusers model"""
|
"""Convert a checkpoint model into a diffusers model"""
|
||||||
logger = ApiDependencies.invoker.services.logger
|
logger = ApiDependencies.invoker.services.logger
|
||||||
try:
|
try:
|
||||||
logger.info(
|
logger.info(f"Merging models: {model_names} into {merge_dest_directory or '<MODELS>'}/{merged_model_name}")
|
||||||
f"Merging models: {body.model_names} into {body.merge_dest_directory or '<MODELS>'}/{body.merged_model_name}"
|
dest = pathlib.Path(merge_dest_directory) if merge_dest_directory else None
|
||||||
)
|
|
||||||
dest = pathlib.Path(body.merge_dest_directory) if body.merge_dest_directory else None
|
|
||||||
result = ApiDependencies.invoker.services.model_manager.merge_models(
|
result = ApiDependencies.invoker.services.model_manager.merge_models(
|
||||||
model_names=body.model_names,
|
model_names,
|
||||||
base_model=base_model,
|
base_model,
|
||||||
merged_model_name=body.merged_model_name or "+".join(body.model_names),
|
merged_model_name=merged_model_name or "+".join(model_names),
|
||||||
alpha=body.alpha,
|
alpha=alpha,
|
||||||
interp=body.interp,
|
interp=interp,
|
||||||
force=body.force,
|
force=force,
|
||||||
merge_dest_directory=dest,
|
merge_dest_directory=dest,
|
||||||
)
|
)
|
||||||
model_raw = ApiDependencies.invoker.services.model_manager.list_model(
|
model_raw = ApiDependencies.invoker.services.model_manager.list_model(
|
||||||
@ -416,12 +380,9 @@ async def merge_models(
|
|||||||
base_model=base_model,
|
base_model=base_model,
|
||||||
model_type=ModelType.Main,
|
model_type=ModelType.Main,
|
||||||
)
|
)
|
||||||
response = ConvertModelResponseValidator.validate_python(model_raw)
|
response = parse_obj_as(ConvertModelResponse, model_raw)
|
||||||
except ModelNotFoundException:
|
except ModelNotFoundException:
|
||||||
raise HTTPException(
|
raise HTTPException(status_code=404, detail=f"One or more of the models '{model_names}' not found")
|
||||||
status_code=404,
|
|
||||||
detail=f"One or more of the models '{body.model_names}' not found",
|
|
||||||
)
|
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
raise HTTPException(status_code=400, detail=str(e))
|
raise HTTPException(status_code=400, detail=str(e))
|
||||||
return response
|
return response
|
||||||
|
@ -12,13 +12,15 @@ from invokeai.app.services.session_queue.session_queue_common import (
|
|||||||
CancelByBatchIDsResult,
|
CancelByBatchIDsResult,
|
||||||
ClearResult,
|
ClearResult,
|
||||||
EnqueueBatchResult,
|
EnqueueBatchResult,
|
||||||
|
EnqueueGraphResult,
|
||||||
PruneResult,
|
PruneResult,
|
||||||
SessionQueueItem,
|
SessionQueueItem,
|
||||||
SessionQueueItemDTO,
|
SessionQueueItemDTO,
|
||||||
SessionQueueStatus,
|
SessionQueueStatus,
|
||||||
)
|
)
|
||||||
from invokeai.app.services.shared.pagination import CursorPaginatedResults
|
from invokeai.app.services.shared.models import CursorPaginatedResults
|
||||||
|
|
||||||
|
from ...services.graph import Graph
|
||||||
from ..dependencies import ApiDependencies
|
from ..dependencies import ApiDependencies
|
||||||
|
|
||||||
session_queue_router = APIRouter(prefix="/v1/queue", tags=["queue"])
|
session_queue_router = APIRouter(prefix="/v1/queue", tags=["queue"])
|
||||||
@ -31,6 +33,23 @@ class SessionQueueAndProcessorStatus(BaseModel):
|
|||||||
processor: SessionProcessorStatus
|
processor: SessionProcessorStatus
|
||||||
|
|
||||||
|
|
||||||
|
@session_queue_router.post(
|
||||||
|
"/{queue_id}/enqueue_graph",
|
||||||
|
operation_id="enqueue_graph",
|
||||||
|
responses={
|
||||||
|
201: {"model": EnqueueGraphResult},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
async def enqueue_graph(
|
||||||
|
queue_id: str = Path(description="The queue id to perform this operation on"),
|
||||||
|
graph: Graph = Body(description="The graph to enqueue"),
|
||||||
|
prepend: bool = Body(default=False, description="Whether or not to prepend this batch in the queue"),
|
||||||
|
) -> EnqueueGraphResult:
|
||||||
|
"""Enqueues a graph for single execution."""
|
||||||
|
|
||||||
|
return ApiDependencies.invoker.services.session_queue.enqueue_graph(queue_id=queue_id, graph=graph, prepend=prepend)
|
||||||
|
|
||||||
|
|
||||||
@session_queue_router.post(
|
@session_queue_router.post(
|
||||||
"/{queue_id}/enqueue_batch",
|
"/{queue_id}/enqueue_batch",
|
||||||
operation_id="enqueue_batch",
|
operation_id="enqueue_batch",
|
||||||
|
@ -1,50 +1,56 @@
|
|||||||
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654)
|
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654)
|
||||||
|
|
||||||
|
from typing import Annotated, Optional, Union
|
||||||
|
|
||||||
from fastapi import HTTPException, Path
|
from fastapi import Body, HTTPException, Path, Query, Response
|
||||||
from fastapi.routing import APIRouter
|
from fastapi.routing import APIRouter
|
||||||
|
from pydantic.fields import Field
|
||||||
|
|
||||||
from ...services.shared.graph import GraphExecutionState
|
# Importing * is bad karma but needed here for node detection
|
||||||
|
from ...invocations import * # noqa: F401 F403
|
||||||
|
from ...invocations.baseinvocation import BaseInvocation
|
||||||
|
from ...services.graph import Edge, EdgeConnection, Graph, GraphExecutionState, NodeAlreadyExecutedError
|
||||||
|
from ...services.item_storage import PaginatedResults
|
||||||
from ..dependencies import ApiDependencies
|
from ..dependencies import ApiDependencies
|
||||||
|
|
||||||
session_router = APIRouter(prefix="/v1/sessions", tags=["sessions"])
|
session_router = APIRouter(prefix="/v1/sessions", tags=["sessions"])
|
||||||
|
|
||||||
|
|
||||||
# @session_router.post(
|
@session_router.post(
|
||||||
# "/",
|
"/",
|
||||||
# operation_id="create_session",
|
operation_id="create_session",
|
||||||
# responses={
|
responses={
|
||||||
# 200: {"model": GraphExecutionState},
|
200: {"model": GraphExecutionState},
|
||||||
# 400: {"description": "Invalid json"},
|
400: {"description": "Invalid json"},
|
||||||
# },
|
},
|
||||||
# deprecated=True,
|
deprecated=True,
|
||||||
# )
|
)
|
||||||
# async def create_session(
|
async def create_session(
|
||||||
# queue_id: str = Query(default="", description="The id of the queue to associate the session with"),
|
queue_id: str = Query(default="", description="The id of the queue to associate the session with"),
|
||||||
# graph: Optional[Graph] = Body(default=None, description="The graph to initialize the session with"),
|
graph: Optional[Graph] = Body(default=None, description="The graph to initialize the session with"),
|
||||||
# ) -> GraphExecutionState:
|
) -> GraphExecutionState:
|
||||||
# """Creates a new session, optionally initializing it with an invocation graph"""
|
"""Creates a new session, optionally initializing it with an invocation graph"""
|
||||||
# session = ApiDependencies.invoker.create_execution_state(queue_id=queue_id, graph=graph)
|
session = ApiDependencies.invoker.create_execution_state(queue_id=queue_id, graph=graph)
|
||||||
# return session
|
return session
|
||||||
|
|
||||||
|
|
||||||
# @session_router.get(
|
@session_router.get(
|
||||||
# "/",
|
"/",
|
||||||
# operation_id="list_sessions",
|
operation_id="list_sessions",
|
||||||
# responses={200: {"model": PaginatedResults[GraphExecutionState]}},
|
responses={200: {"model": PaginatedResults[GraphExecutionState]}},
|
||||||
# deprecated=True,
|
deprecated=True,
|
||||||
# )
|
)
|
||||||
# async def list_sessions(
|
async def list_sessions(
|
||||||
# page: int = Query(default=0, description="The page of results to get"),
|
page: int = Query(default=0, description="The page of results to get"),
|
||||||
# per_page: int = Query(default=10, description="The number of results per page"),
|
per_page: int = Query(default=10, description="The number of results per page"),
|
||||||
# query: str = Query(default="", description="The query string to search for"),
|
query: str = Query(default="", description="The query string to search for"),
|
||||||
# ) -> PaginatedResults[GraphExecutionState]:
|
) -> PaginatedResults[GraphExecutionState]:
|
||||||
# """Gets a list of sessions, optionally searching"""
|
"""Gets a list of sessions, optionally searching"""
|
||||||
# if query == "":
|
if query == "":
|
||||||
# result = ApiDependencies.invoker.services.graph_execution_manager.list(page, per_page)
|
result = ApiDependencies.invoker.services.graph_execution_manager.list(page, per_page)
|
||||||
# else:
|
else:
|
||||||
# result = ApiDependencies.invoker.services.graph_execution_manager.search(query, page, per_page)
|
result = ApiDependencies.invoker.services.graph_execution_manager.search(query, page, per_page)
|
||||||
# return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@session_router.get(
|
@session_router.get(
|
||||||
@ -54,6 +60,7 @@ session_router = APIRouter(prefix="/v1/sessions", tags=["sessions"])
|
|||||||
200: {"model": GraphExecutionState},
|
200: {"model": GraphExecutionState},
|
||||||
404: {"description": "Session not found"},
|
404: {"description": "Session not found"},
|
||||||
},
|
},
|
||||||
|
deprecated=True,
|
||||||
)
|
)
|
||||||
async def get_session(
|
async def get_session(
|
||||||
session_id: str = Path(description="The id of the session to get"),
|
session_id: str = Path(description="The id of the session to get"),
|
||||||
@ -66,211 +73,211 @@ async def get_session(
|
|||||||
return session
|
return session
|
||||||
|
|
||||||
|
|
||||||
# @session_router.post(
|
@session_router.post(
|
||||||
# "/{session_id}/nodes",
|
"/{session_id}/nodes",
|
||||||
# operation_id="add_node",
|
operation_id="add_node",
|
||||||
# responses={
|
responses={
|
||||||
# 200: {"model": str},
|
200: {"model": str},
|
||||||
# 400: {"description": "Invalid node or link"},
|
400: {"description": "Invalid node or link"},
|
||||||
# 404: {"description": "Session not found"},
|
404: {"description": "Session not found"},
|
||||||
# },
|
},
|
||||||
# deprecated=True,
|
deprecated=True,
|
||||||
# )
|
)
|
||||||
# async def add_node(
|
async def add_node(
|
||||||
# session_id: str = Path(description="The id of the session"),
|
session_id: str = Path(description="The id of the session"),
|
||||||
# node: Annotated[Union[BaseInvocation.get_invocations()], Field(discriminator="type")] = Body( # type: ignore
|
node: Annotated[Union[BaseInvocation.get_invocations()], Field(discriminator="type")] = Body( # type: ignore
|
||||||
# description="The node to add"
|
description="The node to add"
|
||||||
# ),
|
),
|
||||||
# ) -> str:
|
) -> str:
|
||||||
# """Adds a node to the graph"""
|
"""Adds a node to the graph"""
|
||||||
# session = ApiDependencies.invoker.services.graph_execution_manager.get(session_id)
|
session = ApiDependencies.invoker.services.graph_execution_manager.get(session_id)
|
||||||
# if session is None:
|
if session is None:
|
||||||
# raise HTTPException(status_code=404)
|
raise HTTPException(status_code=404)
|
||||||
|
|
||||||
# try:
|
try:
|
||||||
# session.add_node(node)
|
session.add_node(node)
|
||||||
# ApiDependencies.invoker.services.graph_execution_manager.set(
|
ApiDependencies.invoker.services.graph_execution_manager.set(
|
||||||
# session
|
session
|
||||||
# ) # TODO: can this be done automatically, or add node through an API?
|
) # TODO: can this be done automatically, or add node through an API?
|
||||||
# return session.id
|
return session.id
|
||||||
# except NodeAlreadyExecutedError:
|
except NodeAlreadyExecutedError:
|
||||||
# raise HTTPException(status_code=400)
|
raise HTTPException(status_code=400)
|
||||||
# except IndexError:
|
except IndexError:
|
||||||
# raise HTTPException(status_code=400)
|
raise HTTPException(status_code=400)
|
||||||
|
|
||||||
|
|
||||||
# @session_router.put(
|
@session_router.put(
|
||||||
# "/{session_id}/nodes/{node_path}",
|
"/{session_id}/nodes/{node_path}",
|
||||||
# operation_id="update_node",
|
operation_id="update_node",
|
||||||
# responses={
|
responses={
|
||||||
# 200: {"model": GraphExecutionState},
|
200: {"model": GraphExecutionState},
|
||||||
# 400: {"description": "Invalid node or link"},
|
400: {"description": "Invalid node or link"},
|
||||||
# 404: {"description": "Session not found"},
|
404: {"description": "Session not found"},
|
||||||
# },
|
},
|
||||||
# deprecated=True,
|
deprecated=True,
|
||||||
# )
|
)
|
||||||
# async def update_node(
|
async def update_node(
|
||||||
# session_id: str = Path(description="The id of the session"),
|
session_id: str = Path(description="The id of the session"),
|
||||||
# node_path: str = Path(description="The path to the node in the graph"),
|
node_path: str = Path(description="The path to the node in the graph"),
|
||||||
# node: Annotated[Union[BaseInvocation.get_invocations()], Field(discriminator="type")] = Body( # type: ignore
|
node: Annotated[Union[BaseInvocation.get_invocations()], Field(discriminator="type")] = Body( # type: ignore
|
||||||
# description="The new node"
|
description="The new node"
|
||||||
# ),
|
),
|
||||||
# ) -> GraphExecutionState:
|
) -> GraphExecutionState:
|
||||||
# """Updates a node in the graph and removes all linked edges"""
|
"""Updates a node in the graph and removes all linked edges"""
|
||||||
# session = ApiDependencies.invoker.services.graph_execution_manager.get(session_id)
|
session = ApiDependencies.invoker.services.graph_execution_manager.get(session_id)
|
||||||
# if session is None:
|
if session is None:
|
||||||
# raise HTTPException(status_code=404)
|
raise HTTPException(status_code=404)
|
||||||
|
|
||||||
# try:
|
try:
|
||||||
# session.update_node(node_path, node)
|
session.update_node(node_path, node)
|
||||||
# ApiDependencies.invoker.services.graph_execution_manager.set(
|
ApiDependencies.invoker.services.graph_execution_manager.set(
|
||||||
# session
|
session
|
||||||
# ) # TODO: can this be done automatically, or add node through an API?
|
) # TODO: can this be done automatically, or add node through an API?
|
||||||
# return session
|
return session
|
||||||
# except NodeAlreadyExecutedError:
|
except NodeAlreadyExecutedError:
|
||||||
# raise HTTPException(status_code=400)
|
raise HTTPException(status_code=400)
|
||||||
# except IndexError:
|
except IndexError:
|
||||||
# raise HTTPException(status_code=400)
|
raise HTTPException(status_code=400)
|
||||||
|
|
||||||
|
|
||||||
# @session_router.delete(
|
@session_router.delete(
|
||||||
# "/{session_id}/nodes/{node_path}",
|
"/{session_id}/nodes/{node_path}",
|
||||||
# operation_id="delete_node",
|
operation_id="delete_node",
|
||||||
# responses={
|
responses={
|
||||||
# 200: {"model": GraphExecutionState},
|
200: {"model": GraphExecutionState},
|
||||||
# 400: {"description": "Invalid node or link"},
|
400: {"description": "Invalid node or link"},
|
||||||
# 404: {"description": "Session not found"},
|
404: {"description": "Session not found"},
|
||||||
# },
|
},
|
||||||
# deprecated=True,
|
deprecated=True,
|
||||||
# )
|
)
|
||||||
# async def delete_node(
|
async def delete_node(
|
||||||
# session_id: str = Path(description="The id of the session"),
|
session_id: str = Path(description="The id of the session"),
|
||||||
# node_path: str = Path(description="The path to the node to delete"),
|
node_path: str = Path(description="The path to the node to delete"),
|
||||||
# ) -> GraphExecutionState:
|
) -> GraphExecutionState:
|
||||||
# """Deletes a node in the graph and removes all linked edges"""
|
"""Deletes a node in the graph and removes all linked edges"""
|
||||||
# session = ApiDependencies.invoker.services.graph_execution_manager.get(session_id)
|
session = ApiDependencies.invoker.services.graph_execution_manager.get(session_id)
|
||||||
# if session is None:
|
if session is None:
|
||||||
# raise HTTPException(status_code=404)
|
raise HTTPException(status_code=404)
|
||||||
|
|
||||||
# try:
|
try:
|
||||||
# session.delete_node(node_path)
|
session.delete_node(node_path)
|
||||||
# ApiDependencies.invoker.services.graph_execution_manager.set(
|
ApiDependencies.invoker.services.graph_execution_manager.set(
|
||||||
# session
|
session
|
||||||
# ) # TODO: can this be done automatically, or add node through an API?
|
) # TODO: can this be done automatically, or add node through an API?
|
||||||
# return session
|
return session
|
||||||
# except NodeAlreadyExecutedError:
|
except NodeAlreadyExecutedError:
|
||||||
# raise HTTPException(status_code=400)
|
raise HTTPException(status_code=400)
|
||||||
# except IndexError:
|
except IndexError:
|
||||||
# raise HTTPException(status_code=400)
|
raise HTTPException(status_code=400)
|
||||||
|
|
||||||
|
|
||||||
# @session_router.post(
|
@session_router.post(
|
||||||
# "/{session_id}/edges",
|
"/{session_id}/edges",
|
||||||
# operation_id="add_edge",
|
operation_id="add_edge",
|
||||||
# responses={
|
responses={
|
||||||
# 200: {"model": GraphExecutionState},
|
200: {"model": GraphExecutionState},
|
||||||
# 400: {"description": "Invalid node or link"},
|
400: {"description": "Invalid node or link"},
|
||||||
# 404: {"description": "Session not found"},
|
404: {"description": "Session not found"},
|
||||||
# },
|
},
|
||||||
# deprecated=True,
|
deprecated=True,
|
||||||
# )
|
)
|
||||||
# async def add_edge(
|
async def add_edge(
|
||||||
# session_id: str = Path(description="The id of the session"),
|
session_id: str = Path(description="The id of the session"),
|
||||||
# edge: Edge = Body(description="The edge to add"),
|
edge: Edge = Body(description="The edge to add"),
|
||||||
# ) -> GraphExecutionState:
|
) -> GraphExecutionState:
|
||||||
# """Adds an edge to the graph"""
|
"""Adds an edge to the graph"""
|
||||||
# session = ApiDependencies.invoker.services.graph_execution_manager.get(session_id)
|
session = ApiDependencies.invoker.services.graph_execution_manager.get(session_id)
|
||||||
# if session is None:
|
if session is None:
|
||||||
# raise HTTPException(status_code=404)
|
raise HTTPException(status_code=404)
|
||||||
|
|
||||||
# try:
|
try:
|
||||||
# session.add_edge(edge)
|
session.add_edge(edge)
|
||||||
# ApiDependencies.invoker.services.graph_execution_manager.set(
|
ApiDependencies.invoker.services.graph_execution_manager.set(
|
||||||
# session
|
session
|
||||||
# ) # TODO: can this be done automatically, or add node through an API?
|
) # TODO: can this be done automatically, or add node through an API?
|
||||||
# return session
|
return session
|
||||||
# except NodeAlreadyExecutedError:
|
except NodeAlreadyExecutedError:
|
||||||
# raise HTTPException(status_code=400)
|
raise HTTPException(status_code=400)
|
||||||
# except IndexError:
|
except IndexError:
|
||||||
# raise HTTPException(status_code=400)
|
raise HTTPException(status_code=400)
|
||||||
|
|
||||||
|
|
||||||
# # TODO: the edge being in the path here is really ugly, find a better solution
|
# TODO: the edge being in the path here is really ugly, find a better solution
|
||||||
# @session_router.delete(
|
@session_router.delete(
|
||||||
# "/{session_id}/edges/{from_node_id}/{from_field}/{to_node_id}/{to_field}",
|
"/{session_id}/edges/{from_node_id}/{from_field}/{to_node_id}/{to_field}",
|
||||||
# operation_id="delete_edge",
|
operation_id="delete_edge",
|
||||||
# responses={
|
responses={
|
||||||
# 200: {"model": GraphExecutionState},
|
200: {"model": GraphExecutionState},
|
||||||
# 400: {"description": "Invalid node or link"},
|
400: {"description": "Invalid node or link"},
|
||||||
# 404: {"description": "Session not found"},
|
404: {"description": "Session not found"},
|
||||||
# },
|
},
|
||||||
# deprecated=True,
|
deprecated=True,
|
||||||
# )
|
)
|
||||||
# async def delete_edge(
|
async def delete_edge(
|
||||||
# session_id: str = Path(description="The id of the session"),
|
session_id: str = Path(description="The id of the session"),
|
||||||
# from_node_id: str = Path(description="The id of the node the edge is coming from"),
|
from_node_id: str = Path(description="The id of the node the edge is coming from"),
|
||||||
# from_field: str = Path(description="The field of the node the edge is coming from"),
|
from_field: str = Path(description="The field of the node the edge is coming from"),
|
||||||
# to_node_id: str = Path(description="The id of the node the edge is going to"),
|
to_node_id: str = Path(description="The id of the node the edge is going to"),
|
||||||
# to_field: str = Path(description="The field of the node the edge is going to"),
|
to_field: str = Path(description="The field of the node the edge is going to"),
|
||||||
# ) -> GraphExecutionState:
|
) -> GraphExecutionState:
|
||||||
# """Deletes an edge from the graph"""
|
"""Deletes an edge from the graph"""
|
||||||
# session = ApiDependencies.invoker.services.graph_execution_manager.get(session_id)
|
session = ApiDependencies.invoker.services.graph_execution_manager.get(session_id)
|
||||||
# if session is None:
|
if session is None:
|
||||||
# raise HTTPException(status_code=404)
|
raise HTTPException(status_code=404)
|
||||||
|
|
||||||
# try:
|
try:
|
||||||
# edge = Edge(
|
edge = Edge(
|
||||||
# source=EdgeConnection(node_id=from_node_id, field=from_field),
|
source=EdgeConnection(node_id=from_node_id, field=from_field),
|
||||||
# destination=EdgeConnection(node_id=to_node_id, field=to_field),
|
destination=EdgeConnection(node_id=to_node_id, field=to_field),
|
||||||
# )
|
)
|
||||||
# session.delete_edge(edge)
|
session.delete_edge(edge)
|
||||||
# ApiDependencies.invoker.services.graph_execution_manager.set(
|
ApiDependencies.invoker.services.graph_execution_manager.set(
|
||||||
# session
|
session
|
||||||
# ) # TODO: can this be done automatically, or add node through an API?
|
) # TODO: can this be done automatically, or add node through an API?
|
||||||
# return session
|
return session
|
||||||
# except NodeAlreadyExecutedError:
|
except NodeAlreadyExecutedError:
|
||||||
# raise HTTPException(status_code=400)
|
raise HTTPException(status_code=400)
|
||||||
# except IndexError:
|
except IndexError:
|
||||||
# raise HTTPException(status_code=400)
|
raise HTTPException(status_code=400)
|
||||||
|
|
||||||
|
|
||||||
# @session_router.put(
|
@session_router.put(
|
||||||
# "/{session_id}/invoke",
|
"/{session_id}/invoke",
|
||||||
# operation_id="invoke_session",
|
operation_id="invoke_session",
|
||||||
# responses={
|
responses={
|
||||||
# 200: {"model": None},
|
200: {"model": None},
|
||||||
# 202: {"description": "The invocation is queued"},
|
202: {"description": "The invocation is queued"},
|
||||||
# 400: {"description": "The session has no invocations ready to invoke"},
|
400: {"description": "The session has no invocations ready to invoke"},
|
||||||
# 404: {"description": "Session not found"},
|
404: {"description": "Session not found"},
|
||||||
# },
|
},
|
||||||
# deprecated=True,
|
deprecated=True,
|
||||||
# )
|
)
|
||||||
# async def invoke_session(
|
async def invoke_session(
|
||||||
# queue_id: str = Query(description="The id of the queue to associate the session with"),
|
queue_id: str = Query(description="The id of the queue to associate the session with"),
|
||||||
# session_id: str = Path(description="The id of the session to invoke"),
|
session_id: str = Path(description="The id of the session to invoke"),
|
||||||
# all: bool = Query(default=False, description="Whether or not to invoke all remaining invocations"),
|
all: bool = Query(default=False, description="Whether or not to invoke all remaining invocations"),
|
||||||
# ) -> Response:
|
) -> Response:
|
||||||
# """Invokes a session"""
|
"""Invokes a session"""
|
||||||
# session = ApiDependencies.invoker.services.graph_execution_manager.get(session_id)
|
session = ApiDependencies.invoker.services.graph_execution_manager.get(session_id)
|
||||||
# if session is None:
|
if session is None:
|
||||||
# raise HTTPException(status_code=404)
|
raise HTTPException(status_code=404)
|
||||||
|
|
||||||
# if session.is_complete():
|
if session.is_complete():
|
||||||
# raise HTTPException(status_code=400)
|
raise HTTPException(status_code=400)
|
||||||
|
|
||||||
# ApiDependencies.invoker.invoke(queue_id, session, invoke_all=all)
|
ApiDependencies.invoker.invoke(queue_id, session, invoke_all=all)
|
||||||
# return Response(status_code=202)
|
return Response(status_code=202)
|
||||||
|
|
||||||
|
|
||||||
# @session_router.delete(
|
@session_router.delete(
|
||||||
# "/{session_id}/invoke",
|
"/{session_id}/invoke",
|
||||||
# operation_id="cancel_session_invoke",
|
operation_id="cancel_session_invoke",
|
||||||
# responses={202: {"description": "The invocation is canceled"}},
|
responses={202: {"description": "The invocation is canceled"}},
|
||||||
# deprecated=True,
|
deprecated=True,
|
||||||
# )
|
)
|
||||||
# async def cancel_session_invoke(
|
async def cancel_session_invoke(
|
||||||
# session_id: str = Path(description="The id of the session to cancel"),
|
session_id: str = Path(description="The id of the session to cancel"),
|
||||||
# ) -> Response:
|
) -> Response:
|
||||||
# """Invokes a session"""
|
"""Invokes a session"""
|
||||||
# ApiDependencies.invoker.cancel(session_id)
|
ApiDependencies.invoker.cancel(session_id)
|
||||||
# return Response(status_code=202)
|
return Response(status_code=202)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from typing import Optional, Union
|
from typing import Optional
|
||||||
|
|
||||||
from dynamicprompts.generators import CombinatorialPromptGenerator, RandomPromptGenerator
|
from dynamicprompts.generators import CombinatorialPromptGenerator, RandomPromptGenerator
|
||||||
from fastapi import Body
|
from fastapi import Body
|
||||||
@ -27,7 +27,6 @@ async def parse_dynamicprompts(
|
|||||||
combinatorial: bool = Body(default=True, description="Whether to use the combinatorial generator"),
|
combinatorial: bool = Body(default=True, description="Whether to use the combinatorial generator"),
|
||||||
) -> DynamicPromptsResponse:
|
) -> DynamicPromptsResponse:
|
||||||
"""Creates a batch process"""
|
"""Creates a batch process"""
|
||||||
generator: Union[RandomPromptGenerator, CombinatorialPromptGenerator]
|
|
||||||
try:
|
try:
|
||||||
error: Optional[str] = None
|
error: Optional[str] = None
|
||||||
if combinatorial:
|
if combinatorial:
|
||||||
|
@ -1,97 +0,0 @@
|
|||||||
from typing import Optional
|
|
||||||
|
|
||||||
from fastapi import APIRouter, Body, HTTPException, Path, Query
|
|
||||||
|
|
||||||
from invokeai.app.api.dependencies import ApiDependencies
|
|
||||||
from invokeai.app.services.shared.pagination import PaginatedResults
|
|
||||||
from invokeai.app.services.shared.sqlite.sqlite_common import SQLiteDirection
|
|
||||||
from invokeai.app.services.workflow_records.workflow_records_common import (
|
|
||||||
Workflow,
|
|
||||||
WorkflowCategory,
|
|
||||||
WorkflowNotFoundError,
|
|
||||||
WorkflowRecordDTO,
|
|
||||||
WorkflowRecordListItemDTO,
|
|
||||||
WorkflowRecordOrderBy,
|
|
||||||
WorkflowWithoutID,
|
|
||||||
)
|
|
||||||
|
|
||||||
workflows_router = APIRouter(prefix="/v1/workflows", tags=["workflows"])
|
|
||||||
|
|
||||||
|
|
||||||
@workflows_router.get(
|
|
||||||
"/i/{workflow_id}",
|
|
||||||
operation_id="get_workflow",
|
|
||||||
responses={
|
|
||||||
200: {"model": WorkflowRecordDTO},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
async def get_workflow(
|
|
||||||
workflow_id: str = Path(description="The workflow to get"),
|
|
||||||
) -> WorkflowRecordDTO:
|
|
||||||
"""Gets a workflow"""
|
|
||||||
try:
|
|
||||||
return ApiDependencies.invoker.services.workflow_records.get(workflow_id)
|
|
||||||
except WorkflowNotFoundError:
|
|
||||||
raise HTTPException(status_code=404, detail="Workflow not found")
|
|
||||||
|
|
||||||
|
|
||||||
@workflows_router.patch(
|
|
||||||
"/i/{workflow_id}",
|
|
||||||
operation_id="update_workflow",
|
|
||||||
responses={
|
|
||||||
200: {"model": WorkflowRecordDTO},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
async def update_workflow(
|
|
||||||
workflow: Workflow = Body(description="The updated workflow", embed=True),
|
|
||||||
) -> WorkflowRecordDTO:
|
|
||||||
"""Updates a workflow"""
|
|
||||||
return ApiDependencies.invoker.services.workflow_records.update(workflow=workflow)
|
|
||||||
|
|
||||||
|
|
||||||
@workflows_router.delete(
|
|
||||||
"/i/{workflow_id}",
|
|
||||||
operation_id="delete_workflow",
|
|
||||||
)
|
|
||||||
async def delete_workflow(
|
|
||||||
workflow_id: str = Path(description="The workflow to delete"),
|
|
||||||
) -> None:
|
|
||||||
"""Deletes a workflow"""
|
|
||||||
ApiDependencies.invoker.services.workflow_records.delete(workflow_id)
|
|
||||||
|
|
||||||
|
|
||||||
@workflows_router.post(
|
|
||||||
"/",
|
|
||||||
operation_id="create_workflow",
|
|
||||||
responses={
|
|
||||||
200: {"model": WorkflowRecordDTO},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
async def create_workflow(
|
|
||||||
workflow: WorkflowWithoutID = Body(description="The workflow to create", embed=True),
|
|
||||||
) -> WorkflowRecordDTO:
|
|
||||||
"""Creates a workflow"""
|
|
||||||
return ApiDependencies.invoker.services.workflow_records.create(workflow=workflow)
|
|
||||||
|
|
||||||
|
|
||||||
@workflows_router.get(
|
|
||||||
"/",
|
|
||||||
operation_id="list_workflows",
|
|
||||||
responses={
|
|
||||||
200: {"model": PaginatedResults[WorkflowRecordListItemDTO]},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
async def list_workflows(
|
|
||||||
page: int = Query(default=0, description="The page to get"),
|
|
||||||
per_page: int = Query(default=10, description="The number of workflows per page"),
|
|
||||||
order_by: WorkflowRecordOrderBy = Query(
|
|
||||||
default=WorkflowRecordOrderBy.Name, description="The attribute to order by"
|
|
||||||
),
|
|
||||||
direction: SQLiteDirection = Query(default=SQLiteDirection.Ascending, description="The direction to order by"),
|
|
||||||
category: WorkflowCategory = Query(default=WorkflowCategory.User, description="The category of workflow to get"),
|
|
||||||
query: Optional[str] = Query(default=None, description="The text to query by (matches name and description)"),
|
|
||||||
) -> PaginatedResults[WorkflowRecordListItemDTO]:
|
|
||||||
"""Gets a page of workflows"""
|
|
||||||
return ApiDependencies.invoker.services.workflow_records.get_many(
|
|
||||||
page=page, per_page=per_page, order_by=order_by, direction=direction, query=query, category=category
|
|
||||||
)
|
|
@ -5,7 +5,7 @@ from fastapi_events.handlers.local import local_handler
|
|||||||
from fastapi_events.typing import Event
|
from fastapi_events.typing import Event
|
||||||
from socketio import ASGIApp, AsyncServer
|
from socketio import ASGIApp, AsyncServer
|
||||||
|
|
||||||
from ..services.events.events_base import EventServiceBase
|
from ..services.events import EventServiceBase
|
||||||
|
|
||||||
|
|
||||||
class SocketIO:
|
class SocketIO:
|
||||||
@ -20,7 +20,6 @@ class SocketIO:
|
|||||||
self.__sio.on("subscribe_queue", handler=self._handle_sub_queue)
|
self.__sio.on("subscribe_queue", handler=self._handle_sub_queue)
|
||||||
self.__sio.on("unsubscribe_queue", handler=self._handle_unsub_queue)
|
self.__sio.on("unsubscribe_queue", handler=self._handle_unsub_queue)
|
||||||
local_handler.register(event_name=EventServiceBase.queue_event, _func=self._handle_queue_event)
|
local_handler.register(event_name=EventServiceBase.queue_event, _func=self._handle_queue_event)
|
||||||
local_handler.register(event_name=EventServiceBase.model_event, _func=self._handle_model_event)
|
|
||||||
|
|
||||||
async def _handle_queue_event(self, event: Event):
|
async def _handle_queue_event(self, event: Event):
|
||||||
await self.__sio.emit(
|
await self.__sio.emit(
|
||||||
@ -29,13 +28,10 @@ class SocketIO:
|
|||||||
room=event[1]["data"]["queue_id"],
|
room=event[1]["data"]["queue_id"],
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _handle_sub_queue(self, sid, data, *args, **kwargs) -> None:
|
async def _handle_sub_queue(self, sid, data, *args, **kwargs):
|
||||||
if "queue_id" in data:
|
if "queue_id" in data:
|
||||||
await self.__sio.enter_room(sid, data["queue_id"])
|
await self.__sio.enter_room(sid, data["queue_id"])
|
||||||
|
|
||||||
async def _handle_unsub_queue(self, sid, data, *args, **kwargs) -> None:
|
async def _handle_unsub_queue(self, sid, data, *args, **kwargs):
|
||||||
if "queue_id" in data:
|
if "queue_id" in data:
|
||||||
await self.__sio.leave_room(sid, data["queue_id"])
|
await self.__sio.enter_room(sid, data["queue_id"])
|
||||||
|
|
||||||
async def _handle_model_event(self, event: Event) -> None:
|
|
||||||
await self.__sio.emit(event=event[1]["event"], data=event[1]["data"])
|
|
||||||
|
@ -1,17 +1,10 @@
|
|||||||
|
from .services.config import InvokeAIAppConfig
|
||||||
|
|
||||||
# parse_args() must be called before any other imports. if it is not called first, consumers of the config
|
# parse_args() must be called before any other imports. if it is not called first, consumers of the config
|
||||||
# which are imported/used before parse_args() is called will get the default config values instead of the
|
# which are imported/used before parse_args() is called will get the default config values instead of the
|
||||||
# values from the command line or config file.
|
# values from the command line or config file.
|
||||||
import sys
|
|
||||||
|
|
||||||
from invokeai.version.invokeai_version import __version__
|
|
||||||
|
|
||||||
from .services.config import InvokeAIAppConfig
|
|
||||||
|
|
||||||
app_config = InvokeAIAppConfig.get_config()
|
app_config = InvokeAIAppConfig.get_config()
|
||||||
app_config.parse_args()
|
app_config.parse_args()
|
||||||
if app_config.version:
|
|
||||||
print(f"InvokeAI version {__version__}")
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
if True: # hack to make flake8 happy with imports coming after setting up the config
|
if True: # hack to make flake8 happy with imports coming after setting up the config
|
||||||
import asyncio
|
import asyncio
|
||||||
@ -19,56 +12,38 @@ if True: # hack to make flake8 happy with imports coming after setting up the c
|
|||||||
import socket
|
import socket
|
||||||
from inspect import signature
|
from inspect import signature
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
|
import torch
|
||||||
import uvicorn
|
import uvicorn
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from fastapi.middleware.gzip import GZipMiddleware
|
|
||||||
from fastapi.openapi.docs import get_redoc_html, get_swagger_ui_html
|
from fastapi.openapi.docs import get_redoc_html, get_swagger_ui_html
|
||||||
from fastapi.openapi.utils import get_openapi
|
from fastapi.openapi.utils import get_openapi
|
||||||
from fastapi.responses import FileResponse, HTMLResponse
|
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
from fastapi_events.handlers.local import local_handler
|
from fastapi_events.handlers.local import local_handler
|
||||||
from fastapi_events.middleware import EventHandlerASGIMiddleware
|
from fastapi_events.middleware import EventHandlerASGIMiddleware
|
||||||
from pydantic.json_schema import models_json_schema
|
from pydantic.schema import schema
|
||||||
from torch.backends.mps import is_available as is_mps_available
|
|
||||||
|
|
||||||
# for PyCharm:
|
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
import invokeai.backend.util.hotfixes # noqa: F401 (monkeypatching on import)
|
import invokeai.backend.util.hotfixes # noqa: F401 (monkeypatching on import)
|
||||||
import invokeai.frontend.web as web_dir
|
import invokeai.frontend.web as web_dir
|
||||||
|
from invokeai.version.invokeai_version import __version__
|
||||||
|
|
||||||
from ..backend.util.logging import InvokeAILogger
|
from ..backend.util.logging import InvokeAILogger
|
||||||
from .api.dependencies import ApiDependencies
|
from .api.dependencies import ApiDependencies
|
||||||
from .api.routers import (
|
from .api.routers import app_info, board_images, boards, images, models, session_queue, sessions, utilities
|
||||||
app_info,
|
|
||||||
board_images,
|
|
||||||
boards,
|
|
||||||
download_queue,
|
|
||||||
images,
|
|
||||||
model_records,
|
|
||||||
models,
|
|
||||||
session_queue,
|
|
||||||
sessions,
|
|
||||||
utilities,
|
|
||||||
workflows,
|
|
||||||
)
|
|
||||||
from .api.sockets import SocketIO
|
from .api.sockets import SocketIO
|
||||||
from .invocations.baseinvocation import (
|
from .invocations.baseinvocation import BaseInvocation, UIConfigBase, _InputField, _OutputField
|
||||||
BaseInvocation,
|
|
||||||
InputFieldJSONSchemaExtra,
|
|
||||||
OutputFieldJSONSchemaExtra,
|
|
||||||
UIConfigBase,
|
|
||||||
)
|
|
||||||
|
|
||||||
if is_mps_available():
|
if torch.backends.mps.is_available():
|
||||||
|
# noinspection PyUnresolvedReferences
|
||||||
import invokeai.backend.util.mps_fixes # noqa: F401 (monkeypatching on import)
|
import invokeai.backend.util.mps_fixes # noqa: F401 (monkeypatching on import)
|
||||||
|
|
||||||
|
|
||||||
app_config = InvokeAIAppConfig.get_config()
|
app_config = InvokeAIAppConfig.get_config()
|
||||||
app_config.parse_args()
|
app_config.parse_args()
|
||||||
logger = InvokeAILogger.get_logger(config=app_config)
|
logger = InvokeAILogger.get_logger(config=app_config)
|
||||||
|
|
||||||
# fix for windows mimetypes registry entries being borked
|
# fix for windows mimetypes registry entries being borked
|
||||||
# see https://github.com/invoke-ai/InvokeAI/discussions/3684#discussioncomment-6391352
|
# see https://github.com/invoke-ai/InvokeAI/discussions/3684#discussioncomment-6391352
|
||||||
mimetypes.add_type("application/javascript", ".js")
|
mimetypes.add_type("application/javascript", ".js")
|
||||||
@ -76,7 +51,7 @@ mimetypes.add_type("text/css", ".css")
|
|||||||
|
|
||||||
# Create the app
|
# Create the app
|
||||||
# TODO: create this all in a method so configuration/etc. can be passed in?
|
# TODO: create this all in a method so configuration/etc. can be passed in?
|
||||||
app = FastAPI(title="Invoke AI", docs_url=None, redoc_url=None, separate_input_output_schemas=False)
|
app = FastAPI(title="Invoke AI", docs_url=None, redoc_url=None)
|
||||||
|
|
||||||
# Add event handler
|
# Add event handler
|
||||||
event_handler_id: int = id(app)
|
event_handler_id: int = id(app)
|
||||||
@ -88,47 +63,53 @@ app.add_middleware(
|
|||||||
|
|
||||||
socket_io = SocketIO(app)
|
socket_io = SocketIO(app)
|
||||||
|
|
||||||
app.add_middleware(
|
|
||||||
CORSMiddleware,
|
|
||||||
allow_origins=app_config.allow_origins,
|
|
||||||
allow_credentials=app_config.allow_credentials,
|
|
||||||
allow_methods=app_config.allow_methods,
|
|
||||||
allow_headers=app_config.allow_headers,
|
|
||||||
)
|
|
||||||
|
|
||||||
app.add_middleware(GZipMiddleware, minimum_size=1000)
|
|
||||||
|
|
||||||
|
|
||||||
# Add startup event to load dependencies
|
# Add startup event to load dependencies
|
||||||
@app.on_event("startup")
|
@app.on_event("startup")
|
||||||
async def startup_event() -> None:
|
async def startup_event():
|
||||||
|
app.add_middleware(
|
||||||
|
CORSMiddleware,
|
||||||
|
allow_origins=app_config.allow_origins,
|
||||||
|
allow_credentials=app_config.allow_credentials,
|
||||||
|
allow_methods=app_config.allow_methods,
|
||||||
|
allow_headers=app_config.allow_headers,
|
||||||
|
)
|
||||||
|
|
||||||
ApiDependencies.initialize(config=app_config, event_handler_id=event_handler_id, logger=logger)
|
ApiDependencies.initialize(config=app_config, event_handler_id=event_handler_id, logger=logger)
|
||||||
|
|
||||||
|
|
||||||
# Shut down threads
|
# Shut down threads
|
||||||
@app.on_event("shutdown")
|
@app.on_event("shutdown")
|
||||||
async def shutdown_event() -> None:
|
async def shutdown_event():
|
||||||
ApiDependencies.shutdown()
|
ApiDependencies.shutdown()
|
||||||
|
|
||||||
|
|
||||||
# Include all routers
|
# Include all routers
|
||||||
|
# TODO: REMOVE
|
||||||
|
# app.include_router(
|
||||||
|
# invocation.invocation_router,
|
||||||
|
# prefix = '/api')
|
||||||
|
|
||||||
app.include_router(sessions.session_router, prefix="/api")
|
app.include_router(sessions.session_router, prefix="/api")
|
||||||
|
|
||||||
app.include_router(utilities.utilities_router, prefix="/api")
|
app.include_router(utilities.utilities_router, prefix="/api")
|
||||||
|
|
||||||
app.include_router(models.models_router, prefix="/api")
|
app.include_router(models.models_router, prefix="/api")
|
||||||
app.include_router(model_records.model_records_router, prefix="/api")
|
|
||||||
app.include_router(download_queue.download_queue_router, prefix="/api")
|
|
||||||
app.include_router(images.images_router, prefix="/api")
|
app.include_router(images.images_router, prefix="/api")
|
||||||
|
|
||||||
app.include_router(boards.boards_router, prefix="/api")
|
app.include_router(boards.boards_router, prefix="/api")
|
||||||
|
|
||||||
app.include_router(board_images.board_images_router, prefix="/api")
|
app.include_router(board_images.board_images_router, prefix="/api")
|
||||||
|
|
||||||
app.include_router(app_info.app_router, prefix="/api")
|
app.include_router(app_info.app_router, prefix="/api")
|
||||||
|
|
||||||
app.include_router(session_queue.session_queue_router, prefix="/api")
|
app.include_router(session_queue.session_queue_router, prefix="/api")
|
||||||
app.include_router(workflows.workflows_router, prefix="/api")
|
|
||||||
|
|
||||||
|
|
||||||
# Build a custom OpenAPI to include all outputs
|
# Build a custom OpenAPI to include all outputs
|
||||||
# TODO: can outputs be included on metadata of invocation schemas somehow?
|
# TODO: can outputs be included on metadata of invocation schemas somehow?
|
||||||
def custom_openapi() -> dict[str, Any]:
|
def custom_openapi():
|
||||||
if app.openapi_schema:
|
if app.openapi_schema:
|
||||||
return app.openapi_schema
|
return app.openapi_schema
|
||||||
openapi_schema = get_openapi(
|
openapi_schema = get_openapi(
|
||||||
@ -136,47 +117,39 @@ def custom_openapi() -> dict[str, Any]:
|
|||||||
description="An API for invoking AI image operations",
|
description="An API for invoking AI image operations",
|
||||||
version="1.0.0",
|
version="1.0.0",
|
||||||
routes=app.routes,
|
routes=app.routes,
|
||||||
separate_input_output_schemas=False, # https://fastapi.tiangolo.com/how-to/separate-openapi-schemas/
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add all outputs
|
# Add all outputs
|
||||||
all_invocations = BaseInvocation.get_invocations()
|
all_invocations = BaseInvocation.get_invocations()
|
||||||
output_types = set()
|
output_types = set()
|
||||||
output_type_titles = {}
|
output_type_titles = dict()
|
||||||
for invoker in all_invocations:
|
for invoker in all_invocations:
|
||||||
output_type = signature(invoker.invoke).return_annotation
|
output_type = signature(invoker.invoke).return_annotation
|
||||||
output_types.add(output_type)
|
output_types.add(output_type)
|
||||||
|
|
||||||
output_schemas = models_json_schema(
|
output_schemas = schema(output_types, ref_prefix="#/components/schemas/")
|
||||||
models=[(o, "serialization") for o in output_types], ref_template="#/components/schemas/{model}"
|
for schema_key, output_schema in output_schemas["definitions"].items():
|
||||||
)
|
output_schema["class"] = "output"
|
||||||
for schema_key, output_schema in output_schemas[1]["$defs"].items():
|
openapi_schema["components"]["schemas"][schema_key] = output_schema
|
||||||
|
|
||||||
# TODO: note that we assume the schema_key here is the TYPE.__name__
|
# TODO: note that we assume the schema_key here is the TYPE.__name__
|
||||||
# This could break in some cases, figure out a better way to do it
|
# This could break in some cases, figure out a better way to do it
|
||||||
output_type_titles[schema_key] = output_schema["title"]
|
output_type_titles[schema_key] = output_schema["title"]
|
||||||
|
|
||||||
# Add Node Editor UI helper schemas
|
# Add Node Editor UI helper schemas
|
||||||
ui_config_schemas = models_json_schema(
|
ui_config_schemas = schema([UIConfigBase, _InputField, _OutputField], ref_prefix="#/components/schemas/")
|
||||||
[
|
for schema_key, ui_config_schema in ui_config_schemas["definitions"].items():
|
||||||
(UIConfigBase, "serialization"),
|
|
||||||
(InputFieldJSONSchemaExtra, "serialization"),
|
|
||||||
(OutputFieldJSONSchemaExtra, "serialization"),
|
|
||||||
],
|
|
||||||
ref_template="#/components/schemas/{model}",
|
|
||||||
)
|
|
||||||
for schema_key, ui_config_schema in ui_config_schemas[1]["$defs"].items():
|
|
||||||
openapi_schema["components"]["schemas"][schema_key] = ui_config_schema
|
openapi_schema["components"]["schemas"][schema_key] = ui_config_schema
|
||||||
|
|
||||||
# Add a reference to the output type to additionalProperties of the invoker schema
|
# Add a reference to the output type to additionalProperties of the invoker schema
|
||||||
for invoker in all_invocations:
|
for invoker in all_invocations:
|
||||||
invoker_name = invoker.__name__ # type: ignore [attr-defined] # this is a valid attribute
|
invoker_name = invoker.__name__
|
||||||
output_type = signature(obj=invoker.invoke).return_annotation
|
output_type = signature(invoker.invoke).return_annotation
|
||||||
output_type_title = output_type_titles[output_type.__name__]
|
output_type_title = output_type_titles[output_type.__name__]
|
||||||
invoker_schema = openapi_schema["components"]["schemas"][f"{invoker_name}"]
|
invoker_schema = openapi_schema["components"]["schemas"][invoker_name]
|
||||||
outputs_ref = {"$ref": f"#/components/schemas/{output_type_title}"}
|
outputs_ref = {"$ref": f"#/components/schemas/{output_type_title}"}
|
||||||
invoker_schema["output"] = outputs_ref
|
invoker_schema["output"] = outputs_ref
|
||||||
invoker_schema["class"] = "invocation"
|
invoker_schema["class"] = "invocation"
|
||||||
openapi_schema["components"]["schemas"][f"{output_type_title}"]["class"] = "output"
|
|
||||||
|
|
||||||
from invokeai.backend.model_management.models import get_model_config_enums
|
from invokeai.backend.model_management.models import get_model_config_enums
|
||||||
|
|
||||||
@ -187,57 +160,48 @@ def custom_openapi() -> dict[str, Any]:
|
|||||||
# print(f"Config with name {name} already defined")
|
# print(f"Config with name {name} already defined")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
openapi_schema["components"]["schemas"][name] = {
|
# "BaseModelType":{"title":"BaseModelType","description":"An enumeration.","enum":["sd-1","sd-2"],"type":"string"}
|
||||||
"title": name,
|
openapi_schema["components"]["schemas"][name] = dict(
|
||||||
"description": "An enumeration.",
|
title=name,
|
||||||
"type": "string",
|
description="An enumeration.",
|
||||||
"enum": [v.value for v in model_config_format_enum],
|
type="string",
|
||||||
}
|
enum=list(v.value for v in model_config_format_enum),
|
||||||
|
)
|
||||||
|
|
||||||
app.openapi_schema = openapi_schema
|
app.openapi_schema = openapi_schema
|
||||||
return app.openapi_schema
|
return app.openapi_schema
|
||||||
|
|
||||||
|
|
||||||
app.openapi = custom_openapi # type: ignore [method-assign] # this is a valid assignment
|
app.openapi = custom_openapi
|
||||||
|
|
||||||
|
# Override API doc favicons
|
||||||
|
app.mount("/static", StaticFiles(directory=Path(web_dir.__path__[0], "static/dream_web")), name="static")
|
||||||
|
|
||||||
|
|
||||||
@app.get("/docs", include_in_schema=False)
|
@app.get("/docs", include_in_schema=False)
|
||||||
def overridden_swagger() -> HTMLResponse:
|
def overridden_swagger():
|
||||||
return get_swagger_ui_html(
|
return get_swagger_ui_html(
|
||||||
openapi_url=app.openapi_url, # type: ignore [arg-type] # this is always a string
|
openapi_url=app.openapi_url,
|
||||||
title=app.title,
|
title=app.title,
|
||||||
swagger_favicon_url="/static/docs/favicon.ico",
|
swagger_favicon_url="/static/favicon.ico",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/redoc", include_in_schema=False)
|
@app.get("/redoc", include_in_schema=False)
|
||||||
def overridden_redoc() -> HTMLResponse:
|
def overridden_redoc():
|
||||||
return get_redoc_html(
|
return get_redoc_html(
|
||||||
openapi_url=app.openapi_url, # type: ignore [arg-type] # this is always a string
|
openapi_url=app.openapi_url,
|
||||||
title=app.title,
|
title=app.title,
|
||||||
redoc_favicon_url="/static/docs/favicon.ico",
|
redoc_favicon_url="/static/favicon.ico",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
web_root_path = Path(list(web_dir.__path__)[0])
|
# Must mount *after* the other routes else it borks em
|
||||||
|
app.mount("/", StaticFiles(directory=Path(web_dir.__path__[0], "dist"), html=True), name="ui")
|
||||||
# Only serve the UI if we it has a build
|
|
||||||
if (web_root_path / "dist").exists():
|
|
||||||
# Cannot add headers to StaticFiles, so we must serve index.html with a custom route
|
|
||||||
# Add cache-control: no-store header to prevent caching of index.html, which leads to broken UIs at release
|
|
||||||
@app.get("/", include_in_schema=False, name="ui_root")
|
|
||||||
def get_index() -> FileResponse:
|
|
||||||
return FileResponse(Path(web_root_path, "dist/index.html"), headers={"Cache-Control": "no-store"})
|
|
||||||
|
|
||||||
# # Must mount *after* the other routes else it borks em
|
|
||||||
app.mount("/assets", StaticFiles(directory=Path(web_root_path, "dist/assets/")), name="assets")
|
|
||||||
app.mount("/locales", StaticFiles(directory=Path(web_root_path, "dist/locales/")), name="locales")
|
|
||||||
|
|
||||||
app.mount("/static", StaticFiles(directory=Path(web_root_path, "static/")), name="static") # docs favicon is in here
|
|
||||||
|
|
||||||
|
|
||||||
def invoke_api() -> None:
|
def invoke_api():
|
||||||
def find_port(port: int) -> int:
|
def find_port(port: int):
|
||||||
"""Find a port not in use starting at given port"""
|
"""Find a port not in use starting at given port"""
|
||||||
# Taken from https://waylonwalker.com/python-find-available-port/, thanks Waylon!
|
# Taken from https://waylonwalker.com/python-find-available-port/, thanks Waylon!
|
||||||
# https://github.com/WaylonWalker
|
# https://github.com/WaylonWalker
|
||||||
@ -272,10 +236,8 @@ def invoke_api() -> None:
|
|||||||
app=app,
|
app=app,
|
||||||
host=app_config.host,
|
host=app_config.host,
|
||||||
port=port,
|
port=port,
|
||||||
loop="asyncio",
|
loop=loop,
|
||||||
log_level=app_config.log_level,
|
log_level=app_config.log_level,
|
||||||
ssl_certfile=app_config.ssl_certfile,
|
|
||||||
ssl_keyfile=app_config.ssl_keyfile,
|
|
||||||
)
|
)
|
||||||
server = uvicorn.Server(config)
|
server = uvicorn.Server(config)
|
||||||
|
|
||||||
@ -290,4 +252,7 @@ def invoke_api() -> None:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
invoke_api()
|
if app_config.version:
|
||||||
|
print(f"InvokeAI version {__version__}")
|
||||||
|
else:
|
||||||
|
invoke_api()
|
||||||
|
313
invokeai/app/cli/commands.py
Normal file
313
invokeai/app/cli/commands.py
Normal file
@ -0,0 +1,313 @@
|
|||||||
|
# Copyright (c) 2023 Kyle Schouviller (https://github.com/kyle0654)
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
from abc import ABC, abstractmethod
|
||||||
|
from typing import Any, Callable, Iterable, Literal, Union, get_args, get_origin, get_type_hints
|
||||||
|
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import networkx as nx
|
||||||
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
import invokeai.backend.util.logging as logger
|
||||||
|
|
||||||
|
from ..invocations.baseinvocation import BaseInvocation
|
||||||
|
from ..invocations.image import ImageField
|
||||||
|
from ..services.graph import Edge, GraphExecutionState, LibraryGraph
|
||||||
|
from ..services.invoker import Invoker
|
||||||
|
|
||||||
|
|
||||||
|
def add_field_argument(command_parser, name: str, field, default_override=None):
|
||||||
|
default = (
|
||||||
|
default_override
|
||||||
|
if default_override is not None
|
||||||
|
else field.default
|
||||||
|
if field.default_factory is None
|
||||||
|
else field.default_factory()
|
||||||
|
)
|
||||||
|
if get_origin(field.type_) == Literal:
|
||||||
|
allowed_values = get_args(field.type_)
|
||||||
|
allowed_types = set()
|
||||||
|
for val in allowed_values:
|
||||||
|
allowed_types.add(type(val))
|
||||||
|
allowed_types_list = list(allowed_types)
|
||||||
|
field_type = allowed_types_list[0] if len(allowed_types) == 1 else Union[allowed_types_list] # type: ignore
|
||||||
|
|
||||||
|
command_parser.add_argument(
|
||||||
|
f"--{name}",
|
||||||
|
dest=name,
|
||||||
|
type=field_type,
|
||||||
|
default=default,
|
||||||
|
choices=allowed_values,
|
||||||
|
help=field.field_info.description,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
command_parser.add_argument(
|
||||||
|
f"--{name}",
|
||||||
|
dest=name,
|
||||||
|
type=field.type_,
|
||||||
|
default=default,
|
||||||
|
help=field.field_info.description,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_parsers(
|
||||||
|
subparsers,
|
||||||
|
commands: list[type],
|
||||||
|
command_field: str = "type",
|
||||||
|
exclude_fields: list[str] = ["id", "type"],
|
||||||
|
add_arguments: Union[Callable[[argparse.ArgumentParser], None], None] = None,
|
||||||
|
):
|
||||||
|
"""Adds parsers for each command to the subparsers"""
|
||||||
|
|
||||||
|
# Create subparsers for each command
|
||||||
|
for command in commands:
|
||||||
|
hints = get_type_hints(command)
|
||||||
|
cmd_name = get_args(hints[command_field])[0]
|
||||||
|
command_parser = subparsers.add_parser(cmd_name, help=command.__doc__)
|
||||||
|
|
||||||
|
if add_arguments is not None:
|
||||||
|
add_arguments(command_parser)
|
||||||
|
|
||||||
|
# Convert all fields to arguments
|
||||||
|
fields = command.__fields__ # type: ignore
|
||||||
|
for name, field in fields.items():
|
||||||
|
if name in exclude_fields:
|
||||||
|
continue
|
||||||
|
|
||||||
|
add_field_argument(command_parser, name, field)
|
||||||
|
|
||||||
|
|
||||||
|
def add_graph_parsers(
|
||||||
|
subparsers, graphs: list[LibraryGraph], add_arguments: Union[Callable[[argparse.ArgumentParser], None], None] = None
|
||||||
|
):
|
||||||
|
for graph in graphs:
|
||||||
|
command_parser = subparsers.add_parser(graph.name, help=graph.description)
|
||||||
|
|
||||||
|
if add_arguments is not None:
|
||||||
|
add_arguments(command_parser)
|
||||||
|
|
||||||
|
# Add arguments for inputs
|
||||||
|
for exposed_input in graph.exposed_inputs:
|
||||||
|
node = graph.graph.get_node(exposed_input.node_path)
|
||||||
|
field = node.__fields__[exposed_input.field]
|
||||||
|
default_override = getattr(node, exposed_input.field)
|
||||||
|
add_field_argument(command_parser, exposed_input.alias, field, default_override)
|
||||||
|
|
||||||
|
|
||||||
|
class CliContext:
|
||||||
|
invoker: Invoker
|
||||||
|
session: GraphExecutionState
|
||||||
|
parser: argparse.ArgumentParser
|
||||||
|
defaults: dict[str, Any]
|
||||||
|
graph_nodes: dict[str, str]
|
||||||
|
nodes_added: list[str]
|
||||||
|
|
||||||
|
def __init__(self, invoker: Invoker, session: GraphExecutionState, parser: argparse.ArgumentParser):
|
||||||
|
self.invoker = invoker
|
||||||
|
self.session = session
|
||||||
|
self.parser = parser
|
||||||
|
self.defaults = dict()
|
||||||
|
self.graph_nodes = dict()
|
||||||
|
self.nodes_added = list()
|
||||||
|
|
||||||
|
def get_session(self):
|
||||||
|
self.session = self.invoker.services.graph_execution_manager.get(self.session.id)
|
||||||
|
return self.session
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
self.session = self.invoker.create_execution_state()
|
||||||
|
self.graph_nodes = dict()
|
||||||
|
self.nodes_added = list()
|
||||||
|
# Leave defaults unchanged
|
||||||
|
|
||||||
|
def add_node(self, node: BaseInvocation):
|
||||||
|
self.get_session()
|
||||||
|
self.session.graph.add_node(node)
|
||||||
|
self.nodes_added.append(node.id)
|
||||||
|
self.invoker.services.graph_execution_manager.set(self.session)
|
||||||
|
|
||||||
|
def add_edge(self, edge: Edge):
|
||||||
|
self.get_session()
|
||||||
|
self.session.add_edge(edge)
|
||||||
|
self.invoker.services.graph_execution_manager.set(self.session)
|
||||||
|
|
||||||
|
|
||||||
|
class ExitCli(Exception):
|
||||||
|
"""Exception to exit the CLI"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BaseCommand(ABC, BaseModel):
|
||||||
|
"""A CLI command"""
|
||||||
|
|
||||||
|
# All commands must include a type name like this:
|
||||||
|
# type: Literal['your_command_name'] = 'your_command_name'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_all_subclasses(cls):
|
||||||
|
subclasses = []
|
||||||
|
toprocess = [cls]
|
||||||
|
while len(toprocess) > 0:
|
||||||
|
next = toprocess.pop(0)
|
||||||
|
next_subclasses = next.__subclasses__()
|
||||||
|
subclasses.extend(next_subclasses)
|
||||||
|
toprocess.extend(next_subclasses)
|
||||||
|
return subclasses
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_commands(cls):
|
||||||
|
return tuple(BaseCommand.get_all_subclasses())
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_commands_map(cls):
|
||||||
|
# Get the type strings out of the literals and into a dictionary
|
||||||
|
return dict(map(lambda t: (get_args(get_type_hints(t)["type"])[0], t), BaseCommand.get_all_subclasses()))
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def run(self, context: CliContext) -> None:
|
||||||
|
"""Run the command. Raise ExitCli to exit."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ExitCommand(BaseCommand):
|
||||||
|
"""Exits the CLI"""
|
||||||
|
|
||||||
|
type: Literal["exit"] = "exit"
|
||||||
|
|
||||||
|
def run(self, context: CliContext) -> None:
|
||||||
|
raise ExitCli()
|
||||||
|
|
||||||
|
|
||||||
|
class HelpCommand(BaseCommand):
|
||||||
|
"""Shows help"""
|
||||||
|
|
||||||
|
type: Literal["help"] = "help"
|
||||||
|
|
||||||
|
def run(self, context: CliContext) -> None:
|
||||||
|
context.parser.print_help()
|
||||||
|
|
||||||
|
|
||||||
|
def get_graph_execution_history(
|
||||||
|
graph_execution_state: GraphExecutionState,
|
||||||
|
) -> Iterable[str]:
|
||||||
|
"""Gets the history of fully-executed invocations for a graph execution"""
|
||||||
|
return (n for n in reversed(graph_execution_state.executed_history) if n in graph_execution_state.graph.nodes)
|
||||||
|
|
||||||
|
|
||||||
|
def get_invocation_command(invocation) -> str:
|
||||||
|
fields = invocation.__fields__.items()
|
||||||
|
type_hints = get_type_hints(type(invocation))
|
||||||
|
command = [invocation.type]
|
||||||
|
for name, field in fields:
|
||||||
|
if name in ["id", "type"]:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# TODO: add links
|
||||||
|
|
||||||
|
# Skip image fields when serializing command
|
||||||
|
type_hint = type_hints.get(name) or None
|
||||||
|
if type_hint is ImageField or ImageField in get_args(type_hint):
|
||||||
|
continue
|
||||||
|
|
||||||
|
field_value = getattr(invocation, name)
|
||||||
|
field_default = field.default
|
||||||
|
if field_value != field_default:
|
||||||
|
if type_hint is str or str in get_args(type_hint):
|
||||||
|
command.append(f'--{name} "{field_value}"')
|
||||||
|
else:
|
||||||
|
command.append(f"--{name} {field_value}")
|
||||||
|
|
||||||
|
return " ".join(command)
|
||||||
|
|
||||||
|
|
||||||
|
class HistoryCommand(BaseCommand):
|
||||||
|
"""Shows the invocation history"""
|
||||||
|
|
||||||
|
type: Literal["history"] = "history"
|
||||||
|
|
||||||
|
# Inputs
|
||||||
|
# fmt: off
|
||||||
|
count: int = Field(default=5, gt=0, description="The number of history entries to show")
|
||||||
|
# fmt: on
|
||||||
|
|
||||||
|
def run(self, context: CliContext) -> None:
|
||||||
|
history = list(get_graph_execution_history(context.get_session()))
|
||||||
|
for i in range(min(self.count, len(history))):
|
||||||
|
entry_id = history[-1 - i]
|
||||||
|
entry = context.get_session().graph.get_node(entry_id)
|
||||||
|
logger.info(f"{entry_id}: {get_invocation_command(entry)}")
|
||||||
|
|
||||||
|
|
||||||
|
class SetDefaultCommand(BaseCommand):
|
||||||
|
"""Sets a default value for a field"""
|
||||||
|
|
||||||
|
type: Literal["default"] = "default"
|
||||||
|
|
||||||
|
# Inputs
|
||||||
|
# fmt: off
|
||||||
|
field: str = Field(description="The field to set the default for")
|
||||||
|
value: str = Field(description="The value to set the default to, or None to clear the default")
|
||||||
|
# fmt: on
|
||||||
|
|
||||||
|
def run(self, context: CliContext) -> None:
|
||||||
|
if self.value is None:
|
||||||
|
if self.field in context.defaults:
|
||||||
|
del context.defaults[self.field]
|
||||||
|
else:
|
||||||
|
context.defaults[self.field] = self.value
|
||||||
|
|
||||||
|
|
||||||
|
class DrawGraphCommand(BaseCommand):
|
||||||
|
"""Debugs a graph"""
|
||||||
|
|
||||||
|
type: Literal["draw_graph"] = "draw_graph"
|
||||||
|
|
||||||
|
def run(self, context: CliContext) -> None:
|
||||||
|
session: GraphExecutionState = context.invoker.services.graph_execution_manager.get(context.session.id)
|
||||||
|
nxgraph = session.graph.nx_graph_flat()
|
||||||
|
|
||||||
|
# Draw the networkx graph
|
||||||
|
plt.figure(figsize=(20, 20))
|
||||||
|
pos = nx.spectral_layout(nxgraph)
|
||||||
|
nx.draw_networkx_nodes(nxgraph, pos, node_size=1000)
|
||||||
|
nx.draw_networkx_edges(nxgraph, pos, width=2)
|
||||||
|
nx.draw_networkx_labels(nxgraph, pos, font_size=20, font_family="sans-serif")
|
||||||
|
plt.axis("off")
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
class DrawExecutionGraphCommand(BaseCommand):
|
||||||
|
"""Debugs an execution graph"""
|
||||||
|
|
||||||
|
type: Literal["draw_xgraph"] = "draw_xgraph"
|
||||||
|
|
||||||
|
def run(self, context: CliContext) -> None:
|
||||||
|
session: GraphExecutionState = context.invoker.services.graph_execution_manager.get(context.session.id)
|
||||||
|
nxgraph = session.execution_graph.nx_graph_flat()
|
||||||
|
|
||||||
|
# Draw the networkx graph
|
||||||
|
plt.figure(figsize=(20, 20))
|
||||||
|
pos = nx.spectral_layout(nxgraph)
|
||||||
|
nx.draw_networkx_nodes(nxgraph, pos, node_size=1000)
|
||||||
|
nx.draw_networkx_edges(nxgraph, pos, width=2)
|
||||||
|
nx.draw_networkx_labels(nxgraph, pos, font_size=20, font_family="sans-serif")
|
||||||
|
plt.axis("off")
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
class SortedHelpFormatter(argparse.HelpFormatter):
|
||||||
|
def _iter_indented_subactions(self, action):
|
||||||
|
try:
|
||||||
|
get_subactions = action._get_subactions
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self._indent()
|
||||||
|
if isinstance(action, argparse._SubParsersAction):
|
||||||
|
for subaction in sorted(get_subactions(), key=lambda x: x.dest):
|
||||||
|
yield subaction
|
||||||
|
else:
|
||||||
|
for subaction in get_subactions():
|
||||||
|
yield subaction
|
||||||
|
self._dedent()
|
171
invokeai/app/cli/completer.py
Normal file
171
invokeai/app/cli/completer.py
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
"""
|
||||||
|
Readline helper functions for cli_app.py
|
||||||
|
You may import the global singleton `completer` to get access to the
|
||||||
|
completer object.
|
||||||
|
"""
|
||||||
|
import atexit
|
||||||
|
import readline
|
||||||
|
import shlex
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Dict, List, Literal, get_args, get_origin, get_type_hints
|
||||||
|
|
||||||
|
import invokeai.backend.util.logging as logger
|
||||||
|
|
||||||
|
from ...backend import ModelManager
|
||||||
|
from ..invocations.baseinvocation import BaseInvocation
|
||||||
|
from ..services.invocation_services import InvocationServices
|
||||||
|
from .commands import BaseCommand
|
||||||
|
|
||||||
|
# singleton object, class variable
|
||||||
|
completer = None
|
||||||
|
|
||||||
|
|
||||||
|
class Completer(object):
|
||||||
|
def __init__(self, model_manager: ModelManager):
|
||||||
|
self.commands = self.get_commands()
|
||||||
|
self.matches = None
|
||||||
|
self.linebuffer = None
|
||||||
|
self.manager = model_manager
|
||||||
|
return
|
||||||
|
|
||||||
|
def complete(self, text, state):
|
||||||
|
"""
|
||||||
|
Complete commands and switches fromm the node CLI command line.
|
||||||
|
Switches are determined in a context-specific manner.
|
||||||
|
"""
|
||||||
|
|
||||||
|
buffer = readline.get_line_buffer()
|
||||||
|
if state == 0:
|
||||||
|
options = None
|
||||||
|
try:
|
||||||
|
current_command, current_switch = self.get_current_command(buffer)
|
||||||
|
options = self.get_command_options(current_command, current_switch)
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
options = options or list(self.parse_commands().keys())
|
||||||
|
|
||||||
|
if not text: # first time
|
||||||
|
self.matches = options
|
||||||
|
else:
|
||||||
|
self.matches = [s for s in options if s and s.startswith(text)]
|
||||||
|
|
||||||
|
try:
|
||||||
|
match = self.matches[state]
|
||||||
|
except IndexError:
|
||||||
|
match = None
|
||||||
|
return match
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_commands(self) -> List[object]:
|
||||||
|
"""
|
||||||
|
Return a list of all the client commands and invocations.
|
||||||
|
"""
|
||||||
|
return BaseCommand.get_commands() + BaseInvocation.get_invocations()
|
||||||
|
|
||||||
|
def get_current_command(self, buffer: str) -> tuple[str, str]:
|
||||||
|
"""
|
||||||
|
Parse the readline buffer to find the most recent command and its switch.
|
||||||
|
"""
|
||||||
|
if len(buffer) == 0:
|
||||||
|
return None, None
|
||||||
|
tokens = shlex.split(buffer)
|
||||||
|
command = None
|
||||||
|
switch = None
|
||||||
|
for t in tokens:
|
||||||
|
if t[0].isalpha():
|
||||||
|
if switch is None:
|
||||||
|
command = t
|
||||||
|
else:
|
||||||
|
switch = t
|
||||||
|
# don't try to autocomplete switches that are already complete
|
||||||
|
if switch and buffer.endswith(" "):
|
||||||
|
switch = None
|
||||||
|
return command or "", switch or ""
|
||||||
|
|
||||||
|
def parse_commands(self) -> Dict[str, List[str]]:
|
||||||
|
"""
|
||||||
|
Return a dict in which the keys are the command name
|
||||||
|
and the values are the parameters the command takes.
|
||||||
|
"""
|
||||||
|
result = dict()
|
||||||
|
for command in self.commands:
|
||||||
|
hints = get_type_hints(command)
|
||||||
|
name = get_args(hints["type"])[0]
|
||||||
|
result.update({name: hints})
|
||||||
|
return result
|
||||||
|
|
||||||
|
def get_command_options(self, command: str, switch: str) -> List[str]:
|
||||||
|
"""
|
||||||
|
Return all the parameters that can be passed to the command as
|
||||||
|
command-line switches. Returns None if the command is unrecognized.
|
||||||
|
"""
|
||||||
|
parsed_commands = self.parse_commands()
|
||||||
|
if command not in parsed_commands:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# handle switches in the format "-foo=bar"
|
||||||
|
argument = None
|
||||||
|
if switch and "=" in switch:
|
||||||
|
switch, argument = switch.split("=")
|
||||||
|
|
||||||
|
parameter = switch.strip("-")
|
||||||
|
if parameter in parsed_commands[command]:
|
||||||
|
if argument is None:
|
||||||
|
return self.get_parameter_options(parameter, parsed_commands[command][parameter])
|
||||||
|
else:
|
||||||
|
return [
|
||||||
|
f"--{parameter}={x}"
|
||||||
|
for x in self.get_parameter_options(parameter, parsed_commands[command][parameter])
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
return [f"--{x}" for x in parsed_commands[command].keys()]
|
||||||
|
|
||||||
|
def get_parameter_options(self, parameter: str, typehint) -> List[str]:
|
||||||
|
"""
|
||||||
|
Given a parameter type (such as Literal), offers autocompletions.
|
||||||
|
"""
|
||||||
|
if get_origin(typehint) == Literal:
|
||||||
|
return get_args(typehint)
|
||||||
|
if parameter == "model":
|
||||||
|
return self.manager.model_names()
|
||||||
|
|
||||||
|
def _pre_input_hook(self):
|
||||||
|
if self.linebuffer:
|
||||||
|
readline.insert_text(self.linebuffer)
|
||||||
|
readline.redisplay()
|
||||||
|
self.linebuffer = None
|
||||||
|
|
||||||
|
|
||||||
|
def set_autocompleter(services: InvocationServices) -> Completer:
|
||||||
|
global completer
|
||||||
|
|
||||||
|
if completer:
|
||||||
|
return completer
|
||||||
|
|
||||||
|
completer = Completer(services.model_manager)
|
||||||
|
|
||||||
|
readline.set_completer(completer.complete)
|
||||||
|
try:
|
||||||
|
readline.set_auto_history(True)
|
||||||
|
except AttributeError:
|
||||||
|
# pyreadline3 does not have a set_auto_history() method
|
||||||
|
pass
|
||||||
|
readline.set_pre_input_hook(completer._pre_input_hook)
|
||||||
|
readline.set_completer_delims(" ")
|
||||||
|
readline.parse_and_bind("tab: complete")
|
||||||
|
readline.parse_and_bind("set print-completions-horizontally off")
|
||||||
|
readline.parse_and_bind("set page-completions on")
|
||||||
|
readline.parse_and_bind("set skip-completed-text on")
|
||||||
|
readline.parse_and_bind("set show-all-if-ambiguous on")
|
||||||
|
|
||||||
|
histfile = Path(services.configuration.root_dir / ".invoke_history")
|
||||||
|
try:
|
||||||
|
readline.read_history_file(histfile)
|
||||||
|
readline.set_history_length(1000)
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
except OSError: # file likely corrupted
|
||||||
|
newname = f"{histfile}.old"
|
||||||
|
logger.error(f"Your history file {histfile} couldn't be loaded and may be corrupted. Renaming it to {newname}")
|
||||||
|
histfile.replace(Path(newname))
|
||||||
|
atexit.register(readline.write_history_file, histfile)
|
484
invokeai/app/cli_app.py
Normal file
484
invokeai/app/cli_app.py
Normal file
@ -0,0 +1,484 @@
|
|||||||
|
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654) and the InvokeAI Team
|
||||||
|
|
||||||
|
from invokeai.app.services.invocation_cache.invocation_cache_memory import MemoryInvocationCache
|
||||||
|
|
||||||
|
from .services.config import InvokeAIAppConfig
|
||||||
|
|
||||||
|
# parse_args() must be called before any other imports. if it is not called first, consumers of the config
|
||||||
|
# which are imported/used before parse_args() is called will get the default config values instead of the
|
||||||
|
# values from the command line or config file.
|
||||||
|
|
||||||
|
if True: # hack to make flake8 happy with imports coming after setting up the config
|
||||||
|
import argparse
|
||||||
|
import re
|
||||||
|
import shlex
|
||||||
|
import sqlite3
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
from typing import Optional, Union, get_type_hints
|
||||||
|
|
||||||
|
import torch
|
||||||
|
from pydantic import BaseModel, ValidationError
|
||||||
|
from pydantic.fields import Field
|
||||||
|
|
||||||
|
import invokeai.backend.util.hotfixes # noqa: F401 (monkeypatching on import)
|
||||||
|
from invokeai.app.services.board_image_record_storage import SqliteBoardImageRecordStorage
|
||||||
|
from invokeai.app.services.board_images import BoardImagesService, BoardImagesServiceDependencies
|
||||||
|
from invokeai.app.services.board_record_storage import SqliteBoardRecordStorage
|
||||||
|
from invokeai.app.services.boards import BoardService, BoardServiceDependencies
|
||||||
|
from invokeai.app.services.image_record_storage import SqliteImageRecordStorage
|
||||||
|
from invokeai.app.services.images import ImageService, ImageServiceDependencies
|
||||||
|
from invokeai.app.services.invocation_stats import InvocationStatsService
|
||||||
|
from invokeai.app.services.resource_name import SimpleNameService
|
||||||
|
from invokeai.app.services.urls import LocalUrlService
|
||||||
|
from invokeai.backend.util.logging import InvokeAILogger
|
||||||
|
from invokeai.version.invokeai_version import __version__
|
||||||
|
|
||||||
|
from .cli.commands import BaseCommand, CliContext, ExitCli, SortedHelpFormatter, add_graph_parsers, add_parsers
|
||||||
|
from .cli.completer import set_autocompleter
|
||||||
|
from .invocations.baseinvocation import BaseInvocation
|
||||||
|
from .services.default_graphs import create_system_graphs, default_text_to_image_graph_id
|
||||||
|
from .services.events import EventServiceBase
|
||||||
|
from .services.graph import (
|
||||||
|
Edge,
|
||||||
|
EdgeConnection,
|
||||||
|
GraphExecutionState,
|
||||||
|
GraphInvocation,
|
||||||
|
LibraryGraph,
|
||||||
|
are_connection_types_compatible,
|
||||||
|
)
|
||||||
|
from .services.image_file_storage import DiskImageFileStorage
|
||||||
|
from .services.invocation_queue import MemoryInvocationQueue
|
||||||
|
from .services.invocation_services import InvocationServices
|
||||||
|
from .services.invoker import Invoker
|
||||||
|
from .services.latent_storage import DiskLatentsStorage, ForwardCacheLatentsStorage
|
||||||
|
from .services.model_manager_service import ModelManagerService
|
||||||
|
from .services.processor import DefaultInvocationProcessor
|
||||||
|
from .services.sqlite import SqliteItemStorage
|
||||||
|
|
||||||
|
if torch.backends.mps.is_available():
|
||||||
|
import invokeai.backend.util.mps_fixes # noqa: F401 (monkeypatching on import)
|
||||||
|
|
||||||
|
config = InvokeAIAppConfig.get_config()
|
||||||
|
config.parse_args()
|
||||||
|
logger = InvokeAILogger().get_logger(config=config)
|
||||||
|
|
||||||
|
|
||||||
|
class CliCommand(BaseModel):
|
||||||
|
command: Union[BaseCommand.get_commands() + BaseInvocation.get_invocations()] = Field(discriminator="type") # type: ignore
|
||||||
|
|
||||||
|
|
||||||
|
class InvalidArgs(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def add_invocation_args(command_parser):
|
||||||
|
# Add linking capability
|
||||||
|
command_parser.add_argument(
|
||||||
|
"--link",
|
||||||
|
"-l",
|
||||||
|
action="append",
|
||||||
|
nargs=3,
|
||||||
|
help="A link in the format 'source_node source_field dest_field'. source_node can be relative to history (e.g. -1)",
|
||||||
|
)
|
||||||
|
|
||||||
|
command_parser.add_argument(
|
||||||
|
"--link_node",
|
||||||
|
"-ln",
|
||||||
|
action="append",
|
||||||
|
help="A link from all fields in the specified node. Node can be relative to history (e.g. -1)",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_command_parser(services: InvocationServices) -> argparse.ArgumentParser:
|
||||||
|
# Create invocation parser
|
||||||
|
parser = argparse.ArgumentParser(formatter_class=SortedHelpFormatter)
|
||||||
|
|
||||||
|
def exit(*args, **kwargs):
|
||||||
|
raise InvalidArgs
|
||||||
|
|
||||||
|
parser.exit = exit
|
||||||
|
subparsers = parser.add_subparsers(dest="type")
|
||||||
|
|
||||||
|
# Create subparsers for each invocation
|
||||||
|
invocations = BaseInvocation.get_all_subclasses()
|
||||||
|
add_parsers(subparsers, invocations, add_arguments=add_invocation_args)
|
||||||
|
|
||||||
|
# Create subparsers for each command
|
||||||
|
commands = BaseCommand.get_all_subclasses()
|
||||||
|
add_parsers(subparsers, commands, exclude_fields=["type"])
|
||||||
|
|
||||||
|
# Create subparsers for exposed CLI graphs
|
||||||
|
# TODO: add a way to identify these graphs
|
||||||
|
text_to_image = services.graph_library.get(default_text_to_image_graph_id)
|
||||||
|
add_graph_parsers(subparsers, [text_to_image], add_arguments=add_invocation_args)
|
||||||
|
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
class NodeField:
|
||||||
|
alias: str
|
||||||
|
node_path: str
|
||||||
|
field: str
|
||||||
|
field_type: type
|
||||||
|
|
||||||
|
def __init__(self, alias: str, node_path: str, field: str, field_type: type):
|
||||||
|
self.alias = alias
|
||||||
|
self.node_path = node_path
|
||||||
|
self.field = field
|
||||||
|
self.field_type = field_type
|
||||||
|
|
||||||
|
|
||||||
|
def fields_from_type_hints(hints: dict[str, type], node_path: str) -> dict[str, NodeField]:
|
||||||
|
return {k: NodeField(alias=k, node_path=node_path, field=k, field_type=v) for k, v in hints.items()}
|
||||||
|
|
||||||
|
|
||||||
|
def get_node_input_field(graph: LibraryGraph, field_alias: str, node_id: str) -> NodeField:
|
||||||
|
"""Gets the node field for the specified field alias"""
|
||||||
|
exposed_input = next(e for e in graph.exposed_inputs if e.alias == field_alias)
|
||||||
|
node_type = type(graph.graph.get_node(exposed_input.node_path))
|
||||||
|
return NodeField(
|
||||||
|
alias=exposed_input.alias,
|
||||||
|
node_path=f"{node_id}.{exposed_input.node_path}",
|
||||||
|
field=exposed_input.field,
|
||||||
|
field_type=get_type_hints(node_type)[exposed_input.field],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_node_output_field(graph: LibraryGraph, field_alias: str, node_id: str) -> NodeField:
|
||||||
|
"""Gets the node field for the specified field alias"""
|
||||||
|
exposed_output = next(e for e in graph.exposed_outputs if e.alias == field_alias)
|
||||||
|
node_type = type(graph.graph.get_node(exposed_output.node_path))
|
||||||
|
node_output_type = node_type.get_output_type()
|
||||||
|
return NodeField(
|
||||||
|
alias=exposed_output.alias,
|
||||||
|
node_path=f"{node_id}.{exposed_output.node_path}",
|
||||||
|
field=exposed_output.field,
|
||||||
|
field_type=get_type_hints(node_output_type)[exposed_output.field],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_node_inputs(invocation: BaseInvocation, context: CliContext) -> dict[str, NodeField]:
|
||||||
|
"""Gets the inputs for the specified invocation from the context"""
|
||||||
|
node_type = type(invocation)
|
||||||
|
if node_type is not GraphInvocation:
|
||||||
|
return fields_from_type_hints(get_type_hints(node_type), invocation.id)
|
||||||
|
else:
|
||||||
|
graph: LibraryGraph = context.invoker.services.graph_library.get(context.graph_nodes[invocation.id])
|
||||||
|
return {e.alias: get_node_input_field(graph, e.alias, invocation.id) for e in graph.exposed_inputs}
|
||||||
|
|
||||||
|
|
||||||
|
def get_node_outputs(invocation: BaseInvocation, context: CliContext) -> dict[str, NodeField]:
|
||||||
|
"""Gets the outputs for the specified invocation from the context"""
|
||||||
|
node_type = type(invocation)
|
||||||
|
if node_type is not GraphInvocation:
|
||||||
|
return fields_from_type_hints(get_type_hints(node_type.get_output_type()), invocation.id)
|
||||||
|
else:
|
||||||
|
graph: LibraryGraph = context.invoker.services.graph_library.get(context.graph_nodes[invocation.id])
|
||||||
|
return {e.alias: get_node_output_field(graph, e.alias, invocation.id) for e in graph.exposed_outputs}
|
||||||
|
|
||||||
|
|
||||||
|
def generate_matching_edges(a: BaseInvocation, b: BaseInvocation, context: CliContext) -> list[Edge]:
|
||||||
|
"""Generates all possible edges between two invocations"""
|
||||||
|
afields = get_node_outputs(a, context)
|
||||||
|
bfields = get_node_inputs(b, context)
|
||||||
|
|
||||||
|
matching_fields = set(afields.keys()).intersection(bfields.keys())
|
||||||
|
|
||||||
|
# Remove invalid fields
|
||||||
|
invalid_fields = set(["type", "id"])
|
||||||
|
matching_fields = matching_fields.difference(invalid_fields)
|
||||||
|
|
||||||
|
# Validate types
|
||||||
|
matching_fields = [
|
||||||
|
f for f in matching_fields if are_connection_types_compatible(afields[f].field_type, bfields[f].field_type)
|
||||||
|
]
|
||||||
|
|
||||||
|
edges = [
|
||||||
|
Edge(
|
||||||
|
source=EdgeConnection(node_id=afields[alias].node_path, field=afields[alias].field),
|
||||||
|
destination=EdgeConnection(node_id=bfields[alias].node_path, field=bfields[alias].field),
|
||||||
|
)
|
||||||
|
for alias in matching_fields
|
||||||
|
]
|
||||||
|
return edges
|
||||||
|
|
||||||
|
|
||||||
|
class SessionError(Exception):
|
||||||
|
"""Raised when a session error has occurred"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def invoke_all(context: CliContext):
|
||||||
|
"""Runs all invocations in the specified session"""
|
||||||
|
context.invoker.invoke(context.session, invoke_all=True)
|
||||||
|
while not context.get_session().is_complete():
|
||||||
|
# Wait some time
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
# Print any errors
|
||||||
|
if context.session.has_error():
|
||||||
|
for n in context.session.errors:
|
||||||
|
context.invoker.services.logger.error(
|
||||||
|
f"Error in node {n} (source node {context.session.prepared_source_mapping[n]}): {context.session.errors[n]}"
|
||||||
|
)
|
||||||
|
|
||||||
|
raise SessionError()
|
||||||
|
|
||||||
|
|
||||||
|
def invoke_cli():
|
||||||
|
logger.info(f"InvokeAI version {__version__}")
|
||||||
|
# get the optional list of invocations to execute on the command line
|
||||||
|
parser = config.get_parser()
|
||||||
|
parser.add_argument("commands", nargs="*")
|
||||||
|
invocation_commands = parser.parse_args().commands
|
||||||
|
|
||||||
|
# get the optional file to read commands from.
|
||||||
|
# Simplest is to use it for STDIN
|
||||||
|
if infile := config.from_file:
|
||||||
|
sys.stdin = open(infile, "r")
|
||||||
|
|
||||||
|
model_manager = ModelManagerService(config, logger)
|
||||||
|
|
||||||
|
events = EventServiceBase()
|
||||||
|
output_folder = config.output_path
|
||||||
|
|
||||||
|
# TODO: build a file/path manager?
|
||||||
|
if config.use_memory_db:
|
||||||
|
db_location = ":memory:"
|
||||||
|
else:
|
||||||
|
db_location = config.db_path
|
||||||
|
db_location.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
db_conn = sqlite3.connect(db_location, check_same_thread=False) # TODO: figure out a better threading solution
|
||||||
|
logger.info(f'InvokeAI database location is "{db_location}"')
|
||||||
|
|
||||||
|
graph_execution_manager = SqliteItemStorage[GraphExecutionState](conn=db_conn, table_name="graph_executions")
|
||||||
|
|
||||||
|
urls = LocalUrlService()
|
||||||
|
image_record_storage = SqliteImageRecordStorage(conn=db_conn)
|
||||||
|
image_file_storage = DiskImageFileStorage(f"{output_folder}/images")
|
||||||
|
names = SimpleNameService()
|
||||||
|
|
||||||
|
board_record_storage = SqliteBoardRecordStorage(conn=db_conn)
|
||||||
|
board_image_record_storage = SqliteBoardImageRecordStorage(conn=db_conn)
|
||||||
|
|
||||||
|
boards = BoardService(
|
||||||
|
services=BoardServiceDependencies(
|
||||||
|
board_image_record_storage=board_image_record_storage,
|
||||||
|
board_record_storage=board_record_storage,
|
||||||
|
image_record_storage=image_record_storage,
|
||||||
|
url=urls,
|
||||||
|
logger=logger,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
board_images = BoardImagesService(
|
||||||
|
services=BoardImagesServiceDependencies(
|
||||||
|
board_image_record_storage=board_image_record_storage,
|
||||||
|
board_record_storage=board_record_storage,
|
||||||
|
image_record_storage=image_record_storage,
|
||||||
|
url=urls,
|
||||||
|
logger=logger,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
images = ImageService(
|
||||||
|
services=ImageServiceDependencies(
|
||||||
|
board_image_record_storage=board_image_record_storage,
|
||||||
|
image_record_storage=image_record_storage,
|
||||||
|
image_file_storage=image_file_storage,
|
||||||
|
url=urls,
|
||||||
|
logger=logger,
|
||||||
|
names=names,
|
||||||
|
graph_execution_manager=graph_execution_manager,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
services = InvocationServices(
|
||||||
|
model_manager=model_manager,
|
||||||
|
events=events,
|
||||||
|
latents=ForwardCacheLatentsStorage(DiskLatentsStorage(f"{output_folder}/latents")),
|
||||||
|
images=images,
|
||||||
|
boards=boards,
|
||||||
|
board_images=board_images,
|
||||||
|
queue=MemoryInvocationQueue(),
|
||||||
|
graph_library=SqliteItemStorage[LibraryGraph](conn=db_conn, table_name="graphs"),
|
||||||
|
graph_execution_manager=graph_execution_manager,
|
||||||
|
processor=DefaultInvocationProcessor(),
|
||||||
|
performance_statistics=InvocationStatsService(graph_execution_manager),
|
||||||
|
logger=logger,
|
||||||
|
configuration=config,
|
||||||
|
invocation_cache=MemoryInvocationCache(max_cache_size=config.node_cache_size),
|
||||||
|
)
|
||||||
|
|
||||||
|
system_graphs = create_system_graphs(services.graph_library)
|
||||||
|
system_graph_names = set([g.name for g in system_graphs])
|
||||||
|
set_autocompleter(services)
|
||||||
|
|
||||||
|
invoker = Invoker(services)
|
||||||
|
session: GraphExecutionState = invoker.create_execution_state()
|
||||||
|
parser = get_command_parser(services)
|
||||||
|
|
||||||
|
re_negid = re.compile("^-[0-9]+$")
|
||||||
|
|
||||||
|
# Uncomment to print out previous sessions at startup
|
||||||
|
# print(services.session_manager.list())
|
||||||
|
|
||||||
|
context = CliContext(invoker, session, parser)
|
||||||
|
set_autocompleter(services)
|
||||||
|
|
||||||
|
command_line_args_exist = len(invocation_commands) > 0
|
||||||
|
done = False
|
||||||
|
|
||||||
|
while not done:
|
||||||
|
try:
|
||||||
|
if command_line_args_exist:
|
||||||
|
cmd_input = invocation_commands.pop(0)
|
||||||
|
done = len(invocation_commands) == 0
|
||||||
|
else:
|
||||||
|
cmd_input = input("invoke> ")
|
||||||
|
except (KeyboardInterrupt, EOFError):
|
||||||
|
# Ctrl-c exits
|
||||||
|
break
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Refresh the state of the session
|
||||||
|
# history = list(get_graph_execution_history(context.session))
|
||||||
|
history = list(reversed(context.nodes_added))
|
||||||
|
|
||||||
|
# Split the command for piping
|
||||||
|
cmds = cmd_input.split("|")
|
||||||
|
start_id = len(context.nodes_added)
|
||||||
|
current_id = start_id
|
||||||
|
new_invocations = list()
|
||||||
|
for cmd in cmds:
|
||||||
|
if cmd is None or cmd.strip() == "":
|
||||||
|
raise InvalidArgs("Empty command")
|
||||||
|
|
||||||
|
# Parse args to create invocation
|
||||||
|
args = vars(context.parser.parse_args(shlex.split(cmd.strip())))
|
||||||
|
|
||||||
|
# Override defaults
|
||||||
|
for field_name, field_default in context.defaults.items():
|
||||||
|
if field_name in args:
|
||||||
|
args[field_name] = field_default
|
||||||
|
|
||||||
|
# Parse invocation
|
||||||
|
command: CliCommand = None # type:ignore
|
||||||
|
system_graph: Optional[LibraryGraph] = None
|
||||||
|
if args["type"] in system_graph_names:
|
||||||
|
system_graph = next(filter(lambda g: g.name == args["type"], system_graphs))
|
||||||
|
invocation = GraphInvocation(graph=system_graph.graph, id=str(current_id))
|
||||||
|
for exposed_input in system_graph.exposed_inputs:
|
||||||
|
if exposed_input.alias in args:
|
||||||
|
node = invocation.graph.get_node(exposed_input.node_path)
|
||||||
|
field = exposed_input.field
|
||||||
|
setattr(node, field, args[exposed_input.alias])
|
||||||
|
command = CliCommand(command=invocation)
|
||||||
|
context.graph_nodes[invocation.id] = system_graph.id
|
||||||
|
else:
|
||||||
|
args["id"] = current_id
|
||||||
|
command = CliCommand(command=args)
|
||||||
|
|
||||||
|
if command is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Run any CLI commands immediately
|
||||||
|
if isinstance(command.command, BaseCommand):
|
||||||
|
# Invoke all current nodes to preserve operation order
|
||||||
|
invoke_all(context)
|
||||||
|
|
||||||
|
# Run the command
|
||||||
|
command.command.run(context)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# TODO: handle linking with library graphs
|
||||||
|
# Pipe previous command output (if there was a previous command)
|
||||||
|
edges: list[Edge] = list()
|
||||||
|
if len(history) > 0 or current_id != start_id:
|
||||||
|
from_id = history[0] if current_id == start_id else str(current_id - 1)
|
||||||
|
from_node = (
|
||||||
|
next(filter(lambda n: n[0].id == from_id, new_invocations))[0]
|
||||||
|
if current_id != start_id
|
||||||
|
else context.session.graph.get_node(from_id)
|
||||||
|
)
|
||||||
|
matching_edges = generate_matching_edges(from_node, command.command, context)
|
||||||
|
edges.extend(matching_edges)
|
||||||
|
|
||||||
|
# Parse provided links
|
||||||
|
if "link_node" in args and args["link_node"]:
|
||||||
|
for link in args["link_node"]:
|
||||||
|
node_id = link
|
||||||
|
if re_negid.match(node_id):
|
||||||
|
node_id = str(current_id + int(node_id))
|
||||||
|
|
||||||
|
link_node = context.session.graph.get_node(node_id)
|
||||||
|
matching_edges = generate_matching_edges(link_node, command.command, context)
|
||||||
|
matching_destinations = [e.destination for e in matching_edges]
|
||||||
|
edges = [e for e in edges if e.destination not in matching_destinations]
|
||||||
|
edges.extend(matching_edges)
|
||||||
|
|
||||||
|
if "link" in args and args["link"]:
|
||||||
|
for link in args["link"]:
|
||||||
|
edges = [
|
||||||
|
e
|
||||||
|
for e in edges
|
||||||
|
if e.destination.node_id != command.command.id or e.destination.field != link[2]
|
||||||
|
]
|
||||||
|
|
||||||
|
node_id = link[0]
|
||||||
|
if re_negid.match(node_id):
|
||||||
|
node_id = str(current_id + int(node_id))
|
||||||
|
|
||||||
|
# TODO: handle missing input/output
|
||||||
|
node_output = get_node_outputs(context.session.graph.get_node(node_id), context)[link[1]]
|
||||||
|
node_input = get_node_inputs(command.command, context)[link[2]]
|
||||||
|
|
||||||
|
edges.append(
|
||||||
|
Edge(
|
||||||
|
source=EdgeConnection(node_id=node_output.node_path, field=node_output.field),
|
||||||
|
destination=EdgeConnection(node_id=node_input.node_path, field=node_input.field),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
new_invocations.append((command.command, edges))
|
||||||
|
|
||||||
|
current_id = current_id + 1
|
||||||
|
|
||||||
|
# Add the node to the session
|
||||||
|
context.add_node(command.command)
|
||||||
|
for edge in edges:
|
||||||
|
print(edge)
|
||||||
|
context.add_edge(edge)
|
||||||
|
|
||||||
|
# Execute all remaining nodes
|
||||||
|
invoke_all(context)
|
||||||
|
|
||||||
|
except InvalidArgs:
|
||||||
|
invoker.services.logger.warning('Invalid command, use "help" to list commands')
|
||||||
|
continue
|
||||||
|
|
||||||
|
except ValidationError:
|
||||||
|
invoker.services.logger.warning('Invalid command arguments, run "<command> --help" for summary')
|
||||||
|
|
||||||
|
except SessionError:
|
||||||
|
# Start a new session
|
||||||
|
invoker.services.logger.warning("Session error: creating a new session")
|
||||||
|
context.reset()
|
||||||
|
|
||||||
|
except ExitCli:
|
||||||
|
break
|
||||||
|
|
||||||
|
except SystemExit:
|
||||||
|
continue
|
||||||
|
|
||||||
|
invoker.stop()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if config.version:
|
||||||
|
print(f"InvokeAI version {__version__}")
|
||||||
|
else:
|
||||||
|
invoke_cli()
|
@ -1,28 +1,8 @@
|
|||||||
import shutil
|
import os
|
||||||
import sys
|
|
||||||
from importlib.util import module_from_spec, spec_from_file_location
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from invokeai.app.services.config.config_default import InvokeAIAppConfig
|
__all__ = []
|
||||||
|
|
||||||
custom_nodes_path = Path(InvokeAIAppConfig.get_config().custom_nodes_path.resolve())
|
dirname = os.path.dirname(os.path.abspath(__file__))
|
||||||
custom_nodes_path.mkdir(parents=True, exist_ok=True)
|
for f in os.listdir(dirname):
|
||||||
|
if f != "__init__.py" and os.path.isfile("%s/%s" % (dirname, f)) and f[-3:] == ".py":
|
||||||
custom_nodes_init_path = str(custom_nodes_path / "__init__.py")
|
__all__.append(f[:-3])
|
||||||
custom_nodes_readme_path = str(custom_nodes_path / "README.md")
|
|
||||||
|
|
||||||
# copy our custom nodes __init__.py to the custom nodes directory
|
|
||||||
shutil.copy(Path(__file__).parent / "custom_nodes/init.py", custom_nodes_init_path)
|
|
||||||
shutil.copy(Path(__file__).parent / "custom_nodes/README.md", custom_nodes_readme_path)
|
|
||||||
|
|
||||||
# Import custom nodes, see https://docs.python.org/3/library/importlib.html#importing-programmatically
|
|
||||||
spec = spec_from_file_location("custom_nodes", custom_nodes_init_path)
|
|
||||||
if spec is None or spec.loader is None:
|
|
||||||
raise RuntimeError(f"Could not load custom nodes from {custom_nodes_init_path}")
|
|
||||||
module = module_from_spec(spec)
|
|
||||||
sys.modules[spec.name] = module
|
|
||||||
spec.loader.exec_module(module)
|
|
||||||
|
|
||||||
# add core nodes to __all__
|
|
||||||
python_files = filter(lambda f: not f.name.startswith("_"), Path(__file__).parent.glob("*.py"))
|
|
||||||
__all__ = [f.stem for f in python_files] # type: ignore
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pydantic import ValidationInfo, field_validator
|
from pydantic import validator
|
||||||
|
|
||||||
from invokeai.app.invocations.primitives import IntegerCollectionOutput
|
from invokeai.app.invocations.primitives import IntegerCollectionOutput
|
||||||
from invokeai.app.util.misc import SEED_MAX
|
from invokeai.app.util.misc import SEED_MAX, get_random_seed
|
||||||
|
|
||||||
from .baseinvocation import BaseInvocation, InputField, InvocationContext, invocation
|
from .baseinvocation import BaseInvocation, InputField, InvocationContext, invocation
|
||||||
|
|
||||||
@ -20,9 +20,9 @@ class RangeInvocation(BaseInvocation):
|
|||||||
stop: int = InputField(default=10, description="The stop of the range")
|
stop: int = InputField(default=10, description="The stop of the range")
|
||||||
step: int = InputField(default=1, description="The step of the range")
|
step: int = InputField(default=1, description="The step of the range")
|
||||||
|
|
||||||
@field_validator("stop")
|
@validator("stop")
|
||||||
def stop_gt_start(cls, v: int, info: ValidationInfo):
|
def stop_gt_start(cls, v, values):
|
||||||
if "start" in info.data and v <= info.data["start"]:
|
if "start" in values and v <= values["start"]:
|
||||||
raise ValueError("stop must be greater than start")
|
raise ValueError("stop must be greater than start")
|
||||||
return v
|
return v
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ class RangeOfSizeInvocation(BaseInvocation):
|
|||||||
title="Random Range",
|
title="Random Range",
|
||||||
tags=["range", "integer", "random", "collection"],
|
tags=["range", "integer", "random", "collection"],
|
||||||
category="collections",
|
category="collections",
|
||||||
version="1.0.1",
|
version="1.0.0",
|
||||||
use_cache=False,
|
use_cache=False,
|
||||||
)
|
)
|
||||||
class RandomRangeInvocation(BaseInvocation):
|
class RandomRangeInvocation(BaseInvocation):
|
||||||
@ -65,10 +65,10 @@ class RandomRangeInvocation(BaseInvocation):
|
|||||||
high: int = InputField(default=np.iinfo(np.int32).max, description="The exclusive high value")
|
high: int = InputField(default=np.iinfo(np.int32).max, description="The exclusive high value")
|
||||||
size: int = InputField(default=1, description="The number of values to generate")
|
size: int = InputField(default=1, description="The number of values to generate")
|
||||||
seed: int = InputField(
|
seed: int = InputField(
|
||||||
default=0,
|
|
||||||
ge=0,
|
ge=0,
|
||||||
le=SEED_MAX,
|
le=SEED_MAX,
|
||||||
description="The seed for the RNG (omit for random)",
|
description="The seed for the RNG (omit for random)",
|
||||||
|
default_factory=get_random_seed,
|
||||||
)
|
)
|
||||||
|
|
||||||
def invoke(self, context: InvocationContext) -> IntegerCollectionOutput:
|
def invoke(self, context: InvocationContext) -> IntegerCollectionOutput:
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
|
import re
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import List, Optional, Union
|
from typing import List, Union
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from compel import Compel, ReturnedEmbeddingsType
|
from compel import Compel, ReturnedEmbeddingsType
|
||||||
from compel.prompt_parser import Blend, Conjunction, CrossAttentionControlSubstitute, FlattenedPrompt, Fragment
|
from compel.prompt_parser import Blend, Conjunction, CrossAttentionControlSubstitute, FlattenedPrompt, Fragment
|
||||||
|
|
||||||
from invokeai.app.invocations.primitives import ConditioningField, ConditioningOutput
|
from invokeai.app.invocations.primitives import ConditioningField, ConditioningOutput
|
||||||
from invokeai.app.shared.fields import FieldDescriptions
|
|
||||||
from invokeai.backend.stable_diffusion.diffusion.conditioning_data import (
|
from invokeai.backend.stable_diffusion.diffusion.conditioning_data import (
|
||||||
BasicConditioningInfo,
|
BasicConditioningInfo,
|
||||||
ExtraConditioningInfo,
|
ExtraConditioningInfo,
|
||||||
@ -16,10 +16,10 @@ from invokeai.backend.stable_diffusion.diffusion.conditioning_data import (
|
|||||||
from ...backend.model_management.lora import ModelPatcher
|
from ...backend.model_management.lora import ModelPatcher
|
||||||
from ...backend.model_management.models import ModelNotFoundException, ModelType
|
from ...backend.model_management.models import ModelNotFoundException, ModelType
|
||||||
from ...backend.util.devices import torch_dtype
|
from ...backend.util.devices import torch_dtype
|
||||||
from ..util.ti_utils import extract_ti_triggers_from_prompt
|
|
||||||
from .baseinvocation import (
|
from .baseinvocation import (
|
||||||
BaseInvocation,
|
BaseInvocation,
|
||||||
BaseInvocationOutput,
|
BaseInvocationOutput,
|
||||||
|
FieldDescriptions,
|
||||||
Input,
|
Input,
|
||||||
InputField,
|
InputField,
|
||||||
InvocationContext,
|
InvocationContext,
|
||||||
@ -43,13 +43,7 @@ class ConditioningFieldData:
|
|||||||
# PerpNeg = "perp_neg"
|
# PerpNeg = "perp_neg"
|
||||||
|
|
||||||
|
|
||||||
@invocation(
|
@invocation("compel", title="Prompt", tags=["prompt", "compel"], category="conditioning", version="1.0.0")
|
||||||
"compel",
|
|
||||||
title="Prompt",
|
|
||||||
tags=["prompt", "compel"],
|
|
||||||
category="conditioning",
|
|
||||||
version="1.0.0",
|
|
||||||
)
|
|
||||||
class CompelInvocation(BaseInvocation):
|
class CompelInvocation(BaseInvocation):
|
||||||
"""Parse prompt using compel package to conditioning."""
|
"""Parse prompt using compel package to conditioning."""
|
||||||
|
|
||||||
@ -67,19 +61,17 @@ class CompelInvocation(BaseInvocation):
|
|||||||
@torch.no_grad()
|
@torch.no_grad()
|
||||||
def invoke(self, context: InvocationContext) -> ConditioningOutput:
|
def invoke(self, context: InvocationContext) -> ConditioningOutput:
|
||||||
tokenizer_info = context.services.model_manager.get_model(
|
tokenizer_info = context.services.model_manager.get_model(
|
||||||
**self.clip.tokenizer.model_dump(),
|
**self.clip.tokenizer.dict(),
|
||||||
context=context,
|
context=context,
|
||||||
)
|
)
|
||||||
text_encoder_info = context.services.model_manager.get_model(
|
text_encoder_info = context.services.model_manager.get_model(
|
||||||
**self.clip.text_encoder.model_dump(),
|
**self.clip.text_encoder.dict(),
|
||||||
context=context,
|
context=context,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _lora_loader():
|
def _lora_loader():
|
||||||
for lora in self.clip.loras:
|
for lora in self.clip.loras:
|
||||||
lora_info = context.services.model_manager.get_model(
|
lora_info = context.services.model_manager.get_model(**lora.dict(exclude={"weight"}), context=context)
|
||||||
**lora.model_dump(exclude={"weight"}), context=context
|
|
||||||
)
|
|
||||||
yield (lora_info.context.model, lora.weight)
|
yield (lora_info.context.model, lora.weight)
|
||||||
del lora_info
|
del lora_info
|
||||||
return
|
return
|
||||||
@ -87,7 +79,7 @@ class CompelInvocation(BaseInvocation):
|
|||||||
# loras = [(context.services.model_manager.get_model(**lora.dict(exclude={"weight"})).context.model, lora.weight) for lora in self.clip.loras]
|
# loras = [(context.services.model_manager.get_model(**lora.dict(exclude={"weight"})).context.model, lora.weight) for lora in self.clip.loras]
|
||||||
|
|
||||||
ti_list = []
|
ti_list = []
|
||||||
for trigger in extract_ti_triggers_from_prompt(self.prompt):
|
for trigger in re.findall(r"<[a-zA-Z0-9., _-]+>", self.prompt):
|
||||||
name = trigger[1:-1]
|
name = trigger[1:-1]
|
||||||
try:
|
try:
|
||||||
ti_list.append(
|
ti_list.append(
|
||||||
@ -108,15 +100,13 @@ class CompelInvocation(BaseInvocation):
|
|||||||
print(f'Warn: trigger: "{trigger}" not found')
|
print(f'Warn: trigger: "{trigger}" not found')
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
ModelPatcher.apply_lora_text_encoder(text_encoder_info.context.model, _lora_loader()),
|
||||||
ModelPatcher.apply_ti(tokenizer_info.context.model, text_encoder_info.context.model, ti_list) as (
|
ModelPatcher.apply_ti(tokenizer_info.context.model, text_encoder_info.context.model, ti_list) as (
|
||||||
tokenizer,
|
tokenizer,
|
||||||
ti_manager,
|
ti_manager,
|
||||||
),
|
),
|
||||||
text_encoder_info as text_encoder,
|
|
||||||
# Apply the LoRA after text_encoder has been moved to its target device for faster patching.
|
|
||||||
ModelPatcher.apply_lora_text_encoder(text_encoder, _lora_loader()),
|
|
||||||
# Apply CLIP Skip after LoRA to prevent LoRA application from failing on skipped layers.
|
|
||||||
ModelPatcher.apply_clip_skip(text_encoder_info.context.model, self.clip.skipped_layers),
|
ModelPatcher.apply_clip_skip(text_encoder_info.context.model, self.clip.skipped_layers),
|
||||||
|
text_encoder_info as text_encoder,
|
||||||
):
|
):
|
||||||
compel = Compel(
|
compel = Compel(
|
||||||
tokenizer=tokenizer,
|
tokenizer=tokenizer,
|
||||||
@ -170,11 +160,11 @@ class SDXLPromptInvocationBase:
|
|||||||
zero_on_empty: bool,
|
zero_on_empty: bool,
|
||||||
):
|
):
|
||||||
tokenizer_info = context.services.model_manager.get_model(
|
tokenizer_info = context.services.model_manager.get_model(
|
||||||
**clip_field.tokenizer.model_dump(),
|
**clip_field.tokenizer.dict(),
|
||||||
context=context,
|
context=context,
|
||||||
)
|
)
|
||||||
text_encoder_info = context.services.model_manager.get_model(
|
text_encoder_info = context.services.model_manager.get_model(
|
||||||
**clip_field.text_encoder.model_dump(),
|
**clip_field.text_encoder.dict(),
|
||||||
context=context,
|
context=context,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -182,11 +172,7 @@ class SDXLPromptInvocationBase:
|
|||||||
if prompt == "" and zero_on_empty:
|
if prompt == "" and zero_on_empty:
|
||||||
cpu_text_encoder = text_encoder_info.context.model
|
cpu_text_encoder = text_encoder_info.context.model
|
||||||
c = torch.zeros(
|
c = torch.zeros(
|
||||||
(
|
(1, cpu_text_encoder.config.max_position_embeddings, cpu_text_encoder.config.hidden_size),
|
||||||
1,
|
|
||||||
cpu_text_encoder.config.max_position_embeddings,
|
|
||||||
cpu_text_encoder.config.hidden_size,
|
|
||||||
),
|
|
||||||
dtype=text_encoder_info.context.cache.precision,
|
dtype=text_encoder_info.context.cache.precision,
|
||||||
)
|
)
|
||||||
if get_pooled:
|
if get_pooled:
|
||||||
@ -200,9 +186,7 @@ class SDXLPromptInvocationBase:
|
|||||||
|
|
||||||
def _lora_loader():
|
def _lora_loader():
|
||||||
for lora in clip_field.loras:
|
for lora in clip_field.loras:
|
||||||
lora_info = context.services.model_manager.get_model(
|
lora_info = context.services.model_manager.get_model(**lora.dict(exclude={"weight"}), context=context)
|
||||||
**lora.model_dump(exclude={"weight"}), context=context
|
|
||||||
)
|
|
||||||
yield (lora_info.context.model, lora.weight)
|
yield (lora_info.context.model, lora.weight)
|
||||||
del lora_info
|
del lora_info
|
||||||
return
|
return
|
||||||
@ -210,7 +194,7 @@ class SDXLPromptInvocationBase:
|
|||||||
# loras = [(context.services.model_manager.get_model(**lora.dict(exclude={"weight"})).context.model, lora.weight) for lora in self.clip.loras]
|
# loras = [(context.services.model_manager.get_model(**lora.dict(exclude={"weight"})).context.model, lora.weight) for lora in self.clip.loras]
|
||||||
|
|
||||||
ti_list = []
|
ti_list = []
|
||||||
for trigger in extract_ti_triggers_from_prompt(prompt):
|
for trigger in re.findall(r"<[a-zA-Z0-9., _-]+>", prompt):
|
||||||
name = trigger[1:-1]
|
name = trigger[1:-1]
|
||||||
try:
|
try:
|
||||||
ti_list.append(
|
ti_list.append(
|
||||||
@ -231,15 +215,13 @@ class SDXLPromptInvocationBase:
|
|||||||
print(f'Warn: trigger: "{trigger}" not found')
|
print(f'Warn: trigger: "{trigger}" not found')
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
ModelPatcher.apply_lora(text_encoder_info.context.model, _lora_loader(), lora_prefix),
|
||||||
ModelPatcher.apply_ti(tokenizer_info.context.model, text_encoder_info.context.model, ti_list) as (
|
ModelPatcher.apply_ti(tokenizer_info.context.model, text_encoder_info.context.model, ti_list) as (
|
||||||
tokenizer,
|
tokenizer,
|
||||||
ti_manager,
|
ti_manager,
|
||||||
),
|
),
|
||||||
text_encoder_info as text_encoder,
|
|
||||||
# Apply the LoRA after text_encoder has been moved to its target device for faster patching.
|
|
||||||
ModelPatcher.apply_lora(text_encoder, _lora_loader(), lora_prefix),
|
|
||||||
# Apply CLIP Skip after LoRA to prevent LoRA application from failing on skipped layers.
|
|
||||||
ModelPatcher.apply_clip_skip(text_encoder_info.context.model, clip_field.skipped_layers),
|
ModelPatcher.apply_clip_skip(text_encoder_info.context.model, clip_field.skipped_layers),
|
||||||
|
text_encoder_info as text_encoder,
|
||||||
):
|
):
|
||||||
compel = Compel(
|
compel = Compel(
|
||||||
tokenizer=tokenizer,
|
tokenizer=tokenizer,
|
||||||
@ -291,16 +273,8 @@ class SDXLPromptInvocationBase:
|
|||||||
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
|
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
|
||||||
"""Parse prompt using compel package to conditioning."""
|
"""Parse prompt using compel package to conditioning."""
|
||||||
|
|
||||||
prompt: str = InputField(
|
prompt: str = InputField(default="", description=FieldDescriptions.compel_prompt, ui_component=UIComponent.Textarea)
|
||||||
default="",
|
style: str = InputField(default="", description=FieldDescriptions.compel_prompt, ui_component=UIComponent.Textarea)
|
||||||
description=FieldDescriptions.compel_prompt,
|
|
||||||
ui_component=UIComponent.Textarea,
|
|
||||||
)
|
|
||||||
style: str = InputField(
|
|
||||||
default="",
|
|
||||||
description=FieldDescriptions.compel_prompt,
|
|
||||||
ui_component=UIComponent.Textarea,
|
|
||||||
)
|
|
||||||
original_width: int = InputField(default=1024, description="")
|
original_width: int = InputField(default=1024, description="")
|
||||||
original_height: int = InputField(default=1024, description="")
|
original_height: int = InputField(default=1024, description="")
|
||||||
crop_top: int = InputField(default=0, description="")
|
crop_top: int = InputField(default=0, description="")
|
||||||
@ -336,9 +310,7 @@ class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
|
|||||||
[
|
[
|
||||||
c1,
|
c1,
|
||||||
torch.zeros(
|
torch.zeros(
|
||||||
(c1.shape[0], c2.shape[1] - c1.shape[1], c1.shape[2]),
|
(c1.shape[0], c2.shape[1] - c1.shape[1], c1.shape[2]), device=c1.device, dtype=c1.dtype
|
||||||
device=c1.device,
|
|
||||||
dtype=c1.dtype,
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
dim=1,
|
dim=1,
|
||||||
@ -349,9 +321,7 @@ class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
|
|||||||
[
|
[
|
||||||
c2,
|
c2,
|
||||||
torch.zeros(
|
torch.zeros(
|
||||||
(c2.shape[0], c1.shape[1] - c2.shape[1], c2.shape[2]),
|
(c2.shape[0], c1.shape[1] - c2.shape[1], c2.shape[2]), device=c2.device, dtype=c2.dtype
|
||||||
device=c2.device,
|
|
||||||
dtype=c2.dtype,
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
dim=1,
|
dim=1,
|
||||||
@ -389,9 +359,7 @@ class SDXLRefinerCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase
|
|||||||
"""Parse prompt using compel package to conditioning."""
|
"""Parse prompt using compel package to conditioning."""
|
||||||
|
|
||||||
style: str = InputField(
|
style: str = InputField(
|
||||||
default="",
|
default="", description=FieldDescriptions.compel_prompt, ui_component=UIComponent.Textarea
|
||||||
description=FieldDescriptions.compel_prompt,
|
|
||||||
ui_component=UIComponent.Textarea,
|
|
||||||
) # TODO: ?
|
) # TODO: ?
|
||||||
original_width: int = InputField(default=1024, description="")
|
original_width: int = InputField(default=1024, description="")
|
||||||
original_height: int = InputField(default=1024, description="")
|
original_height: int = InputField(default=1024, description="")
|
||||||
@ -435,16 +403,10 @@ class SDXLRefinerCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase
|
|||||||
class ClipSkipInvocationOutput(BaseInvocationOutput):
|
class ClipSkipInvocationOutput(BaseInvocationOutput):
|
||||||
"""Clip skip node output"""
|
"""Clip skip node output"""
|
||||||
|
|
||||||
clip: Optional[ClipField] = OutputField(default=None, description=FieldDescriptions.clip, title="CLIP")
|
clip: ClipField = OutputField(default=None, description=FieldDescriptions.clip, title="CLIP")
|
||||||
|
|
||||||
|
|
||||||
@invocation(
|
@invocation("clip_skip", title="CLIP Skip", tags=["clipskip", "clip", "skip"], category="conditioning", version="1.0.0")
|
||||||
"clip_skip",
|
|
||||||
title="CLIP Skip",
|
|
||||||
tags=["clipskip", "clip", "skip"],
|
|
||||||
category="conditioning",
|
|
||||||
version="1.0.0",
|
|
||||||
)
|
|
||||||
class ClipSkipInvocation(BaseInvocation):
|
class ClipSkipInvocation(BaseInvocation):
|
||||||
"""Skip layers in clip text_encoder model."""
|
"""Skip layers in clip text_encoder model."""
|
||||||
|
|
||||||
@ -459,9 +421,7 @@ class ClipSkipInvocation(BaseInvocation):
|
|||||||
|
|
||||||
|
|
||||||
def get_max_token_count(
|
def get_max_token_count(
|
||||||
tokenizer,
|
tokenizer, prompt: Union[FlattenedPrompt, Blend, Conjunction], truncate_if_too_long=False
|
||||||
prompt: Union[FlattenedPrompt, Blend, Conjunction],
|
|
||||||
truncate_if_too_long=False,
|
|
||||||
) -> int:
|
) -> int:
|
||||||
if type(prompt) is Blend:
|
if type(prompt) is Blend:
|
||||||
blend: Blend = prompt
|
blend: Blend = prompt
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# initial implementation by Gregg Helt, 2023
|
# initial implementation by Gregg Helt, 2023
|
||||||
# heavily leverages controlnet_aux package: https://github.com/patrickvonplaten/controlnet_aux
|
# heavily leverages controlnet_aux package: https://github.com/patrickvonplaten/controlnet_aux
|
||||||
from builtins import bool, float
|
from builtins import bool, float
|
||||||
from typing import Dict, List, Literal, Union
|
from typing import Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@ -24,21 +24,20 @@ from controlnet_aux import (
|
|||||||
)
|
)
|
||||||
from controlnet_aux.util import HWC3, ade_palette
|
from controlnet_aux.util import HWC3, ade_palette
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
from pydantic import BaseModel, Field, validator
|
||||||
|
|
||||||
from invokeai.app.invocations.primitives import ImageField, ImageOutput
|
from invokeai.app.invocations.primitives import ImageField, ImageOutput
|
||||||
from invokeai.app.services.image_records.image_records_common import ImageCategory, ResourceOrigin
|
|
||||||
from invokeai.app.shared.fields import FieldDescriptions
|
|
||||||
|
|
||||||
from ...backend.model_management import BaseModelType
|
from ...backend.model_management import BaseModelType
|
||||||
|
from ..models.image import ImageCategory, ResourceOrigin
|
||||||
from .baseinvocation import (
|
from .baseinvocation import (
|
||||||
BaseInvocation,
|
BaseInvocation,
|
||||||
BaseInvocationOutput,
|
BaseInvocationOutput,
|
||||||
|
FieldDescriptions,
|
||||||
Input,
|
Input,
|
||||||
InputField,
|
InputField,
|
||||||
InvocationContext,
|
InvocationContext,
|
||||||
OutputField,
|
OutputField,
|
||||||
WithMetadata,
|
|
||||||
invocation,
|
invocation,
|
||||||
invocation_output,
|
invocation_output,
|
||||||
)
|
)
|
||||||
@ -58,8 +57,6 @@ class ControlNetModelField(BaseModel):
|
|||||||
model_name: str = Field(description="Name of the ControlNet model")
|
model_name: str = Field(description="Name of the ControlNet model")
|
||||||
base_model: BaseModelType = Field(description="Base model")
|
base_model: BaseModelType = Field(description="Base model")
|
||||||
|
|
||||||
model_config = ConfigDict(protected_namespaces=())
|
|
||||||
|
|
||||||
|
|
||||||
class ControlField(BaseModel):
|
class ControlField(BaseModel):
|
||||||
image: ImageField = Field(description="The control image")
|
image: ImageField = Field(description="The control image")
|
||||||
@ -74,7 +71,7 @@ class ControlField(BaseModel):
|
|||||||
control_mode: CONTROLNET_MODE_VALUES = Field(default="balanced", description="The control mode to use")
|
control_mode: CONTROLNET_MODE_VALUES = Field(default="balanced", description="The control mode to use")
|
||||||
resize_mode: CONTROLNET_RESIZE_VALUES = Field(default="just_resize", description="The resize mode to use")
|
resize_mode: CONTROLNET_RESIZE_VALUES = Field(default="just_resize", description="The resize mode to use")
|
||||||
|
|
||||||
@field_validator("control_weight")
|
@validator("control_weight")
|
||||||
def validate_control_weight(cls, v):
|
def validate_control_weight(cls, v):
|
||||||
"""Validate that all control weights in the valid range"""
|
"""Validate that all control weights in the valid range"""
|
||||||
if isinstance(v, list):
|
if isinstance(v, list):
|
||||||
@ -95,7 +92,7 @@ class ControlOutput(BaseInvocationOutput):
|
|||||||
control: ControlField = OutputField(description=FieldDescriptions.control)
|
control: ControlField = OutputField(description=FieldDescriptions.control)
|
||||||
|
|
||||||
|
|
||||||
@invocation("controlnet", title="ControlNet", tags=["controlnet"], category="controlnet", version="1.1.0")
|
@invocation("controlnet", title="ControlNet", tags=["controlnet"], category="controlnet", version="1.0.0")
|
||||||
class ControlNetInvocation(BaseInvocation):
|
class ControlNetInvocation(BaseInvocation):
|
||||||
"""Collects ControlNet info to pass to other nodes"""
|
"""Collects ControlNet info to pass to other nodes"""
|
||||||
|
|
||||||
@ -127,13 +124,15 @@ class ControlNetInvocation(BaseInvocation):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# This invocation exists for other invocations to subclass it - do not register with @invocation!
|
@invocation(
|
||||||
class ImageProcessorInvocation(BaseInvocation, WithMetadata):
|
"image_processor", title="Base Image Processor", tags=["controlnet"], category="controlnet", version="1.0.0"
|
||||||
|
)
|
||||||
|
class ImageProcessorInvocation(BaseInvocation):
|
||||||
"""Base class for invocations that preprocess images for ControlNet"""
|
"""Base class for invocations that preprocess images for ControlNet"""
|
||||||
|
|
||||||
image: ImageField = InputField(description="The image to process")
|
image: ImageField = InputField(description="The image to process")
|
||||||
|
|
||||||
def run_processor(self, image: Image.Image) -> Image.Image:
|
def run_processor(self, image):
|
||||||
# superclass just passes through image without processing
|
# superclass just passes through image without processing
|
||||||
return image
|
return image
|
||||||
|
|
||||||
@ -151,8 +150,7 @@ class ImageProcessorInvocation(BaseInvocation, WithMetadata):
|
|||||||
session_id=context.graph_execution_state_id,
|
session_id=context.graph_execution_state_id,
|
||||||
node_id=self.id,
|
node_id=self.id,
|
||||||
is_intermediate=self.is_intermediate,
|
is_intermediate=self.is_intermediate,
|
||||||
metadata=self.metadata,
|
workflow=self.workflow,
|
||||||
workflow=context.workflow,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
"""Builds an ImageOutput and its ImageField"""
|
"""Builds an ImageOutput and its ImageField"""
|
||||||
@ -172,7 +170,7 @@ class ImageProcessorInvocation(BaseInvocation, WithMetadata):
|
|||||||
title="Canny Processor",
|
title="Canny Processor",
|
||||||
tags=["controlnet", "canny"],
|
tags=["controlnet", "canny"],
|
||||||
category="controlnet",
|
category="controlnet",
|
||||||
version="1.2.0",
|
version="1.0.0",
|
||||||
)
|
)
|
||||||
class CannyImageProcessorInvocation(ImageProcessorInvocation):
|
class CannyImageProcessorInvocation(ImageProcessorInvocation):
|
||||||
"""Canny edge detection for ControlNet"""
|
"""Canny edge detection for ControlNet"""
|
||||||
@ -195,7 +193,7 @@ class CannyImageProcessorInvocation(ImageProcessorInvocation):
|
|||||||
title="HED (softedge) Processor",
|
title="HED (softedge) Processor",
|
||||||
tags=["controlnet", "hed", "softedge"],
|
tags=["controlnet", "hed", "softedge"],
|
||||||
category="controlnet",
|
category="controlnet",
|
||||||
version="1.2.0",
|
version="1.0.0",
|
||||||
)
|
)
|
||||||
class HedImageProcessorInvocation(ImageProcessorInvocation):
|
class HedImageProcessorInvocation(ImageProcessorInvocation):
|
||||||
"""Applies HED edge detection to image"""
|
"""Applies HED edge detection to image"""
|
||||||
@ -224,7 +222,7 @@ class HedImageProcessorInvocation(ImageProcessorInvocation):
|
|||||||
title="Lineart Processor",
|
title="Lineart Processor",
|
||||||
tags=["controlnet", "lineart"],
|
tags=["controlnet", "lineart"],
|
||||||
category="controlnet",
|
category="controlnet",
|
||||||
version="1.2.0",
|
version="1.0.0",
|
||||||
)
|
)
|
||||||
class LineartImageProcessorInvocation(ImageProcessorInvocation):
|
class LineartImageProcessorInvocation(ImageProcessorInvocation):
|
||||||
"""Applies line art processing to image"""
|
"""Applies line art processing to image"""
|
||||||
@ -246,7 +244,7 @@ class LineartImageProcessorInvocation(ImageProcessorInvocation):
|
|||||||
title="Lineart Anime Processor",
|
title="Lineart Anime Processor",
|
||||||
tags=["controlnet", "lineart", "anime"],
|
tags=["controlnet", "lineart", "anime"],
|
||||||
category="controlnet",
|
category="controlnet",
|
||||||
version="1.2.0",
|
version="1.0.0",
|
||||||
)
|
)
|
||||||
class LineartAnimeImageProcessorInvocation(ImageProcessorInvocation):
|
class LineartAnimeImageProcessorInvocation(ImageProcessorInvocation):
|
||||||
"""Applies line art anime processing to image"""
|
"""Applies line art anime processing to image"""
|
||||||
@ -269,7 +267,7 @@ class LineartAnimeImageProcessorInvocation(ImageProcessorInvocation):
|
|||||||
title="Openpose Processor",
|
title="Openpose Processor",
|
||||||
tags=["controlnet", "openpose", "pose"],
|
tags=["controlnet", "openpose", "pose"],
|
||||||
category="controlnet",
|
category="controlnet",
|
||||||
version="1.2.0",
|
version="1.0.0",
|
||||||
)
|
)
|
||||||
class OpenposeImageProcessorInvocation(ImageProcessorInvocation):
|
class OpenposeImageProcessorInvocation(ImageProcessorInvocation):
|
||||||
"""Applies Openpose processing to image"""
|
"""Applies Openpose processing to image"""
|
||||||
@ -294,7 +292,7 @@ class OpenposeImageProcessorInvocation(ImageProcessorInvocation):
|
|||||||
title="Midas Depth Processor",
|
title="Midas Depth Processor",
|
||||||
tags=["controlnet", "midas"],
|
tags=["controlnet", "midas"],
|
||||||
category="controlnet",
|
category="controlnet",
|
||||||
version="1.2.0",
|
version="1.0.0",
|
||||||
)
|
)
|
||||||
class MidasDepthImageProcessorInvocation(ImageProcessorInvocation):
|
class MidasDepthImageProcessorInvocation(ImageProcessorInvocation):
|
||||||
"""Applies Midas depth processing to image"""
|
"""Applies Midas depth processing to image"""
|
||||||
@ -321,7 +319,7 @@ class MidasDepthImageProcessorInvocation(ImageProcessorInvocation):
|
|||||||
title="Normal BAE Processor",
|
title="Normal BAE Processor",
|
||||||
tags=["controlnet"],
|
tags=["controlnet"],
|
||||||
category="controlnet",
|
category="controlnet",
|
||||||
version="1.2.0",
|
version="1.0.0",
|
||||||
)
|
)
|
||||||
class NormalbaeImageProcessorInvocation(ImageProcessorInvocation):
|
class NormalbaeImageProcessorInvocation(ImageProcessorInvocation):
|
||||||
"""Applies NormalBae processing to image"""
|
"""Applies NormalBae processing to image"""
|
||||||
@ -338,7 +336,7 @@ class NormalbaeImageProcessorInvocation(ImageProcessorInvocation):
|
|||||||
|
|
||||||
|
|
||||||
@invocation(
|
@invocation(
|
||||||
"mlsd_image_processor", title="MLSD Processor", tags=["controlnet", "mlsd"], category="controlnet", version="1.2.0"
|
"mlsd_image_processor", title="MLSD Processor", tags=["controlnet", "mlsd"], category="controlnet", version="1.0.0"
|
||||||
)
|
)
|
||||||
class MlsdImageProcessorInvocation(ImageProcessorInvocation):
|
class MlsdImageProcessorInvocation(ImageProcessorInvocation):
|
||||||
"""Applies MLSD processing to image"""
|
"""Applies MLSD processing to image"""
|
||||||
@ -361,7 +359,7 @@ class MlsdImageProcessorInvocation(ImageProcessorInvocation):
|
|||||||
|
|
||||||
|
|
||||||
@invocation(
|
@invocation(
|
||||||
"pidi_image_processor", title="PIDI Processor", tags=["controlnet", "pidi"], category="controlnet", version="1.2.0"
|
"pidi_image_processor", title="PIDI Processor", tags=["controlnet", "pidi"], category="controlnet", version="1.0.0"
|
||||||
)
|
)
|
||||||
class PidiImageProcessorInvocation(ImageProcessorInvocation):
|
class PidiImageProcessorInvocation(ImageProcessorInvocation):
|
||||||
"""Applies PIDI processing to image"""
|
"""Applies PIDI processing to image"""
|
||||||
@ -388,16 +386,16 @@ class PidiImageProcessorInvocation(ImageProcessorInvocation):
|
|||||||
title="Content Shuffle Processor",
|
title="Content Shuffle Processor",
|
||||||
tags=["controlnet", "contentshuffle"],
|
tags=["controlnet", "contentshuffle"],
|
||||||
category="controlnet",
|
category="controlnet",
|
||||||
version="1.2.0",
|
version="1.0.0",
|
||||||
)
|
)
|
||||||
class ContentShuffleImageProcessorInvocation(ImageProcessorInvocation):
|
class ContentShuffleImageProcessorInvocation(ImageProcessorInvocation):
|
||||||
"""Applies content shuffle processing to image"""
|
"""Applies content shuffle processing to image"""
|
||||||
|
|
||||||
detect_resolution: int = InputField(default=512, ge=0, description=FieldDescriptions.detect_res)
|
detect_resolution: int = InputField(default=512, ge=0, description=FieldDescriptions.detect_res)
|
||||||
image_resolution: int = InputField(default=512, ge=0, description=FieldDescriptions.image_res)
|
image_resolution: int = InputField(default=512, ge=0, description=FieldDescriptions.image_res)
|
||||||
h: int = InputField(default=512, ge=0, description="Content shuffle `h` parameter")
|
h: Optional[int] = InputField(default=512, ge=0, description="Content shuffle `h` parameter")
|
||||||
w: int = InputField(default=512, ge=0, description="Content shuffle `w` parameter")
|
w: Optional[int] = InputField(default=512, ge=0, description="Content shuffle `w` parameter")
|
||||||
f: int = InputField(default=256, ge=0, description="Content shuffle `f` parameter")
|
f: Optional[int] = InputField(default=256, ge=0, description="Content shuffle `f` parameter")
|
||||||
|
|
||||||
def run_processor(self, image):
|
def run_processor(self, image):
|
||||||
content_shuffle_processor = ContentShuffleDetector()
|
content_shuffle_processor = ContentShuffleDetector()
|
||||||
@ -418,7 +416,7 @@ class ContentShuffleImageProcessorInvocation(ImageProcessorInvocation):
|
|||||||
title="Zoe (Depth) Processor",
|
title="Zoe (Depth) Processor",
|
||||||
tags=["controlnet", "zoe", "depth"],
|
tags=["controlnet", "zoe", "depth"],
|
||||||
category="controlnet",
|
category="controlnet",
|
||||||
version="1.2.0",
|
version="1.0.0",
|
||||||
)
|
)
|
||||||
class ZoeDepthImageProcessorInvocation(ImageProcessorInvocation):
|
class ZoeDepthImageProcessorInvocation(ImageProcessorInvocation):
|
||||||
"""Applies Zoe depth processing to image"""
|
"""Applies Zoe depth processing to image"""
|
||||||
@ -434,7 +432,7 @@ class ZoeDepthImageProcessorInvocation(ImageProcessorInvocation):
|
|||||||
title="Mediapipe Face Processor",
|
title="Mediapipe Face Processor",
|
||||||
tags=["controlnet", "mediapipe", "face"],
|
tags=["controlnet", "mediapipe", "face"],
|
||||||
category="controlnet",
|
category="controlnet",
|
||||||
version="1.2.0",
|
version="1.0.0",
|
||||||
)
|
)
|
||||||
class MediapipeFaceProcessorInvocation(ImageProcessorInvocation):
|
class MediapipeFaceProcessorInvocation(ImageProcessorInvocation):
|
||||||
"""Applies mediapipe face processing to image"""
|
"""Applies mediapipe face processing to image"""
|
||||||
@ -457,7 +455,7 @@ class MediapipeFaceProcessorInvocation(ImageProcessorInvocation):
|
|||||||
title="Leres (Depth) Processor",
|
title="Leres (Depth) Processor",
|
||||||
tags=["controlnet", "leres", "depth"],
|
tags=["controlnet", "leres", "depth"],
|
||||||
category="controlnet",
|
category="controlnet",
|
||||||
version="1.2.0",
|
version="1.0.0",
|
||||||
)
|
)
|
||||||
class LeresImageProcessorInvocation(ImageProcessorInvocation):
|
class LeresImageProcessorInvocation(ImageProcessorInvocation):
|
||||||
"""Applies leres processing to image"""
|
"""Applies leres processing to image"""
|
||||||
@ -486,7 +484,7 @@ class LeresImageProcessorInvocation(ImageProcessorInvocation):
|
|||||||
title="Tile Resample Processor",
|
title="Tile Resample Processor",
|
||||||
tags=["controlnet", "tile"],
|
tags=["controlnet", "tile"],
|
||||||
category="controlnet",
|
category="controlnet",
|
||||||
version="1.2.0",
|
version="1.0.0",
|
||||||
)
|
)
|
||||||
class TileResamplerProcessorInvocation(ImageProcessorInvocation):
|
class TileResamplerProcessorInvocation(ImageProcessorInvocation):
|
||||||
"""Tile resampler processor"""
|
"""Tile resampler processor"""
|
||||||
@ -526,7 +524,7 @@ class TileResamplerProcessorInvocation(ImageProcessorInvocation):
|
|||||||
title="Segment Anything Processor",
|
title="Segment Anything Processor",
|
||||||
tags=["controlnet", "segmentanything"],
|
tags=["controlnet", "segmentanything"],
|
||||||
category="controlnet",
|
category="controlnet",
|
||||||
version="1.2.0",
|
version="1.0.0",
|
||||||
)
|
)
|
||||||
class SegmentAnythingProcessorInvocation(ImageProcessorInvocation):
|
class SegmentAnythingProcessorInvocation(ImageProcessorInvocation):
|
||||||
"""Applies segment anything processing to image"""
|
"""Applies segment anything processing to image"""
|
||||||
@ -568,7 +566,7 @@ class SamDetectorReproducibleColors(SamDetector):
|
|||||||
title="Color Map Processor",
|
title="Color Map Processor",
|
||||||
tags=["controlnet"],
|
tags=["controlnet"],
|
||||||
category="controlnet",
|
category="controlnet",
|
||||||
version="1.2.0",
|
version="1.0.0",
|
||||||
)
|
)
|
||||||
class ColorMapImageProcessorInvocation(ImageProcessorInvocation):
|
class ColorMapImageProcessorInvocation(ImageProcessorInvocation):
|
||||||
"""Generates a color map from the provided image"""
|
"""Generates a color map from the provided image"""
|
||||||
@ -577,14 +575,14 @@ class ColorMapImageProcessorInvocation(ImageProcessorInvocation):
|
|||||||
|
|
||||||
def run_processor(self, image: Image.Image):
|
def run_processor(self, image: Image.Image):
|
||||||
image = image.convert("RGB")
|
image = image.convert("RGB")
|
||||||
np_image = np.array(image, dtype=np.uint8)
|
image = np.array(image, dtype=np.uint8)
|
||||||
height, width = np_image.shape[:2]
|
height, width = image.shape[:2]
|
||||||
|
|
||||||
width_tile_size = min(self.color_map_tile_size, width)
|
width_tile_size = min(self.color_map_tile_size, width)
|
||||||
height_tile_size = min(self.color_map_tile_size, height)
|
height_tile_size = min(self.color_map_tile_size, height)
|
||||||
|
|
||||||
color_map = cv2.resize(
|
color_map = cv2.resize(
|
||||||
np_image,
|
image,
|
||||||
(width // width_tile_size, height // height_tile_size),
|
(width // width_tile_size, height // height_tile_size),
|
||||||
interpolation=cv2.INTER_CUBIC,
|
interpolation=cv2.INTER_CUBIC,
|
||||||
)
|
)
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
# Custom Nodes / Node Packs
|
|
||||||
|
|
||||||
Copy your node packs to this directory.
|
|
||||||
|
|
||||||
When nodes are added or changed, you must restart the app to see the changes.
|
|
||||||
|
|
||||||
## Directory Structure
|
|
||||||
|
|
||||||
For a node pack to be loaded, it must be placed in a directory alongside this
|
|
||||||
file. Here's an example structure:
|
|
||||||
|
|
||||||
```py
|
|
||||||
.
|
|
||||||
├── __init__.py # Invoke-managed custom node loader
|
|
||||||
│
|
|
||||||
├── cool_node
|
|
||||||
│ ├── __init__.py # see example below
|
|
||||||
│ └── cool_node.py
|
|
||||||
│
|
|
||||||
└── my_node_pack
|
|
||||||
├── __init__.py # see example below
|
|
||||||
├── tasty_node.py
|
|
||||||
├── bodacious_node.py
|
|
||||||
├── utils.py
|
|
||||||
└── extra_nodes
|
|
||||||
└── fancy_node.py
|
|
||||||
```
|
|
||||||
|
|
||||||
## Node Pack `__init__.py`
|
|
||||||
|
|
||||||
Each node pack must have an `__init__.py` file that imports its nodes.
|
|
||||||
|
|
||||||
The structure of each node or node pack is otherwise not important.
|
|
||||||
|
|
||||||
Here are examples, based on the example directory structure.
|
|
||||||
|
|
||||||
### `cool_node/__init__.py`
|
|
||||||
|
|
||||||
```py
|
|
||||||
from .cool_node import CoolInvocation
|
|
||||||
```
|
|
||||||
|
|
||||||
### `my_node_pack/__init__.py`
|
|
||||||
|
|
||||||
```py
|
|
||||||
from .tasty_node import TastyInvocation
|
|
||||||
from .bodacious_node import BodaciousInvocation
|
|
||||||
from .extra_nodes.fancy_node import FancyInvocation
|
|
||||||
```
|
|
||||||
|
|
||||||
Only nodes imported in the `__init__.py` file are loaded.
|
|
@ -1,53 +0,0 @@
|
|||||||
"""
|
|
||||||
Invoke-managed custom node loader. See README.md for more information.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import sys
|
|
||||||
from importlib.util import module_from_spec, spec_from_file_location
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from invokeai.backend.util.logging import InvokeAILogger
|
|
||||||
|
|
||||||
logger = InvokeAILogger.get_logger()
|
|
||||||
loaded_count = 0
|
|
||||||
|
|
||||||
|
|
||||||
for d in Path(__file__).parent.iterdir():
|
|
||||||
# skip files
|
|
||||||
if not d.is_dir():
|
|
||||||
continue
|
|
||||||
|
|
||||||
# skip hidden directories
|
|
||||||
if d.name.startswith("_") or d.name.startswith("."):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# skip directories without an `__init__.py`
|
|
||||||
init = d / "__init__.py"
|
|
||||||
if not init.exists():
|
|
||||||
continue
|
|
||||||
|
|
||||||
module_name = init.parent.stem
|
|
||||||
|
|
||||||
# skip if already imported
|
|
||||||
if module_name in globals():
|
|
||||||
continue
|
|
||||||
|
|
||||||
# load the module, appending adding a suffix to identify it as a custom node pack
|
|
||||||
spec = spec_from_file_location(module_name, init.absolute())
|
|
||||||
|
|
||||||
if spec is None or spec.loader is None:
|
|
||||||
logger.warn(f"Could not load {init}")
|
|
||||||
continue
|
|
||||||
|
|
||||||
logger.info(f"Loading node pack {module_name}")
|
|
||||||
|
|
||||||
module = module_from_spec(spec)
|
|
||||||
sys.modules[spec.name] = module
|
|
||||||
spec.loader.exec_module(module)
|
|
||||||
|
|
||||||
loaded_count += 1
|
|
||||||
|
|
||||||
del init, module_name
|
|
||||||
|
|
||||||
if loaded_count > 0:
|
|
||||||
logger.info(f"Loaded {loaded_count} node packs from {Path(__file__).parent}")
|
|
@ -6,13 +6,13 @@ import numpy
|
|||||||
from PIL import Image, ImageOps
|
from PIL import Image, ImageOps
|
||||||
|
|
||||||
from invokeai.app.invocations.primitives import ImageField, ImageOutput
|
from invokeai.app.invocations.primitives import ImageField, ImageOutput
|
||||||
from invokeai.app.services.image_records.image_records_common import ImageCategory, ResourceOrigin
|
from invokeai.app.models.image import ImageCategory, ResourceOrigin
|
||||||
|
|
||||||
from .baseinvocation import BaseInvocation, InputField, InvocationContext, WithMetadata, invocation
|
from .baseinvocation import BaseInvocation, InputField, InvocationContext, invocation
|
||||||
|
|
||||||
|
|
||||||
@invocation("cv_inpaint", title="OpenCV Inpaint", tags=["opencv", "inpaint"], category="inpaint", version="1.2.0")
|
@invocation("cv_inpaint", title="OpenCV Inpaint", tags=["opencv", "inpaint"], category="inpaint", version="1.0.0")
|
||||||
class CvInpaintInvocation(BaseInvocation, WithMetadata):
|
class CvInpaintInvocation(BaseInvocation):
|
||||||
"""Simple inpaint using opencv."""
|
"""Simple inpaint using opencv."""
|
||||||
|
|
||||||
image: ImageField = InputField(description="The image to inpaint")
|
image: ImageField = InputField(description="The image to inpaint")
|
||||||
@ -41,7 +41,7 @@ class CvInpaintInvocation(BaseInvocation, WithMetadata):
|
|||||||
node_id=self.id,
|
node_id=self.id,
|
||||||
session_id=context.graph_execution_state_id,
|
session_id=context.graph_execution_state_id,
|
||||||
is_intermediate=self.is_intermediate,
|
is_intermediate=self.is_intermediate,
|
||||||
workflow=context.workflow,
|
workflow=self.workflow,
|
||||||
)
|
)
|
||||||
|
|
||||||
return ImageOutput(
|
return ImageOutput(
|
||||||
|
@ -8,7 +8,7 @@ import numpy as np
|
|||||||
from mediapipe.python.solutions.face_mesh import FaceMesh # type: ignore[import]
|
from mediapipe.python.solutions.face_mesh import FaceMesh # type: ignore[import]
|
||||||
from PIL import Image, ImageDraw, ImageFilter, ImageFont, ImageOps
|
from PIL import Image, ImageDraw, ImageFilter, ImageFont, ImageOps
|
||||||
from PIL.Image import Image as ImageType
|
from PIL.Image import Image as ImageType
|
||||||
from pydantic import field_validator
|
from pydantic import validator
|
||||||
|
|
||||||
import invokeai.assets.fonts as font_assets
|
import invokeai.assets.fonts as font_assets
|
||||||
from invokeai.app.invocations.baseinvocation import (
|
from invokeai.app.invocations.baseinvocation import (
|
||||||
@ -16,12 +16,11 @@ from invokeai.app.invocations.baseinvocation import (
|
|||||||
InputField,
|
InputField,
|
||||||
InvocationContext,
|
InvocationContext,
|
||||||
OutputField,
|
OutputField,
|
||||||
WithMetadata,
|
|
||||||
invocation,
|
invocation,
|
||||||
invocation_output,
|
invocation_output,
|
||||||
)
|
)
|
||||||
from invokeai.app.invocations.primitives import ImageField, ImageOutput
|
from invokeai.app.invocations.primitives import ImageField, ImageOutput
|
||||||
from invokeai.app.services.image_records.image_records_common import ImageCategory, ResourceOrigin
|
from invokeai.app.models.image import ImageCategory, ResourceOrigin
|
||||||
|
|
||||||
|
|
||||||
@invocation_output("face_mask_output")
|
@invocation_output("face_mask_output")
|
||||||
@ -130,7 +129,7 @@ def prepare_faces_list(
|
|||||||
deduped_faces: list[FaceResultData] = []
|
deduped_faces: list[FaceResultData] = []
|
||||||
|
|
||||||
if len(face_result_list) == 0:
|
if len(face_result_list) == 0:
|
||||||
return []
|
return list()
|
||||||
|
|
||||||
for candidate in face_result_list:
|
for candidate in face_result_list:
|
||||||
should_add = True
|
should_add = True
|
||||||
@ -209,7 +208,7 @@ def generate_face_box_mask(
|
|||||||
# Check if any face is detected.
|
# Check if any face is detected.
|
||||||
if results.multi_face_landmarks: # type: ignore # this are via protobuf and not typed
|
if results.multi_face_landmarks: # type: ignore # this are via protobuf and not typed
|
||||||
# Search for the face_id in the detected faces.
|
# Search for the face_id in the detected faces.
|
||||||
for _face_id, face_landmarks in enumerate(results.multi_face_landmarks): # type: ignore #this are via protobuf and not typed
|
for face_id, face_landmarks in enumerate(results.multi_face_landmarks): # type: ignore #this are via protobuf and not typed
|
||||||
# Get the bounding box of the face mesh.
|
# Get the bounding box of the face mesh.
|
||||||
x_coordinates = [landmark.x for landmark in face_landmarks.landmark]
|
x_coordinates = [landmark.x for landmark in face_landmarks.landmark]
|
||||||
y_coordinates = [landmark.y for landmark in face_landmarks.landmark]
|
y_coordinates = [landmark.y for landmark in face_landmarks.landmark]
|
||||||
@ -437,8 +436,8 @@ def get_faces_list(
|
|||||||
return all_faces
|
return all_faces
|
||||||
|
|
||||||
|
|
||||||
@invocation("face_off", title="FaceOff", tags=["image", "faceoff", "face", "mask"], category="image", version="1.2.0")
|
@invocation("face_off", title="FaceOff", tags=["image", "faceoff", "face", "mask"], category="image", version="1.0.2")
|
||||||
class FaceOffInvocation(BaseInvocation, WithMetadata):
|
class FaceOffInvocation(BaseInvocation):
|
||||||
"""Bound, extract, and mask a face from an image using MediaPipe detection"""
|
"""Bound, extract, and mask a face from an image using MediaPipe detection"""
|
||||||
|
|
||||||
image: ImageField = InputField(description="Image for face detection")
|
image: ImageField = InputField(description="Image for face detection")
|
||||||
@ -507,7 +506,7 @@ class FaceOffInvocation(BaseInvocation, WithMetadata):
|
|||||||
node_id=self.id,
|
node_id=self.id,
|
||||||
session_id=context.graph_execution_state_id,
|
session_id=context.graph_execution_state_id,
|
||||||
is_intermediate=self.is_intermediate,
|
is_intermediate=self.is_intermediate,
|
||||||
workflow=context.workflow,
|
workflow=self.workflow,
|
||||||
)
|
)
|
||||||
|
|
||||||
mask_dto = context.services.images.create(
|
mask_dto = context.services.images.create(
|
||||||
@ -531,8 +530,8 @@ class FaceOffInvocation(BaseInvocation, WithMetadata):
|
|||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
@invocation("face_mask_detection", title="FaceMask", tags=["image", "face", "mask"], category="image", version="1.2.0")
|
@invocation("face_mask_detection", title="FaceMask", tags=["image", "face", "mask"], category="image", version="1.0.2")
|
||||||
class FaceMaskInvocation(BaseInvocation, WithMetadata):
|
class FaceMaskInvocation(BaseInvocation):
|
||||||
"""Face mask creation using mediapipe face detection"""
|
"""Face mask creation using mediapipe face detection"""
|
||||||
|
|
||||||
image: ImageField = InputField(description="Image to face detect")
|
image: ImageField = InputField(description="Image to face detect")
|
||||||
@ -551,7 +550,7 @@ class FaceMaskInvocation(BaseInvocation, WithMetadata):
|
|||||||
)
|
)
|
||||||
invert_mask: bool = InputField(default=False, description="Toggle to invert the mask")
|
invert_mask: bool = InputField(default=False, description="Toggle to invert the mask")
|
||||||
|
|
||||||
@field_validator("face_ids")
|
@validator("face_ids")
|
||||||
def validate_comma_separated_ints(cls, v) -> str:
|
def validate_comma_separated_ints(cls, v) -> str:
|
||||||
comma_separated_ints_regex = re.compile(r"^\d*(,\d+)*$")
|
comma_separated_ints_regex = re.compile(r"^\d*(,\d+)*$")
|
||||||
if comma_separated_ints_regex.match(v) is None:
|
if comma_separated_ints_regex.match(v) is None:
|
||||||
@ -626,7 +625,7 @@ class FaceMaskInvocation(BaseInvocation, WithMetadata):
|
|||||||
node_id=self.id,
|
node_id=self.id,
|
||||||
session_id=context.graph_execution_state_id,
|
session_id=context.graph_execution_state_id,
|
||||||
is_intermediate=self.is_intermediate,
|
is_intermediate=self.is_intermediate,
|
||||||
workflow=context.workflow,
|
workflow=self.workflow,
|
||||||
)
|
)
|
||||||
|
|
||||||
mask_dto = context.services.images.create(
|
mask_dto = context.services.images.create(
|
||||||
@ -649,9 +648,9 @@ class FaceMaskInvocation(BaseInvocation, WithMetadata):
|
|||||||
|
|
||||||
|
|
||||||
@invocation(
|
@invocation(
|
||||||
"face_identifier", title="FaceIdentifier", tags=["image", "face", "identifier"], category="image", version="1.2.0"
|
"face_identifier", title="FaceIdentifier", tags=["image", "face", "identifier"], category="image", version="1.0.2"
|
||||||
)
|
)
|
||||||
class FaceIdentifierInvocation(BaseInvocation, WithMetadata):
|
class FaceIdentifierInvocation(BaseInvocation):
|
||||||
"""Outputs an image with detected face IDs printed on each face. For use with other FaceTools."""
|
"""Outputs an image with detected face IDs printed on each face. For use with other FaceTools."""
|
||||||
|
|
||||||
image: ImageField = InputField(description="Image to face detect")
|
image: ImageField = InputField(description="Image to face detect")
|
||||||
@ -715,7 +714,7 @@ class FaceIdentifierInvocation(BaseInvocation, WithMetadata):
|
|||||||
node_id=self.id,
|
node_id=self.id,
|
||||||
session_id=context.graph_execution_state_id,
|
session_id=context.graph_execution_state_id,
|
||||||
is_intermediate=self.is_intermediate,
|
is_intermediate=self.is_intermediate,
|
||||||
workflow=context.workflow,
|
workflow=self.workflow,
|
||||||
)
|
)
|
||||||
|
|
||||||
return ImageOutput(
|
return ImageOutput(
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user