From 5b8cd23b850d740dd6ec28768c819c8bd4dfcbfd Mon Sep 17 00:00:00 2001 From: Mathieu Broillet Date: Sat, 10 Aug 2024 21:27:45 +0200 Subject: [PATCH] add update function to stablediff --- .gitignore | 1 + stablediffusion-rocm/.gitignore | 2 ++ stablediffusion-rocm/install.sh | 20 +++++++++++++++----- utils.sh | 21 +++++++++++++++++---- 4 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62c8935 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/stablediffusion-rocm/.gitignore b/stablediffusion-rocm/.gitignore index 70295cf..4c452cd 100644 --- a/stablediffusion-rocm/.gitignore +++ b/stablediffusion-rocm/.gitignore @@ -1,2 +1,4 @@ venv/ webui/ +models/ +outputs/ \ No newline at end of file diff --git a/stablediffusion-rocm/install.sh b/stablediffusion-rocm/install.sh index 8e0364d..0de13f3 100755 --- a/stablediffusion-rocm/install.sh +++ b/stablediffusion-rocm/install.sh @@ -2,16 +2,26 @@ source ../utils.sh python_exec=venv/bin/python3.10 -# Function to install StableDiffusion +# Function to install/update StableDiffusion install_stablediffusion() { if [ -d "webui" ]; then - echo "StableDiffusion repository already exists. Skipping clone." + echo "StableDiffusion repository already exists." + yes_or_no "Do you want to update StableDiffusion WebUI (dev branch) ?" && { + cd webui + git pull + echo "StableDiffusion WebUI successfully updated." + } else echo "Cloning StableDiffusion repository..." git clone -b dev https://github.com/AUTOMATIC1111/stable-diffusion-webui webui + + echo "Running StableDiffusion setup..." + $python_exec webui/launch.py --skip-torch-cuda-test --exit + + ln -s webui/models models + ln -s webui/outputs outputs fi - echo "Running StableDiffusion setup..." - $python_exec webui/launch.py --skip-torch-cuda-test --exit + } # Main function @@ -23,7 +33,7 @@ main() { clean - echo "StableDiffusion installation complete." + echo "StableDiffusion installation/update complete. Use ./run.sh to start" } # Run main function diff --git a/utils.sh b/utils.sh index 391e3a6..a250acf 100644 --- a/utils.sh +++ b/utils.sh @@ -27,17 +27,20 @@ use_venv() { # Function to install build-essential or equivalent install_build_essentials() { echo "Checking for build essentials..." + if [ -f /etc/debian_version ]; then sudo apt-get update sudo apt-get install -y build-essential python3.10-dev + elif [ -f /etc/fedora-release ]; then - if dnf list installed @development-tools &>/dev/null; then - echo "Development Tools are already installed." + if rpm -q gcc &>/dev/null && rpm -q python3.10-devel &>/dev/null; then + echo "Development Tools and Python 3.10 development files are already installed." else - echo "Installing Development Tools..." + echo "Installing Development Tools and Python 3.10 development files..." sudo dnf groupinstall -y "Development Tools" - sudo dnf install python3.10-devel + sudo dnf install -y python3.10-devel fi + else echo "Unsupported operating system. Please install build-essential or equivalent manually." exit 1 @@ -68,4 +71,14 @@ prepare_env(){ clean() { python3.10 -m pip cache purge +} + +yes_or_no() { + while true; do + read -p "$* [y/n]: " yn + case $yn in + [Yy]*) return 0 ;; + [Nn]*) echo "Aborted" ; return 1 ;; + esac + done } \ No newline at end of file