diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..3c662bf0 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +ko_fi: cmdr2_stablediffusion_ui diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..f1f80c00 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,41 @@ +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) Comment out the line at the top of `/projects/stable-diffusion-ui-archive/scripts/on_sd_start.sh` that copies `on_env_start`. For e.g. `@copy sd-ui-files\scripts\on_env_start.bat scripts\ /Y` +8) Delete the current `ui` folder at `/projects/stable-diffusion-ui-archive/ui` +9) 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/How to install and run.txt b/How to install and run.txt index 2f35d75b..e48d217c 100644 --- a/How to install and run.txt +++ b/How to install and run.txt @@ -1,6 +1,6 @@ Congrats on downloading Stable Diffusion UI, version 2! -If you haven't downloaded Stable Diffusion UI yet, please download from https://github.com/cmdr2/stable-diffusion-ui +If you haven't downloaded Stable Diffusion UI yet, please download from https://github.com/cmdr2/stable-diffusion-ui#installation After downloading, to install please follow these instructions: diff --git a/README BEFORE YOU RUN THIS.txt b/README BEFORE YOU RUN THIS.txt new file mode 100644 index 00000000..e9f81544 --- /dev/null +++ b/README BEFORE YOU RUN THIS.txt @@ -0,0 +1,8 @@ +Hi there, + +What you have downloaded is meant for the developers of this project, not for users. + +If you only want to use the Stable Diffusion UI, you've downloaded the wrong file. +Please download and follow the instructions at https://github.com/cmdr2/stable-diffusion-ui#installation + +Thanks \ No newline at end of file diff --git a/README.md b/README.md index 108e10a7..dcee9b2a 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,18 @@ -# Stable Diffusion UI - v2 (beta) -### A simple way to install and use [Stable Diffusion](https://github.com/CompVis/stable-diffusion) on your own computer (Win 10/11, Linux). No dependencies or technical knowledge required. +# Stable Diffusion UI v2 +### A simple 1-click way to install and use [Stable Diffusion](https://github.com/CompVis/stable-diffusion) on your own computer. No dependencies or technical knowledge required. -[![Discord Server](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.com/invite/u9yhsFmEkB) (for support, and development discussion) +

+ + +

