Lstein release candidate 2.2.5 (#2137)

* installer tweaks in preparation for v2.2.5

- pin numpy to 1.23.* to avoid requirements conflict with numba
- update.sh and update.bat now accept a tag or branch string, not a URL
- update scripts download latest requirements-base before updating.

* update.bat.in debugged and working

* update pulls from "latest" now

* bump version number

* fix permissions on create_installer.sh

* give Linux user option of installing ROCm or CUDA

* rc2.2.5 (install.sh) relative path fixes (#2155)

* (installer) fix bug in resolution of relative paths in linux install script

point installer at 2.2.5-rc1

selecting ~/Data/myapps/ as location  would create a ./~/Data/myapps
instead of expanding the ~/ to the value of ${HOME}

also, squash the trailing slash in path, if it was entered by the user

* (installer) add option to automatically start the app after install

also: when exiting, print the command to get back into the app

* remove extraneous whitespace

* model_cache applies rootdir to config path

* bring installers up to date with 2.2.5-rc2

* bump rc version

* create_installer now adds version number

* rebuild frontend

* bump rc#

* add locales to frontend dist package

- bump to patchlevel 6

* bump patchlevel

* use invoke-ai version of GFPGAN

- This version is very slightly modified to allow weights files
  to be pre-downloaded by the configure script.

* fix formatting error during startup

* bump patch level

* workaround #2 for GFPGAN facexlib() weights downloading

* bump patch

* ready for merge and release

* remove extraneous comment

* set PYTORCH_ENABLE_MPS_FALLBACK directly in invoke.py

Co-authored-by: Eugene Brodsky <ebr@users.noreply.github.com>
This commit is contained in:
Lincoln Stein 2023-01-01 12:54:45 -05:00 committed by GitHub
parent caf7caddf7
commit 3929bd3e13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 149 additions and 64 deletions

View File

@ -14,7 +14,7 @@ huggingface-hub
imageio
imageio-ffmpeg
kornia
numpy
numpy==1.23.*
omegaconf
opencv-python
picklescan

View File

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>InvokeAI - A Stable Diffusion Toolkit</title>
<link rel="shortcut icon" type="icon" href="./assets/favicon.0d253ced.ico" />
<script type="module" crossorigin src="./assets/index.726ca2dc.js"></script>
<script type="module" crossorigin src="./assets/index.ec2d89c6.js"></script>
<link rel="stylesheet" href="./assets/index.0dadf5d0.css">
<script type="module">try{import.meta.url;import("_").catch(()=>1);}catch(e){}window.__vite_is_modern_browser=true;</script>
<script type="module">!function(){if(window.__vite_is_modern_browser)return;console.warn("vite: loading legacy build because dynamic import or import.meta.url is unsupported, syntax error above should be ignored");var e=document.getElementById("vite-legacy-polyfill"),n=document.createElement("script");n.src=e.src,n.onload=function(){System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))},document.body.appendChild(n)}();</script>
@ -18,6 +18,6 @@
<script nomodule>!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",(function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()}),!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script>
<script nomodule crossorigin id="vite-legacy-polyfill" src="./assets/polyfills-legacy-dde3a68a.js"></script>
<script nomodule crossorigin id="vite-legacy-entry" data-src="./assets/index-legacy-f39d2eb7.js">System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))</script>
<script nomodule crossorigin id="vite-legacy-entry" data-src="./assets/index-legacy-5c5a479d.js">System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))</script>
</body>
</html>

31
installer/create_installer.sh Normal file → Executable file
View File

