2022-09-09 17:32:33 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-02-14 09:00:02 +01:00
|
|
|
cp sd-ui-files/scripts/functions.sh scripts/
|
2022-09-09 10:36:37 +02:00
|
|
|
cp sd-ui-files/scripts/on_env_start.sh scripts/
|
2022-10-22 19:54:13 +02:00
|
|
|
cp sd-ui-files/scripts/bootstrap.sh scripts/
|
2022-12-24 09:26:05 +01:00
|
|
|
cp sd-ui-files/scripts/check_modules.py scripts/
|
2023-04-19 12:43:29 +02:00
|
|
|
cp sd-ui-files/scripts/check_models.py scripts/
|
2022-09-07 16:31:39 +02:00
|
|
|
|
2023-02-14 09:00:02 +01:00
|
|
|
source ./scripts/functions.sh
|
|
|
|
|
2022-10-26 08:45:58 +02:00
|
|
|
# activate the installer env
|
|
|
|
CONDA_BASEPATH=$(conda info --base)
|
|
|
|
source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # avoids the 'shell not initialized' error
|
|
|
|
|
2022-11-05 18:59:59 +01:00
|
|
|
conda activate || fail "Failed to activate conda"
|
2022-10-26 08:45:58 +02:00
|
|
|
|
2022-10-22 19:54:13 +02:00
|
|
|
# remove the old version of the dev console script, if it's still present
|
2022-10-07 16:22:31 +02:00
|
|
|
if [ -e "open_dev_console.sh" ]; then
|
|
|
|
rm "open_dev_console.sh"
|
|
|
|
fi
|
2022-10-07 15:20:07 +02:00
|
|
|
|
2022-12-24 09:07:50 +01:00
|
|
|
# set the correct installer path (current vs legacy)
|
|
|
|
if [ -e "installer_files/env" ]; then
|
|
|
|
export INSTALL_ENV_DIR="$(pwd)/installer_files/env"
|
2022-11-25 07:47:44 +01:00
|
|
|
fi
|
2022-12-24 09:07:50 +01:00
|
|
|
if [ -e "stable-diffusion/env" ]; then
|
|
|
|
export INSTALL_ENV_DIR="$(pwd)/stable-diffusion/env"
|
2022-09-02 18:24:32 +02:00
|
|
|
fi
|
|
|
|
|
2022-12-24 09:07:50 +01:00
|
|
|
# create the stable-diffusion folder, to work with legacy installations
|
|
|
|
if [ ! -e "stable-diffusion" ]; then mkdir stable-diffusion; fi
|
2022-09-02 18:24:32 +02:00
|
|
|
cd stable-diffusion
|
|
|
|
|
2022-12-24 09:07:50 +01:00
|
|
|
# activate the old stable-diffusion env, if it exists
|
|
|
|
if [ -e "env" ]; then
|
2022-11-05 18:59:59 +01:00
|
|
|
conda activate ./env || fail "conda activate failed"
|
2022-12-24 09:07:50 +01:00
|
|
|
fi
|
|
|
|
|
2022-12-24 09:31:33 +01:00
|
|
|
# disable the legacy src and ldm folder (otherwise this prevents installing gfpgan and realesrgan)
|
|
|
|
if [ -e "src" ]; then mv src src-old; fi
|
|
|
|
if [ -e "ldm" ]; then mv ldm ldm-old; fi
|
|
|
|
|
2023-04-19 12:41:16 +02:00
|
|
|
# Download the required packages
|
2023-04-18 12:12:33 +02:00
|
|
|
if ! python ../scripts/check_modules.py; then
|
|
|
|
read -p "Press any key to continue"
|
|
|
|
exit 1
|
2022-09-06 15:31:21 +02:00
|
|
|
fi
|
2022-09-02 18:24:32 +02:00
|
|
|
|
2023-04-18 12:12:33 +02:00
|
|
|
if ! command -v uvicorn &> /dev/null; then
|
|
|
|
fail "UI packages not found!"
|
2022-11-16 22:34:02 +01:00
|
|
|
fi
|
|
|
|
|
2023-04-19 12:41:16 +02:00
|
|
|
# Download the required models
|
|
|
|
if ! python ../scripts/check_models.py; then
|
|
|
|
read -p "Press any key to continue"
|
|
|
|
exit 1
|
2022-09-09 17:35:24 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ `grep -c sd_install_complete ../scripts/install_status.txt` -gt "0" ]; then
|
2022-09-02 18:24:32 +02:00
|
|
|
echo sd_weights_downloaded >> ../scripts/install_status.txt
|
|
|
|
echo sd_install_complete >> ../scripts/install_status.txt
|
|
|
|
fi
|
|
|
|
|
2023-02-14 09:00:02 +01:00
|
|
|
printf "\n\nEasy Diffusion installation complete, starting the server!\n\n"
|
2022-09-02 18:24:32 +02:00
|
|
|
|
2022-09-13 07:06:50 +02:00
|
|
|
SD_PATH=`pwd`
|
2022-12-24 09:07:50 +01:00
|
|
|
|
2023-03-07 22:57:37 +01:00
|
|
|
export PYTORCH_ENABLE_MPS_FALLBACK=1
|
2022-12-24 09:07:50 +01:00
|
|
|
export PYTHONPATH="$INSTALL_ENV_DIR/lib/python3.8/site-packages"
|
2022-09-13 07:06:50 +02:00
|
|
|
echo "PYTHONPATH=$PYTHONPATH"
|
|
|
|
|
2022-10-26 12:30:21 +02:00
|
|
|
which python
|
|
|
|
python --version
|
|
|
|
|
2022-09-05 12:00:04 +02:00
|
|
|
cd ..
|
|
|
|
export SD_UI_PATH=`pwd`/ui
|
|
|
|
cd stable-diffusion
|
2022-09-02 18:24:32 +02:00
|
|
|
|
2022-12-24 10:59:49 +01:00
|
|
|
uvicorn main:server_api --app-dir "$SD_UI_PATH" --port ${SD_UI_BIND_PORT:-9000} --host ${SD_UI_BIND_IP:-0.0.0.0} --log-level error
|
2022-09-02 18:24:32 +02:00
|
|
|
|
2022-09-12 13:09:23 +02:00
|
|
|
read -p "Press any key to continue"
|