+ +[![Discord Server](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.com/invite/u9yhsFmEkB) (for support, and development discussion) | [Troubleshooting guide for common problems](Troubleshooting.md) + +️‍🔥🎉 **New!** Face Correction (GFPGAN) and Upscaling (RealESRGAN) have been added! # Features in the new v2 Version: - **No Dependencies or Technical Knowledge Required**: 1-click install for Windows 10/11 and Linux. *No dependencies*, no need for WSL or Docker or Conda or technical setup. Just download and run! +- **Face Correction (GFPGAN) and Upscaling (RealESRGAN)** - **Image Modifiers**: A library of *modifier tags* like *"Realistic"*, *"Pencil Sketch"*, *"ArtStation"* etc. Experiment with various styles quickly. - **New UI**: with cleaner design - Supports "*Text to Image*" and "*Image to Image*" @@ -21,18 +29,20 @@ You do not need anything else. You do not need WSL, Docker or Conda. The installer will take care of it. # Installation -1. Download [for Windows](https://drive.google.com/file/d/1MY5gzsQHV_KREbYs3gw33QL4gGIlQRqj/view?usp=sharing) or [for Linux](https://drive.google.com/file/d/1Gwz1LVQUCart8HhCjrmXkS6TWKbTsLsR/view?usp=sharing) (this will be hosted on GitHub in the future). +1. **Download** [for Windows](https://github.com/cmdr2/stable-diffusion-ui/releases/download/v2.05/stable-diffusion-ui-win64.zip) or [for Linux](https://github.com/cmdr2/stable-diffusion-ui/releases/download/v2.05/stable-diffusion-ui-linux.tar.xz). -2. Extract: +2. **Extract**: - For Windows: After unzipping the file, please move the `stable-diffusion-ui` folder to your `C:` (or any drive like D: at the top root level). For e.g. `C:\stable-diffusion-ui`. This will avoid a common problem with Windows (of file path length limits). - For Linux: After extracting the .tar.xz file, please open a terminal, and go to the `stable-diffusion-ui` directory. -3. Run: +3. **Run**: - For Windows: `Start Stable Diffusion UI.cmd` by double-clicking it. - For Linux: In the terminal, run `./start.sh` (or `bash start.sh`) This will automatically install Stable Diffusion, set it up, and start the interface. No additional steps are needed. +**To Uninstall:** Just delete the `stable-diffusion-ui` folder, to uninstall all the downloaded packages. + # Usage Open http://localhost:9000 in your browser (after running step 3 previously). @@ -47,12 +57,14 @@ Open http://localhost:9000 in your browser (after running step 3 previously). 2. An optional text prompt can help you further describe the kind of image you want to generate. 3. Press `Make Image`. See the image generated using your prompt. +You can use Face Correction or Upscaling to improve the image further. + **Pro tip:** You can also click `Use as Input` on a generated image, to use it as the input image for your next generation. This can be useful for sequentially refining the generated image with a single click. **Another tip:** Images with the same aspect ratio of your generated image work best. E.g. 1:1 if you're generating images sized 512x512. -## Problems? -Please ask on the new [discord server](https://discord.com/invite/u9yhsFmEkB), or [file an issue](https://github.com/cmdr2/stable-diffusion-ui/issues) if this did not work for you (after trying the common [troubleshooting](#troubleshooting) steps)! +## Problems? Troubleshooting +Please try the common [troubleshooting](Troubleshooting.md) steps. If that doesn't fix it, please ask on the [discord server](https://discord.com/invite/u9yhsFmEkB), or [file an issue](https://github.com/cmdr2/stable-diffusion-ui/issues). # Advanced Settings You can also set the configuration like `seed`, `width`, `height`, `num_outputs`, `num_inference_steps` and `guidance_scale` using the 'show' button next to 'Advanced settings'. @@ -61,9 +73,6 @@ Use the same `seed` number to get the same image for a certain prompt. This is u ![Screenshot of advanced settings](media/config-v5.jpg?raw=true) -# Troubleshooting -The [Troubleshooting wiki page](https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting) contains some common errors and their solutions. Please check that, and if it doesn't work, feel free to ask on the [discord server](https://discord.com/invite/u9yhsFmEkB) or [file an issue](https://github.com/cmdr2/stable-diffusion-ui/issues). - # What is this? Why no Docker? This version is a 1-click installer. You don't need WSL or Docker or anything beyond a working NVIDIA GPU with an updated driver. You don't need to use the command-line at all. Even if you don't have a compatible GPU, you can run it on your CPU (albeit very slowly). diff --git a/Troubleshooting.md b/Troubleshooting.md new file mode 100644 index 00000000..315ec273 --- /dev/null +++ b/Troubleshooting.md @@ -0,0 +1,43 @@ +Common issues and their solutions. If these solutions don't work, please feel free to ask at the [discord server](https://discord.com/invite/u9yhsFmEkB) or [file an issue](https://github.com/cmdr2/stable-diffusion-ui/issues). + +## RuntimeError: CUDA out of memory +This can happen if your PC has less than 6GB of VRAM. + +Try disabling the "Turbo mode" setting under "Advanced Settings", since that takes an additional 1 GB of VRAM (to increase the speed). + +Additionally, a common reason for this error is that you're using an initial image larger than 768x768 pixels. Try using a smaller initial image. + +Also try generating smaller sized images. + +## No ldm found, or antlr4 or any other missing module, or ClobberError: This transaction has incompatible packages due to a shared path +On Windows, please ensure that you had placed the `stable-diffusion-ui` folder after unzipping to the root of C: or D: (or any drive). For e.g. `C:\stable-diffusion-ui`. **Note:** This has to be done **before** you start the installation process. If you have already installed (and are facing this error), please delete the installed folder, and start fresh by unzipping and placing the folder at the top of your drive. + +This error can also be caused if you already have conda/miniconda/anaconda installed, due to package conflicts. Please open your Anaconda Prompt, and run `conda clean --all` to clean up unused packages. + +If nothing works, this could be due to a corrupted installation. Please try reinstalling this, by deleting the installed folder, and unzipping from the downloaded zip file. + +## Green image generated +This usually happens if you're running NVIDIA 1650 or 1660 Super. To solve this, please close and run the Stable Diffusion command on your computer. If you're using the older Docker-based solution (v1), please upgrade to v2: https://github.com/cmdr2/stable-diffusion-ui/tree/v2#installation + +If you're still seeing this error, please try enabling "Full Precision" under "Advanced Settings" in the Stable Diffusion UI. + +## './docker-compose.yml' is invalid: +> ERROR: The Compose file './docker-compose.yml' is invalid because: +> services.stability-ai.deploy.resources.reservations value Additional properties are not allowed ('devices' was unexpected) + +Please ensure you have `docker-compose` version 1.29 or higher. Check `docker-compose --version`, and if required [update it to 1.29](https://docs.docker.com/compose/install/). (Thanks [HVRyan](https://github.com/HVRyan)) + +## RuntimeError: Found no NVIDIA driver on your system: +If you have an NVIDIA GPU and the latest [NVIDIA driver](http://www.nvidia.com/Download/index.aspx), please ensure that you've installed [nvidia-container-toolkit](https://stackoverflow.com/a/58432877). (Thanks [u/exintrovert420](https://www.reddit.com/user/exintrovert420/)) + +## Some other process is already running at port 9000 / port 9000 could not be bound +You can override the port used. Please change `docker-compose.yml` inside the project directory, and update the line `9000:9000` to `1337:9000` (where 1337 is whichever port number you want). + +After doing this, please restart your server, by running `./server restart`. + +After this, you can access the server at `http://localhost:1337` (where 1337 is the new port you specified earlier). + +## RuntimeError: CUDA error: unknown error +Please ensure that you have an NVIDIA GPU and the latest [NVIDIA driver](http://www.nvidia.com/Download/index.aspx), and that you've installed [nvidia-container-toolkit](https://stackoverflow.com/a/58432877). + +Also, if you are using WSL (Windows), please ensure you have the latest WSL kernel by running `wsl --shutdown` and then `wsl --update`. (Thanks [AndrWeisR](https://github.com/AndrWeisR)) diff --git a/build.bat b/build.bat index e5e30b6a..d1bcaab7 100644 --- a/build.bat +++ b/build.bat @@ -1,3 +1,13 @@ +@echo off + +@echo "Hi there, what you are running is meant for the developers of this project, not for users." & echo. +@echo "If you only want to use the Stable Diffusion UI, you've downloaded the wrong file." +@echo "Please download and follow the instructions at https://github.com/cmdr2/stable-diffusion-ui#installation" & echo. +@echo "If you are actually a developer of this project, please type Y and press enter" & echo. + +set /p answer=Are you a developer of this project (Y/N)? +if /i "%answer:~,1%" NEQ "Y" exit /b + @mkdir dist\stable-diffusion-ui @echo "Downloading components for the installer.." diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 index 582f81da..04579d1f --- a/build.sh +++ b/build.sh @@ -1,5 +1,16 @@ #!/bin/bash +printf "Hi there, what you are running is meant for the developers of this project, not for users.\n\n" +printf "If you only want to use the Stable Diffusion UI, you've downloaded the wrong file.\n" +printf "Please download and follow the instructions at https://github.com/cmdr2/stable-diffusion-ui#installation\n\n" +printf "If you are actually a developer of this project, please type Y and press enter\n\n" + +read -p "Are you a developer of this project (Y/N) " yn +case $yn in + [Yy]* ) ;; + * ) exit;; +esac + mkdir -p dist/stable-diffusion-ui echo "Downloading components for the installer.." @@ -23,11 +34,13 @@ tar -xf ../../installer.tar -C installer mkdir scripts cp ../../scripts/on_env_start.sh scripts/ -cp "../../scripts/start.sh" . +cp ../../scripts/start.sh . cp ../../LICENSE . cp "../../CreativeML Open RAIL-M License" . cp "../../How to install and run.txt" . +chmod u+x start.sh + echo "Build ready. Zip the 'dist/stable-diffusion-ui' folder." echo "Cleaning up.." diff --git a/media/download buttons.xcf b/media/download buttons.xcf new file mode 100644 index 00000000..7427a46d Binary files /dev/null and b/media/download buttons.xcf differ diff --git a/media/download-linux.png b/media/download-linux.png new file mode 100644 index 00000000..2fd1340e Binary files /dev/null and b/media/download-linux.png differ diff --git a/media/download-win.png b/media/download-win.png new file mode 100644 index 00000000..da1ff788 Binary files /dev/null and b/media/download-win.png differ diff --git a/scripts/on_env_start.bat b/scripts/on_env_start.bat index 66aa0004..068231ff 100644 --- a/scripts/on_env_start.bat +++ b/scripts/on_env_start.bat @@ -1,30 +1,59 @@ -@echo. & echo "Stable Diffusion UI" & echo. +@echo off + +@echo. & echo "Stable Diffusion UI - v2" & echo. @cd .. +if exist "scripts\config.bat" ( + @call scripts\config.bat +) + +if "%update_branch%"=="" ( + set update_branch=main +) + +@>nul grep -c "conda_sd_ui_deps_installed" scripts\install_status.txt +@if "%ERRORLEVEL%" NEQ "0" ( + for /f "tokens=*" %%a in ('python -c "import os; parts = os.getcwd().split(os.path.sep); print(len(parts))"') do if "%%a" NEQ "2" ( + echo. & echo "!!!! WARNING !!!!" & echo. + echo "Your 'stable-diffusion-ui' folder is at %cd%" & echo. + echo "The 'stable-diffusion-ui' folder needs to be at the top of your drive, for e.g. 'C:\stable-diffusion-ui' or 'D:\stable-diffusion-ui' etc." + echo "Not placing this folder at the top of a drive can cause errors on some computers." + echo. & echo "Recommended: Please close this window and move the 'stable-diffusion-ui' folder to the top of a drive. For e.g. 'C:\stable-diffusion-ui'. Then run the installer again." & echo. + echo "Not Recommended: If you're sure that you want to install at the current location, please press any key to continue." & echo. + + pause + ) +) + @>nul grep -c "sd_ui_git_cloned" scripts\install_status.txt @if "%ERRORLEVEL%" EQU "0" ( - @echo "Stable Diffusion UI's git repository was already installed. Updating.." + @echo "Stable Diffusion UI's git repository was already installed. Updating from %update_branch%.." @cd sd-ui-files @call git reset --hard + @call git checkout "%update_branch%" @call git pull @cd .. ) else ( @echo. & echo "Downloading Stable Diffusion UI.." & echo. + @echo "Using the %update_branch% channel" & echo. - @call git clone https://github.com/cmdr2/stable-diffusion-ui.git sd-ui-files && ( + @call git clone -b "%update_branch%" https://github.com/cmdr2/stable-diffusion-ui.git sd-ui-files && ( @echo sd_ui_git_cloned >> scripts\install_status.txt ) || ( - @echo "Error downloading Stable Diffusion UI. Please try re-running this installer. If it doesn't work, please copy the messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB or file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" + @echo "Error downloading Stable Diffusion UI. 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!" pause @exit /b ) ) @xcopy sd-ui-files\ui ui /s /i /Y -@xcopy sd-ui-files\scripts scripts /s /i /Y +@copy sd-ui-files\scripts\on_sd_start.bat scripts\ /Y +@copy "sd-ui-files\scripts\Start Stable Diffusion UI.cmd" . /Y @call scripts\on_sd_start.bat + +@pause \ No newline at end of file diff --git a/scripts/on_env_start.sh b/scripts/on_env_start.sh index 7be26051..79ab23a7 100755 --- a/scripts/on_env_start.sh +++ b/scripts/on_env_start.sh @@ -1,28 +1,43 @@ +#!/bin/bash + printf "\n\nStable Diffusion UI\n\n" +if [ -f "scripts/config.sh" ]; then + source scripts/config.sh +fi + +if [ "$update_branch" == "" ]; then + export update_branch="main" +fi + if [ -f "scripts/install_status.txt" ] && [ `grep -c sd_ui_git_cloned scripts/install_status.txt` -gt "0" ]; then - echo "Stable Diffusion UI's git repository was already installed. Updating.." + echo "Stable Diffusion UI's git repository was already installed. Updating from $update_branch.." cd sd-ui-files git reset --hard + git checkout "$update_branch" git pull cd .. else printf "\n\nDownloading Stable Diffusion UI..\n\n" + printf "Using the $update_branch channel\n\n" - if git clone https://github.com/cmdr2/stable-diffusion-ui.git sd-ui-files ; then + if git clone -b "$update_branch" https://github.com/cmdr2/stable-diffusion-ui.git sd-ui-files ; then echo sd_ui_git_cloned >> scripts/install_status.txt else - printf "\n\nError downloading Stable Diffusion UI. Please try re-running this installer. If it doesn't work, please copy the messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB or file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\n\n" + printf "\n\nError downloading Stable Diffusion UI. 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 -cp -Rf sd-ui-files/ui ui -cp -Rf sd-ui-files/scripts/* scripts/ -cp "scripts/start.sh" . +rm -rf ui +cp -Rf sd-ui-files/ui . +cp sd-ui-files/scripts/on_sd_start.sh scripts/ +cp sd-ui-files/scripts/start.sh . ./scripts/on_sd_start.sh + +read -p "Press any key to continue" diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index a88ba88c..9f993ec2 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -1,4 +1,11 @@ -@set cmd_had_error=F +@echo off + +@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 @if "%ERRORLEVEL%" EQU "0" ( @@ -8,6 +15,7 @@ @call git reset --hard @call git pull + @call git checkout d154155d4c0b43e13ec1f00eb72b7ff9d522fcf9 @cd .. ) else ( @@ -16,18 +24,14 @@ @call git clone https://github.com/basujindal/stable-diffusion.git && ( @echo sd_git_cloned >> scripts\install_status.txt ) || ( - @set cmd_had_error=T - ) - - if "%ERRORLEVEL%" NEQ "0" ( - @set cmd_had_error=T - ) - - if "%cmd_had_error%"=="T" ( - @echo "Error downloading Stable Diffusion. Please try re-running this installer. If it doesn't work, please copy the messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB or file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" + @echo "Error downloading Stable Diffusion. 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!" pause @exit /b ) + + @cd stable-diffusion + @call git checkout d154155d4c0b43e13ec1f00eb72b7ff9d522fcf9 + @cd .. ) @cd stable-diffusion @@ -35,25 +39,71 @@ @>nul grep -c "conda_sd_env_created" ..\scripts\install_status.txt @if "%ERRORLEVEL%" EQU "0" ( @echo "Packages necessary for Stable Diffusion were already installed" + + @call conda activate .\env ) else ( @echo. & echo "Downloading packages necessary for Stable Diffusion.." & echo. & echo "***** This will take some time (depending on the speed of the Internet connection) and may appear to be stuck, but please be patient ***** .." & echo. @rmdir /s /q .\env - @call conda env create --prefix env -f environment.yaml && ( - @echo conda_sd_env_created >> ..\scripts\install_status.txt - ) || ( - @set cmd_had_error=T - ) - - if "%cmd_had_error%"=="T" ( - echo "Error installing the packages necessary for Stable Diffusion. Please try re-running this installer. If it doesn't work, please copy the messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB or file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" + @call conda env create --prefix env -f environment.yaml || ( + @echo. & echo "Error installing the packages necessary for Stable Diffusion. 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 ) + + @call conda activate .\env + + for /f "tokens=*" %%a in ('python -c "import torch; import ldm; import transformers; import numpy; import antlr4; print(42)"') do if "%%a" NEQ "42" ( + @echo. & echo "Dependency test failed! Error installing the packages necessary for Stable Diffusion. 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_env_created >> ..\scripts\install_status.txt ) -@call conda activate .\env +@>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" ( @@ -61,43 +111,159 @@ ) else ( @echo. & echo "Downloading packages necessary for Stable Diffusion UI.." & echo. - @call conda install -c conda-forge -y --prefix env uvicorn fastapi && ( - @echo conda_sd_ui_deps_installed >> ..\scripts\install_status.txt - ) || ( - @set cmd_had_error=T - ) - - if "%ERRORLEVEL%" NEQ "0" ( - @set cmd_had_error=T - ) - - if "%cmd_had_error%"=="T" ( - echo "Error installing the packages necessary for Stable Diffusion UI. Please try re-running this installer. If it doesn't work, please copy the messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB or file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" + @call conda install -c conda-forge -y --prefix env uvicorn fastapi || ( + echo "Error installing the packages necessary for Stable Diffusion UI. 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!" pause exit /b ) ) +call WHERE uvicorn > .tmp +@>nul grep -c "uvicorn" .tmp +@if "%ERRORLEVEL%" NEQ "0" ( + @echo. & echo "UI packages not found! 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 "conda_sd_ui_deps_installed" ..\scripts\install_status.txt +@if "%ERRORLEVEL%" NEQ "0" ( + @echo conda_sd_ui_deps_installed >> ..\scripts\install_status.txt +) + + + @if exist "sd-v1-4.ckpt" ( - echo "Data files (weights) necessary for Stable Diffusion were already downloaded" -) else ( + for %%I in ("sd-v1-4.ckpt") do if "%%~zI" EQU "4265380512" ( + echo "Data files (weights) necessary for Stable Diffusion were already downloaded" + ) else ( + echo. & echo "The model file present at %cd%\sd-v1-4.ckpt is invalid. It is only %%~zI bytes in size. Re-downloading.." & echo. + del "sd-v1-4.ckpt" + ) +) + +@if not exist "sd-v1-4.ckpt" ( @echo. & echo "Downloading data files (weights) for Stable Diffusion.." & echo. - @call curl -L https://me.cmdr2.org/stable-diffusion-ui/sd-v1-4.ckpt > sd-v1-4.ckpt + @call curl -L -k https://me.cmdr2.org/stable-diffusion-ui/sd-v1-4.ckpt > sd-v1-4.ckpt - @if not exist "sd-v1-4.ckpt" ( - echo "Error downloading the data files (weights) for Stable Diffusion. Please try re-running this installer. If it doesn't work, please copy the messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB or file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" + @if exist "sd-v1-4.ckpt" ( + for %%I in ("sd-v1-4.ckpt") do if "%%~zI" NEQ "4265380512" ( + echo. & echo "Error: The downloaded model file was invalid! Bytes downloaded: %%~zI" & echo. + echo. & echo "Error downloading the data files (weights) for Stable Diffusion. 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 Stable Diffusion. 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 "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 @echo sd_install_complete >> ..\scripts\install_status.txt ) @echo. & echo "Stable Diffusion is ready!" & echo. -@set SD_UI_PATH=%cd%\..\ui +@cd .. +@set SD_UI_PATH=%cd%\ui +@cd stable-diffusion @uvicorn server:app --app-dir "%SD_UI_PATH%" --port 9000 --host 0.0.0.0 diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index e263488b..b50a5546 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -1,12 +1,22 @@ +#!/bin/bash + +cp sd-ui-files/scripts/on_env_start.sh scripts/ + source installer/etc/profile.d/conda.sh -if [ `grep -c sd_git_cloned scripts/install_status.txt` -gt "0" ]; then +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.." cd stable-diffusion git reset --hard git pull + git checkout d154155d4c0b43e13ec1f00eb72b7ff9d522fcf9 cd .. else @@ -15,30 +25,91 @@ else if git clone https://github.com/basujindal/stable-diffusion.git ; then echo sd_git_cloned >> scripts/install_status.txt else - printf "\n\nError downloading Stable Diffusion. Please try re-running this installer. If it doesn't work, please copy the messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB or file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\n\n" + printf "\n\nError downloading Stable Diffusion. 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 + + cd stable-diffusion + git checkout d154155d4c0b43e13ec1f00eb72b7ff9d522fcf9 + cd .. fi cd stable-diffusion if [ `grep -c conda_sd_env_created ../scripts/install_status.txt` -gt "0" ]; then echo "Packages necessary for Stable Diffusion were already installed" + + conda activate ./env else printf "\n\nDownloading packages necessary for Stable Diffusion..\n" printf "\n\n***** This will take some time (depending on the speed of the Internet connection) and may appear to be stuck, but please be patient ***** ..\n\n" if conda env create --prefix env --force -f environment.yaml ; then - echo conda_sd_env_created >> ../scripts/install_status.txt + echo "Installed. Testing.." else - printf "\n\nError installing the packages necessary for Stable Diffusion. Please try re-running this installer. If it doesn't work, please copy the messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB or file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\n\n" + printf "\n\nError installing the packages necessary for Stable Diffusion. 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 + + conda activate ./env + + out_test=`python -c "import torch; import ldm; import transformers; import numpy; import antlr4; print(42)"` + if [ "$out_test" != "42" ]; then + printf "\n\nDependency test failed! Error installing the packages necessary for Stable Diffusion. 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_env_created >> ../scripts/install_status.txt fi -conda activate ./env +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" @@ -46,34 +117,162 @@ else printf "\n\nDownloading packages necessary for Stable Diffusion UI..\n\n" if conda install -c conda-forge --prefix ./env -y uvicorn fastapi ; then - echo conda_sd_ui_deps_installed >> ../scripts/install_status.txt + echo "Installed. Testing.." else - printf "\n\nError installing the packages necessary for Stable Diffusion UI. Please try re-running this installer. If it doesn't work, please copy the messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB or file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\n\n" + printf "\n\nError installing the packages necessary for Stable Diffusion UI. 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 + + if ! command -v uvicorn &> /dev/null; then + printf "\n\nUI packages not found! Error installing the packages necessary for Stable Diffusion UI. 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_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}'` + + if [ "$model_size" -eq "4265380512" ]; then + echo "Data files (weights) necessary for Stable Diffusion were already downloaded" + else + printf "\n\nThe model file present at $PWD/sd-v1-4.ckpt is invalid. It is only $model_size bytes in size. Re-downloading.." + rm sd-v1-4.ckpt + fi +fi + +if [ ! -f "sd-v1-4.ckpt" ]; then + echo "Downloading data files (weights) for Stable Diffusion.." + + curl -L -k https://me.cmdr2.org/stable-diffusion-ui/sd-v1-4.ckpt > sd-v1-4.ckpt + + if [ -f "sd-v1-4.ckpt" ]; then + model_size=`ls -l sd-v1-4.ckpt | awk '{print $5}'` + if [ ! "$model_size" -eq "4265380512" ]; then + printf "\n\nError: The downloaded model file was invalid! Bytes downloaded: $model_size\n\n" + printf "\n\nError downloading the data files (weights) for Stable Diffusion. 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 Stable Diffusion. 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 "sd-v1-4.ckpt" ]; then - echo "Data files (weights) necessary for Stable Diffusion were already downloaded" -else - echo "Downloading data files (weights) for Stable Diffusion.." - curl -L https://me.cmdr2.org/stable-diffusion-ui/sd-v1-4.ckpt > sd-v1-4.ckpt +if [ -f "GFPGANv1.3.pth" ]; then + model_size=`ls -l GFPGANv1.3.pth | awk '{print $5}'` - if [ ! -f "sd-v1-4.ckpt" ]; then - printf "\n\nError downloading the data files (weights) for Stable Diffusion. Please try re-running this installer. If it doesn't work, please copy the messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB or file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\n\n" + 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 printf "\n\nStable Diffusion is ready!\n\n" -export SD_UI_PATH=`pwd`/../ui +cd .. +export SD_UI_PATH=`pwd`/ui +cd stable-diffusion uvicorn server:app --app-dir "$SD_UI_PATH" --port 9000 --host 0.0.0.0 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/hotfix/9c24e6cd9f499d02c4f21a033736dabd365962dc80fe3aeb57a8f85ea45a20a3.26fead7ea4f0f843f6eb4055dfd25693f1a71f3c6871b184042d4b126244e142 b/ui/hotfix/9c24e6cd9f499d02c4f21a033736dabd365962dc80fe3aeb57a8f85ea45a20a3.26fead7ea4f0f843f6eb4055dfd25693f1a71f3c6871b184042d4b126244e142 new file mode 100644 index 00000000..2c19f666 --- /dev/null +++ b/ui/hotfix/9c24e6cd9f499d02c4f21a033736dabd365962dc80fe3aeb57a8f85ea45a20a3.26fead7ea4f0f843f6eb4055dfd25693f1a71f3c6871b184042d4b126244e142 @@ -0,0 +1,171 @@ +{ + "_name_or_path": "clip-vit-large-patch14/", + "architectures": [ + "CLIPModel" + ], + "initializer_factor": 1.0, + "logit_scale_init_value": 2.6592, + "model_type": "clip", + "projection_dim": 768, + "text_config": { + "_name_or_path": "", + "add_cross_attention": false, + "architectures": null, + "attention_dropout": 0.0, + "bad_words_ids": null, + "bos_token_id": 0, + "chunk_size_feed_forward": 0, + "cross_attention_hidden_size": null, + "decoder_start_token_id": null, + "diversity_penalty": 0.0, + "do_sample": false, + "dropout": 0.0, + "early_stopping": false, + "encoder_no_repeat_ngram_size": 0, + "eos_token_id": 2, + "finetuning_task": null, + "forced_bos_token_id": null, + "forced_eos_token_id": null, + "hidden_act": "quick_gelu", + "hidden_size": 768, + "id2label": { + "0": "LABEL_0", + "1": "LABEL_1" + }, + "initializer_factor": 1.0, + "initializer_range": 0.02, + "intermediate_size": 3072, + "is_decoder": false, + "is_encoder_decoder": false, + "label2id": { + "LABEL_0": 0, + "LABEL_1": 1 + }, + "layer_norm_eps": 1e-05, + "length_penalty": 1.0, + "max_length": 20, + "max_position_embeddings": 77, + "min_length": 0, + "model_type": "clip_text_model", + "no_repeat_ngram_size": 0, + "num_attention_heads": 12, + "num_beam_groups": 1, + "num_beams": 1, + "num_hidden_layers": 12, + "num_return_sequences": 1, + "output_attentions": false, + "output_hidden_states": false, + "output_scores": false, + "pad_token_id": 1, + "prefix": null, + "problem_type": null, + "projection_dim" : 768, + "pruned_heads": {}, + "remove_invalid_values": false, + "repetition_penalty": 1.0, + "return_dict": true, + "return_dict_in_generate": false, + "sep_token_id": null, + "task_specific_params": null, + "temperature": 1.0, + "tie_encoder_decoder": false, + "tie_word_embeddings": true, + "tokenizer_class": null, + "top_k": 50, + "top_p": 1.0, + "torch_dtype": null, + "torchscript": false, + "transformers_version": "4.16.0.dev0", + "use_bfloat16": false, + "vocab_size": 49408 + }, + "text_config_dict": { + "hidden_size": 768, + "intermediate_size": 3072, + "num_attention_heads": 12, + "num_hidden_layers": 12, + "projection_dim": 768 + }, + "torch_dtype": "float32", + "transformers_version": null, + "vision_config": { + "_name_or_path": "", + "add_cross_attention": false, + "architectures": null, + "attention_dropout": 0.0, + "bad_words_ids": null, + "bos_token_id": null, + "chunk_size_feed_forward": 0, + "cross_attention_hidden_size": null, + "decoder_start_token_id": null, + "diversity_penalty": 0.0, + "do_sample": false, + "dropout": 0.0, + "early_stopping": false, + "encoder_no_repeat_ngram_size": 0, + "eos_token_id": null, + "finetuning_task": null, + "forced_bos_token_id": null, + "forced_eos_token_id": null, + "hidden_act": "quick_gelu", + "hidden_size": 1024, + "id2label": { + "0": "LABEL_0", + "1": "LABEL_1" + }, + "image_size": 224, + "initializer_factor": 1.0, + "initializer_range": 0.02, + "intermediate_size": 4096, + "is_decoder": false, + "is_encoder_decoder": false, + "label2id": { + "LABEL_0": 0, + "LABEL_1": 1 + }, + "layer_norm_eps": 1e-05, + "length_penalty": 1.0, + "max_length": 20, + "min_length": 0, + "model_type": "clip_vision_model", + "no_repeat_ngram_size": 0, + "num_attention_heads": 16, + "num_beam_groups": 1, + "num_beams": 1, + "num_hidden_layers": 24, + "num_return_sequences": 1, + "output_attentions": false, + "output_hidden_states": false, + "output_scores": false, + "pad_token_id": null, + "patch_size": 14, + "prefix": null, + "problem_type": null, + "projection_dim" : 768, + "pruned_heads": {}, + "remove_invalid_values": false, + "repetition_penalty": 1.0, + "return_dict": true, + "return_dict_in_generate": false, + "sep_token_id": null, + "task_specific_params": null, + "temperature": 1.0, + "tie_encoder_decoder": false, + "tie_word_embeddings": true, + "tokenizer_class": null, + "top_k": 50, + "top_p": 1.0, + "torch_dtype": null, + "torchscript": false, + "transformers_version": "4.16.0.dev0", + "use_bfloat16": false + }, + "vision_config_dict": { + "hidden_size": 1024, + "intermediate_size": 4096, + "num_attention_heads": 16, + "num_hidden_layers": 24, + "patch_size": 14, + "projection_dim": 768 + } +} diff --git a/ui/index.html b/ui/index.html index 4578ec04..7ed226ec 100644 --- a/ui/index.html +++ b/ui/index.html @@ -254,6 +254,10 @@ font-size: 16pt; margin-bottom: 10pt; } + #coffeeButton { + height: 23px; + transform: translateY(25%); + } @@ -265,7 +269,7 @@
 
Stable Diffusion is starting.. -

Stable Diffusion UI v2.05 (beta)

+

Stable Diffusion UI v2.1

@@ -295,6 +299,16 @@

Advanced Settings

    +
  • +
  • + + +
  • +
  • +
  • (images at once)
  • @@ -339,12 +353,14 @@

  •  
  • -
  • +
  • -
  • +
  • +
    +
@@ -367,7 +383,8 @@