@ -3,12 +3,23 @@
cd "$(dirname "$0")"
VERSION=$(grep ^VERSION ../setup.py | awk '{ print $3 }' | sed "s/'//g" )
VERSION="$VERSION-p5"
PATCH=""
VERSION="v${VERSION}${PATCH}"
echo "Be certain that you're in the 'installer' directory before continuing."
read -p "Press any key to continue, or CTRL-C to exit..."
echo Building installer zip fles for InvokeAI v$VERSION
git commit -a
if ! git tag $VERSION ; then
echo "Existing/invalid tag"
exit -1
fi
git push origin :refs/tags/latest
git tag -fa latest
echo Building installer zip fles for InvokeAI $VERSION
# get rid of any old ones
rm *.zip
@ -23,7 +34,7 @@ cp -pr ../configs InvokeAI-Installer/templates/rootdir/
mkdir InvokeAI-Installer/templates/rootdir/{outputs,embeddings,models}
cp install.sh.in InvokeAI-Installer/install.sh
perl -p -e "s/^INVOKEAI_VERSION=.*/INVOKEAI_VERSION=\"$VERSION\"/" install.sh.in > InvokeAI-Installer/install.sh
chmod a+rx InvokeAI-Installer/install.sh
zip -r InvokeAI-installer-$VERSION-linux.zip InvokeAI-Installer
@ -31,7 +42,7 @@ zip -r InvokeAI-installer-$VERSION-mac.zip InvokeAI-Installer
# now do the windows installer
rm InvokeAI-Installer/install.sh
cp 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/
# this gets rid of the "-e ." at the end of the windows requirements file
@ -40,8 +51,18 @@ egrep -v '^-e .' InvokeAI-Installer/environments-and-requirements/requirements-w
cp InvokeAI-Installer/requirements.txt InvokeAI-Installer/environments-and-requirements/requirements-win-colab-cuda.txt
zip -r InvokeAI-installer-$VERSION-windows.zip InvokeAI-Installer
mkdir tmp
cp templates/update.sh.in tmp/update.sh
cp templates/update.bat.in tmp/update.bat
chmod +x tmp/update.sh
chmod +x tmp/update.bat
cd tmp
zip InvokeAI-updater-$VERSION.zip update.sh update.bat
cd ..
mv tmp/InvokeAI-updater-$VERSION.zip .
# clean up
rm -rf InvokeAI-Installer
rm -rf InvokeAI-Installer tmp
exit 0

View File

@ -13,9 +13,10 @@ if "%1" == "use-cache" (
)
@rem Config
@rem this should be changed to the tagged release!
@rem set INVOKE_AI_SRC=https://github.com/invoke-ai/InvokeAI/archive/main.zip
set INVOKE_AI_SRC=https://github.com/invoke-ai/InvokeAI/archive/refs/tags/v2.2.4.zip
@rem The version in the next line is replaced by an up to date release number
@rem when create_installer.sh is run. Change the release number there.
set INVOKEAI_VERSION=latest
set INVOKE_AI_SRC=https://github.com/invoke-ai/InvokeAI/archive/refs/tags/%INVOKEAI_VERSION%.zip
set INSTRUCTIONS=https://invoke-ai.github.io/InvokeAI/installation/INSTALL_AUTOMATED/
set TROUBLESHOOTING=https://invoke-ai.github.io/InvokeAI/installation/INSTALL_AUTOMATED/#troubleshooting
set PYTHON_URL=https://www.python.org/downloads/windows/

View File

