Initial files for installer v2.5
@ -1,24 +0,0 @@
|
|||||||
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#installation
|
|
||||||
|
|
||||||
After downloading, to install please follow these instructions:
|
|
||||||
|
|
||||||
For Windows:
|
|
||||||
- Please double-click the "Start Stable Diffusion UI.cmd" file inside the "stable-diffusion-ui" folder.
|
|
||||||
|
|
||||||
For Linux:
|
|
||||||
- Please open a terminal, and go to the "stable-diffusion-ui" directory. Then run ./start.sh
|
|
||||||
|
|
||||||
That file will automatically install everything. After that it will start the Stable Diffusion interface in a web browser.
|
|
||||||
|
|
||||||
To start the UI in the future, please run the same command mentioned above.
|
|
||||||
|
|
||||||
|
|
||||||
If you have any problems, please:
|
|
||||||
1. Try the troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting
|
|
||||||
2. Or, seek help from the community at https://discord.com/invite/u9yhsFmEkB
|
|
||||||
3. Or, file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues
|
|
||||||
|
|
||||||
Thanks
|
|
||||||
cmdr2 (and contributors to the project)
|
|
@ -1,8 +0,0 @@
|
|||||||
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
|
|
30
Start Stable Diffusion UI.cmd
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
echo. & echo "Stable Diffusion UI - v2.5" & echo.
|
||||||
|
|
||||||
|
set PATH=C:\Windows\System32;%PATH%
|
||||||
|
|
||||||
|
set RUN_CMD_FILENAME="Start Stable Diffusion UI.cmd"
|
||||||
|
|
||||||
|
set SD_BASE_DIR=%cd%
|
||||||
|
|
||||||
|
@rem Confirm or change the installation dir
|
||||||
|
call installer\bootstrap\check-install-dir.bat
|
||||||
|
|
||||||
|
@rem set the vars again, if the installer dir has changed
|
||||||
|
set SD_BASE_DIR=%cd%
|
||||||
|
|
||||||
|
echo Working in %SD_BASE_DIR%
|
||||||
|
|
||||||
|
@rem Setup the packages required for the installer
|
||||||
|
call installer\bootstrap\bootstrap.bat
|
||||||
|
|
||||||
|
@rem Test the bootstrap
|
||||||
|
call git --version
|
||||||
|
call python --version
|
||||||
|
|
||||||
|
@rem Download the rest of the installer and UI
|
||||||
|
@REM call installer\install-sd-ui.bat
|
||||||
|
call python installer\installer\main.py
|
||||||
|
|
||||||
|
pause
|
47
build.bat
@ -1,47 +0,0 @@
|
|||||||
@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
|
|
||||||
|
|
||||||
@set PYTHONNOUSERSITE=1
|
|
||||||
|
|
||||||
@mkdir dist\stable-diffusion-ui
|
|
||||||
|
|
||||||
@echo "Downloading components for the installer.."
|
|
||||||
|
|
||||||
@call conda env create --prefix installer -f environment.yaml
|
|
||||||
@call conda activate .\installer
|
|
||||||
|
|
||||||
@echo "Creating a distributable package.."
|
|
||||||
|
|
||||||
@call conda install -c conda-forge -y conda-pack
|
|
||||||
@call conda pack --n-threads -1 --prefix installer --format tar
|
|
||||||
|
|
||||||
@cd dist\stable-diffusion-ui
|
|
||||||
@mkdir installer
|
|
||||||
|
|
||||||
@call tar -xf ..\..\installer.tar -C installer
|
|
||||||
|
|
||||||
@mkdir scripts
|
|
||||||
|
|
||||||
@copy ..\..\scripts\on_env_start.bat scripts\
|
|
||||||
@copy "..\..\scripts\Start Stable Diffusion UI.cmd" .
|
|
||||||
@copy ..\..\LICENSE .
|
|
||||||
@copy "..\..\CreativeML Open RAIL-M License" .
|
|
||||||
@copy "..\..\How to install and run.txt" .
|
|
||||||
@echo. > scripts\install_status.txt
|
|
||||||
|
|
||||||
@echo "Build ready. Zip the 'dist\stable-diffusion-ui' folder."
|
|
||||||
|
|
||||||
@echo "Cleaning up.."
|
|
||||||
|
|
||||||
@cd ..\..
|
|
||||||
|
|
||||||
@rmdir /s /q installer
|
|
||||||
|
|
||||||
@del installer.tar
|
|
55
build.sh
@ -1,55 +0,0 @@
|
|||||||
#!/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
|
|
||||||
|
|
||||||
export PYTHONNOUSERSITE=1
|
|
||||||
|
|
||||||
mkdir -p dist/stable-diffusion-ui
|
|
||||||
|
|
||||||
echo "Downloading components for the installer.."
|
|
||||||
|
|
||||||
source ~/miniconda3/etc/profile.d/conda.sh
|
|
||||||
|
|
||||||
conda install -c conda-forge -y conda-pack
|
|
||||||
|
|
||||||
conda env create --prefix installer -f environment.yaml
|
|
||||||
conda activate ./installer
|
|
||||||
|
|
||||||
echo "Creating a distributable package.."
|
|
||||||
|
|
||||||
conda pack --n-threads -1 --prefix installer --format tar
|
|
||||||
|
|
||||||
cd dist/stable-diffusion-ui
|
|
||||||
mkdir installer
|
|
||||||
|
|
||||||
tar -xf ../../installer.tar -C installer
|
|
||||||
|
|
||||||
mkdir scripts
|
|
||||||
|
|
||||||
cp ../../scripts/on_env_start.sh scripts/
|
|
||||||
cp ../../scripts/start.sh .
|
|
||||||
cp ../../LICENSE .
|
|
||||||
cp "../../CreativeML Open RAIL-M License" .
|
|
||||||
cp "../../How to install and run.txt" .
|
|
||||||
echo "" > scripts/install_status.txt
|
|
||||||
|
|
||||||
chmod u+x start.sh
|
|
||||||
|
|
||||||
echo "Build ready. Zip the 'dist/stable-diffusion-ui' folder."
|
|
||||||
|
|
||||||
echo "Cleaning up.."
|
|
||||||
|
|
||||||
cd ../..
|
|
||||||
|
|
||||||
rm -rf installer
|
|
||||||
|
|
||||||
rm installer.tar
|
|
237
engine/server.py
Normal file
@ -0,0 +1,237 @@
|
|||||||
|
import json
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
SCRIPT_DIR = os.getcwd()
|
||||||
|
print('started in ', SCRIPT_DIR)
|
||||||
|
|
||||||
|
SD_UI_DIR = os.getenv('SD_UI_PATH', None)
|
||||||
|
sys.path.append(os.path.dirname(SD_UI_DIR))
|
||||||
|
|
||||||
|
CONFIG_DIR = os.path.join(SD_UI_DIR, '..', 'scripts')
|
||||||
|
|
||||||
|
OUTPUT_DIRNAME = "Stable Diffusion UI" # in the user's home folder
|
||||||
|
|
||||||
|
from fastapi import FastAPI, HTTPException
|
||||||
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
from starlette.responses import FileResponse, StreamingResponse
|
||||||
|
from pydantic import BaseModel
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from sd_internal import Request, Response
|
||||||
|
|
||||||
|
app = FastAPI()
|
||||||
|
|
||||||
|
model_loaded = False
|
||||||
|
model_is_loading = False
|
||||||
|
|
||||||
|
modifiers_cache = None
|
||||||
|
outpath = os.path.join(os.path.expanduser("~"), OUTPUT_DIRNAME)
|
||||||
|
|
||||||
|
# don't show access log entries for URLs that start with the given prefix
|
||||||
|
ACCESS_LOG_SUPPRESS_PATH_PREFIXES = ['/ping', '/modifier-thumbnails']
|
||||||
|
|
||||||
|
app.mount('/media', StaticFiles(directory=os.path.join(SD_UI_DIR, 'media/')), name="media")
|
||||||
|
|
||||||
|
# defaults from https://huggingface.co/blog/stable_diffusion
|
||||||
|
class ImageRequest(BaseModel):
|
||||||
|
session_id: str = "session"
|
||||||
|
prompt: str = ""
|
||||||
|
negative_prompt: str = ""
|
||||||
|
init_image: str = None # base64
|
||||||
|
mask: str = None # base64
|
||||||
|
num_outputs: int = 1
|
||||||
|
num_inference_steps: int = 50
|
||||||
|
guidance_scale: float = 7.5
|
||||||
|
width: int = 512
|
||||||
|
height: int = 512
|
||||||
|
seed: int = 42
|
||||||
|
prompt_strength: float = 0.8
|
||||||
|
sampler: str = None # "ddim", "plms", "heun", "euler", "euler_a", "dpm2", "dpm2_a", "lms"
|
||||||
|
# allow_nsfw: bool = False
|
||||||
|
save_to_disk_path: str = None
|
||||||
|
turbo: bool = True
|
||||||
|
use_cpu: bool = False
|
||||||
|
use_full_precision: bool = False
|
||||||
|
use_face_correction: str = None # or "GFPGANv1.3"
|
||||||
|
use_upscale: str = None # or "RealESRGAN_x4plus" or "RealESRGAN_x4plus_anime_6B"
|
||||||
|
show_only_filtered_image: bool = False
|
||||||
|
|
||||||
|
stream_progress_updates: bool = False
|
||||||
|
stream_image_progress: bool = False
|
||||||
|
|
||||||
|
class SetAppConfigRequest(BaseModel):
|
||||||
|
update_branch: str = "main"
|
||||||
|
|
||||||
|
@app.get('/')
|
||||||
|
def read_root():
|
||||||
|
headers = {"Cache-Control": "no-cache, no-store, must-revalidate", "Pragma": "no-cache", "Expires": "0"}
|
||||||
|
return FileResponse(os.path.join(SD_UI_DIR, 'index.html'), headers=headers)
|
||||||
|
|
||||||
|
@app.get('/ping')
|
||||||
|
async def ping():
|
||||||
|
global model_loaded, model_is_loading
|
||||||
|
|
||||||
|
try:
|
||||||
|
if model_loaded:
|
||||||
|
return {'OK'}
|
||||||
|
|
||||||
|
if model_is_loading:
|
||||||
|
return {'ERROR'}
|
||||||
|
|
||||||
|
model_is_loading = True
|
||||||
|
|
||||||
|
from sd_internal import runtime
|
||||||
|
|
||||||
|
custom_weight_path = os.path.join(SCRIPT_DIR, 'custom-model.ckpt')
|
||||||
|
ckpt_to_use = "sd-v1-4" if not os.path.exists(custom_weight_path) else "custom-model"
|
||||||
|
runtime.load_model_ckpt(ckpt_to_use=ckpt_to_use)
|
||||||
|
|
||||||
|
model_loaded = True
|
||||||
|
model_is_loading = False
|
||||||
|
|
||||||
|
return {'OK'}
|
||||||
|
except Exception as e:
|
||||||
|
print(traceback.format_exc())
|
||||||
|
return HTTPException(status_code=500, detail=str(e))
|
||||||
|
|
||||||
|
@app.post('/image')
|
||||||
|
def image(req : ImageRequest):
|
||||||
|
from sd_internal import runtime
|
||||||
|
|
||||||
|
r = Request()
|
||||||
|
r.session_id = req.session_id
|
||||||
|
r.prompt = req.prompt
|
||||||
|
r.negative_prompt = req.negative_prompt
|
||||||
|
r.init_image = req.init_image
|
||||||
|
r.mask = req.mask
|
||||||
|
r.num_outputs = req.num_outputs
|
||||||
|
r.num_inference_steps = req.num_inference_steps
|
||||||
|
r.guidance_scale = req.guidance_scale
|
||||||
|
r.width = req.width
|
||||||
|
r.height = req.height
|
||||||
|
r.seed = req.seed
|
||||||
|
r.prompt_strength = req.prompt_strength
|
||||||
|
r.sampler = req.sampler
|
||||||
|
# r.allow_nsfw = req.allow_nsfw
|
||||||
|
r.turbo = req.turbo
|
||||||
|
r.use_cpu = req.use_cpu
|
||||||
|
r.use_full_precision = req.use_full_precision
|
||||||
|
r.save_to_disk_path = req.save_to_disk_path
|
||||||
|
r.use_upscale: str = req.use_upscale
|
||||||
|
r.use_face_correction = req.use_face_correction
|
||||||
|
r.show_only_filtered_image = req.show_only_filtered_image
|
||||||
|
|
||||||
|
r.stream_progress_updates = True # the underlying implementation only supports streaming
|
||||||
|
r.stream_image_progress = req.stream_image_progress
|
||||||
|
|
||||||
|
try:
|
||||||
|
if not req.stream_progress_updates:
|
||||||
|
r.stream_image_progress = False
|
||||||
|
|
||||||
|
res = runtime.mk_img(r)
|
||||||
|
|
||||||
|
if req.stream_progress_updates:
|
||||||
|
return StreamingResponse(res, media_type='application/json')
|
||||||
|
else: # compatibility mode: buffer the streaming responses, and return the last one
|
||||||
|
last_result = None
|
||||||
|
|
||||||
|
for result in res:
|
||||||
|
last_result = result
|
||||||
|
|
||||||
|
return json.loads(last_result)
|
||||||
|
except Exception as e:
|
||||||
|
print(traceback.format_exc())
|
||||||
|
return HTTPException(status_code=500, detail=str(e))
|
||||||
|
|
||||||
|
@app.get('/image/stop')
|
||||||
|
def stop():
|
||||||
|
try:
|
||||||
|
if model_is_loading:
|
||||||
|
return {'ERROR'}
|
||||||
|
|
||||||
|
from sd_internal import runtime
|
||||||
|
runtime.stop_processing = True
|
||||||
|
|
||||||
|
return {'OK'}
|
||||||
|
except Exception as e:
|
||||||
|
print(traceback.format_exc())
|
||||||
|
return HTTPException(status_code=500, detail=str(e))
|
||||||
|
|
||||||
|
@app.get('/image/tmp/{session_id}/{img_id}')
|
||||||
|
def get_image(session_id, img_id):
|
||||||
|
from sd_internal import runtime
|
||||||
|
buf = runtime.temp_images[session_id + '/' + img_id]
|
||||||
|
buf.seek(0)
|
||||||
|
return StreamingResponse(buf, media_type='image/jpeg')
|
||||||
|
|
||||||
|
@app.post('/app_config')
|
||||||
|
async def setAppConfig(req : SetAppConfigRequest):
|
||||||
|
try:
|
||||||
|
config = {
|
||||||
|
'update_branch': req.update_branch
|
||||||
|
}
|
||||||
|
|
||||||
|
config_json_str = json.dumps(config)
|
||||||
|
config_bat_str = f'@set update_branch={req.update_branch}'
|
||||||
|
config_sh_str = f'export update_branch={req.update_branch}'
|
||||||
|
|
||||||
|
config_json_path = os.path.join(CONFIG_DIR, 'config.json')
|
||||||
|
config_bat_path = os.path.join(CONFIG_DIR, 'config.bat')
|
||||||
|
config_sh_path = os.path.join(CONFIG_DIR, 'config.sh')
|
||||||
|
|
||||||
|
with open(config_json_path, 'w') as f:
|
||||||
|
f.write(config_json_str)
|
||||||
|
|
||||||
|
with open(config_bat_path, 'w') as f:
|
||||||
|
f.write(config_bat_str)
|
||||||
|
|
||||||
|
with open(config_sh_path, 'w') as f:
|
||||||
|
f.write(config_sh_str)
|
||||||
|
|
||||||
|
return {'OK'}
|
||||||
|
except Exception as e:
|
||||||
|
print(traceback.format_exc())
|
||||||
|
return HTTPException(status_code=500, detail=str(e))
|
||||||
|
|
||||||
|
@app.get('/app_config')
|
||||||
|
def getAppConfig():
|
||||||
|
try:
|
||||||
|
config_json_path = os.path.join(CONFIG_DIR, 'config.json')
|
||||||
|
|
||||||
|
if not os.path.exists(config_json_path):
|
||||||
|
return HTTPException(status_code=500, detail="No config file")
|
||||||
|
|
||||||
|
with open(config_json_path, 'r') as f:
|
||||||
|
config_json_str = f.read()
|
||||||
|
config = json.loads(config_json_str)
|
||||||
|
return config
|
||||||
|
except Exception as e:
|
||||||
|
print(traceback.format_exc())
|
||||||
|
return HTTPException(status_code=500, detail=str(e))
|
||||||
|
|
||||||
|
@app.get('/modifiers.json')
|
||||||
|
def read_modifiers():
|
||||||
|
headers = {"Cache-Control": "no-cache, no-store, must-revalidate", "Pragma": "no-cache", "Expires": "0"}
|
||||||
|
return FileResponse(os.path.join(SD_UI_DIR, 'modifiers.json'), headers=headers)
|
||||||
|
|
||||||
|
@app.get('/output_dir')
|
||||||
|
def read_home_dir():
|
||||||
|
return {outpath}
|
||||||
|
|
||||||
|
# don't log certain requests
|
||||||
|
class LogSuppressFilter(logging.Filter):
|
||||||
|
def filter(self, record: logging.LogRecord) -> bool:
|
||||||
|
path = record.getMessage()
|
||||||
|
for prefix in ACCESS_LOG_SUPPRESS_PATH_PREFIXES:
|
||||||
|
if path.find(prefix) != -1:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
logging.getLogger('uvicorn.access').addFilter(LogSuppressFilter())
|
||||||
|
|
||||||
|
# start the browser ui
|
||||||
|
import webbrowser; webbrowser.open('http://localhost:9000')
|
@ -1,7 +0,0 @@
|
|||||||
name: stable-diffusion-ui-installer
|
|
||||||
channels:
|
|
||||||
- defaults
|
|
||||||
- conda-forge
|
|
||||||
dependencies:
|
|
||||||
- conda
|
|
||||||
- git
|
|
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 45 KiB |
BIN
media/ding.mp3
Before Width: | Height: | Size: 122 KiB |
Before Width: | Height: | Size: 67 KiB |
Before Width: | Height: | Size: 244 KiB |
@ -1,19 +0,0 @@
|
|||||||
@echo off
|
|
||||||
|
|
||||||
@REM Delete the post-activate hook from the old installer
|
|
||||||
if exist "installer\etc\conda\activate.d\post_activate.bat" (
|
|
||||||
echo. > installer\etc\conda\activate.d\post_activate.bat
|
|
||||||
)
|
|
||||||
|
|
||||||
@call installer\Scripts\activate.bat
|
|
||||||
|
|
||||||
@call conda-unpack
|
|
||||||
|
|
||||||
@call conda --version
|
|
||||||
@call git --version
|
|
||||||
|
|
||||||
@cd installer
|
|
||||||
|
|
||||||
@call ..\scripts\on_env_start.bat
|
|
||||||
|
|
||||||
@pause
|
|
@ -1,61 +0,0 @@
|
|||||||
@echo off
|
|
||||||
|
|
||||||
@echo. & echo "Stable Diffusion UI - v2" & echo.
|
|
||||||
|
|
||||||
set PATH=C:\Windows\System32;%PATH%
|
|
||||||
|
|
||||||
@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 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 -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. 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
|
|
||||||
@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
|
|
@ -1,43 +0,0 @@
|
|||||||
#!/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 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 -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. 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
|
|
||||||
|
|
||||||
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"
|
|
@ -1,317 +0,0 @@
|
|||||||
@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) if os.path.exists(dst) else print(''); print('Hotfixed broken JSON file from OpenAI');"
|
|
||||||
|
|
||||||
@>nul grep -c "sd_git_cloned" scripts\install_status.txt
|
|
||||||
@if "%ERRORLEVEL%" EQU "0" (
|
|
||||||
@echo "Stable Diffusion's git repository was already installed. Updating.."
|
|
||||||
|
|
||||||
@cd stable-diffusion
|
|
||||||
|
|
||||||
@call git reset --hard
|
|
||||||
@call git pull
|
|
||||||
@call git checkout f6cfebffa752ee11a7b07497b8529d5971de916c
|
|
||||||
|
|
||||||
@call git apply ..\ui\sd_internal\ddim_callback.patch
|
|
||||||
@call git apply ..\ui\sd_internal\env_yaml.patch
|
|
||||||
|
|
||||||
@cd ..
|
|
||||||
) else (
|
|
||||||
@echo. & echo "Downloading Stable Diffusion.." & echo.
|
|
||||||
|
|
||||||
@call git clone https://github.com/basujindal/stable-diffusion.git && (
|
|
||||||
@echo sd_git_cloned >> scripts\install_status.txt
|
|
||||||
) || (
|
|
||||||
@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 f6cfebffa752ee11a7b07497b8529d5971de916c
|
|
||||||
|
|
||||||
@call git apply ..\ui\sd_internal\ddim_callback.patch
|
|
||||||
@call git apply ..\ui\sd_internal\env_yaml.patch
|
|
||||||
|
|
||||||
@cd ..
|
|
||||||
)
|
|
||||||
|
|
||||||
@cd stable-diffusion
|
|
||||||
|
|
||||||
@>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
|
|
||||||
|
|
||||||
@REM prevent conda from using packages from the user's home directory, to avoid conflicts
|
|
||||||
@set PYTHONNOUSERSITE=1
|
|
||||||
|
|
||||||
@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
|
|
||||||
|
|
||||||
@call conda install -c conda-forge -y --prefix env antlr4-python3-runtime=4.8 || (
|
|
||||||
@echo. & echo "Error installing antlr4-python3-runtime 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
|
|
||||||
)
|
|
||||||
|
|
||||||
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
|
|
||||||
)
|
|
||||||
|
|
||||||
set PATH=C:\Windows\System32;%PATH%
|
|
||||||
|
|
||||||
@>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.
|
|
||||||
|
|
||||||
@set PYTHONNOUSERSITE=1
|
|
||||||
|
|
||||||
@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
|
|
||||||
)
|
|
||||||
|
|
||||||
@call pip install basicsr==1.4.2 || (
|
|
||||||
@echo. & echo "Error installing the basicsr package 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.
|
|
||||||
|
|
||||||
@set PYTHONNOUSERSITE=1
|
|
||||||
|
|
||||||
@call pip install -e git+https://github.com/xinntao/Real-ESRGAN#egg=realesrgan || (
|
|
||||||
@echo. & echo "Error installing the packages necessary for ESRGAN (Resolution Upscaling). Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo.
|
|
||||||
pause
|
|
||||||
exit /b
|
|
||||||
)
|
|
||||||
|
|
||||||
for /f "tokens=*" %%a in ('python -c "from basicsr.archs.rrdbnet_arch import RRDBNet; from realesrgan import RealESRGANer; print(42)"') do if "%%a" NEQ "42" (
|
|
||||||
@echo. & echo "Dependency test failed! Error installing the packages necessary for ESRGAN (Resolution Upscaling). Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo.
|
|
||||||
pause
|
|
||||||
exit /b
|
|
||||||
)
|
|
||||||
|
|
||||||
@echo conda_sd_esrgan_deps_installed >> ..\scripts\install_status.txt
|
|
||||||
)
|
|
||||||
|
|
||||||
@>nul grep -c "conda_sd_ui_deps_installed" ..\scripts\install_status.txt
|
|
||||||
@if "%ERRORLEVEL%" EQU "0" (
|
|
||||||
echo "Packages necessary for Stable Diffusion UI were already installed"
|
|
||||||
) else (
|
|
||||||
@echo. & echo "Downloading packages necessary for Stable Diffusion UI.." & echo.
|
|
||||||
|
|
||||||
@set PYTHONNOUSERSITE=1
|
|
||||||
|
|
||||||
@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" (
|
|
||||||
for %%I in ("sd-v1-4.ckpt") do if "%%~zI" EQU "4265380512" (
|
|
||||||
echo "Data files (weights) necessary for Stable Diffusion were already downloaded. Using the HuggingFace 4 GB Model."
|
|
||||||
) else (
|
|
||||||
for %%J in ("sd-v1-4.ckpt") do if "%%~zJ" EQU "7703807346" (
|
|
||||||
echo "Data files (weights) necessary for Stable Diffusion were already downloaded. Using the HuggingFace 7 GB Model."
|
|
||||||
) else (
|
|
||||||
for %%K in ("sd-v1-4.ckpt") do if "%%~zK" EQU "7703810927" (
|
|
||||||
echo "Data files (weights) necessary for Stable Diffusion were already downloaded. Using the Waifu Model."
|
|
||||||
) else (
|
|
||||||
echo. & echo "The model file present at %cd%\sd-v1-4.ckpt is invalid. It is only %%~zK 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 -k https://me.cmdr2.org/stable-diffusion-ui/sd-v1-4.ckpt > sd-v1-4.ckpt
|
|
||||||
|
|
||||||
@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_DIR=%cd%
|
|
||||||
|
|
||||||
@cd env\lib\site-packages
|
|
||||||
@set PYTHONPATH=%SD_DIR%;%cd%
|
|
||||||
@cd ..\..\..
|
|
||||||
@echo PYTHONPATH=%PYTHONPATH%
|
|
||||||
|
|
||||||
@cd ..
|
|
||||||
@set SD_UI_PATH=%cd%\ui
|
|
||||||
@cd stable-diffusion
|
|
||||||
|
|
||||||
@call python --version
|
|
||||||
|
|
||||||
@uvicorn server:app --app-dir "%SD_UI_PATH%" --port 9000 --host 0.0.0.0
|
|
||||||
|
|
||||||
@pause
|
|
@ -1,309 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
cp sd-ui-files/scripts/on_env_start.sh scripts/
|
|
||||||
|
|
||||||
source installer/etc/profile.d/conda.sh
|
|
||||||
|
|
||||||
python -c "import os; import shutil; frm = 'sd-ui-files/ui/hotfix/9c24e6cd9f499d02c4f21a033736dabd365962dc80fe3aeb57a8f85ea45a20a3.26fead7ea4f0f843f6eb4055dfd25693f1a71f3c6871b184042d4b126244e142'; dst = os.path.join(os.path.expanduser('~'), '.cache', 'huggingface', 'transformers', '9c24e6cd9f499d02c4f21a033736dabd365962dc80fe3aeb57a8f85ea45a20a3.26fead7ea4f0f843f6eb4055dfd25693f1a71f3c6871b184042d4b126244e142'); shutil.copyfile(frm, dst) if os.path.exists(dst) else print(''); 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 f6cfebffa752ee11a7b07497b8529d5971de916c
|
|
||||||
|
|
||||||
git apply ../ui/sd_internal/ddim_callback.patch
|
|
||||||
git apply ../ui/sd_internal/env_yaml.patch
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
else
|
|
||||||
printf "\n\nDownloading Stable Diffusion..\n\n"
|
|
||||||
|
|
||||||
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. 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 f6cfebffa752ee11a7b07497b8529d5971de916c
|
|
||||||
|
|
||||||
git apply ../ui/sd_internal/ddim_callback.patch
|
|
||||||
git apply ../ui/sd_internal/env_yaml.patch
|
|
||||||
|
|
||||||
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"
|
|
||||||
|
|
||||||
# prevent conda from using packages from the user's home directory, to avoid conflicts
|
|
||||||
export PYTHONNOUSERSITE=1
|
|
||||||
|
|
||||||
if conda env create --prefix env --force -f environment.yaml ; then
|
|
||||||
echo "Installed. Testing.."
|
|
||||||
else
|
|
||||||
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
|
|
||||||
|
|
||||||
if conda install -c conda-forge --prefix ./env -y antlr4-python3-runtime=4.8 ; then
|
|
||||||
echo "Installed. Testing.."
|
|
||||||
else
|
|
||||||
printf "\n\nError installing antlr4-python3-runtime 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
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
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"
|
|
||||||
|
|
||||||
export PYTHONNOUSERSITE=1
|
|
||||||
|
|
||||||
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"
|
|
||||||
|
|
||||||
export PYTHONNOUSERSITE=1
|
|
||||||
|
|
||||||
if pip install -e git+https://github.com/xinntao/Real-ESRGAN#egg=realesrgan ; then
|
|
||||||
echo "Installed. Testing.."
|
|
||||||
else
|
|
||||||
printf "\n\nError installing the packages necessary for ESRGAN (Resolution Upscaling). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n"
|
|
||||||
read -p "Press any key to continue"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
out_test=`python -c "from basicsr.archs.rrdbnet_arch import RRDBNet; from realesrgan import RealESRGANer; print(42)"`
|
|
||||||
if [ "$out_test" != "42" ]; then
|
|
||||||
printf "\n\nDependency test failed! Error installing the packages necessary for ESRGAN (Resolution Upscaling). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/blob/main/Troubleshooting.md\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n"
|
|
||||||
read -p "Press any key to continue"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo conda_sd_esrgan_deps_installed >> ../scripts/install_status.txt
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ `grep -c conda_sd_ui_deps_installed ../scripts/install_status.txt` -gt "0" ]; then
|
|
||||||
echo "Packages necessary for Stable Diffusion UI were already installed"
|
|
||||||
else
|
|
||||||
printf "\n\nDownloading packages necessary for Stable Diffusion UI..\n\n"
|
|
||||||
|
|
||||||
export PYTHONNOUSERSITE=1
|
|
||||||
|
|
||||||
if conda install -c conda-forge --prefix ./env -y uvicorn fastapi ; then
|
|
||||||
echo "Installed. Testing.."
|
|
||||||
else
|
|
||||||
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=`find "sd-v1-4.ckpt" -printf "%s"`
|
|
||||||
|
|
||||||
if [ "$model_size" -eq "4265380512" ] || [ "$model_size" -eq "7703807346" ] || [ "$model_size" -eq "7703810927" ]; 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=`find "sd-v1-4.ckpt" -printf "%s"`
|
|
||||||
if [ ! "$model_size" == "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 "GFPGANv1.3.pth" ]; then
|
|
||||||
model_size=`find "GFPGANv1.3.pth" -printf "%s"`
|
|
||||||
|
|
||||||
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=`find "GFPGANv1.3.pth" -printf "%s"`
|
|
||||||
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=`find "RealESRGAN_x4plus.pth" -printf "%s"`
|
|
||||||
|
|
||||||
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=`find "RealESRGAN_x4plus.pth" -printf "%s"`
|
|
||||||
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=`find "RealESRGAN_x4plus_anime_6B.pth" -printf "%s"`
|
|
||||||
|
|
||||||
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=`find "RealESRGAN_x4plus_anime_6B.pth" -printf "%s"`
|
|
||||||
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"
|
|
||||||
|
|
||||||
SD_PATH=`pwd`
|
|
||||||
export PYTHONPATH="$SD_PATH;$SD_PATH/env/lib/python3.8/site-packages"
|
|
||||||
echo "PYTHONPATH=$PYTHONPATH"
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
export SD_UI_PATH=`pwd`/ui
|
|
||||||
cd stable-diffusion
|
|
||||||
|
|
||||||
python --version
|
|
||||||
|
|
||||||
uvicorn server:app --app-dir "$SD_UI_PATH" --port 9000 --host 0.0.0.0
|
|
||||||
|
|
||||||
read -p "Press any key to continue"
|
|
@ -1,6 +0,0 @@
|
|||||||
@call conda --version
|
|
||||||
@call git --version
|
|
||||||
|
|
||||||
cd %CONDA_PREFIX%\..\scripts
|
|
||||||
|
|
||||||
on_env_start.bat
|
|
@ -1,12 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
conda-unpack
|
|
||||||
|
|
||||||
source $CONDA_PREFIX/etc/profile.d/conda.sh
|
|
||||||
|
|
||||||
conda --version
|
|
||||||
git --version
|
|
||||||
|
|
||||||
cd $CONDA_PREFIX/../scripts
|
|
||||||
|
|
||||||
./on_env_start.sh
|
|
@ -1,10 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
source installer/bin/activate
|
|
||||||
|
|
||||||
conda-unpack
|
|
||||||
|
|
||||||
conda --version
|
|
||||||
git --version
|
|
||||||
|
|
||||||
scripts/on_env_start.sh
|
|
@ -1,2 +0,0 @@
|
|||||||
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name LongPathsEnabled -Type DWord -Value 1
|
|
||||||
pause
|
|
@ -1,171 +0,0 @@
|
|||||||
{
|
|
||||||
"_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
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,332 +0,0 @@
|
|||||||
diff --git a/optimizedSD/ddpm.py b/optimizedSD/ddpm.py
|
|
||||||
index b967b55..35ef520 100644
|
|
||||||
--- a/optimizedSD/ddpm.py
|
|
||||||
+++ b/optimizedSD/ddpm.py
|
|
||||||
@@ -22,7 +22,7 @@ from ldm.util import exists, default, instantiate_from_config
|
|
||||||
from ldm.modules.diffusionmodules.util import make_beta_schedule
|
|
||||||
from ldm.modules.diffusionmodules.util import make_ddim_sampling_parameters, make_ddim_timesteps, noise_like
|
|
||||||
from ldm.modules.diffusionmodules.util import make_beta_schedule, extract_into_tensor, noise_like
|
|
||||||
-from samplers import CompVisDenoiser, get_ancestral_step, to_d, append_dims,linear_multistep_coeff
|
|
||||||
+from .samplers import CompVisDenoiser, get_ancestral_step, to_d, append_dims,linear_multistep_coeff
|
|
||||||
|
|
||||||
def disabled_train(self):
|
|
||||||
"""Overwrite model.train with this function to make sure train/eval mode
|
|
||||||
@@ -506,6 +506,8 @@ class UNet(DDPM):
|
|
||||||
|
|
||||||
x_latent = noise if x0 is None else x0
|
|
||||||
# sampling
|
|
||||||
+ if sampler in ('ddim', 'dpm2', 'heun', 'dpm2_a', 'lms') and not hasattr(self, 'ddim_timesteps'):
|
|
||||||
+ self.make_schedule(ddim_num_steps=S, ddim_eta=eta, verbose=False)
|
|
||||||
|
|
||||||
if sampler == "plms":
|
|
||||||
self.make_schedule(ddim_num_steps=S, ddim_eta=eta, verbose=False)
|
|
||||||
@@ -528,39 +530,46 @@ class UNet(DDPM):
|
|
||||||
elif sampler == "ddim":
|
|
||||||
samples = self.ddim_sampling(x_latent, conditioning, S, unconditional_guidance_scale=unconditional_guidance_scale,
|
|
||||||
unconditional_conditioning=unconditional_conditioning,
|
|
||||||
- mask = mask,init_latent=x_T,use_original_steps=False)
|
|
||||||
+ mask = mask,init_latent=x_T,use_original_steps=False,
|
|
||||||
+ callback=callback, img_callback=img_callback)
|
|
||||||
|
|
||||||
elif sampler == "euler":
|
|
||||||
self.make_schedule(ddim_num_steps=S, ddim_eta=eta, verbose=False)
|
|
||||||
samples = self.euler_sampling(self.alphas_cumprod,x_latent, S, conditioning, unconditional_conditioning=unconditional_conditioning,
|
|
||||||
- unconditional_guidance_scale=unconditional_guidance_scale)
|
|
||||||
+ unconditional_guidance_scale=unconditional_guidance_scale,
|
|
||||||
+ img_callback=img_callback)
|
|
||||||
elif sampler == "euler_a":
|
|
||||||
self.make_schedule(ddim_num_steps=S, ddim_eta=eta, verbose=False)
|
|
||||||
samples = self.euler_ancestral_sampling(self.alphas_cumprod,x_latent, S, conditioning, unconditional_conditioning=unconditional_conditioning,
|
|
||||||
- unconditional_guidance_scale=unconditional_guidance_scale)
|
|
||||||
+ unconditional_guidance_scale=unconditional_guidance_scale,
|
|
||||||
+ img_callback=img_callback)
|
|
||||||
|
|
||||||
elif sampler == "dpm2":
|
|
||||||
samples = self.dpm_2_sampling(self.alphas_cumprod,x_latent, S, conditioning, unconditional_conditioning=unconditional_conditioning,
|
|
||||||
- unconditional_guidance_scale=unconditional_guidance_scale)
|
|
||||||
+ unconditional_guidance_scale=unconditional_guidance_scale,
|
|
||||||
+ img_callback=img_callback)
|
|
||||||
elif sampler == "heun":
|
|
||||||
samples = self.heun_sampling(self.alphas_cumprod,x_latent, S, conditioning, unconditional_conditioning=unconditional_conditioning,
|
|
||||||
- unconditional_guidance_scale=unconditional_guidance_scale)
|
|
||||||
+ unconditional_guidance_scale=unconditional_guidance_scale,
|
|
||||||
+ img_callback=img_callback)
|
|
||||||
|
|
||||||
elif sampler == "dpm2_a":
|
|
||||||
samples = self.dpm_2_ancestral_sampling(self.alphas_cumprod,x_latent, S, conditioning, unconditional_conditioning=unconditional_conditioning,
|
|
||||||
- unconditional_guidance_scale=unconditional_guidance_scale)
|
|
||||||
+ unconditional_guidance_scale=unconditional_guidance_scale,
|
|
||||||
+ img_callback=img_callback)
|
|
||||||
|
|
||||||
|
|
||||||
elif sampler == "lms":
|
|
||||||
samples = self.lms_sampling(self.alphas_cumprod,x_latent, S, conditioning, unconditional_conditioning=unconditional_conditioning,
|
|
||||||
- unconditional_guidance_scale=unconditional_guidance_scale)
|
|
||||||
+ unconditional_guidance_scale=unconditional_guidance_scale,
|
|
||||||
+ img_callback=img_callback)
|
|
||||||
+
|
|
||||||
+ yield from samples
|
|
||||||
|
|
||||||
if(self.turbo):
|
|
||||||
self.model1.to("cpu")
|
|
||||||
self.model2.to("cpu")
|
|
||||||
|
|
||||||
- return samples
|
|
||||||
-
|
|
||||||
@torch.no_grad()
|
|
||||||
def plms_sampling(self, cond,b, img,
|
|
||||||
ddim_use_original_steps=False,
|
|
||||||
@@ -599,10 +608,10 @@ class UNet(DDPM):
|
|
||||||
old_eps.append(e_t)
|
|
||||||
if len(old_eps) >= 4:
|
|
||||||
old_eps.pop(0)
|
|
||||||
- if callback: callback(i)
|
|
||||||
- if img_callback: img_callback(pred_x0, i)
|
|
||||||
+ if callback: yield from callback(i)
|
|
||||||
+ if img_callback: yield from img_callback(pred_x0, i)
|
|
||||||
|
|
||||||
- return img
|
|
||||||
+ yield from img_callback(img, len(iterator)-1)
|
|
||||||
|
|
||||||
@torch.no_grad()
|
|
||||||
def p_sample_plms(self, x, c, t, index, repeat_noise=False, use_original_steps=False, quantize_denoised=False,
|
|
||||||
@@ -706,7 +715,8 @@ class UNet(DDPM):
|
|
||||||
|
|
||||||
@torch.no_grad()
|
|
||||||
def ddim_sampling(self, x_latent, cond, t_start, unconditional_guidance_scale=1.0, unconditional_conditioning=None,
|
|
||||||
- mask = None,init_latent=None,use_original_steps=False):
|
|
||||||
+ mask = None,init_latent=None,use_original_steps=False,
|
|
||||||
+ callback=None, img_callback=None):
|
|
||||||
|
|
||||||
timesteps = self.ddim_timesteps
|
|
||||||
timesteps = timesteps[:t_start]
|
|
||||||
@@ -730,10 +740,13 @@ class UNet(DDPM):
|
|
||||||
unconditional_guidance_scale=unconditional_guidance_scale,
|
|
||||||
unconditional_conditioning=unconditional_conditioning)
|
|
||||||
|
|
||||||
+ if callback: yield from callback(i)
|
|
||||||
+ if img_callback: yield from img_callback(x_dec, i)
|
|
||||||
+
|
|
||||||
if mask is not None:
|
|
||||||
- return x0 * mask + (1. - mask) * x_dec
|
|
||||||
+ x_dec = x0 * mask + (1. - mask) * x_dec
|
|
||||||
|
|
||||||
- return x_dec
|
|
||||||
+ yield from img_callback(x_dec, len(iterator)-1)
|
|
||||||
|
|
||||||
|
|
||||||
@torch.no_grad()
|
|
||||||
@@ -779,13 +792,16 @@ class UNet(DDPM):
|
|
||||||
|
|
||||||
|
|
||||||
@torch.no_grad()
|
|
||||||
- def euler_sampling(self, ac, x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1,extra_args=None,callback=None, disable=None, s_churn=0., s_tmin=0., s_tmax=float('inf'), s_noise=1.):
|
|
||||||
+ def euler_sampling(self, ac, x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1,extra_args=None,callback=None, disable=None, s_churn=0., s_tmin=0., s_tmax=float('inf'), s_noise=1.,
|
|
||||||
+ img_callback=None):
|
|
||||||
"""Implements Algorithm 2 (Euler steps) from Karras et al. (2022)."""
|
|
||||||
extra_args = {} if extra_args is None else extra_args
|
|
||||||
cvd = CompVisDenoiser(ac)
|
|
||||||
sigmas = cvd.get_sigmas(S)
|
|
||||||
x = x*sigmas[0]
|
|
||||||
|
|
||||||
+ print(f"Running Euler Sampling with {len(sigmas) - 1} timesteps")
|
|
||||||
+
|
|
||||||
s_in = x.new_ones([x.shape[0]]).half()
|
|
||||||
for i in trange(len(sigmas) - 1, disable=disable):
|
|
||||||
gamma = min(s_churn / (len(sigmas) - 1), 2 ** 0.5 - 1) if s_tmin <= sigmas[i] <= s_tmax else 0.
|
|
||||||
@@ -807,13 +823,18 @@ class UNet(DDPM):
|
|
||||||
d = to_d(x, sigma_hat, denoised)
|
|
||||||
if callback is not None:
|
|
||||||
callback({'x': x, 'i': i, 'sigma': sigmas[i], 'sigma_hat': sigma_hat, 'denoised': denoised})
|
|
||||||
+
|
|
||||||
+ if img_callback: yield from img_callback(x, i)
|
|
||||||
+
|
|
||||||
dt = sigmas[i + 1] - sigma_hat
|
|
||||||
# Euler method
|
|
||||||
x = x + d * dt
|
|
||||||
- return x
|
|
||||||
+
|
|
||||||
+ yield from img_callback(x, len(sigmas)-1)
|
|
||||||
|
|
||||||
@torch.no_grad()
|
|
||||||
- def euler_ancestral_sampling(self,ac,x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1,extra_args=None, callback=None, disable=None):
|
|
||||||
+ def euler_ancestral_sampling(self,ac,x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1,extra_args=None, callback=None, disable=None,
|
|
||||||
+ img_callback=None):
|
|
||||||
"""Ancestral sampling with Euler method steps."""
|
|
||||||
extra_args = {} if extra_args is None else extra_args
|
|
||||||
|
|
||||||
@@ -822,6 +843,8 @@ class UNet(DDPM):
|
|
||||||
sigmas = cvd.get_sigmas(S)
|
|
||||||
x = x*sigmas[0]
|
|
||||||
|
|
||||||
+ print(f"Running Euler Ancestral Sampling with {len(sigmas) - 1} timesteps")
|
|
||||||
+
|
|
||||||
s_in = x.new_ones([x.shape[0]]).half()
|
|
||||||
for i in trange(len(sigmas) - 1, disable=disable):
|
|
||||||
|
|
||||||
@@ -837,17 +860,22 @@ class UNet(DDPM):
|
|
||||||
sigma_down, sigma_up = get_ancestral_step(sigmas[i], sigmas[i + 1])
|
|
||||||
if callback is not None:
|
|
||||||
callback({'x': x, 'i': i, 'sigma': sigmas[i], 'sigma_hat': sigmas[i], 'denoised': denoised})
|
|
||||||
+
|
|
||||||
+ if img_callback: yield from img_callback(x, i)
|
|
||||||
+
|
|
||||||
d = to_d(x, sigmas[i], denoised)
|
|
||||||
# Euler method
|
|
||||||
dt = sigma_down - sigmas[i]
|
|
||||||
x = x + d * dt
|
|
||||||
x = x + torch.randn_like(x) * sigma_up
|
|
||||||
- return x
|
|
||||||
+
|
|
||||||
+ yield from img_callback(x, len(sigmas)-1)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@torch.no_grad()
|
|
||||||
- def heun_sampling(self, ac, x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1, extra_args=None, callback=None, disable=None, s_churn=0., s_tmin=0., s_tmax=float('inf'), s_noise=1.):
|
|
||||||
+ def heun_sampling(self, ac, x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1, extra_args=None, callback=None, disable=None, s_churn=0., s_tmin=0., s_tmax=float('inf'), s_noise=1.,
|
|
||||||
+ img_callback=None):
|
|
||||||
"""Implements Algorithm 2 (Heun steps) from Karras et al. (2022)."""
|
|
||||||
extra_args = {} if extra_args is None else extra_args
|
|
||||||
|
|
||||||
@@ -855,6 +883,8 @@ class UNet(DDPM):
|
|
||||||
sigmas = cvd.get_sigmas(S)
|
|
||||||
x = x*sigmas[0]
|
|
||||||
|
|
||||||
+ print(f"Running Heun Sampling with {len(sigmas) - 1} timesteps")
|
|
||||||
+
|
|
||||||
|
|
||||||
s_in = x.new_ones([x.shape[0]]).half()
|
|
||||||
for i in trange(len(sigmas) - 1, disable=disable):
|
|
||||||
@@ -876,6 +906,9 @@ class UNet(DDPM):
|
|
||||||
d = to_d(x, sigma_hat, denoised)
|
|
||||||
if callback is not None:
|
|
||||||
callback({'x': x, 'i': i, 'sigma': sigmas[i], 'sigma_hat': sigma_hat, 'denoised': denoised})
|
|
||||||
+
|
|
||||||
+ if img_callback: yield from img_callback(x, i)
|
|
||||||
+
|
|
||||||
dt = sigmas[i + 1] - sigma_hat
|
|
||||||
if sigmas[i + 1] == 0:
|
|
||||||
# Euler method
|
|
||||||
@@ -895,11 +928,13 @@ class UNet(DDPM):
|
|
||||||
d_2 = to_d(x_2, sigmas[i + 1], denoised_2)
|
|
||||||
d_prime = (d + d_2) / 2
|
|
||||||
x = x + d_prime * dt
|
|
||||||
- return x
|
|
||||||
+
|
|
||||||
+ yield from img_callback(x, len(sigmas)-1)
|
|
||||||
|
|
||||||
|
|
||||||
@torch.no_grad()
|
|
||||||
- def dpm_2_sampling(self,ac,x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1,extra_args=None, callback=None, disable=None, s_churn=0., s_tmin=0., s_tmax=float('inf'), s_noise=1.):
|
|
||||||
+ def dpm_2_sampling(self,ac,x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1,extra_args=None, callback=None, disable=None, s_churn=0., s_tmin=0., s_tmax=float('inf'), s_noise=1.,
|
|
||||||
+ img_callback=None):
|
|
||||||
"""A sampler inspired by DPM-Solver-2 and Algorithm 2 from Karras et al. (2022)."""
|
|
||||||
extra_args = {} if extra_args is None else extra_args
|
|
||||||
|
|
||||||
@@ -907,6 +942,8 @@ class UNet(DDPM):
|
|
||||||
sigmas = cvd.get_sigmas(S)
|
|
||||||
x = x*sigmas[0]
|
|
||||||
|
|
||||||
+ print(f"Running DPM2 Sampling with {len(sigmas) - 1} timesteps")
|
|
||||||
+
|
|
||||||
s_in = x.new_ones([x.shape[0]]).half()
|
|
||||||
for i in trange(len(sigmas) - 1, disable=disable):
|
|
||||||
gamma = min(s_churn / (len(sigmas) - 1), 2 ** 0.5 - 1) if s_tmin <= sigmas[i] <= s_tmax else 0.
|
|
||||||
@@ -924,7 +961,7 @@ class UNet(DDPM):
|
|
||||||
e_t_uncond, e_t = (x_in + eps * c_out).chunk(2)
|
|
||||||
denoised = e_t_uncond + unconditional_guidance_scale * (e_t - e_t_uncond)
|
|
||||||
|
|
||||||
-
|
|
||||||
+ if img_callback: yield from img_callback(x, i)
|
|
||||||
|
|
||||||
d = to_d(x, sigma_hat, denoised)
|
|
||||||
# Midpoint method, where the midpoint is chosen according to a rho=3 Karras schedule
|
|
||||||
@@ -945,11 +982,13 @@ class UNet(DDPM):
|
|
||||||
|
|
||||||
d_2 = to_d(x_2, sigma_mid, denoised_2)
|
|
||||||
x = x + d_2 * dt_2
|
|
||||||
- return x
|
|
||||||
+
|
|
||||||
+ yield from img_callback(x, len(sigmas)-1)
|
|
||||||
|
|
||||||
|
|
||||||
@torch.no_grad()
|
|
||||||
- def dpm_2_ancestral_sampling(self,ac,x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1, extra_args=None, callback=None, disable=None):
|
|
||||||
+ def dpm_2_ancestral_sampling(self,ac,x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1, extra_args=None, callback=None, disable=None,
|
|
||||||
+ img_callback=None):
|
|
||||||
"""Ancestral sampling with DPM-Solver inspired second-order steps."""
|
|
||||||
extra_args = {} if extra_args is None else extra_args
|
|
||||||
|
|
||||||
@@ -957,6 +996,8 @@ class UNet(DDPM):
|
|
||||||
sigmas = cvd.get_sigmas(S)
|
|
||||||
x = x*sigmas[0]
|
|
||||||
|
|
||||||
+ print(f"Running DPM2 Ancestral Sampling with {len(sigmas) - 1} timesteps")
|
|
||||||
+
|
|
||||||
s_in = x.new_ones([x.shape[0]]).half()
|
|
||||||
for i in trange(len(sigmas) - 1, disable=disable):
|
|
||||||
|
|
||||||
@@ -973,6 +1014,9 @@ class UNet(DDPM):
|
|
||||||
sigma_down, sigma_up = get_ancestral_step(sigmas[i], sigmas[i + 1])
|
|
||||||
if callback is not None:
|
|
||||||
callback({'x': x, 'i': i, 'sigma': sigmas[i], 'sigma_hat': sigmas[i], 'denoised': denoised})
|
|
||||||
+
|
|
||||||
+ if img_callback: yield from img_callback(x, i)
|
|
||||||
+
|
|
||||||
d = to_d(x, sigmas[i], denoised)
|
|
||||||
# Midpoint method, where the midpoint is chosen according to a rho=3 Karras schedule
|
|
||||||
sigma_mid = ((sigmas[i] ** (1 / 3) + sigma_down ** (1 / 3)) / 2) ** 3
|
|
||||||
@@ -993,11 +1037,13 @@ class UNet(DDPM):
|
|
||||||
d_2 = to_d(x_2, sigma_mid, denoised_2)
|
|
||||||
x = x + d_2 * dt_2
|
|
||||||
x = x + torch.randn_like(x) * sigma_up
|
|
||||||
- return x
|
|
||||||
+
|
|
||||||
+ yield from img_callback(x, len(sigmas)-1)
|
|
||||||
|
|
||||||
|
|
||||||
@torch.no_grad()
|
|
||||||
- def lms_sampling(self,ac,x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1, extra_args=None, callback=None, disable=None, order=4):
|
|
||||||
+ def lms_sampling(self,ac,x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1, extra_args=None, callback=None, disable=None, order=4,
|
|
||||||
+ img_callback=None):
|
|
||||||
extra_args = {} if extra_args is None else extra_args
|
|
||||||
s_in = x.new_ones([x.shape[0]])
|
|
||||||
|
|
||||||
@@ -1005,6 +1051,8 @@ class UNet(DDPM):
|
|
||||||
sigmas = cvd.get_sigmas(S)
|
|
||||||
x = x*sigmas[0]
|
|
||||||
|
|
||||||
+ print(f"Running LMS Sampling with {len(sigmas) - 1} timesteps")
|
|
||||||
+
|
|
||||||
ds = []
|
|
||||||
for i in trange(len(sigmas) - 1, disable=disable):
|
|
||||||
|
|
||||||
@@ -1017,6 +1065,7 @@ class UNet(DDPM):
|
|
||||||
e_t_uncond, e_t = (x_in + eps * c_out).chunk(2)
|
|
||||||
denoised = e_t_uncond + unconditional_guidance_scale * (e_t - e_t_uncond)
|
|
||||||
|
|
||||||
+ if img_callback: yield from img_callback(x, i)
|
|
||||||
|
|
||||||
d = to_d(x, sigmas[i], denoised)
|
|
||||||
ds.append(d)
|
|
||||||
@@ -1027,4 +1076,5 @@ class UNet(DDPM):
|
|
||||||
cur_order = min(i + 1, order)
|
|
||||||
coeffs = [linear_multistep_coeff(cur_order, sigmas.cpu(), i, j) for j in range(cur_order)]
|
|
||||||
x = x + sum(coeff * d for coeff, d in zip(coeffs, reversed(ds)))
|
|
||||||
- return x
|
|
||||||
+
|
|
||||||
+ yield from img_callback(x, len(sigmas)-1)
|
|
||||||
diff --git a/optimizedSD/openaimodelSplit.py b/optimizedSD/openaimodelSplit.py
|
|
||||||
index abc3098..7a32ffe 100644
|
|
||||||
--- a/optimizedSD/openaimodelSplit.py
|
|
||||||
+++ b/optimizedSD/openaimodelSplit.py
|
|
||||||
@@ -13,7 +13,7 @@ from ldm.modules.diffusionmodules.util import (
|
|
||||||
normalization,
|
|
||||||
timestep_embedding,
|
|
||||||
)
|
|
||||||
-from splitAttention import SpatialTransformer
|
|
||||||
+from .splitAttention import SpatialTransformer
|
|
||||||
|
|
||||||
|
|
||||||
class AttentionPool2d(nn.Module):
|
|
@ -1,13 +0,0 @@
|
|||||||
diff --git a/environment.yaml b/environment.yaml
|
|
||||||
index 7f25da8..306750f 100644
|
|
||||||
--- a/environment.yaml
|
|
||||||
+++ b/environment.yaml
|
|
||||||
@@ -23,6 +23,8 @@ dependencies:
|
|
||||||
- torch-fidelity==0.3.0
|
|
||||||
- transformers==4.19.2
|
|
||||||
- torchmetrics==0.6.0
|
|
||||||
+ - pywavelets==1.3.0
|
|
||||||
+ - pandas==1.4.4
|
|
||||||
- kornia==0.6
|
|
||||||
- -e git+https://github.com/CompVis/taming-transformers.git@master#egg=taming-transformers
|
|
||||||
- -e git+https://github.com/openai/CLIP.git@main#egg=clip
|
|