Skip to content

Commit 8b8a43e

Browse files
committed
Merge remote-tracking branch 'upstream/main' into feat_save_attention_maps_redo
2 parents c683fe1 + d2026d0 commit 8b8a43e

File tree

23 files changed

+417
-79
lines changed

23 files changed

+417
-79
lines changed

.dockerignore

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
*
22
!backend
3-
!configs
4-
!environments-and-requirements
53
!frontend
6-
!installer
4+
!binary_installer
75
!ldm
86
!main.py
97
!scripts
108
!server
119
!static
1210
!setup.py
11+
!docker-build
12+
!docs
13+
docker-build/Dockerfile
14+
15+
# Guard against pulling in any models that might exist in the directory tree
16+
**/*.pt*
17+
18+
# unignore configs, but only ignore the custom models.yaml, in case it exists
19+
!configs
20+
configs/models.yaml
21+
22+
# unignore environment dirs/files, but ignore the environment.yml file or symlink in case it exists
23+
!environment*
24+
environment.yml
25+
26+
**/__pycache__

.github/workflows/build-cloud-img.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Build and push cloud image
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- v*
9+
# we will NOT push the image on pull requests, only test buildability.
10+
pull_request:
11+
branches:
12+
- main
13+
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
env:
19+
REGISTRY: ghcr.io
20+
IMAGE_NAME: ${{ github.repository }}
21+
22+
jobs:
23+
docker:
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
arch:
28+
- x86_64
29+
# requires resolving a patchmatch issue
30+
# - aarch64
31+
runs-on: ubuntu-latest
32+
name: ${{ matrix.arch }}
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v3
36+
37+
- name: Set up QEMU
38+
uses: docker/setup-qemu-action@v2
39+
if: matrix.arch == 'aarch64'
40+
41+
- name: Docker meta
42+
id: meta
43+
uses: docker/metadata-action@v4
44+
with:
45+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
46+
# see https://github.com/docker/metadata-action
47+
# will push the following tags:
48+
# :edge
49+
# :main (+ any other branches enabled in the workflow)
50+
# :<tag>
51+
# :1.2.3 (for semver tags)
52+
# :1.2 (for semver tags)
53+
# :<sha>
54+
tags: |
55+
type=edge,branch=main
56+
type=ref,event=branch
57+
type=ref,event=tag
58+
type=semver,pattern={{version}}
59+
type=semver,pattern={{major}}.{{minor}}
60+
type=sha
61+
# suffix image tags with architecture
62+
flavor: |
63+
latest=auto
64+
suffix=-${{ matrix.arch }},latest=true
65+
66+
- name: Set up Docker Buildx
67+
uses: docker/setup-buildx-action@v2
68+
69+
# do not login to container registry on PRs
70+
- if: github.event_name != 'pull_request'
71+
name: Docker login
72+
uses: docker/login-action@v2
73+
with:
74+
registry: ghcr.io
75+
username: ${{ github.actor }}
76+
password: ${{ secrets.GITHUB_TOKEN }}
77+
78+
- name: Build and push cloud image
79+
uses: docker/build-push-action@v3
80+
with:
81+
context: .
82+
file: docker-build/Dockerfile.cloud
83+
platforms: Linux/${{ matrix.arch }}
84+
# do not push the image on PRs
85+
push: ${{ github.event_name != 'pull_request' }}
86+
tags: ${{ steps.meta.outputs.tags }}
87+
labels: ${{ steps.meta.outputs.labels }}

README.md

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<div align="center">
22

3-
# InvokeAI: A Stable Diffusion Toolkit
4-
5-
_Formerly known as lstein/stable-diffusion_
3+
![project logo](docs/assets/invoke_ai_banner.png)
64

7-
![project logo](docs/assets/logo.png)
5+
# InvokeAI: A Stable Diffusion Toolkit
86

97
[![discord badge]][discord link]
108