@ -4,13 +4,15 @@
scriptdir=$(dirname "$0")
cd "$scriptdir"
# This version number will be replaced by the one supplied to create_installers.sh.
# Do not change it here - change it in create_installers.sh.
INVOKEAI_VERSION="latest"
# make sure we are not already in a venv
# (don't need to check status)
deactivate >/dev/null 2>&1
# this should be changed to the tagged release!
# INVOKE_AI_SRC=https://github.com/invoke-ai/InvokeAI/archive/main.zip
INVOKE_AI_SRC=https://github.com/invoke-ai/InvokeAI/archive/refs/tags/v2.2.4.zip
INVOKE_AI_SRC=https://github.com/invoke-ai/InvokeAI/archive/refs/tags/${INVOKEAI_VERSION}.zip
INSTRUCTIONS=https://invoke-ai.github.io/InvokeAI/installation/INSTALL_AUTOMATED/
TROUBLESHOOTING=https://invoke-ai.github.io/InvokeAI/installation/INSTALL_AUTOMATED/#troubleshooting
MINIMUM_PYTHON_VERSION=3.9.0
@ -44,7 +46,7 @@ function readinput() {
local i="$1"
case "$i" in
"-i")
if read -i "default" 2>/dev/null <<< "test"; then
if read -i "default" 2>/dev/null <<< "test"; then
CLEAN_ARGS="$CLEAN_ARGS -i \"$2\""
fi
shift
@ -94,7 +96,7 @@ echo "Installing for $OS_NAME-$OS_ARCH"
PYTHON=""
for candidate in python3.10 python3.9 python3 python python3.11 ; do
if ppath=`which $candidate`; then
python_version=$($ppath -V | awk '{ print $2 }')
python_version=$($ppath -V | awk '{ print $2 }')
if [ $(version $python_version) -ge $(version "$MINIMUM_PYTHON_VERSION") ]; then
PYTHON=$ppath
echo Python $python_version found at $PYTHON
@ -117,6 +119,10 @@ do
echo
readinput -e -p "Select your preferred location for the 'invokeai' directory [$HOME]: " -i $HOME input
ROOTDIR=${input:=$HOME}/invokeai
# This is surprisingly hard to do in plain Bash; easier in ZSH. Just running python in subshell is easiest.
ROOTDIR=$(python -c "from pathlib import Path; print(Path('${ROOTDIR}').expanduser().resolve())")
read -e -p "InvokeAI will be installed into $ROOTDIR. OK? [y]: " input
RESPONSE=${input:='y'}
if [ "$RESPONSE" == 'y' ]; then
@ -126,7 +132,7 @@ do
RESPONSE=${input:='y'}
if [ "$RESPONSE" != 'y' ]; then
ROOTDIR=""
fi
fi
else
mkdir -p "$ROOTDIR"
if [ $? -ne 0 ]; then
@ -166,8 +172,15 @@ if [ "$OS_NAME" == "osx" ]; then
egrep -v '^-e .' environments-and-requirements/requirements-mac-mps-cpu.txt >requirements.txt
else
if (lsmod | grep amdgpu) &>/dev/null ; then
echo "Linux system with AMD GPU driver detected. Installing ROCm and CPU support"
egrep -v '^-e .' environments-and-requirements/requirements-lin-amd.txt >requirements.txt
readinput -e -p "Linux system with AMD GPU driver detected. Install ROCm AMD accelerated support? (Otherwise, CUDA support will be installed) [n]: " input
RESPONSE=${input:='n'}
if [ "$RESPONSE" != "n" ]; then
echo "Installing ROCm (AMD) support"
egrep -v '^-e .' environments-and-requirements/requirements-lin-amd.txt >requirements.txt
else
echo "Installing CUDA support"
egrep -v '^-e .' environments-and-requirements/requirements-lin-cuda.txt >requirements.txt
fi
else
echo "Linux system detected. Installing CUDA and CPU support."
egrep -v '^-e .' environments-and-requirements/requirements-lin-cuda.txt >requirements.txt
@ -209,4 +222,13 @@ chmod a+rx "$ROOTDIR"/invoke.sh
cp templates/update.sh.in "$ROOTDIR"/update.sh
chmod a+rx "$ROOTDIR"/update.sh
echo "You may now run InvokeAI by entering the directory $ROOTDIR and running invoke.sh"
echo "You may now run InvokeAI by entering the directory $ROOTDIR and running invoke.sh:"
echo
echo " ${ROOTDIR}/invoke.sh"
echo
read -e -p "Run InvokeAI now? [y]:" input
RESPONSE=${input:='y'}
if [ "$RESPONSE" == 'y' ]; then
exec ${ROOTDIR}/invoke.sh
fi

View File

@ -11,9 +11,9 @@ cd "$scriptdir"
export INVOKEAI_ROOT="$scriptdir"
# set required env var for torch on mac MPS
if [ "$(uname -s)" == "Darwin" ]; then
export PYTORCH_ENABLE_MPS_FALLBACK=1
fi
if [ "$(uname -s)" == "Darwin" ]; then
export PYTORCH_ENABLE_MPS_FALLBACK=1
fi
if [ "$0" != "bash" ]; then
echo "Do you want to generate images using the"

View File

