A collection of utility scripts for working with the InvokeAI SQLite database.
These tools are designed for recovering lost image entries, rebuilding the image index, and reclassifying images as user assets and vice versa.
Script: Restore_Images_DB_v2.1.py
This script scans the directory you provide via --outputs and compares files to the entries stored in the database.
Any images that exist on disk but are missing from the database are added back.
The path is defined by the string in your invokeai.yaml.
Script also attempts to recover any metadata image might have.
The script:
- Scans
<OUTPUTS_PATH>/images/ - Detects all PNG images not present in
imagestable of cuirrent DB - Inserts them with:
image_category = "general"image_origin = "internal"is_intermediate = 0
- Creates a board named
Recovered DD-MM-YY - Adds all recovered images to that board
Script: Convert_Board_to_Assets.py
This tool updates images belonging to a specific board and classifies them as assets.
It:
- Locates a board by name (Not case-sensitive)
- Reads all
image_nameentries fromboard_images - Updates the corresponding rows in the
imagestable:image_category = "user"image_origin = "external"
- Does not modify board membership or any other fields
Script: Convert_Assets_to_Board_v1.0.py
This tool updates images belonging to a specific board and classifies them as regular gallery images.
It:
- Locates a board by name (not case-sensitive)
- Reads all
image_nameentries fromboard_images - Updates the corresponding rows in the
imagestable:image_category = "general"image_origin = "internal"
- Does not modify board membership or any other fields
Useful for reorganizing imports or turning grouped images into asset references.
If you use the official InvokeAI Launcher, you don’t need to activate the virtual
environment manually. The Launcher provides a dedicated Dev Console with the
venv already activated. Just click >_ button in lower left corner
-
Open the InvokeAI Launcher.
-
Click
>_button in lower left corner. ThenStart Dev ConsoleThis opens a terminal window with the proper virtual environment activated. -
In the Dev Console, run:
python path/to/Restore_Images_DB_v2.1.py --db path/to/invokeai.db --outputs path/to/outputs
or
python path/to/Convert_Board_to_Assets.py --db path/to/invokeai.db --board-name "Board name to convert" --verboseor
python path/to/Convert_Assets_to_Board_v1.0.py --db path/to/invokeai.db --board-name "Board name to convert" --verbose
Launch it manually via PowerShell or CMD, you can use the same virtual environment as InvokeAI to run these tools. No separate Python installation needed.
-
Open a terminal.
-
Navigate to your InvokeAI installation directory:
cd path\to\InvokeAI
-
Activate the virtual environment:
.venv\Scripts\activate
-
Run the script:
python path\to\Restore_Images_DB_v2.1.py --db path\to\invokeai.db --outputs path/to/outputs
or
python path\to\Convert_Board_to_Assets.py --db path\to\invokeai.db --board-name "Board name to convert" --verbose
or
python path\to\Convert_Assets_to_Board_v1.0.py --db path\to\invokeai.db --board-name "Board name to convert" --verbose
-
Open a terminal.
-
Navigate to your InvokeAI directory:
cd /path/to/InvokeAI -
Activate the venv:
source .venv/bin/activate -
Run the script:
python /path/to/Restore_Images_DB_v2.1.py --db /path/to/invokeai.db --outputs /path/to/outputs
or
python path/to/Convert_Board_to_Assets.py --db path/to/invokeai.db --board-name "Board name to convert" --verboseor
python path/to/Convert_Assets_to_Board_v1.0.py --db path/to/invokeai.db --board-name "Board name to convert" --verboseThis uses the same Python environment as InvokeAI, so no extra dependencies are required.