@@ -48,7 +46,10 @@ _Note: InvokeAI is rapidly evolving. Please use the
4846
[Issues](https://github.com/invoke-ai/InvokeAI/issues) tab to report bugs and make feature
4947
requests. Be sure to use the provided templates. They will help us diagnose issues faster._
5048

51-
## Installation Quick-Start
49+
# Getting Started with InvokeAI
50+
51+
For full installation and upgrade instructions, please see:
52+
[InvokeAI Installation Overview](https://invoke-ai.github.io/InvokeAI/installation/)
5253

5354
1. Go to the bottom of the [Latest Release Page](https://github.com/invoke-ai/InvokeAI/releases/tag/v2.2.3)
5455
2. Download the .zip file for your OS (Windows/macOS/Linux).
@@ -62,8 +63,6 @@ requests. Be sure to use the provided templates. They will help us diagnose issu
6263
<div align="center"><img src="docs/assets/invoke-web-server-1.png" width=640></div>
6364

6465

65-
For full installation and upgrade instructions, please see:
66-
[InvokeAI Installation Overview](https://invoke-ai.github.io/InvokeAI/installation/)
6766

6867
## Table of Contents
6968

@@ -118,11 +117,12 @@ Similarly, specify full-precision mode on Apple M1 hardware.
118117

119118
Precision is auto configured based on the device. If however you encounter
120119
errors like 'expected type Float but found Half' or 'not implemented for Half'
121-
you can try starting `invoke.py` with the `--precision=float32` flag:
120+
you can try starting `invoke.py` with the `--precision=float32` flag to your initialization command
122121

123122
```bash
124123
(invokeai) ~/InvokeAI$ python scripts/invoke.py --precision=float32
125124
```
125+
Or by updating your InvokeAI configuration file with this argument.
126126

127127
### Features
128128

@@ -151,39 +151,7 @@ you can try starting `invoke.py` with the `--precision=float32` flag:
151151

152152
### Latest Changes
153153

154-
- v2.0.1 (13 November 2022)
155-
- fix noisy images at high step count when using k* samplers
156-
- dream.py script now calls invoke.py module directly rather than
157-
via a new python process (which could break the environment)
158-
159-
- v2.0.0 (9 November 2022)
160-
161-
- `dream.py` script renamed `invoke.py`. A `dream.py` script wrapper remains
162-
for backward compatibility.
163-
- Completely new WebGUI - launch with `python3 scripts/invoke.py --web`
164-
- Support for <a href="https://invoke-ai.github.io/InvokeAI/features/INPAINTING/">inpainting</a> and <a href="https://invoke-ai.github.io/InvokeAI/features/OUTPAINTING/">outpainting</a>
165-
- img2img runs on all k* samplers
166-
- Support for <a href="https://invoke-ai.github.io/InvokeAI/features/PROMPTS/#negative-and-unconditioned-prompts">negative prompts</a>
167-
- Support for CodeFormer face reconstruction
168-
- Support for Textual Inversion on macOS
169-
- Support in both WebGUI and CLI for <a href="https://invoke-ai.github.io/InvokeAI/features/POSTPROCESS/">post-processing of previously-generated images</a>
170-
using facial reconstruction, ESRGAN upscaling, outcropping (similar to DALL-E infinite canvas),
171-
and "embiggen" upscaling. See the `!fix` command.
172-
- New `--hires` option on `invoke>` line allows <a href="https://invoke-ai.github.io/InvokeAI/features/CLI/#txt2img">larger images to be created without duplicating elements</a>, at the cost of some performance.
173-
- New `--perlin` and `--threshold` options allow you to add and control variation
174-
during image generation (see <a href="https://github.com/invoke-ai/InvokeAI/blob/main/docs/features/OTHER.md#thresholding-and-perlin-noise-initialization-options">Thresholding and Perlin Noise Initialization</a>
175-
- Extensive metadata now written into PNG files, allowing reliable regeneration of images
176-
and tweaking of previous settings.
177-
- Command-line completion in `invoke.py` now works on Windows, Linux and macOS platforms.
178-
- Improved <a href="https://invoke-ai.github.io/InvokeAI/features/CLI/">command-line completion behavior</a>.
179-
New commands added:
180-
- List command-line history with `!history`
181-
- Search command-line history with `!search`
182-
- Clear history with `!clear`
183-
- Deprecated `--full_precision` / `-F`. Simply omit it and `invoke.py` will auto
184-
configure. To switch away from auto use the new flag like `--precision=float32`.
185-
186-
For older changelogs, please visit the **[CHANGELOG](https://invoke-ai.github.io/InvokeAI/CHANGELOG#v114-11-september-2022)**.
154+
For our latest changes, view our [Release Notes](https://github.com/invoke-ai/InvokeAI/releases)
187155

188156
### Troubleshooting
189157

@@ -193,8 +161,9 @@ problems and other issues.
193161
# Contributing
194162

195163
Anyone who wishes to contribute to this project, whether documentation, features, bug fixes, code
196-
cleanup, testing, or code reviews, is very much encouraged to do so. To join, just raise your hand on the InvokeAI
197-
Discord server or discussion board.
164+
cleanup, testing, or code reviews, is very much encouraged to do so.
165+
166+
To join, just raise your hand on the InvokeAI Discord server (#dev-chat) or the GitHub discussion board.
198167

199168
If you are unfamiliar with how
200169
to contribute to GitHub projects, here is a

binary_installer/invoke.sh.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
set -eu
44

5+
# ensure we're in the correct folder in case user's CWD is somewhere else
6+
scriptdir=$(dirname "$0")
7+
cd "$scriptdir"
8+
59
. .venv/bin/activate
610

711
# set required env var for torch on mac MPS

configs/stable-diffusion/v1-inference.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ model:
3232
placeholder_strings: ["*"]
3333
initializer_words: ['sculpture']
3434
per_image_tokens: false
35-
num_vectors_per_token: 8
35+
num_vectors_per_token: 1
3636
progressive_words: False
3737

3838
unet_config:

docker-build/Dockerfile.cloud

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#######################
2+
#### Builder stage ####
3+
4+
FROM library/ubuntu:22.04 AS builder
5+
6+
ARG DEBIAN_FRONTEND=noninteractive
7+
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
8+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
9+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
10+
apt update && apt-get install -y \
11+
git \
12+
libglib2.0-0 \
13+
libgl1-mesa-glx \
14+
python3-venv \
15+
python3-pip \
16+
build-essential \
17+
python3-opencv \
18+
libopencv-dev
19+
20+
# This is needed for patchmatch support
21+
RUN cd /usr/lib/x86_64-linux-gnu/pkgconfig/ &&\
22+
ln -sf opencv4.pc opencv.pc
23+
24+
ARG WORKDIR=/invokeai
25+
WORKDIR ${WORKDIR}
26+
27+
ENV VIRTUAL_ENV=${WORKDIR}/.venv
28+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
29+
30+
RUN --mount=type=cache,target=/root/.cache/pip \
31+
python3 -m venv ${VIRTUAL_ENV} &&\
32+
pip install --extra-index-url https://download.pytorch.org/whl/cu116 \
33+
torch==1.12.0+cu116 \
34+
torchvision==0.13.0+cu116 &&\
35+
pip install -e git+https://github.com/invoke-ai/[email protected]#egg=pypatchmatch
36+
37+
COPY . .
38+
RUN --mount=type=cache,target=/root/.cache/pip \
39+
cp binary_installer/py3.10-linux-x86_64-cuda-reqs.txt requirements.txt && \
40+
pip install -r requirements.txt &&\
41+
pip install -e .
42+
43+
44+
#######################
45+
#### Runtime stage ####
46+
47+
FROM library/ubuntu:22.04 as runtime
48+
49+
ARG DEBIAN_FRONTEND=noninteractive
50+
ENV PYTHONUNBUFFERED=1
51+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
52+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
53+
apt update && apt install -y --no-install-recommends \
54+
git \
55+
curl \
56+
ncdu \
57+
iotop \
58+
bzip2 \
59+
libglib2.0-0 \
60+
libgl1-mesa-glx \
61+
python3-venv \
62+
python3-pip \
63+
build-essential \
64+
python3-opencv \
65+
libopencv-dev &&\
66+
apt-get clean && apt-get autoclean
67+
68+
ARG WORKDIR=/invokeai
69+
WORKDIR ${WORKDIR}
70+
71+
ENV INVOKEAI_ROOT=/mnt/invokeai
72+
ENV VIRTUAL_ENV=${WORKDIR}/.venv
73+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
74+
75+
COPY --from=builder ${WORKDIR} ${WORKDIR}
76+
COPY --from=builder /usr/lib/x86_64-linux-gnu/pkgconfig /usr/lib/x86_64-linux-gnu/pkgconfig
77+
78+
# build patchmatch
79+
RUN python -c "from patchmatch import patch_match"
80+
81+
## workaround for non-existent initfile when runtime directory is mounted; see #1613
82+
RUN touch /root/.invokeai
83+
84+
ENTRYPOINT ["bash"]
85+
86+
CMD ["-c", "python3 scripts/invoke.py --web --host 0.0.0.0"]

docker-build/Makefile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Directory in the container where the INVOKEAI_ROOT (runtime dir) will be mounted
2+
INVOKEAI_ROOT=/mnt/invokeai
3+
# Host directory to contain the runtime dir. Will be mounted at INVOKEAI_ROOT path in the container
4+
HOST_MOUNT_PATH=${HOME}/invokeai
5+
6+
IMAGE=local/invokeai:latest
7+
8+
USER=$(shell id -u)
9+
GROUP=$(shell id -g)
10+
11+
# All downloaded models, config, etc will end up in ${HOST_MOUNT_PATH} on the host.
12+
# This is consistent with the expected non-Docker behaviour.
13+
# Contents can be moved to a persistent storage and used to prime the cache on another host.
14+
15+
build:
16+
DOCKER_BUILDKIT=1 docker build -t local/invokeai:latest -f Dockerfile.cloud ..
17+
18+
configure:
19+
docker run --rm -it --runtime=nvidia --gpus=all \
20+
-v ${HOST_MOUNT_PATH}:${INVOKEAI_ROOT} \
21+
-e INVOKEAI_ROOT=${INVOKEAI_ROOT} \
22+
${IMAGE} -c "python scripts/configure_invokeai.py"
23+
24+
# Run the container with the runtime dir mounted and the web server exposed on port 9090
25+
web:
26+
docker run --rm -it --runtime=nvidia --gpus=all \
27+
-v ${HOST_MOUNT_PATH}:${INVOKEAI_ROOT} \
28+
-e INVOKEAI_ROOT=${INVOKEAI_ROOT} \
29+
-p 9090:9090 \
30+
${IMAGE} -c "python scripts/invoke.py --web --host 0.0.0.0"
31+
32+
# Run the cli with the runtime dir mounted
33+
cli:
34+
docker run --rm -it --runtime=nvidia --gpus=all \
35+
-v ${HOST_MOUNT_PATH}:${INVOKEAI_ROOT} \
36+
-e INVOKEAI_ROOT=${INVOKEAI_ROOT} \
37+
${IMAGE} -c "python scripts/invoke.py"
38+
39+
# Run the container with the runtime dir mounted and open a bash shell
40+
shell:
41+
docker run --rm -it --runtime=nvidia --gpus=all \
42+
-v ${HOST_MOUNT_PATH}:${INVOKEAI_ROOT} ${IMAGE} --
43+
44+
.PHONY: build configure web cli shell

0 commit comments

Comments
 (0)