Go to file
psychedelicious c42d692ea6
feat: workflow library (#5148)
* chore: bump pydantic to 2.5.2

This release fixes pydantic/pydantic#8175 and allows us to use `JsonValue`

* fix(ui): exclude public/en.json from prettier config

* fix(workflow_records): fix SQLite workflow insertion to ignore duplicates

* feat(backend): update workflows handling

Update workflows handling for Workflow Library.

**Updated Workflow Storage**

"Embedded Workflows" are workflows associated with images, and are now only stored in the image files. "Library Workflows" are not associated with images, and are stored only in DB.

This works out nicely. We have always saved workflows to files, but recently began saving them to the DB in addition to in image files. When that happened, we stopped reading workflows from files, so all the workflows that only existed in images were inaccessible. With this change, access to those workflows is restored, and no workflows are lost.

**Updated Workflow Handling in Nodes**

Prior to this change, workflows were embedded in images by passing the whole workflow JSON to a special workflow field on a node. In the node's `invoke()` function, the node was able to access this workflow and save it with the image. This (inaccurately) models workflows as a property of an image and is rather awkward technically.

A workflow is now a property of a batch/session queue item. It is available in the InvocationContext and therefore available to all nodes during `invoke()`.

**Database Migrations**

Added a `SQLiteMigrator` class to handle database migrations. Migrations were needed to accomodate the DB-related changes in this PR. See the code for details.

The `images`, `workflows` and `session_queue` tables required migrations for this PR, and are using the new migrator. Other tables/services are still creating tables themselves. A followup PR will adapt them to use the migrator.

**Other/Support Changes**

- Add a `has_workflow` column to `images` table to indicate that the image has an embedded workflow.
- Add handling for retrieving the workflow from an image in python. The image file must be fetched, the workflow extracted, and then sent to client, avoiding needing the browser to parse the image file. With the `has_workflow` column, the UI knows if there is a workflow to be fetched, and only fetches when the user requests to load the workflow.
- Add route to get the workflow from an image
- Add CRUD service/routes for the library workflows
- `workflow_images` table and services removed (no longer needed now that embedded workflows are not in the DB)

* feat(ui): updated workflow handling (WIP)

Clientside updates for the backend workflow changes.

Includes roughed-out workflow library UI.

* feat: revert SQLiteMigrator class

Will pursue this in a separate PR.

* feat(nodes): do not overwrite custom node module names

Use a different, simpler method to detect if a node is custom.

* feat(nodes): restore WithWorkflow as no-op class

This class is deprecated and no longer needed. Set its workflow attr value to None (meaning it is now a no-op), and issue a warning when an invocation subclasses it.

* fix(nodes): fix get_workflow from queue item dict func

* feat(backend): add WorkflowRecordListItemDTO

This is the id, name, description, created at and updated at workflow columns/attrs. Used to display lists of workflowsl

* chore(ui): typegen

* feat(ui): add workflow loading, deleting to workflow library UI

* feat(ui): workflow library pagination button styles

* wip

* feat: workflow library WIP

- Save to library
- Duplicate
- Filter/sort
- UI/queries

* feat: workflow library - system graphs - wip

* feat(backend): sync system workflows to db

* fix: merge conflicts

* feat: simplify default workflows

- Rename "system" -> "default"
- Simplify syncing logic
- Update UI to match

* feat(workflows): update default workflows

- Update TextToImage_SD15
- Add TextToImage_SDXL
- Add README

* feat(ui): refine workflow list UI

* fix(workflow_records): typo

* fix(tests): fix tests

* feat(ui): clean up workflow library hooks

* fix(db): fix mis-ordered db cleanup step

It was happening before pruning queue items - should happen afterwards, else you have to restart the app again to free disk space made available by the pruning.

* feat(ui): tweak reset workflow editor translations

* feat(ui): split out workflow redux state

The `nodes` slice is a rather complicated slice. Removing `workflow` makes it a bit more reasonable.

Also helps to flatten state out a bit.

* docs: update default workflows README

* fix: tidy up unused files, unrelated changes

* fix(backend): revert unrelated service organisational changes

* feat(backend): workflow_records.get_many arg "filter_text" -> "query"

* feat(ui): use custom hook in current image buttons

Already in use elsewhere, forgot to use it here.

* fix(ui): remove commented out property

* fix(ui): fix workflow loading

- Different handling for loading from library vs external
- Fix bug where only nodes and edges loaded

* fix(ui): fix save/save-as workflow naming

* fix(ui): fix circular dependency

* fix(db): fix bug with releasing without lock in db.clean()

* fix(db): remove extraneous lock

* chore: bump ruff

* fix(workflow_records): default `category` to `WorkflowCategory.User`

This allows old workflows to validate when reading them from the db or image files.

* hide workflow library buttons if feature is disabled

---------

Co-authored-by: Mary Hipp <maryhipp@Marys-MacBook-Air.local>
2023-12-09 09:48:38 +11:00
.dev_scripts Apply black 2023-07-27 10:54:01 -04:00
.github change stylecheck name from "black" to "ruff" 2023-11-14 11:06:10 -05:00
coverage combine pytest.ini with pyproject.toml 2023-03-05 17:00:08 +00:00
docker Fix ROCm support in Docker container 2023-11-06 13:47:08 -08:00
docs Update communityNodes.md with VeyDlin's nodes 2023-12-08 05:34:19 -08:00
installer Updated JS files 2023-11-17 13:36:50 +11:00
invokeai feat: workflow library (#5148) 2023-12-09 09:48:38 +11:00
scripts chore: ruff format 2023-11-11 10:55:40 +11:00
tests feat: workflow library (#5148) 2023-12-09 09:48:38 +11:00
.dockerignore Update dockerignore, set venv to 3.10, pass cache to yarn vite buidl 2023-07-12 16:51:15 -04:00
.editorconfig Merge dev into main for 2.2.0 (#1642) 2022-11-30 16:12:23 -05:00
.git-blame-ignore-revs (meta) hide the 'black' formatting commit from git blame 2023-07-27 11:29:22 -04:00
.gitattributes Enforce Unix line endings in container (#4990) 2023-10-30 12:34:30 -04:00
.gitignore feat(docker): update docker image, etc. to python3.11+ubuntu23.04 2023-10-19 11:26:16 -04:00
.gitmodules remove src directory, which is gumming up conda installs; addresses issue #77 2022-08-25 10:43:05 -04:00
.pre-commit-config.yaml Adding isort GHA and pre-commit hooks 2023-09-12 13:01:58 -04:00
.prettierrc.yaml change printWidth for markdown files to 80 2022-09-17 02:23:00 +02:00
flake.lock Add Nix Flake for development, which uses Python virtualenv. 2023-07-31 19:14:30 +10:00
flake.nix fix: flake: add opencv with CUDA, new patchmatch dependency. 2023-08-01 23:56:41 +10:00
InvokeAI_Statement_of_Values.md Add @ebr to Contributors (#2095) 2022-12-21 14:33:08 -05:00
LICENSE Update LICENSE 2023-07-05 23:46:27 -04:00
LICENSE-SD1+SD2.txt updated LICENSE files and added information about watermarking 2023-07-26 17:27:33 -04:00
LICENSE-SDXL.txt updated LICENSE files and added information about watermarking 2023-07-26 17:27:33 -04:00
Makefile feat: update mypy script comment 2023-11-21 20:22:27 +11:00
mkdocs.yml (fix) docs formatting 2023-11-16 18:22:21 +11:00
pyproject.toml feat: workflow library (#5148) 2023-12-09 09:48:38 +11:00
README.md Update README.md 2023-11-27 10:15:05 +11:00
Stable_Diffusion_v1_Model_Card.md Global replace [ \t]+$, add "GB" (#1751) 2022-12-19 16:36:39 +00:00

project hero

Invoke AI - Generative AI for Professional Creatives

Professional Creative Tools for Stable Diffusion, Custom-Trained Models, and more.

To learn more about Invoke AI, get started instantly, or implement our Business solutions, visit invoke.ai

discord badge

latest release badge github stars badge github forks badge

CI checks on main badge latest commit to main badge

github open issues badge github open prs badge translation status badge

InvokeAI is a leading creative engine built to empower professionals and enthusiasts alike. Generate and create stunning visual media using the latest AI-driven technologies. InvokeAI offers an industry leading Web Interface, interactive Command Line Interface, and also serves as the foundation for multiple commercial products.

Quick links: [How to Install] [Discord Server] [Documentation and Tutorials] [Bug Reports] [Discussion, Ideas & Q&A] [Contributing]

canvas preview

Table of Contents

Table of Contents 📝

Getting Started

  1. 🏁 Quick Start
  2. 🖥️ Hardware Requirements

More About Invoke

  1. 🌟 Features
  2. 📣 Latest Changes
  3. 🛠️ Troubleshooting

Supporting the Project

  1. 🤝 Contributing
  2. 👥 Contributors
  3. 💕 Support

Quick Start

For full installation and upgrade instructions, please see: InvokeAI Installation Overview

If upgrading from version 2.3, please read Migrating a 2.3 root directory to 3.0 first.

Automatic Installer (suggested for 1st time users)

  1. Go to the bottom of the Latest Release Page

  2. Download the .zip file for your OS (Windows/macOS/Linux).

  3. Unzip the file.

  4. Windows: double-click on the install.bat script. macOS: Open a Terminal window, drag the file install.sh from Finder into the Terminal, and press return. Linux: run install.sh.

  5. You'll be asked to confirm the location of the folder in which to install InvokeAI and its image generation model files. Pick a location with at least 15 GB of free memory. More if you plan on installing lots of models.

  6. Wait while the installer does its thing. After installing the software, the installer will launch a script that lets you configure InvokeAI and select a set of starting image generation models.

  7. Find the folder that InvokeAI was installed into (it is not the same as the unpacked zip file directory!) The default location of this folder (if you didn't change it in step 5) is ~/invokeai on Linux/Mac systems, and C:\Users\YourName\invokeai on Windows. This directory will contain launcher scripts named invoke.sh and invoke.bat.

  8. On Windows systems, double-click on the invoke.bat file. On macOS, open a Terminal window, drag invoke.sh from the folder into the Terminal, and press return. On Linux, run invoke.sh

  9. Press 2 to open the "browser-based UI", press enter/return, wait a minute or two for Stable Diffusion to start up, then open your browser and go to http://localhost:9090.

  10. Type banana sushi in the box on the top left and click Invoke

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 later versions are not supported. Node.js also needs to be installed along with yarn (can be installed with the command npm install -g yarn if needed)

  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:

    mkdir invokeai
    
  3. Create a virtual environment named .venv inside this directory and activate it:

    cd invokeai
    python -m venv .venv --prompt InvokeAI
    
  4. Activate the virtual environment (do it every time you run InvokeAI)

    For Linux/Mac users:

    source .venv/bin/activate
    

    For Windows users:

    .venv\Scripts\activate
    
  5. Install the InvokeAI module and its dependencies. Choose the command suited for your platform & GPU.

    For Windows/Linux with an NVIDIA GPU:

    pip install "InvokeAI[xformers]" --use-pep517 --extra-index-url https://download.pytorch.org/whl/cu121
    

    For Linux with an AMD GPU:

    pip install InvokeAI --use-pep517 --extra-index-url https://download.pytorch.org/whl/rocm5.4.2
    

    For non-GPU systems:

    pip install InvokeAI --use-pep517 --extra-index-url https://download.pytorch.org/whl/cpu
    

    For Macintoshes, either Intel or M1/M2/M3:

    pip install InvokeAI --use-pep517
    
  6. Configure InvokeAI and install a starting set of image generation models (you only need to do this once):

    invokeai-configure --root .
    

    Don't miss the dot at the end!

  7. Launch the web server (do it every time you run InvokeAI):

    invokeai-web
    
  8. Point your browser to http://localhost:9090 to bring up the web interface.

  9. Type banana sushi in the box on the top left and click Invoke.

Be sure to activate the virtual environment each time before re-launching InvokeAI, using source .venv/bin/activate or .venv\Scripts\activate.

Detailed Installation Instructions

This fork is supported across Linux, Windows and Macintosh. Linux users can use either an Nvidia-based card (with CUDA support) or an AMD card (using the ROCm driver). For full installation and upgrade instructions, please see: InvokeAI Installation Overview

Migrating a v2.3 InvokeAI root directory

The InvokeAI root directory is where the InvokeAI startup file, installed models, and generated images are stored. It is ordinarily named invokeai and located in your home directory. The contents and layout of this directory has changed between versions 2.3 and 3.0 and cannot be used directly.

We currently recommend that you use the installer to create a new root directory named differently from the 2.3 one, e.g. invokeai-3 and then use a migration script to copy your 2.3 models into the new location. However, if you choose, you can upgrade this directory in place. This section gives both recipes.

Creating a new root directory and migrating old models

This is the safer recipe because it leaves your old root directory in place to fall back on.

  1. Follow the instructions above to create and install InvokeAI in a directory that has a different name from the 2.3 invokeai directory. In this example, we will use "invokeai-3"

  2. When you are prompted to select models to install, select a minimal set of models, such as stable-diffusion-v1.5 only.

  3. After installation is complete launch invokeai.sh (Linux/Mac) or invokeai.bat and select option 8 "Open the developers console". This will take you to the command line.

  4. Issue the command invokeai-migrate3 --from /path/to/v2.3-root --to /path/to/invokeai-3-root. Provide the correct --from and --to paths for your v2.3 and v3.0 root directories respectively.

This will copy and convert your old models from 2.3 format to 3.0 format and create a new models directory in the 3.0 directory. The old models directory (which contains the models selected at install time) will be renamed models.orig and can be deleted once you have confirmed that the migration was successful.

If you wish, you can pass the 2.3 root directory to both --from and --to in order to update in place. Warning: this directory will no longer be usable with InvokeAI 2.3.

Migrating in place

For the adventurous, you may do an in-place upgrade from 2.3 to 3.0 without touching the command line. *This recipe does not work on Windows platforms due to a bug in the Windows version of the 2.3 upgrade script. See the next section for a Windows recipe.

For Mac and Linux Users:
  1. Launch the InvokeAI launcher script in your current v2.3 root directory.

  2. Select option [9] "Update InvokeAI" to bring up the updater dialog.

  3. Select option [1] to upgrade to the latest release.

  4. Once the upgrade is finished you will be returned to the launcher menu. Select option [7] "Re-run the configure script to fix a broken install or to complete a major upgrade".

This will run the configure script against the v2.3 directory and update it to the 3.0 format. The following files will be replaced:

  • The invokeai.init file, replaced by invokeai.yaml
  • The models directory
  • The configs/models.yaml model index

The original versions of these files will be saved with the suffix ".orig" appended to the end. Once you have confirmed that the upgrade worked, you can safely remove these files. Alternatively you can restore a working v2.3 directory by removing the new files and restoring the ".orig" files' original names.

For Windows Users:

Windows Users can upgrade with the

  1. Enter the 2.3 root directory you wish to upgrade
  2. Launch invoke.sh or invoke.bat
  3. Select the "Developer's console" option [8]
  4. Type the following commands
pip install "invokeai @ https://github.com/invoke-ai/InvokeAI/archive/refs/tags/v3.0.0" --use-pep517 --upgrade
invokeai-configure --root .

(Replace v3.0.0 with the current release number if this document is out of date).

The first command will install and upgrade new software to run InvokeAI. The second will prepare the 2.3 directory for use with 3.0. You may now launch the WebUI in the usual way, by selecting option [1] from the launcher script

Migrating Images

The migration script will migrate your invokeai settings and models, including textual inversion models, LoRAs and merges that you may have installed previously. However it does not migrate the generated images stored in your 2.3-format outputs directory. To do this, you need to run an additional step:

  1. From a working InvokeAI 3.0 root directory, start the launcher and enter menu option [8] to open the "developer's console".

  2. At the developer's console command line, type the command:

invokeai-import-images
  1. This will lead you through the process of confirming the desired source and destination for the imported images. The images will appear in the gallery board of your choice, and contain the original prompt, model name, and other parameters used to generate the image.

(Many kudos to techjedi for contributing this script.)

Hardware Requirements

InvokeAI is supported across Linux, Windows and macOS. Linux users can use either an Nvidia-based card (with CUDA support) or an AMD card (using the ROCm driver).

System

You will need one of the following:

  • An NVIDIA-based graphics card with 4 GB or more VRAM memory. 6-8 GB of VRAM is highly recommended for rendering using the Stable Diffusion XL models
  • An Apple computer with an M1 chip.
  • An AMD-based graphics card with 4GB or more VRAM memory (Linux only), 6-8 GB for XL rendering.

We do not recommend the GTX 1650 or 1660 series video cards. They are unable to run in half-precision mode and do not have sufficient VRAM to render 512x512 images.

Memory - At least 12 GB Main Memory RAM.

Disk - At least 12 GB of free disk space for the machine learning model, Python, and all its dependencies.

Features

Feature documentation can be reviewed by navigating to the InvokeAI Documentation page

Web Server & UI

InvokeAI offers a locally hosted Web Server & React Frontend, with an industry leading user experience. The Web-based UI allows for simple and intuitive workflows, and is responsive for use on mobile devices and tablets accessing the web server.

Unified Canvas

The Unified Canvas is a fully integrated canvas implementation with support for all core generation capabilities, in/outpainting, brush tools, and more. This creative tool unlocks the capability for artists to create with AI as a creative collaborator, and can be used to augment AI-generated imagery, sketches, photography, renders, and more.

Workflows & Nodes

InvokeAI offers a fully featured workflow management solution, enabling users to combine the power of nodes based workflows with the easy of a UI. This allows for customizable generation pipelines to be developed and shared by users looking to create specific workflows to support their production use-cases.

Invoke AI provides an organized gallery system for easily storing, accessing, and remixing your content in the Invoke workspace. Images can be dragged/dropped onto any Image-base UI element in the application, and rich metadata within the Image allows for easy recall of key prompts or settings used in your workflow.

Other features

  • Support for both ckpt and diffusers models
  • SD 2.0, 2.1, XL support
  • Upscaling Tools
  • Embedding Manager & Support
  • Model Manager & Support
  • Workflow creation & management
  • Node-Based Architecture

Latest Changes

For our latest changes, view our Release Notes and the CHANGELOG.

Troubleshooting

Please check out our Troubleshooting Guide to get solutions for common installation problems and other issues. For more help, please join our Discord

Contributing

Anyone who wishes to contribute to this project, whether documentation, features, bug fixes, code cleanup, testing, or code reviews, is very much encouraged to do so.

Get started with contributing by reading our Contribution documentation, joining the #dev-chat or the GitHub discussion board.

If you are unfamiliar with how to contribute to GitHub projects, we have a new contributor checklist you can follow to get started contributing: New Contributor Checklist.

We hope you enjoy using our software as much as we enjoy creating it, and we hope that some of those of you who are reading this will elect to become part of our community.

Welcome to InvokeAI!

Contributors

This fork is a combined effort of various people from across the world. Check out the list of all these amazing people. We thank them for their time, hard work and effort.

Support

For support, please use this repository's GitHub Issues tracking service, or join the Discord.

Original portions of the software are Copyright (c) 2023 by respective contributors.