Dev Environment#
To make changes to Invoke's backend, frontend, or documentation, you'll need to set up a dev environment.
If you just want to use Invoke, you should use the installer.
Why do I need the frontend toolchain?
The repo doesn't contain a build of the frontend. You'll be responsible for rebuilding it every time you pull in new changes, or run it in dev mode (which incurs a substantial performance penalty).
Warning
Invoke uses a SQLite database. When you run the application as a dev install, 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 to persist your db, you can use an ephemeral in-memory database by setting use_memory_db: true
in your invokeai.yaml
file. You'll also want to set scan_models_on_startup: true
so that your models are registered on startup.
Setup#
- Run through the requirements.
- Fork and clone the InvokeAI repo.
- Create an directory for user data (images, models, db, etc). This is typically at
~/invokeai
, but if you already have a non-dev install, you may want to create a separate directory for the dev install. -
Create a python virtual environment inside the directory you just created:
-
Activate the venv (you'll need to do this every time you want to run the app):
-
Install the repo as an editable install:
pip install -e ".[dev,test,xformers]" --use-pep517 --extra-index-url https://download.pytorch.org/whl/cu121
Refer to the manual installation instructions for more determining the correct install options.
xformers
is optional, butdev
andtest
are not. -
Install the frontend dev toolchain:
-
nodejs
(recommend v20 LTS) -
pnpm
(must be v8 - not v9!) -
Do a production build of the frontend:
-
Start the application:
-
Access the UI at
localhost:9090
.
Updating the UI#
You'll need to run pnpm build
every time you pull in new changes. Another option is to skip the build and instead run the app in dev mode:
This starts a dev server at localhost:5173
, which you will use instead of localhost:9090
.
The dev mode is substantially slower than the production build but may be more convenient if you just need to test things out.
Documentation#
The documentation is built with mkdocs
. To preview it locally, you need a additional set of packages installed.
Then, you can start a live docs dev server, which will auto-refresh when you edit the docs:
On macOS and Linux, there is a make
target for this: