Installer v2.5 now checks out stable diffusion and applies patches

This commit is contained in:
cmdr2 2022-10-04 12:27:36 +05:30
parent 9e07228a90
commit 19a868b2df
5 changed files with 56 additions and 5 deletions

View File

@ -24,7 +24,6 @@ call git --version
call python --version call python --version
@rem Download the rest of the installer and UI @rem Download the rest of the installer and UI
@REM call installer\install-sd-ui.bat
call python installer\installer\main.py call python installer\installer\main.py
pause pause

View File

@ -3,9 +3,11 @@ import json
# config # config
PROJECT_REPO_URL = 'https://github.com/cmdr2/stable-diffusion-ui.git' PROJECT_REPO_URL = 'https://github.com/cmdr2/stable-diffusion-ui.git'
DEFAULT_UPDATE_BRANCH = 'installer_new' DEFAULT_PROJECT_BRANCH = 'installer_new'
PROJECT_REPO_DIR_NAME = 'project_repo' PROJECT_REPO_DIR_NAME = 'project_repo'
STABLE_DIFFUSION_REPO_URL = 'https://github.com/basujindal/stable-diffusion.git'
DEFAULT_STABLE_DIFFUSION_COMMIT = 'f6cfebffa752ee11a7b07497b8529d5971de916c'
STABLE_DIFFUSION_REPO_DIR_NAME = 'stable-diffusion' STABLE_DIFFUSION_REPO_DIR_NAME = 'stable-diffusion'
START_CMD_FILE_NAME = os.environ['START_CMD_FILENAME'] START_CMD_FILE_NAME = os.environ['START_CMD_FILENAME']

View File

@ -6,11 +6,13 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from installer.tasks import ( from installer.tasks import (
fetch_project_repo, fetch_project_repo,
apply_project_update, apply_project_update,
fetch_stable_diffusion_repo,
) )
tasks = [ tasks = [
fetch_project_repo, fetch_project_repo,
apply_project_update, apply_project_update,
fetch_stable_diffusion_repo,
] ]
def run_tasks(): def run_tasks():

View File

@ -5,7 +5,7 @@ from installer import app, helpers
project_repo_git_path = path.join(app.project_repo_dir_path, '.git') project_repo_git_path = path.join(app.project_repo_dir_path, '.git')
def run(): def run():
branch_name = app.config.get('update_branch', app.DEFAULT_UPDATE_BRANCH) branch_name = app.config.get('update_branch', app.DEFAULT_PROJECT_BRANCH)
if path.exists(project_repo_git_path): if path.exists(project_repo_git_path):
helpers.log(f"Stable Diffusion UI's git repository was already installed. Updating from {branch_name}..") helpers.log(f"Stable Diffusion UI's git repository was already installed. Updating from {branch_name}..")
@ -17,8 +17,10 @@ def run():
helpers.log("\nDownloading Stable Diffusion UI..\n") helpers.log("\nDownloading Stable Diffusion UI..\n")
helpers.log(f"Using the {branch_name} channel\n") helpers.log(f"Using the {branch_name} channel\n")
if helpers.run(f'git clone -b "{branch_name}" {app.PROJECT_REPO_URL} "{app.project_repo_dir_path}"'): if helpers.run(f'git clone {app.PROJECT_REPO_URL} "{app.project_repo_dir_path}"'):
helpers.log("Downloaded Stable Diffusion UI") helpers.log("Downloaded Stable Diffusion UI")
else: else:
helpers.show_install_error(error_msg="Could not download Stable Diffusion UI") helpers.show_install_error(error_msg="Could not download Stable Diffusion UI")
exit(1) exit(1)
helpers.run(f'git checkout "{branch_name}"', run_in_folder=app.project_repo_dir_path)

View File

@ -0,0 +1,46 @@
from os import path
from installer import app, helpers
patch_file_names = [
'sd_custom.patch',
]
stable_diffusion_repo_git_path = path.join(app.stable_diffusion_repo_dir_path, '.git')
patches_dir_path = path.join(app.installer_dir_path, 'patches')
is_developer_mode = app.config.get('is_developer_mode', False)
def run():
fetch_repo()
apply_patches()
def fetch_repo():
commit_id = app.config.get('stable_diffusion_commit', app.DEFAULT_STABLE_DIFFUSION_COMMIT)
if path.exists(stable_diffusion_repo_git_path):
helpers.log(f"Stable Diffusion's git repository was already installed. Using commit: {commit_id}..")
if not is_developer_mode:
helpers.run("git reset --hard", run_in_folder=app.stable_diffusion_repo_dir_path)
helpers.run(f'git checkout "{commit_id}"', run_in_folder=app.stable_diffusion_repo_dir_path)
helpers.run("git pull", run_in_folder=app.stable_diffusion_repo_dir_path)
else:
helpers.log("\nDownloading Stable Diffusion..\n")
helpers.log(f"Using commit: {commit_id}\n")
if helpers.run(f'git clone {app.STABLE_DIFFUSION_REPO_URL} "{app.stable_diffusion_repo_dir_path}"'):
helpers.log("Downloaded Stable Diffusion")
else:
helpers.show_install_error(error_msg="Could not download Stable Diffusion")
exit(1)
helpers.run(f'git checkout "{commit_id}"', run_in_folder=app.stable_diffusion_repo_dir_path)
def apply_patches():
if is_developer_mode:
return
for patch_file_name in patch_file_names:
patch_file_path = path.join(patches_dir_path, patch_file_name)
helpers.run(f"git apply {patch_file_path}", run_in_folder=app.stable_diffusion_repo_dir_path)