@ -3,48 +3,66 @@ setlocal EnableExtensions EnableDelayedExpansion
PUSHD "%~dp0"
set INVOKE_AI_SRC=https://github.com/invoke-ai/InvokeAI/archive/main.zip
set INVOKE_AI_VERSION=latest
set arg=%1
if "%arg%" neq "" (
if "%arg:~0,4%" neq "http" (
echo Usage: update.bat ^<release URL^>.zip
if "%arg:~0,2%" equ "/?" (
echo Usage: update.bat ^<release name or branch^>
echo Updates InvokeAI to use the indicated version of the code base.
echo Find the zip file for the release you want, and pass it as the argument.
echo For example update.sh https://github.com/invoke-ai/InvokeAI/archive/refs/tags/v2.2.4.zip
echo.
echo If no argument provided then will install the most recent development version, equivalent to
echo update.bat https://github.com/invoke-ai/InvokeAI/archive/main.zip
exit /b
echo Find the version or branch for the release you want, and pass it as the argument.
echo For example '.\update.bat v2.2.5' for release 2.2.5.
echo '.\update.bat main' for the latest development version
echo.
echo If no argument provided then will install the most recent release, equivalent to
echo '.\update.bat latest'
exit /b
) else (
set INVOKE_AI_SRC=%arg%
set INVOKE_AI_VERSION=%arg%
)
)
call .venv\Scripts\activate.bat
set INVOKE_AI_SRC="https://github.com/invoke-ai/InvokeAI/archive/!INVOKE_AI_VERSION!.zip"
set INVOKE_AI_DEP=https://raw.githubusercontent.com/invoke-ai/InvokeAI/!INVOKE_AI_VERSION!/environments-and-requirements/requirements-base.txt
call curl -I "%INVOKE_AI_DEP%" -fs >.tmp.out
if %errorlevel% neq 0 (
echo '!INVOKE_AI_VERSION!' is not a known branch name or tag. Please check the version and try again.
echo "Press any key to continue"
pause
exit /b
)
del .tmp.out
echo This script will update InvokeAI and all its dependencies to !INVOKE_AI_SRC!.
echo If you do not want to do this, press control-C now!
pause
call curl -L "%INVOKE_AI_DEP%" > environments-and-requirements/requirements-base.txt
call .venv\Scripts\activate.bat
call .venv\Scripts\python -mpip install -r requirements.txt
if %errorlevel% neq 0 (
echo Installation of requirements failed. See https://invoke-ai.github.io/InvokeAI/installation/INSTALL_AUTOMATED/#troubleshooting for suggestions.
pause
exit /b
)
call .venv\Scripts\python -mpip install !INVOKE_AI_SRC!
if %errorlevel% neq 0 (
echo Installation of InvokeAI failed. See https://invoke-ai.github.io/InvokeAI/installation/INSTALL_AUTOMATED/#troubleshooting for suggestions.
pause
exit /b
)
call .venv\Scripts\python .venv\Scripts\configure_invokeai.py --root=.
@rem call .venv\Scripts\python .venv\Scripts\configure_invokeai.py --root=.
if %errorlevel% neq 0 (
echo Configuration InvokeAI failed. See https://invoke-ai.github.io/InvokeAI/installation/INSTALL_AUTOMATED/#troubleshooting for suggestions.
exit /b
)
@rem if %errorlevel% neq 0 (
@rem echo Configuration InvokeAI failed. See https://invoke-ai.github.io/InvokeAI/installation/INSTALL_AUTOMATED/#troubleshooting for suggestions.
@rem pause
@rem exit /b
@rem )
echo InvokeAI has been updated to '%INVOKE_AI_VERSION%'
echo "Press any key to continue"
pause

View File

@ -2,18 +2,22 @@
set -eu
if [ $# -ge 1 ] && [ "${1:0:4}" != "http" ]; then
echo "Usage: update.sh <release URL>.zip"
if [ $# -ge 1 ] && [ "${1:0:2}" == "-h" ]; then
echo "Usage: update.sh <release>"
echo "Updates InvokeAI to use the indicated version of the code base."
echo "Find the zip file for the release you want, and pass it as the argument."
echo "For example update.sh https://github.com/invoke-ai/InvokeAI/archive/refs/tags/v2.2.3.zip"
echo "Find the version or branch for the release you want, and pass it as the argument."
echo "For example: update.sh v2.2.5 for release 2.2.5."
echo " update.sh main for the current development version."
echo ""
echo "If no argument provided then will install the most recent development version, equivalent to"
echo "update.sh https://github.com/invoke-ai/InvokeAI/archive/main.zip"
echo "If no argument provided then will install the version tagged with 'latest', equivalent to"
echo "update.sh latest"
exit -1
fi
INVOKE_AI_VERSION=${1:-latest}
INVOKE_AI_SRC=${1:-https://github.com/invoke-ai/InvokeAI/archive/main.zip}
INVOKE_AI_SRC="https://github.com/invoke-ai/InvokeAI/archive/$INVOKE_AI_VERSION.zip"
INVOKE_AI_DEP=https://raw.githubusercontent.com/invoke-ai/InvokeAI/$INVOKE_AI_VERSION/environments-and-requirements/requirements-base.txt
# ensure we're in the correct folder in case user's CWD is somewhere else
scriptdir=$(dirname "$0")
@ -30,10 +34,17 @@ function _err_exit {
fi
}
echo This script will update InvokeAI and all its dependencies from $INVOKE_AI_SRC.
if ! curl -I "$INVOKE_AI_DEP" -fs >/dev/null; then
echo \'$INVOKE_AI_VERSION\' is not a known branch name or tag. Please check the version and try again.
exit
fi
echo This script will update InvokeAI and all its dependencies to version \'$INVOKE_AI_VERSION\'.
echo If you do not want to do this, press control-C now!
read -p "Press any key to continue, or CTRL-C to exit..."
curl -L "$INVOKE_AI_DEP" > environments-and-requirements/requirements-base.txt
. .venv/bin/activate
./.venv/bin/python -mpip install -r requirements.txt
@ -42,11 +53,7 @@ _err_exit $? "The pip program failed to install InvokeAI's requirements."
./.venv/bin/python -mpip install $INVOKE_AI_SRC
_err_exit $? "The pip program failed to install InvokeAI."
./.venv/bin/python .venv/bin/configure_invokeai.py --root .
_err_exit $? "The configure script failed to run successfully."
echo InvokeAI updated to \'$INVOKE_AI_VERSION\'
# ./.venv/bin/python .venv/bin/configure_invokeai.py --root .
# _err_exit $? "The configure script failed to run successfully."

View File

@ -135,7 +135,7 @@ def main():
try:
main_loop(gen, opt)
except KeyboardInterrupt:
print("\ngoodbye!")
print(f'\nGoodbye!\nYou can start InvokeAI again by running the "invoke.bat" (or "invoke.sh") script from {Globals.root}')
# TODO: main_loop() has gotten busy. Needs to be refactored.
def main_loop(gen, opt):
@ -410,7 +410,8 @@ def main_loop(gen, opt):
output_cntr = write_log(results, log_path ,('txt', 'md'), output_cntr)
print()
print('goodbye!')
print(f'\nGoodbye!\nYou can start InvokeAI again by running the "invoke.bat" (or "invoke.sh") script from {Globals.root}')
# TO DO: remove repetitive code and the awkward command.replace() trope
# Just do a simple parse of the command!

View File

@ -243,7 +243,7 @@ class ModelCache(object):
if 'state_dict' in sd:
sd = sd['state_dict']
print(f' | Forcing garbage collection prior to loading new model')
print(f' | Forcing garbage collection prior to loading new model')
gc.collect()
model = instantiate_from_config(omega_config.model)
model.load_state_dict(sd, strict=False)
@ -361,6 +361,8 @@ class ModelCache(object):
Write current configuration out to the indicated file.
'''
yaml_str = OmegaConf.to_yaml(self.config)
if not os.path.isabs(config_file_path):
config_file_path = os.path.normpath(os.path.join(Globals.root,opt.conf))
tmpfile = os.path.join(os.path.dirname(config_file_path),'new_config.tmp')
with open(tmpfile, 'w') as outfile:
outfile.write(self.preamble())

View File

@ -33,6 +33,8 @@ class GFPGAN():
with warnings.catch_warnings():
warnings.filterwarnings('ignore', category=DeprecationWarning)
warnings.filterwarnings('ignore', category=UserWarning)
cwd = os.getcwd()
os.chdir(os.path.join(Globals.root,'models'))
try:
from gfpgan import GFPGANer
self.gfpgan = GFPGANer(
@ -46,6 +48,7 @@ class GFPGAN():
import traceback
print('>> Error loading GFPGAN:', file=sys.stderr)
print(traceback.format_exc(), file=sys.stderr)
os.chdir(cwd)
if self.gfpgan is None:
print(

View File

@ -1,5 +1,10 @@
#!/usr/bin/env python
import sys
import os
if sys.platform == 'Darsin':
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
import ldm.invoke.CLI
ldm.invoke.CLI.main()

View File

@ -3,9 +3,13 @@ import re
from setuptools import setup, find_packages
def list_files(directory):
return [os.path.join(directory,x) for x in os.listdir(directory) if os.path.isfile(os.path.join(directory,x))]
listing = list()
for root, dirs, files in os.walk(directory,topdown=False):
pair = (root,[os.path.join(root,f) for f in files])
listing.append(pair)
return listing
VERSION = '2.2.4'
VERSION = '2.2.5'
DESCRIPTION = ('An implementation of Stable Diffusion which provides various new features'
' and options to aid the image generation process')
LONG_DESCRIPTION = ('This version of Stable Diffusion features a slick WebGUI, an'
@ -13,6 +17,10 @@ LONG_DESCRIPTION = ('This version of Stable Diffusion features a slick WebGUI, a
' functionality in a "dream bot" style interface, and multiple features'
' and other enhancements.')
HOMEPAGE = 'https://github.com/invoke-ai/InvokeAI'
FRONTEND_FILES = list_files('frontend/dist')
FRONTEND_FILES.append(('assets',['assets/caution.png']))
print(FRONTEND_FILES)
REQUIREMENTS=[
'accelerate',
'albumentations',
@ -79,8 +87,5 @@ setup(
scripts = ['scripts/invoke.py','scripts/configure_invokeai.py', 'scripts/sd-metadata.py',
'scripts/preload_models.py', 'scripts/images2prompt.py','scripts/merge_embeddings.py'
],
data_files=[('frontend/dist',list_files('frontend/dist')),
('frontend/dist/assets',list_files('frontend/dist/assets')),
('assets',['assets/caution.png']),
],
data_files=FRONTEND_FILES,
)