mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2024-11-22 08:13:22 +01:00
86 lines
3.0 KiB
Bash
Executable File
86 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
cp sd-ui-files/scripts/functions.sh scripts/
|
|
cp sd-ui-files/scripts/on_env_start.sh scripts/
|
|
cp sd-ui-files/scripts/bootstrap.sh scripts/
|
|
cp sd-ui-files/scripts/check_modules.py scripts/
|
|
|
|
source ./scripts/functions.sh
|
|
|
|
# activate the installer env
|
|
CONDA_BASEPATH=$(conda info --base)
|
|
source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # avoids the 'shell not initialized' error
|
|
|
|
conda activate || fail "Failed to activate conda"
|
|
|
|
# remove the old version of the dev console script, if it's still present
|
|
if [ -e "open_dev_console.sh" ]; then
|
|
rm "open_dev_console.sh"
|
|
fi
|
|
|
|
# python -c "import os; import shutil; frm = 'sd-ui-files/ui/hotfix/9c24e6cd9f499d02c4f21a033736dabd365962dc80fe3aeb57a8f85ea45a20a3.26fead7ea4f0f843f6eb4055dfd25693f1a71f3c6871b184042d4b126244e142'; dst = os.path.join(os.path.expanduser('~'), '.cache', 'huggingface', 'transformers', '9c24e6cd9f499d02c4f21a033736dabd365962dc80fe3aeb57a8f85ea45a20a3.26fead7ea4f0f843f6eb4055dfd25693f1a71f3c6871b184042d4b126244e142'); shutil.copyfile(frm, dst) if os.path.exists(dst) else print(''); print('Hotfixed broken JSON file from OpenAI');"
|
|
|
|
# Caution, this file will make your eyes and brain bleed. It's such an unholy mess.
|
|
# Note to self: Please rewrite this in Python. For the sake of your own sanity.
|
|
|
|
# set the correct installer path (current vs legacy)
|
|
if [ -e "installer_files/env" ]; then
|
|
export INSTALL_ENV_DIR="$(pwd)/installer_files/env"
|
|
fi
|
|
if [ -e "stable-diffusion/env" ]; then
|
|
export INSTALL_ENV_DIR="$(pwd)/stable-diffusion/env"
|
|
fi
|
|
|
|
# create the stable-diffusion folder, to work with legacy installations
|
|
if [ ! -e "stable-diffusion" ]; then mkdir stable-diffusion; fi
|
|
cd stable-diffusion
|
|
|
|
# activate the old stable-diffusion env, if it exists
|
|
if [ -e "env" ]; then
|
|
conda activate ./env || fail "conda activate failed"
|
|
fi
|
|
|
|
# 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
|
|
|
|
# Download the required packages
|
|
if ! python ../scripts/check_modules.py; then
|
|
read -p "Press any key to continue"
|
|
exit 1
|
|
fi
|
|
|
|
if ! command -v uvicorn &> /dev/null; then
|
|
fail "UI packages not found!"
|
|
fi
|
|
|
|
# Download the required models
|
|
if ! python ../scripts/check_models.py; then
|
|
read -p "Press any key to continue"
|
|
exit 1
|
|
fi
|
|
|
|
if [ `grep -c sd_install_complete ../scripts/install_status.txt` -gt "0" ]; then
|
|
echo sd_weights_downloaded >> ../scripts/install_status.txt
|
|
echo sd_install_complete >> ../scripts/install_status.txt
|
|
fi
|
|
|
|
printf "\n\nEasy Diffusion installation complete, starting the server!\n\n"
|
|
|
|
SD_PATH=`pwd`
|
|
|
|
export PYTORCH_ENABLE_MPS_FALLBACK=1
|
|
export PYTHONPATH="$INSTALL_ENV_DIR/lib/python3.8/site-packages"
|
|
echo "PYTHONPATH=$PYTHONPATH"
|
|
|
|
which python
|
|
python --version
|
|
|
|
cd ..
|
|
export SD_UI_PATH=`pwd`/ui
|
|
cd stable-diffusion
|
|
|
|
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
|
|
|
|
read -p "Press any key to continue"
|