diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..7449d8a6 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,40 @@ +Hi there, these instructions are meant for the developers of this project. + +If you only want to use the Stable Diffusion UI, you've downloaded the wrong file. In that case, please download and follow the instructions at https://github.com/cmdr2/stable-diffusion-ui#installation + +Thanks + +# For developers: + +If you would like to contribute to this project, there is a discord for dicussion: +[![Discord Server](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.com/invite/u9yhsFmEkB) + +## Development environment for UI (frontend and server) changes +This is in-flux, but one way to get a development environment running for editing the UI of this project is: +(swap `.sh` or `.bat` in instructions depending on your environment, and be sure to adjust any paths to match where you're working) + +1) `git clone` the repository, e.g. to `/projects/stable-diffusion-ui-repo` +2) Download the pre-built end user archive from the link on github, and extract it, e.g. to `/projects/stable-diffusion-ui-archive` +3) `cd /projects/stable-diffusion-ui-archive` and run the script to set up and start the project, e.g. `start.sh` +4) Check you can view and generate images on `localhost:9000` +5) Close the server, and edit `/projects/stable-diffusion-ui-archive/scripts/on_env_start.sh` +6) Comment out the line near the bottom that copies the `files/ui` folder, e.g. `cp -Rf sd-ui-files/ui ui` for `.sh` or `@xcopy sd-ui-files\ui ui /s /i /Y` for `.bat` +7) Delete the current `ui` folder at `/projects/stable-diffusion-ui-archive/ui` +8) Now make a symlink between the repository clone (where you will be making changes) and this archive (where you will be running stable diffusion): +`ln -s /projects/stable-diffusion-ui-repo/ui /projects/stable-diffusion-ui-archive/ui` +or for Windows +`mklink /D \projects\stable-diffusion-ui-archive\ui \projects\stable-diffusion-ui-repo\ui` (link name first, source repo dir second) +9) Run the archive again `start.sh` and ensure you can still use the UI. +10) Congrats, now any changes you make in your repo `ui` folder are linked to this running archive of the app and can be previewed in the browser. + +Check the `ui/frontend/build/README.md` for instructions on running and building the React code. + +## Development environment for Installer changes +Build the Windows installer using Windows, and the Linux installer using Linux. Don't mix the two, and don't use WSL. An Ubuntu VM is fine for building the Linux installer on a Windows host. + +1. Install Miniconda 3 or Anaconda. +2. Install `conda install -c conda-forge -y conda-pack` +3. Open the Anaconda Prompt. Do not use WSL if you're building for Windows. +4. Run `build.bat` or `./build.sh` depending on whether you're in Windows or Linux. +5. Compress the `stable-diffusion-ui` folder created inside the `dist` folder. Make a `zip` for Windows, and `tar.xz` for Linux (smaller files, and Linux users already have tar). +6. Make a new GitHub release and upload the Windows and Linux installer builds. diff --git a/scripts/on_env_start.sh b/scripts/on_env_start.sh index d314427b..79ab23a7 100755 --- a/scripts/on_env_start.sh +++ b/scripts/on_env_start.sh @@ -1,3 +1,5 @@ +#!/bin/bash + printf "\n\nStable Diffusion UI\n\n" if [ -f "scripts/config.sh" ]; then diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index cd8a8e23..9f993ec2 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -2,6 +2,9 @@ @copy sd-ui-files\scripts\on_env_start.bat scripts\ /Y +@REM Caution, this file will make your eyes and brain bleed. It's such an unholy mess. +@REM Note to self: Please rewrite this in Python. For the sake of your own sanity. + @call 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); print('Hotfixed broken JSON file from OpenAI');" @>nul grep -c "sd_git_cloned" scripts\install_status.txt @@ -60,6 +63,48 @@ @echo conda_sd_env_created >> ..\scripts\install_status.txt ) +@>nul grep -c "conda_sd_gfpgan_deps_installed" ..\scripts\install_status.txt +@if "%ERRORLEVEL%" EQU "0" ( + @echo "Packages necessary for GFPGAN (Face Correction) were already installed" +) else ( + @echo. & echo "Downloading packages necessary for GFPGAN (Face Correction).." & echo. + + @call pip install -e git+https://github.com/TencentARC/GFPGAN#egg=GFPGAN || ( + @echo. & echo "Error installing the packages necessary for GFPGAN (Face Correction). Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. + pause + exit /b + ) + + for /f "tokens=*" %%a in ('python -c "from gfpgan import GFPGANer; print(42)"') do if "%%a" NEQ "42" ( + @echo. & echo "Dependency test failed! Error installing the packages necessary for GFPGAN (Face Correction). Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. + pause + exit /b + ) + + @echo conda_sd_gfpgan_deps_installed >> ..\scripts\install_status.txt +) + +@>nul grep -c "conda_sd_esrgan_deps_installed" ..\scripts\install_status.txt +@if "%ERRORLEVEL%" EQU "0" ( + @echo "Packages necessary for ESRGAN (Resolution Upscaling) were already installed" +) else ( + @echo. & echo "Downloading packages necessary for ESRGAN (Resolution Upscaling).." & echo. + + @call pip install -e git+https://github.com/xinntao/Real-ESRGAN#egg=realesrgan || ( + @echo. & echo "Error installing the packages necessary for ESRGAN (Resolution Upscaling). Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. + pause + exit /b + ) + + for /f "tokens=*" %%a in ('python -c "from basicsr.archs.rrdbnet_arch import RRDBNet; from realesrgan import RealESRGANer; print(42)"') do if "%%a" NEQ "42" ( + @echo. & echo "Dependency test failed! Error installing the packages necessary for ESRGAN (Resolution Upscaling). Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. + pause + exit /b + ) + + @echo conda_sd_esrgan_deps_installed >> ..\scripts\install_status.txt +) + @>nul grep -c "conda_sd_ui_deps_installed" ..\scripts\install_status.txt @if "%ERRORLEVEL%" EQU "0" ( echo "Packages necessary for Stable Diffusion UI were already installed" @@ -86,6 +131,8 @@ call WHERE uvicorn > .tmp @echo conda_sd_ui_deps_installed >> ..\scripts\install_status.txt ) + + @if exist "sd-v1-4.ckpt" ( for %%I in ("sd-v1-4.ckpt") do if "%%~zI" EQU "4265380512" ( echo "Data files (weights) necessary for Stable Diffusion were already downloaded" @@ -114,6 +161,98 @@ call WHERE uvicorn > .tmp ) ) + + +@if exist "GFPGANv1.3.pth" ( + for %%I in ("GFPGANv1.3.pth") do if "%%~zI" EQU "348632874" ( + echo "Data files (weights) necessary for GFPGAN (Face Correction) were already downloaded" + ) else ( + echo. & echo "The GFPGAN model file present at %cd%\GFPGANv1.3.pth is invalid. It is only %%~zI bytes in size. Re-downloading.." & echo. + del "GFPGANv1.3.pth" + ) +) + +@if not exist "GFPGANv1.3.pth" ( + @echo. & echo "Downloading data files (weights) for GFPGAN (Face Correction).." & echo. + + @call curl -L -k https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth > GFPGANv1.3.pth + + @if exist "GFPGANv1.3.pth" ( + for %%I in ("GFPGANv1.3.pth") do if "%%~zI" NEQ "348632874" ( + echo. & echo "Error: The downloaded GFPGAN model file was invalid! Bytes downloaded: %%~zI" & echo. + echo. & echo "Error downloading the data files (weights) for GFPGAN (Face Correction). Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. + pause + exit /b + ) + ) else ( + @echo. & echo "Error downloading the data files (weights) for GFPGAN (Face Correction). Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. + pause + exit /b + ) +) + + + +@if exist "RealESRGAN_x4plus.pth" ( + for %%I in ("RealESRGAN_x4plus.pth") do if "%%~zI" EQU "67040989" ( + echo "Data files (weights) necessary for ESRGAN (Resolution Upscaling) x4plus were already downloaded" + ) else ( + echo. & echo "The GFPGAN model file present at %cd%\RealESRGAN_x4plus.pth is invalid. It is only %%~zI bytes in size. Re-downloading.." & echo. + del "RealESRGAN_x4plus.pth" + ) +) + +@if not exist "RealESRGAN_x4plus.pth" ( + @echo. & echo "Downloading data files (weights) for ESRGAN (Resolution Upscaling) x4plus.." & echo. + + @call curl -L -k https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth > RealESRGAN_x4plus.pth + + @if exist "RealESRGAN_x4plus.pth" ( + for %%I in ("RealESRGAN_x4plus.pth") do if "%%~zI" NEQ "67040989" ( + echo. & echo "Error: The downloaded ESRGAN x4plus model file was invalid! Bytes downloaded: %%~zI" & echo. + echo. & echo "Error downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. + pause + exit /b + ) + ) else ( + @echo. & echo "Error downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. + pause + exit /b + ) +) + + + +@if exist "RealESRGAN_x4plus_anime_6B.pth" ( + for %%I in ("RealESRGAN_x4plus_anime_6B.pth") do if "%%~zI" EQU "17938799" ( + echo "Data files (weights) necessary for ESRGAN (Resolution Upscaling) x4plus_anime were already downloaded" + ) else ( + echo. & echo "The GFPGAN model file present at %cd%\RealESRGAN_x4plus_anime_6B.pth is invalid. It is only %%~zI bytes in size. Re-downloading.." & echo. + del "RealESRGAN_x4plus_anime_6B.pth" + ) +) + +@if not exist "RealESRGAN_x4plus_anime_6B.pth" ( + @echo. & echo "Downloading data files (weights) for ESRGAN (Resolution Upscaling) x4plus_anime.." & echo. + + @call curl -L -k https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth > RealESRGAN_x4plus_anime_6B.pth + + @if exist "RealESRGAN_x4plus_anime_6B.pth" ( + for %%I in ("RealESRGAN_x4plus_anime_6B.pth") do if "%%~zI" NEQ "17938799" ( + echo. & echo "Error: The downloaded ESRGAN x4plus_anime model file was invalid! Bytes downloaded: %%~zI" & echo. + echo. & echo "Error downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus_anime. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. + pause + exit /b + ) + ) else ( + @echo. & echo "Error downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus_anime. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. + pause + exit /b + ) +) + + + @>nul grep -c "sd_install_complete" ..\scripts\install_status.txt @if "%ERRORLEVEL%" NEQ "0" ( @echo sd_weights_downloaded >> ..\scripts\install_status.txt diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index 5b32b096..b50a5546 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -1,9 +1,14 @@ +#!/bin/bash + cp sd-ui-files/scripts/on_env_start.sh scripts/ source installer/etc/profile.d/conda.sh 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); 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. + if [ -e "scripts/install_status.txt" ] && [ `grep -c sd_git_cloned scripts/install_status.txt` -gt "0" ]; then echo "Stable Diffusion's git repository was already installed. Updating.." @@ -60,6 +65,52 @@ else echo conda_sd_env_created >> ../scripts/install_status.txt fi +if [ `grep -c conda_sd_gfpgan_deps_installed ../scripts/install_status.txt` -gt "0" ]; then + echo "Packages necessary for GFPGAN (Face Correction) were already installed" +else + printf "\n\nDownloading packages necessary for GFPGAN (Face Correction)..\n" + + if pip install -e git+https://github.com/TencentARC/GFPGAN#egg=GFPGAN ; then + echo "Installed. Testing.." + else + printf "\n\nError installing the packages necessary for GFPGAN (Face Correction). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" + read -p "Press any key to continue" + exit + fi + + out_test=`python -c "from gfpgan import GFPGANer; print(42)"` + if [ "$out_test" != "42" ]; then + printf "\n\nDependency test failed! Error installing the packages necessary for GFPGAN (Face Correction). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" + read -p "Press any key to continue" + exit + fi + + echo conda_sd_gfpgan_deps_installed >> ../scripts/install_status.txt +fi + +if [ `grep -c conda_sd_esrgan_deps_installed ../scripts/install_status.txt` -gt "0" ]; then + echo "Packages necessary for ESRGAN (Resolution Upscaling) were already installed" +else + printf "\n\nDownloading packages necessary for ESRGAN (Resolution Upscaling)..\n" + + if pip install -e git+https://github.com/xinntao/Real-ESRGAN#egg=realesrgan ; then + echo "Installed. Testing.." + else + printf "\n\nError installing the packages necessary for ESRGAN (Resolution Upscaling). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" + read -p "Press any key to continue" + exit + fi + + out_test=`python -c "from basicsr.archs.rrdbnet_arch import RRDBNet; from realesrgan import RealESRGANer; print(42)"` + if [ "$out_test" != "42" ]; then + printf "\n\nDependency test failed! Error installing the packages necessary for ESRGAN (Resolution Upscaling). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" + read -p "Press any key to continue" + exit + fi + + echo conda_sd_esrgan_deps_installed >> ../scripts/install_status.txt +fi + if [ `grep -c conda_sd_ui_deps_installed ../scripts/install_status.txt` -gt "0" ]; then echo "Packages necessary for Stable Diffusion UI were already installed" else @@ -82,6 +133,8 @@ else echo conda_sd_ui_deps_installed >> ../scripts/install_status.txt fi + + if [ -f "sd-v1-4.ckpt" ]; then model_size=`ls -l sd-v1-4.ckpt | awk '{print $5}'` @@ -111,7 +164,106 @@ if [ ! -f "sd-v1-4.ckpt" ]; then read -p "Press any key to continue" exit fi +fi + +if [ -f "GFPGANv1.3.pth" ]; then + model_size=`ls -l GFPGANv1.3.pth | awk '{print $5}'` + + if [ "$model_size" -eq "348632874" ]; then + echo "Data files (weights) necessary for GFPGAN (Face Correction) were already downloaded" + else + printf "\n\nThe model file present at $PWD/GFPGANv1.3.pth is invalid. It is only $model_size bytes in size. Re-downloading.." + rm GFPGANv1.3.pth + fi +fi + +if [ ! -f "GFPGANv1.3.pth" ]; then + echo "Downloading data files (weights) for GFPGAN (Face Correction).." + + curl -L -k https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth > GFPGANv1.3.pth + + if [ -f "GFPGANv1.3.pth" ]; then + model_size=`ls -l GFPGANv1.3.pth | awk '{print $5}'` + if [ ! "$model_size" -eq "348632874" ]; then + printf "\n\nError: The downloaded GFPGAN model file was invalid! Bytes downloaded: $model_size\n\n" + printf "\n\nError downloading the data files (weights) for GFPGAN (Face Correction). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" + read -p "Press any key to continue" + exit + fi + else + printf "\n\nError downloading the data files (weights) for GFPGAN (Face Correction). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" + read -p "Press any key to continue" + exit + fi +fi + + +if [ -f "RealESRGAN_x4plus.pth" ]; then + model_size=`ls -l RealESRGAN_x4plus.pth | awk '{print $5}'` + + if [ "$model_size" -eq "67040989" ]; then + echo "Data files (weights) necessary for ESRGAN (Resolution Upscaling) x4plus were already downloaded" + else + printf "\n\nThe model file present at $PWD/RealESRGAN_x4plus.pth is invalid. It is only $model_size bytes in size. Re-downloading.." + rm RealESRGAN_x4plus.pth + fi +fi + +if [ ! -f "RealESRGAN_x4plus.pth" ]; then + echo "Downloading data files (weights) for ESRGAN (Resolution Upscaling) x4plus.." + + curl -L -k https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth > RealESRGAN_x4plus.pth + + if [ -f "RealESRGAN_x4plus.pth" ]; then + model_size=`ls -l RealESRGAN_x4plus.pth | awk '{print $5}'` + if [ ! "$model_size" -eq "67040989" ]; then + printf "\n\nError: The downloaded ESRGAN x4plus model file was invalid! Bytes downloaded: $model_size\n\n" + printf "\n\nError downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" + read -p "Press any key to continue" + exit + fi + else + printf "\n\nError downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" + read -p "Press any key to continue" + exit + fi +fi + + +if [ -f "RealESRGAN_x4plus_anime_6B.pth" ]; then + model_size=`ls -l RealESRGAN_x4plus_anime_6B.pth | awk '{print $5}'` + + if [ "$model_size" -eq "17938799" ]; then + echo "Data files (weights) necessary for ESRGAN (Resolution Upscaling) x4plus_anime were already downloaded" + else + printf "\n\nThe model file present at $PWD/RealESRGAN_x4plus_anime_6B.pth is invalid. It is only $model_size bytes in size. Re-downloading.." + rm RealESRGAN_x4plus_anime_6B.pth + fi +fi + +if [ ! -f "RealESRGAN_x4plus_anime_6B.pth" ]; then + echo "Downloading data files (weights) for ESRGAN (Resolution Upscaling) x4plus_anime.." + + curl -L -k https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth > RealESRGAN_x4plus_anime_6B.pth + + if [ -f "RealESRGAN_x4plus_anime_6B.pth" ]; then + model_size=`ls -l RealESRGAN_x4plus_anime_6B.pth | awk '{print $5}'` + if [ ! "$model_size" -eq "17938799" ]; then + printf "\n\nError: The downloaded ESRGAN x4plus_anime model file was invalid! Bytes downloaded: $model_size\n\n" + printf "\n\nError downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus_anime. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" + read -p "Press any key to continue" + exit + fi + else + printf "\n\nError downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus_anime. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" + read -p "Press any key to continue" + exit + fi +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 diff --git a/scripts/post_activate.sh b/scripts/post_activate.sh index 4f0921d2..ec715af0 100755 --- a/scripts/post_activate.sh +++ b/scripts/post_activate.sh @@ -1,3 +1,5 @@ +#!/bin/bash + conda-unpack source $CONDA_PREFIX/etc/profile.d/conda.sh diff --git a/scripts/start.sh b/scripts/start.sh index 407796a6..d6c75ad8 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -1,3 +1,5 @@ +#!/bin/bash + source installer/bin/activate conda-unpack diff --git a/ui/index.html b/ui/index.html index 27047e12..7ed226ec 100644 --- a/ui/index.html +++ b/ui/index.html @@ -269,7 +269,7 @@