├── LICENSE ├── README.md └── linux-sd.sh /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Joshua Kimsey 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # THIS REPO IS NOW ARCHIVED! I MAKE NO GUARENTEES THAT IT WILL STILL WORK IN THE FUTURE AND WILL NOT BE MAINTAINING IT. IF YOU WISH TO FORK IT AND CONTINUE WORKING ON IT, BY ALL MEANS DO SO. ANY OTHER QUESTIONS REGARDING THE HLKY/SYGIL STABLE DIFFUSION WEBUI SHOULD BE DIRECTED TO THEIR PROJECT REPO: [SYGIL WEBUI](https://github.com/Sygil-Dev/sygil-webui). 2 | 3 | # Linux Installation 4 | 5 | ### The definitive Stable Diffusion WebUI experience ™ Now 100% Linux Compatible! 6 | #### Created by [Joshua Kimsey](https://github.com/JoshuaKimsey) 7 | 8 | ## Features 9 | - Automates the process of installing and running hlky's fork of Stable Diffusion with the WebUI for Linux-based OS users. 10 | - Handles updating from the hlky fork automatically if the users wishes to do so. 11 | - Allows the user to preset their configs for running their setup (Gradio version only). 12 | 13 | ## Change Log 14 | 15 | **PLEASE NOTE: If you are upgrading from using the 1.x versions of the script, it is my strong suggestion that you consider deleting the repo folder created by the script and letting it redownload to ensure everything is properly updated. To do so easily and without losing images you have already generated, simply copy the `outputs` folder to another location outside of the GitHub repo folder. Also, if you do not have a copy of the SD models you are using, make sure you copy the `model.ckpt` file from `models/ldm/stable-diffusion-v1` to another location as well. Delete the repo folder and rerun `linus-sd.sh` to reinstall. When it asks for the model files, if you copied a backup somewhere else, make sure the file is (re)named to `sd-v1-4.ckpt` before you move it to the repo folder as the script requests. Once installation is complete, feel free to copy your `outputs` folder back to the repo folder as well.** 16 | 17 | * Version 2.0: 18 | - Brand new redesign of the script to work with both the newer Streamlit and older Gradio interfaces. 19 | - Now integrates with the in-built `webui.sh` file in the repo itself for better compatibility. 20 | 21 | * Version 1.0 - 1.9: 22 | - Initial versions supporting the single Gradio Interface. 23 | 24 | ## Initial Start Guide 25 | **Note:** This guide assumes you have installed Anaconda already, and have it set up properly. If you have not, please visit the [Anaconda](https://www.anaconda.com/products/distribution) website to download the file for your system and install it. 26 | 27 | **WARNING: Multiple Linux users have reported issues using this script, and potentially Stable Diffusion in general, with Miniconda. As such, I can not recommend using it due to these issues with unknown causes. Please use the full release of Anaconda instead.** 28 | 29 | **Step 1:** Create a folder/directory on your system and place this [script](https://github.com/JoshuaKimsey/Linux-StableDiffusion-Script/blob/main/linux-sd.sh) in it, named `linux-sd.sh`. This directory will be where the files for Stable Diffusion will be downloaded. 30 | 31 | **Step 2:** Download the 1.4 AI model from HuggingFace (or another location, the original guide has some links to mirrors of the model) and place it in the same directory as the script. 32 | 33 | **Step 3:** Make the script executable by opening the directory in your Terminal and typing `chmod +x linux-sd.sh`, or whatever you named this file as. 34 | 35 | **Step 4:** Run the script with `./linux-sd.sh`, it will begin by cloning the [WebUI Github Repo](https://github.com/sd-webui/stable-diffusion-webui) to the directory the script is located in. This folder will be named `stable-diffusion-webui`. 36 | 37 | **Step 5:** The script will pause and ask that you move/copy the downloaded 1.4 AI models to the `stable-diffusion-webui` folder. Press Enter once you have done so to continue. 38 | 39 | **If you are running low on storage space, you can just move the 1.4 AI models file directly to this directory, it will not be deleted, simply moved and renamed. However my personal suggestion is to just **copy** it to the repo folder, in case you desire to delete and rebuild your Stable Diffusion build again.** 40 | 41 | **Step 6:** Next, the script will ask if you wish to customize any of the launch arguments for the Gradio WebUI Interface. If yes, then a series of options will be presented to the user: 42 | - Use the CPU for Extra Upscaler Models to save on VRAM 43 | - Automatically open a new browser window or tab on first launch 44 | - Use Optimized mode for Ultimate Stable Diffusion, which only requires 4GB of VRAM at the cost of speed 45 | - Use Optimized Turbo which uses more VRAM than regular optimized, but is faster (Incompatible with regular optimized mode) 46 | - Open a public xxxxx.gradi.app URL to share your interface with others (Please be careful with this, it is a potential security risk) 47 | 48 | The user will have the ability to set these to yes or no using the menu choices. 49 | 50 | **Note: These only apply to the Gradio WebUI interface. The Streamlit Interface version has/will have the ability to set its own preferences from within the WebUI** 51 | 52 | **Step 7:** The script will then proceed to call the `webui.sh` file within the repo folder. This will handle the creation and updating of the conda environment, named `ldm`, as well as handle the downloading of the upsclaer models used by both Streamlit and Gradio. It will also download the Concepts Library for using custom models in the Streamlit version. 53 | 54 | **Building the Conda environment may take upwards of 15 minutes, depending on your network connection and system specs. This is normal, just leave it be and let it finish. If you are trying to update and the script hangs at `Installing PIP Dependencies`, you will need to `Ctrl-C` to stop the script, delete your `src` folder, and rerun `linux-sd.sh` again.** 55 | 56 | **Step 8:** Once the conda environment has been created and the upscaler models have been downloaded, then the user is presented with a choice to choose between the Streamlit or Gradio versions of the WebUI Interface. 57 | - Streamlit: 58 | - Has A More Modern UI 59 | - More Features Planned 60 | - Will Be The Main UI Going Forward 61 | - Currently In Active Development 62 | - Missing Some Gradio Features 63 | 64 | - Gradio: 65 | - Currently Feature Complete 66 | - Uses An Older Interface Style 67 | - Will Not Receive Major Updates 68 | 69 | **Step 9:** If everything has gone successfully, either a new browser window will open with the Streamlit version, or you should see `Running on local URL: http://localhost:7860/` in your Terminal if you launched the Gradio Interface version. Generated images will be located in the `outputs` directory inside of `stable-diffusion-webui`. Enjoy the definitive Stable Diffusion WebUI experience on Linux! :) 70 | 71 | ## Ultimate Stable Diffusion Customizations 72 | 73 | When running the script again after the initial use, the user will be presented with a choice to run Stable Diffusion with the last used parameters used to launch it. If the user chooses `Yes`, then all customization steps will be skipped and the Stable Diffusion WebUI will launch without pulling in new updates. 74 | 75 | If the user chooses to Customize their setup, then they will be presented with these options on how to customize their Ultimate Stable Diffusion setup: 76 | 77 | - Update the Stable Diffusion WebUI fork from the GitHub Repo 78 | - Customize the launch arguments for Gradio Interface version of Stable Diffusion (See Above) 79 | 80 | ### Refer back to the original [WebUI Github Repo](https://github.com/sd-webui/stable-diffusion-webui) for useful tips and links to other resources that can improve your Stable Diffusion experience 81 | 82 | ## Planned Additions 83 | - Investigate ways to handle Anaconda automatic installation on a user's system. 84 | -------------------------------------------------------------------------------- /linux-sd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -i 2 | 3 | # Linux Stable Diffusion Script 4 | 5 | # Version: 2.0 6 | 7 | # MIT License 8 | 9 | # Copyright (c) 2022 Joshua Kimsey 10 | 11 | ##### Please See My Guide For Running This Script Here: https://rentry.org/linux-sd ##### 12 | 13 | # Confirmed working as of September 22nd, 2022. May be subject to breakage at a later date due to bleeding-edge updates in the Stable Diffusion WebUI repo 14 | # Please see my GitHub for updates on this script: https://github.com/JoshuaKimsey/Linux-StableDiffusion-Script 15 | 16 | printf "\n\n\n" 17 | printf "WELCOME TO THE ULTIMATE STABLE DIFFUSION WEB GUI ON LINUX" 18 | printf "\n\n" 19 | printf "The definitive Stable Diffusion experience™ Now 100% Linux Compatible!" 20 | printf "\n" 21 | printf "Please ensure you have Anaconda installed properly on your Linux system before running this." 22 | printf "\n" 23 | printf "Please refer to the original guide for more info and additional links for this project: https://rentry.org/guitard" 24 | printf "\n\n" 25 | 26 | DIRECTORY=./stable-diffusion-webui 27 | REPO=https://github.com/sd-webui/stable-diffusion-webui.git 28 | ENV=ldm 29 | 30 | ultimate_stable_diffusion_repo () { 31 | # Check to see if Ultimate Stable Diffusion repo is cloned 32 | if [ -d "$DIRECTORY" ]; then 33 | printf "\n\n########## CHECK FOR UPDATES ##########\n\n" 34 | printf "Ultimate Stable Diffusion already exists. Do you want to update Ultimate Stable Diffusion?\n" 35 | printf "(This will reset your launch arguments and they will need to be set again after updating)\n" 36 | select yn in "Yes" "No"; do 37 | case $yn in 38 | Yes ) printf "Pulling updates for the Stable Diffusion WebUI. Please wait...\n"; ultimate_stable_diffusion_repo_update; break;; 39 | No ) printf "Stable Diffusion WebUI will not be updated. Continuing...\n"; break;; 40 | esac 41 | done 42 | else 43 | printf "Cloning Ultimate Stable Diffusion. Please wait..." 44 | git clone $REPO 45 | cp $DIRECTORY/scripts/relauncher.py $DIRECTORY/scripts/relauncher-backup.py 46 | fi 47 | } 48 | 49 | ultimate_stable_diffusion_repo_update () { 50 | cd $DIRECTORY 51 | git fetch --all 52 | git reset --hard origin/master 53 | cp ./scripts/relauncher.py ./scripts/relauncher-backup.py 54 | cd ..; 55 | } 56 | 57 | linux_setup_script () { 58 | cd $DIRECTORY 59 | printf "Running webui.sh...\n\n" 60 | bash -i ./webui.sh 61 | } 62 | 63 | # Checks to see which mode Ultimate Stable Diffusion is running in: STANDARD or OPTIMIZED 64 | # Then asks the user which mode they wish to use 65 | gradio_stable_diffusion_arguments () { 66 | if [ "$1" = "customize" ]; then 67 | printf "Do you want extra upscaling models to be run on the CPU instead of the GPU to save on VRAM at the cost of speed?\n" 68 | select yn in "Yes" "No"; do 69 | case $yn in 70 | Yes ) printf "Setting extra upscaling models to use the CPU...\n"; sed -i 's/extra_models_cpu = False/extra_models_cpu = True/g' $DIRECTORY/scripts/relauncher.py; break;; 71 | No ) printf "Extra upscaling models will run on the GPU. Continuing...\n"; sed -i 's/extra_models_cpu = True/extra_models_cpu = False/g' $DIRECTORY/scripts/relauncher.py; break;; 72 | esac 73 | done 74 | printf "\n\n" 75 | printf "Do you want for Ultimate Stable Diffusion to automatically launch a new browser window or tab on first launch?\n" 76 | select yn in "Yes" "No"; do 77 | case $yn in 78 | Yes ) printf "Setting Ultimate Stable Diffusion to open a new browser window/tab at first launch...\n"; sed -i 's/open_in_browser = False/open_in_browser = True/g' $DIRECTORY/scripts/relauncher.py; break;; 79 | No ) printf "Ultimate Stable Diffusion will not open automatically in a new browser window/tab. Continuing...\n"; sed -i 's/open_in_browser = True/open_in_browser = False/g' $DIRECTORY/scripts/relauncher.py; break;; 80 | esac 81 | done 82 | printf "\n\n" 83 | printf "Do you want to run Ultimate Stable Diffusion in Optimized mode - Requires only 4GB of VRAM, but is significantly slower?\n" 84 | select yn in "Yes" "No"; do 85 | case $yn in 86 | Yes ) printf "Setting Ultimate Stable Diffusion to run in Optimized Mode...\n"; sed -i 's/optimized = False/optimized = True/g' $DIRECTORY/scripts/relauncher.py; break;; 87 | No ) printf "Ultimate Stable Diffusion will launch in Standard Mode. Continuing...\n"; sed -i 's/optimized = True/optimized = False/g' $DIRECTORY/scripts/relauncher.py; break;; 88 | esac 89 | done 90 | printf "\n\n" 91 | printf "Do you want to start Ultimate Stable Diffusion in Optimized Turbo mode - Requires more VRAM than regular optimized, but is faster (incompatible with Optimized Mode)?\n" 92 | select yn in "Yes" "No"; do 93 | case $yn in 94 | Yes ) printf "Setting Ultimate Stable Diffusion to run in Optimized Turbo mode...\n"; sed -i 's/optimized_turbo = False/optimized_turbo = True/g' $DIRECTORY/scripts/relauncher.py; break;; 95 | No ) printf "Ultimate Stable Diffusion will launch in Standard Mode. Continuing...\n"; sed -i 's/optimized_turbo = True/optimized_turbo = False/g' $DIRECTORY/scripts/relauncher.py; break;; 96 | esac 97 | done 98 | printf "\n\n" 99 | printf "Do you want to create a public xxxxx.gradi.app URL to allow others to uses your interface? (Requires properly forwarded ports)\n" 100 | select yn in "Yes" "No"; do 101 | case $yn in 102 | Yes ) printf "Setting Ultimate Stable Diffusion to open a public share URL...\n"; sed -i 's/share = False/share = True/g' $DIRECTORY/scripts/relauncher.py; break;; 103 | No ) printf "Setting Ultimate Stable Diffusion to not open a public share URL. Continuing...\n"; sed -i 's/share = True/share = False/g' $DIRECTORY/scripts/relauncher.py; break;; 104 | esac 105 | done 106 | printf "\n\nCustomization of Ultimate Stable Diffusion is complete. Continuing...\n\n" 107 | else 108 | printf "\n\n########## GRADIO CUSTOMIZATION ##########\nPlease Note: These Arguments Only Affect The Gradio Interface Version Of The Stable Diffusion Webui.\n\n" 109 | printf "Do you wish to customize the launch arguments for the Gradio Webui Interface?\n" 110 | printf "(This will be where you select Optimized mode, auto open in browser, share to public, and more.)\n" 111 | select yn in "Yes" "No"; do 112 | case $yn in 113 | Yes ) printf "Starting customization of Gradio Interface launch arguments...\n"; gradio_stable_diffusion_arguments customize; break;; 114 | No ) printf "Maintaining current Gradio Interface launch arguments...\n"; break;; 115 | esac 116 | done 117 | fi 118 | } 119 | 120 | # Function to install and run the Ultimate Stable Diffusion fork 121 | ultimate_stable_diffusion () { 122 | if [ "$1" = "initial" ]; then 123 | ultimate_stable_diffusion_repo 124 | gradio_stable_diffusion_arguments 125 | linux_setup_script 126 | else 127 | if [[ $(conda env list | grep "$ENV") = $ENV* ]]; then 128 | printf "\n\n########## RUN PREVIOUS SETUP ##########\n\n" 129 | printf "Do you wish to run Ultimate Stable Diffusion with the previous parameters?\n" 130 | printf "(Select NO to customize or update your Ultimate Stable Diffusion setup)\n" 131 | select yn in "Yes" "No"; do 132 | case $yn in 133 | Yes ) printf "Starting Ultimate Stable Diffusion using previous parameters. Please wait..."; linux_setup_script; break;; 134 | No ) printf "Beginning customization of Ultimate Stable Diffusion..."; ultimate_stable_diffusion initial; break;; 135 | esac 136 | done 137 | else 138 | printf "ERROR: Conda Env not found. Will attempt to rebuild, please go through the update steps below...\n" 139 | ultimate_stable_diffusion initial 140 | fi 141 | fi 142 | } 143 | 144 | # Initialization 145 | if [ ! -d "$DIRECTORY" ]; then 146 | printf "Starting Ultimate Stable Diffusion installation..." 147 | printf "\n" 148 | ultimate_stable_diffusion initial 149 | else 150 | ultimate_stable_diffusion 151 | fi 152 | --------------------------------------------------------------------------------