forked from extern/easydiffusion
Compare commits
191 Commits
Author | SHA1 | Date | |
---|---|---|---|
5fe3acd44b | |||
716f30fecb | |||
364902f8a1 | |||
a261a2d47d | |||
dea962dc89 | |||
d062c2149a | |||
7d49dc105e | |||
fcdc3f2dd0 | |||
d17b167a81 | |||
1fa83eda0e | |||
969751a195 | |||
1ae8675487 | |||
05f0bfebba | |||
91ad53cd94 | |||
de680dfd09 | |||
4edeb14e94 | |||
e64cf9c9eb | |||
66d0c4726e | |||
c923b44f56 | |||
b9c343195b | |||
4427e8d3dd | |||
87c8fe2758 | |||
70acde7809 | |||
c4b938f132 | |||
d6fdb8d5a9 | |||
54ac1f7169 | |||
deebfc6850 | |||
21644adbe1 | |||
fe3c648a24 | |||
05f3523364 | |||
4d9b023378 | |||
44789bf16b | |||
ad649a8050 | |||
723304204e | |||
ddf54d589e | |||
a5c9c44e53 | |||
4d28c78fcc | |||
7dc01370ea | |||
21ff109632 | |||
9b0a654d32 | |||
fb749dbe24 | |||
17ef1e04f7 | |||
a5b9eefcf9 | |||
e5519cda37 | |||
d1bd9e2a16 | |||
5924d01789 | |||
47432fe54e | |||
8660a79ccd | |||
dfb26ed781 | |||
547febafba | |||
85eaa305cc | |||
25272ce083 | |||
212fa77b47 | |||
e77629c525 | |||
097780be26 | |||
6489cd785d | |||
a4e651e27e | |||
bedf176e62 | |||
398a0509d7 | |||
52cc99bf1f | |||
824e057d7b | |||
9bd4b3a6d0 | |||
307b00cc05 | |||
8a98df4673 | |||
45a14a9be9 | |||
e419276e34 | |||
0a92b7b1d5 | |||
f110168366 | |||
ce24a05909 | |||
45facf64e5 | |||
e999832c26 | |||
4c8d5a7077 | |||
81643cb3af | |||
7a9bc883df | |||
6280a80129 | |||
a33908b6de | |||
0ea5620413 | |||
e23eb1fea8 | |||
41f2c82eaf | |||
91e3bfe58f | |||
83d5519a31 | |||
cc2666b9d6 | |||
954493fef5 | |||
967c3681cd | |||
87c9df5c0d | |||
62136768d2 | |||
b71b7804fc | |||
e8b7751374 | |||
54d4433141 | |||
14dbebbc35 | |||
d6a02a31a7 | |||
86e2ac40ae | |||
a12ed7533b | |||
9fb0ee2d1b | |||
6311b80474 | |||
c13d1093ee | |||
dd7deeba53 | |||
338aef3e95 | |||
134c98ccb5 | |||
d12877987f | |||
676316e5e4 | |||
52761ad88c | |||
f5e489ba87 | |||
982af1fff3 | |||
1cff398c20 | |||
a6271d2c4e | |||
60f8cc6883 | |||
ffb8feba6b | |||
4aca3c4639 | |||
120f9e567c | |||
c0492511df | |||
1075a5ed93 | |||
58d3507155 | |||
ae0c9b6a6b | |||
ad1374af1d | |||
8436e8a71e | |||
ea07483465 | |||
51f857c3f3 | |||
74c0ca0902 | |||
ad5641fa3e | |||
b0294f8cbd | |||
5d4498ff85 | |||
d52fb15746 | |||
ee6be74e72 | |||
4cbc86f945 | |||
3a5e0cb2d2 | |||
7916b8d26a | |||
a0842b4659 | |||
14ee87ca80 | |||
cec1d7d6c9 | |||
9aeae4d16e | |||
9c1b741d89 | |||
c71a74f857 | |||
524612cee5 | |||
11e47b3871 | |||
4a1b2be45c | |||
d641aa2f6e | |||
237c7a5348 | |||
19f37907d9 | |||
b8706da990 | |||
b458d57355 | |||
a5962dae33 | |||
670768e5b3 | |||
f02b915cd0 | |||
71bbbeb936 | |||
e084b78b53 | |||
013860e3c0 | |||
7a118eeb15 | |||
df408b25e5 | |||
536082c1a6 | |||
b986ca3059 | |||
4bf9e577b9 | |||
a7c12e61d8 | |||
847d27bffb | |||
781e812f22 | |||
e49b5e0e6b | |||
8f1c1b128e | |||
04cbb052d7 | |||
16f0950ebd | |||
e959a3d7ab | |||
fc9941abaa | |||
f177011395 | |||
80e47be5a5 | |||
9a9f6e3559 | |||
1a6e0234b3 | |||
56bea46e3a | |||
a09441b2c8 | |||
105994d96d | |||
d641647b1e | |||
672574d278 | |||
f1ded17399 | |||
d254e3e2fd | |||
ab5450bb27 | |||
a2e9e5eb57 | |||
8965f11ab4 | |||
1dd5644e7a | |||
37f813506e | |||
a5d5ed90e6 | |||
3792a1bc0d | |||
fbafa56ecb | |||
2f910c69b8 | |||
bf06cc48bb | |||
3ef67ebc73 | |||
0c4318fb31 | |||
c55ced93db | |||
807d940001 | |||
8c27fa136c | |||
8e7a6077e5 | |||
53a79c1a81 | |||
e9f54c8bae | |||
c978863e5f |
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,3 +4,5 @@ installer.tar
|
|||||||
dist
|
dist
|
||||||
.idea/*
|
.idea/*
|
||||||
node_modules/*
|
node_modules/*
|
||||||
|
.tmp1
|
||||||
|
.tmp2
|
||||||
|
14
CHANGES.md
14
CHANGES.md
@ -17,6 +17,20 @@
|
|||||||
- **Major rewrite of the code** - We've switched to using diffusers under-the-hood, which allows us to release new features faster, and focus on making the UI and installer even easier to use.
|
- **Major rewrite of the code** - We've switched to using diffusers under-the-hood, which allows us to release new features faster, and focus on making the UI and installer even easier to use.
|
||||||
|
|
||||||
### Detailed changelog
|
### Detailed changelog
|
||||||
|
* 3.0.9 - 28 May 2024 - Slider for controlling the strength of controlnets.
|
||||||
|
* 3.0.8 - 27 May 2024 - SDXL ControlNets for Img2Img and Inpainting.
|
||||||
|
* 3.0.7 - 11 Dec 2023 - Setting to enable/disable VAE tiling (in the Image Settings panel). Sometimes VAE tiling reduces the quality of the image, so this setting will help control that.
|
||||||
|
* 3.0.6 - 18 Sep 2023 - Add thumbnails to embeddings from the UI, using the new `Upload Thumbnail` button in the Embeddings popup. Thanks @JeLuf.
|
||||||
|
* 3.0.6 - 15 Sep 2023 - Fix broken embeddings dialog when LoRA information couldn't be fetched.
|
||||||
|
* 3.0.6 - 14 Sep 2023 - UI for adding notes to LoRA files (to help you remember which prompts to use). Also added a button to automatically fetch prompts from Civitai for a LoRA file, using the `Import from Civitai` button. Thanks @JeLuf.
|
||||||
|
* 3.0.5 - 2 Sep 2023 - Support SDXL ControlNets.
|
||||||
|
* 3.0.4 - 1 Sep 2023 - Fix incorrect metadata generated for embeddings, when the exact word doesn't match the case, or is part of a larger word.
|
||||||
|
* 3.0.4 - 1 Sep 2023 - Simplify the installation for AMD users on Linux. Thanks @JeLuf.
|
||||||
|
* 3.0.4 - 1 Sep 2023 - Allow using a different folder for models. This is useful if you want to share a models folder across different software, or on a different drive. You can change this path in the Settings tab.
|
||||||
|
* 3.0.3 - 31 Aug 2023 - Auto-save images to disk (if enabled by the user) when upscaling/fixing using the buttons on the image.
|
||||||
|
* 3.0.3 - 30 Aug 2023 - Allow loading NovelAI-based custom models.
|
||||||
|
* 3.0.3 - 30 Aug 2023 - Fix broken VAE tiling. This allows you to create larger images with lesser VRAM usage.
|
||||||
|
* 3.0.3 - 30 Aug 2023 - Allow blocking NSFW images using a server-side config. This prevents the browser from generating NSFW images or changing the config. Open `config.yaml` in a text editor (e.g. Notepad), and add `block_nsfw: true` at the end, and save the file.
|
||||||
* 3.0.2 - 29 Aug 2023 - Fixed incorrect matching of embeddings from prompts.
|
* 3.0.2 - 29 Aug 2023 - Fixed incorrect matching of embeddings from prompts.
|
||||||
* 3.0.2 - 24 Aug 2023 - Fix broken seamless tiling.
|
* 3.0.2 - 24 Aug 2023 - Fix broken seamless tiling.
|
||||||
* 3.0.2 - 23 Aug 2023 - Fix styling on mobile devices.
|
* 3.0.2 - 23 Aug 2023 - Fix styling on mobile devices.
|
||||||
|
@ -47,3 +47,5 @@ Build the Windows installer using Windows, and the Linux installer using Linux.
|
|||||||
|
|
||||||
1. Run `build.bat` or `./build.sh` depending on whether you're in Windows or Linux.
|
1. Run `build.bat` or `./build.sh` depending on whether you're in Windows or Linux.
|
||||||
2. Make a new GitHub release and upload the Windows and Linux installer builds created inside the `dist` folder.
|
2. Make a new GitHub release and upload the Windows and Linux installer builds created inside the `dist` folder.
|
||||||
|
|
||||||
|
For NSIS (on Windows), you need to have these plugins in the `nsis/Plugins` folder: `amd64-unicode`, `x86-ansi`, `x86-unicode`
|
||||||
|
BIN
NSIS/astro.bmp
BIN
NSIS/astro.bmp
Binary file not shown.
Before Width: | Height: | Size: 288 KiB |
@ -1 +0,0 @@
|
|||||||
!define EXISTING_INSTALLATION_DIR "D:\path\to\installed\easy-diffusion"
|
|
BIN
NSIS/sd.ico
BIN
NSIS/sd.ico
Binary file not shown.
Before Width: | Height: | Size: 200 KiB |
@ -7,9 +7,9 @@ RequestExecutionLevel user
|
|||||||
!AddPluginDir /amd64-unicode "."
|
!AddPluginDir /amd64-unicode "."
|
||||||
; HM NIS Edit Wizard helper defines
|
; HM NIS Edit Wizard helper defines
|
||||||
!define PRODUCT_NAME "Easy Diffusion"
|
!define PRODUCT_NAME "Easy Diffusion"
|
||||||
!define PRODUCT_VERSION "2.5"
|
!define PRODUCT_VERSION "3.0"
|
||||||
!define PRODUCT_PUBLISHER "cmdr2 and contributors"
|
!define PRODUCT_PUBLISHER "cmdr2 and contributors"
|
||||||
!define PRODUCT_WEB_SITE "https://stable-diffusion-ui.github.io"
|
!define PRODUCT_WEB_SITE "https://easydiffusion.github.io"
|
||||||
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Easy Diffusion\App Paths\installer.exe"
|
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Easy Diffusion\App Paths\installer.exe"
|
||||||
|
|
||||||
; MUI 1.67 compatible ------
|
; MUI 1.67 compatible ------
|
||||||
@ -165,9 +165,9 @@ FunctionEnd
|
|||||||
; MUI Settings
|
; MUI Settings
|
||||||
;---------------------------------------------------------------------------------------------------------
|
;---------------------------------------------------------------------------------------------------------
|
||||||
!define MUI_ABORTWARNING
|
!define MUI_ABORTWARNING
|
||||||
!define MUI_ICON "cyborg_flower_girl.ico"
|
!define MUI_ICON "${EXISTING_INSTALLATION_DIR}\installer_files\cyborg_flower_girl.ico"
|
||||||
|
|
||||||
!define MUI_WELCOMEFINISHPAGE_BITMAP "cyborg_flower_girl.bmp"
|
!define MUI_WELCOMEFINISHPAGE_BITMAP "${EXISTING_INSTALLATION_DIR}\installer_files\cyborg_flower_girl.bmp"
|
||||||
|
|
||||||
; Welcome page
|
; Welcome page
|
||||||
!define MUI_WELCOMEPAGE_TEXT "This installer will guide you through the installation of Easy Diffusion.$\n$\n\
|
!define MUI_WELCOMEPAGE_TEXT "This installer will guide you through the installation of Easy Diffusion.$\n$\n\
|
||||||
@ -176,8 +176,8 @@ Click Next to continue."
|
|||||||
Page custom MediaPackDialog
|
Page custom MediaPackDialog
|
||||||
|
|
||||||
; License page
|
; License page
|
||||||
!insertmacro MUI_PAGE_LICENSE "..\LICENSE"
|
!insertmacro MUI_PAGE_LICENSE "${EXISTING_INSTALLATION_DIR}\LICENSE"
|
||||||
!insertmacro MUI_PAGE_LICENSE "..\CreativeML Open RAIL-M License"
|
!insertmacro MUI_PAGE_LICENSE "${EXISTING_INSTALLATION_DIR}\CreativeML Open RAIL-M License"
|
||||||
; Directory page
|
; Directory page
|
||||||
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE "DirectoryLeave"
|
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE "DirectoryLeave"
|
||||||
!insertmacro MUI_PAGE_DIRECTORY
|
!insertmacro MUI_PAGE_DIRECTORY
|
||||||
@ -210,29 +210,33 @@ ShowInstDetails show
|
|||||||
; List of files to be installed
|
; List of files to be installed
|
||||||
Section "MainSection" SEC01
|
Section "MainSection" SEC01
|
||||||
SetOutPath "$INSTDIR"
|
SetOutPath "$INSTDIR"
|
||||||
File "..\CreativeML Open RAIL-M License"
|
File "${EXISTING_INSTALLATION_DIR}\CreativeML Open RAIL-M License"
|
||||||
File "..\How to install and run.txt"
|
File "${EXISTING_INSTALLATION_DIR}\How to install and run.txt"
|
||||||
File "..\LICENSE"
|
File "${EXISTING_INSTALLATION_DIR}\LICENSE"
|
||||||
File "..\scripts\Start Stable Diffusion UI.cmd"
|
File "${EXISTING_INSTALLATION_DIR}\Start Stable Diffusion UI.cmd"
|
||||||
File /r "${EXISTING_INSTALLATION_DIR}\installer_files"
|
File /r "${EXISTING_INSTALLATION_DIR}\installer_files"
|
||||||
File /r "${EXISTING_INSTALLATION_DIR}\profile"
|
|
||||||
File /r "${EXISTING_INSTALLATION_DIR}\sd-ui-files"
|
File /r "${EXISTING_INSTALLATION_DIR}\sd-ui-files"
|
||||||
SetOutPath "$INSTDIR\installer_files"
|
|
||||||
File "cyborg_flower_girl.ico"
|
|
||||||
SetOutPath "$INSTDIR\scripts"
|
SetOutPath "$INSTDIR\scripts"
|
||||||
File "${EXISTING_INSTALLATION_DIR}\scripts\install_status.txt"
|
File "${EXISTING_INSTALLATION_DIR}\scripts\install_status.txt"
|
||||||
File "..\scripts\on_env_start.bat"
|
File "${EXISTING_INSTALLATION_DIR}\scripts\on_env_start.bat"
|
||||||
File "C:\windows\system32\curl.exe"
|
File "C:\windows\system32\curl.exe"
|
||||||
CreateDirectory "$INSTDIR\models"
|
File "${EXISTING_INSTALLATION_DIR}\scripts\config.yaml.sample"
|
||||||
|
|
||||||
CreateDirectory "$INSTDIR\models\stable-diffusion"
|
CreateDirectory "$INSTDIR\models\stable-diffusion"
|
||||||
CreateDirectory "$INSTDIR\models\gfpgan"
|
CreateDirectory "$INSTDIR\models\gfpgan"
|
||||||
CreateDirectory "$INSTDIR\models\realesrgan"
|
CreateDirectory "$INSTDIR\models\realesrgan"
|
||||||
CreateDirectory "$INSTDIR\models\vae"
|
CreateDirectory "$INSTDIR\models\vae"
|
||||||
|
|
||||||
|
CreateDirectory "$INSTDIR\profile\.cache\huggingface\hub"
|
||||||
|
SetOutPath "$INSTDIR\profile\.cache\huggingface\hub"
|
||||||
|
File /r /x pytorch_model.bin "${EXISTING_INSTALLATION_DIR}\profile\.cache\huggingface\hub\models--openai--clip-vit-large-patch14"
|
||||||
|
|
||||||
CreateDirectory "$SMPROGRAMS\Easy Diffusion"
|
CreateDirectory "$SMPROGRAMS\Easy Diffusion"
|
||||||
CreateShortCut "$SMPROGRAMS\Easy Diffusion\Easy Diffusion.lnk" "$INSTDIR\Start Stable Diffusion UI.cmd" "" "$INSTDIR\installer_files\cyborg_flower_girl.ico"
|
CreateShortCut "$SMPROGRAMS\Easy Diffusion\Easy Diffusion.lnk" "$INSTDIR\Start Stable Diffusion UI.cmd" "" "$INSTDIR\installer_files\cyborg_flower_girl.ico"
|
||||||
|
|
||||||
DetailPrint 'Downloading the Stable Diffusion 1.4 model...'
|
DetailPrint 'Downloading the Stable Diffusion 1.5 model...'
|
||||||
NScurl::http get "https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt" "$INSTDIR\models\stable-diffusion\sd-v1-4.ckpt" /CANCEL /INSIST /END
|
NScurl::http get "https://github.com/easydiffusion/sdkit-test-data/releases/download/assets/sd-v1-5.safetensors" "$INSTDIR\models\stable-diffusion\sd-v1-5.safetensors" /CANCEL /INSIST /END
|
||||||
|
|
||||||
DetailPrint 'Downloading the GFPGAN model...'
|
DetailPrint 'Downloading the GFPGAN model...'
|
||||||
NScurl::http get "https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/GFPGANv1.4.pth" "$INSTDIR\models\gfpgan\GFPGANv1.4.pth" /CANCEL /INSIST /END
|
NScurl::http get "https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/GFPGANv1.4.pth" "$INSTDIR\models\gfpgan\GFPGANv1.4.pth" /CANCEL /INSIST /END
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
|
|
||||||
Does not require technical knowledge, does not require pre-installed software. 1-click install, powerful features, friendly community.
|
Does not require technical knowledge, does not require pre-installed software. 1-click install, powerful features, friendly community.
|
||||||
|
|
||||||
[Installation guide](#installation) | [Troubleshooting guide](https://github.com/easydiffusion/easydiffusion/wiki/Troubleshooting) | <sub>[](https://discord.com/invite/u9yhsFmEkB)</sub> <sup>(for support queries, and development discussions)</sup>
|
️🔥🎉 **New!** Support for SDXL, ControlNet, multiple LoRA files, embeddings (and a lot more) have been added!
|
||||||
|
|
||||||
|
[Installation guide](#installation) | [Troubleshooting guide](https://github.com/easydiffusion/easydiffusion/wiki/Troubleshooting) | [User guide](https://github.com/easydiffusion/easydiffusion/wiki) | <sub>[](https://discord.com/invite/u9yhsFmEkB)</sub> <sup>(for support queries, and development discussions)</sup>
|
||||||
|
|
||||||
---
|
---
|
||||||

|

|
||||||
@ -102,7 +104,7 @@ Just delete the `EasyDiffusion` folder to uninstall all the downloaded packages.
|
|||||||
- **Auto scan for malicious models**: Uses picklescan to prevent malicious models.
|
- **Auto scan for malicious models**: Uses picklescan to prevent malicious models.
|
||||||
- **Safetensors support**: Support loading models in the safetensor format, for improved safety.
|
- **Safetensors support**: Support loading models in the safetensor format, for improved safety.
|
||||||
- **Auto-updater**: Gets you the latest improvements and bug-fixes to a rapidly evolving project.
|
- **Auto-updater**: Gets you the latest improvements and bug-fixes to a rapidly evolving project.
|
||||||
- **Developer Console**: A developer-mode for those who want to modify their Stable Diffusion code, and edit the conda environment.
|
- **Developer Console**: A developer-mode for those who want to modify their Stable Diffusion code, modify packages, and edit the conda environment.
|
||||||
|
|
||||||
**(and a lot more)**
|
**(and a lot more)**
|
||||||
|
|
||||||
|
94
build.bat
94
build.bat
@ -1,48 +1,78 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
setlocal enabledelayedexpansion
|
||||||
|
|
||||||
@echo "Hi there, what you are running is meant for the developers of this project, not for users." & echo.
|
@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 "If you only want to use Easy Diffusion, you've downloaded the wrong file."
|
||||||
@echo "Please download and follow the instructions at https://github.com/easydiffusion/easydiffusion#installation" & echo.
|
@echo "Please download and follow the instructions at https://github.com/easydiffusion/easydiffusion#installation" & echo.
|
||||||
@echo "If you are actually a developer of this project, please type Y and press enter" & 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)?
|
set /p answer=Are you a developer of this project (Y/N)?
|
||||||
if /i "%answer:~,1%" NEQ "Y" exit /b
|
if /i "%answer:~,1%" NEQ "Y" exit /b
|
||||||
|
|
||||||
mkdir dist\win\stable-diffusion-ui\scripts
|
@rem verify dependencies
|
||||||
@REM mkdir dist\linux-mac\stable-diffusion-ui\scripts
|
call makensis /VERSION >.tmp1 2>.tmp2
|
||||||
|
if "!ERRORLEVEL!" NEQ "0" (
|
||||||
|
echo makensis.exe not found! Download it from https://sourceforge.net/projects/nsisbi/files/ and set it on the PATH variable.
|
||||||
|
pause
|
||||||
|
exit
|
||||||
|
)
|
||||||
|
|
||||||
@rem copy the installer files for Windows
|
set /p OUT_DIR=Output folder path (will create the installer files inside this, e.g. F:\EasyDiffusion):
|
||||||
|
|
||||||
copy scripts\on_env_start.bat dist\win\stable-diffusion-ui\scripts\
|
mkdir "%OUT_DIR%\scripts"
|
||||||
copy scripts\bootstrap.bat dist\win\stable-diffusion-ui\scripts\
|
mkdir "%OUT_DIR%\installer_files"
|
||||||
copy scripts\config.yaml.sample dist\win\stable-diffusion-ui\scripts\config.yaml
|
|
||||||
copy "scripts\Start Stable Diffusion UI.cmd" dist\win\stable-diffusion-ui\
|
|
||||||
copy LICENSE dist\win\stable-diffusion-ui\
|
|
||||||
copy "CreativeML Open RAIL-M License" dist\win\stable-diffusion-ui\
|
|
||||||
copy "How to install and run.txt" dist\win\stable-diffusion-ui\
|
|
||||||
echo. > dist\win\stable-diffusion-ui\scripts\install_status.txt
|
|
||||||
|
|
||||||
@rem copy the installer files for Linux and Mac
|
set BASE_DIR=%cd%
|
||||||
|
|
||||||
@REM copy scripts\on_env_start.sh dist\linux-mac\stable-diffusion-ui\scripts\
|
@rem STEP 1: copy the installer files for Windows
|
||||||
@REM copy scripts\bootstrap.sh dist\linux-mac\stable-diffusion-ui\scripts\
|
|
||||||
@REM copy scripts\start.sh dist\linux-mac\stable-diffusion-ui\
|
|
||||||
@REM copy LICENSE dist\linux-mac\stable-diffusion-ui\
|
|
||||||
@REM copy "CreativeML Open RAIL-M License" dist\linux-mac\stable-diffusion-ui\
|
|
||||||
@REM copy "How to install and run.txt" dist\linux-mac\stable-diffusion-ui\
|
|
||||||
@REM echo. > dist\linux-mac\stable-diffusion-ui\scripts\install_status.txt
|
|
||||||
|
|
||||||
@rem make the zip
|
copy "%BASE_DIR%\scripts\on_env_start.bat" "%OUT_DIR%\scripts\"
|
||||||
|
copy "%BASE_DIR%\scripts\config.yaml.sample" "%OUT_DIR%\scripts\config.yaml.sample"
|
||||||
cd dist\win
|
copy "%BASE_DIR%\scripts\Start Stable Diffusion UI.cmd" "%OUT_DIR%\"
|
||||||
call powershell Compress-Archive -Path stable-diffusion-ui -DestinationPath ..\stable-diffusion-ui-windows.zip
|
copy "%BASE_DIR%\LICENSE" "%OUT_DIR%\"
|
||||||
cd ..\..
|
copy "%BASE_DIR%\CreativeML Open RAIL-M License" "%OUT_DIR%\"
|
||||||
|
copy "%BASE_DIR%\How to install and run.txt" "%OUT_DIR%\"
|
||||||
@REM cd dist\linux-mac
|
copy "%BASE_DIR%\NSIS\cyborg_flower_girl.ico" "%OUT_DIR%\installer_files\"
|
||||||
@REM call powershell Compress-Archive -Path stable-diffusion-ui -DestinationPath ..\stable-diffusion-ui-linux.zip
|
copy "%BASE_DIR%\NSIS\cyborg_flower_girl.bmp" "%OUT_DIR%\installer_files\"
|
||||||
@REM call powershell Compress-Archive -Path stable-diffusion-ui -DestinationPath ..\stable-diffusion-ui-mac.zip
|
echo. > "%OUT_DIR%\scripts\install_status.txt"
|
||||||
@REM cd ..\..
|
|
||||||
|
|
||||||
echo "Build ready. Upload the zip files inside the 'dist' folder."
|
|
||||||
|
|
||||||
|
echo ----
|
||||||
|
echo Basic files ready. Verify the files in %OUT_DIR%, then press Enter to initialize the environment, or close to quit.
|
||||||
|
echo ----
|
||||||
|
pause
|
||||||
|
|
||||||
|
@rem STEP 2: Initialize the environment with git, python and conda
|
||||||
|
|
||||||
|
cd /d "%OUT_DIR%\"
|
||||||
|
call "%BASE_DIR%\scripts\bootstrap.bat"
|
||||||
|
|
||||||
|
echo ----
|
||||||
|
echo Environment ready. Verify the environment, then press Enter to download the necessary packages, or close to quit.
|
||||||
|
echo ----
|
||||||
|
pause
|
||||||
|
|
||||||
|
@rem STEP 3: Download the packages and create a working installation
|
||||||
|
|
||||||
|
cd /d "%OUT_DIR%\"
|
||||||
|
start "Install Easy Diffusion" /D "%OUT_DIR%" "Start Stable Diffusion UI.cmd"
|
||||||
|
|
||||||
|
echo ----
|
||||||
|
echo Installation in progress (in a new window). Once complete, verify the installation, then press Enter to create an installer from these files, or close to quit.
|
||||||
|
echo ----
|
||||||
|
pause
|
||||||
|
|
||||||
|
@rem STEP 4: Build the installer from a working installation
|
||||||
|
|
||||||
|
cd /d "%OUT_DIR%\"
|
||||||
|
|
||||||
|
echo ^^!define EXISTING_INSTALLATION_DIR "%OUT_DIR%" > nsisconf.nsh
|
||||||
|
call makensis /NOCD /V4 "%BASE_DIR%\NSIS\sdui.nsi"
|
||||||
|
|
||||||
|
echo ----
|
||||||
|
if "!ERRORLEVEL!" EQU "0" (
|
||||||
|
echo Installer built successfully at %OUT_DIR%
|
||||||
|
) else (
|
||||||
|
echo Installer failed to build at %OUT_DIR%
|
||||||
|
)
|
||||||
|
echo ----
|
||||||
pause
|
pause
|
46
build.sh
46
build.sh
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
printf "Hi there, what you are running is meant for the developers of this project, not for users.\n\n"
|
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 "If you only want to use Easy Diffusion, you've downloaded the wrong file.\n"
|
||||||
printf "Please download and follow the instructions at https://github.com/easydiffusion/easydiffusion#installation \n\n"
|
printf "Please download and follow the instructions at https://github.com/easydiffusion/easydiffusion#installation \n\n"
|
||||||
printf "If you are actually a developer of this project, please type Y and press enter\n\n"
|
printf "If you are actually a developer of this project, please type Y and press enter\n\n"
|
||||||
|
|
||||||
@ -11,40 +11,30 @@ case $yn in
|
|||||||
* ) exit;;
|
* ) exit;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# mkdir -p dist/win/stable-diffusion-ui/scripts
|
mkdir -p dist/linux-mac/easy-diffusion/scripts
|
||||||
mkdir -p dist/linux-mac/stable-diffusion-ui/scripts
|
|
||||||
|
|
||||||
# copy the installer files for Windows
|
|
||||||
|
|
||||||
# cp scripts/on_env_start.bat dist/win/stable-diffusion-ui/scripts/
|
|
||||||
# cp scripts/bootstrap.bat dist/win/stable-diffusion-ui/scripts/
|
|
||||||
# cp "scripts/Start Stable Diffusion UI.cmd" dist/win/stable-diffusion-ui/
|
|
||||||
# cp LICENSE dist/win/stable-diffusion-ui/
|
|
||||||
# cp "CreativeML Open RAIL-M License" dist/win/stable-diffusion-ui/
|
|
||||||
# cp "How to install and run.txt" dist/win/stable-diffusion-ui/
|
|
||||||
# echo "" > dist/win/stable-diffusion-ui/scripts/install_status.txt
|
|
||||||
|
|
||||||
# copy the installer files for Linux and Mac
|
# copy the installer files for Linux and Mac
|
||||||
|
|
||||||
cp scripts/on_env_start.sh dist/linux-mac/stable-diffusion-ui/scripts/
|
cp scripts/on_env_start.sh dist/linux-mac/easy-diffusion/scripts/
|
||||||
cp scripts/bootstrap.sh dist/linux-mac/stable-diffusion-ui/scripts/
|
cp scripts/bootstrap.sh dist/linux-mac/easy-diffusion/scripts/
|
||||||
cp scripts/functions.sh dist/linux-mac/stable-diffusion-ui/scripts/
|
cp scripts/functions.sh dist/linux-mac/easy-diffusion/scripts/
|
||||||
cp scripts/config.yaml.sample dist/linux-mac/stable-diffusion-ui/scripts/config.yaml
|
cp scripts/config.yaml.sample dist/linux-mac/easy-diffusion/scripts/config.yaml.sample
|
||||||
cp scripts/start.sh dist/linux-mac/stable-diffusion-ui/
|
cp scripts/start.sh dist/linux-mac/easy-diffusion/
|
||||||
cp LICENSE dist/linux-mac/stable-diffusion-ui/
|
cp LICENSE dist/linux-mac/easy-diffusion/
|
||||||
cp "CreativeML Open RAIL-M License" dist/linux-mac/stable-diffusion-ui/
|
cp "CreativeML Open RAIL-M License" dist/linux-mac/easy-diffusion/
|
||||||
cp "How to install and run.txt" dist/linux-mac/stable-diffusion-ui/
|
cp "How to install and run.txt" dist/linux-mac/easy-diffusion/
|
||||||
echo "" > dist/linux-mac/stable-diffusion-ui/scripts/install_status.txt
|
echo "" > dist/linux-mac/easy-diffusion/scripts/install_status.txt
|
||||||
|
|
||||||
|
# set the permissions
|
||||||
|
chmod u+x dist/linux-mac/easy-diffusion/scripts/on_env_start.sh
|
||||||
|
chmod u+x dist/linux-mac/easy-diffusion/scripts/bootstrap.sh
|
||||||
|
chmod u+x dist/linux-mac/easy-diffusion/start.sh
|
||||||
|
|
||||||
# make the zip
|
# make the zip
|
||||||
|
|
||||||
# cd dist/win
|
|
||||||
# zip -r ../stable-diffusion-ui-windows.zip stable-diffusion-ui
|
|
||||||
# cd ../..
|
|
||||||
|
|
||||||
cd dist/linux-mac
|
cd dist/linux-mac
|
||||||
zip -r ../stable-diffusion-ui-linux.zip stable-diffusion-ui
|
zip -r ../Easy-Diffusion-Linux.zip easy-diffusion
|
||||||
zip -r ../stable-diffusion-ui-mac.zip stable-diffusion-ui
|
zip -r ../Easy-Diffusion-Mac.zip easy-diffusion
|
||||||
cd ../..
|
cd ../..
|
||||||
|
|
||||||
echo "Build ready. Upload the zip files inside the 'dist' folder."
|
echo "Build ready. Upload the zip files inside the 'dist' folder."
|
||||||
|
BIN
patch.patch
BIN
patch.patch
Binary file not shown.
@ -15,7 +15,7 @@ if exist "on_sd_start.bat" (
|
|||||||
echo download. This will not work.
|
echo download. This will not work.
|
||||||
echo.
|
echo.
|
||||||
echo Recommended: Please close this window and download the installer from
|
echo Recommended: Please close this window and download the installer from
|
||||||
echo https://stable-diffusion-ui.github.io/docs/installation/
|
echo https://easydiffusion.github.io/docs/installation/
|
||||||
echo.
|
echo.
|
||||||
echo ================================================================================
|
echo ================================================================================
|
||||||
echo.
|
echo.
|
||||||
@ -39,6 +39,7 @@ call where conda
|
|||||||
call conda --version
|
call conda --version
|
||||||
echo .
|
echo .
|
||||||
echo COMSPEC=%COMSPEC%
|
echo COMSPEC=%COMSPEC%
|
||||||
|
wmic path win32_VideoController get name,AdapterRAM,DriverDate,DriverVersion
|
||||||
|
|
||||||
@rem Download the rest of the installer and UI
|
@rem Download the rest of the installer and UI
|
||||||
call scripts\on_env_start.bat
|
call scripts\on_env_start.bat
|
||||||
|
@ -14,6 +14,8 @@ set LEGACY_INSTALL_ENV_DIR=%cd%\installer
|
|||||||
set MICROMAMBA_DOWNLOAD_URL=https://github.com/easydiffusion/easydiffusion/releases/download/v1.1/micromamba.exe
|
set MICROMAMBA_DOWNLOAD_URL=https://github.com/easydiffusion/easydiffusion/releases/download/v1.1/micromamba.exe
|
||||||
set umamba_exists=F
|
set umamba_exists=F
|
||||||
|
|
||||||
|
set PYTHONHOME=
|
||||||
|
|
||||||
set OLD_APPDATA=%APPDATA%
|
set OLD_APPDATA=%APPDATA%
|
||||||
set OLD_USERPROFILE=%USERPROFILE%
|
set OLD_USERPROFILE=%USERPROFILE%
|
||||||
set APPDATA=%cd%\installer_files\appdata
|
set APPDATA=%cd%\installer_files\appdata
|
||||||
@ -22,15 +24,12 @@ set USERPROFILE=%cd%\profile
|
|||||||
@rem figure out whether git and conda needs to be installed
|
@rem figure out whether git and conda needs to be installed
|
||||||
if exist "%INSTALL_ENV_DIR%" set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%INSTALL_ENV_DIR%\Library\usr\bin;%PATH%
|
if exist "%INSTALL_ENV_DIR%" set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%INSTALL_ENV_DIR%\Library\usr\bin;%PATH%
|
||||||
|
|
||||||
set PACKAGES_TO_INSTALL=
|
set PACKAGES_TO_INSTALL=git python=3.8.5
|
||||||
|
|
||||||
if not exist "%LEGACY_INSTALL_ENV_DIR%\etc\profile.d\conda.sh" (
|
if not exist "%LEGACY_INSTALL_ENV_DIR%\etc\profile.d\conda.sh" (
|
||||||
if not exist "%INSTALL_ENV_DIR%\etc\profile.d\conda.sh" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% conda python=3.8.5
|
if not exist "%INSTALL_ENV_DIR%\etc\profile.d\conda.sh" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% conda
|
||||||
)
|
)
|
||||||
|
|
||||||
call git --version >.tmp1 2>.tmp2
|
|
||||||
if "!ERRORLEVEL!" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git
|
|
||||||
|
|
||||||
call "%MAMBA_ROOT_PREFIX%\micromamba.exe" --version >.tmp1 2>.tmp2
|
call "%MAMBA_ROOT_PREFIX%\micromamba.exe" --version >.tmp1 2>.tmp2
|
||||||
if "!ERRORLEVEL!" EQU "0" set umamba_exists=T
|
if "!ERRORLEVEL!" EQU "0" set umamba_exists=T
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -34,6 +34,7 @@ call conda activate
|
|||||||
|
|
||||||
@REM remove the old version of the dev console script, if it's still present
|
@REM remove the old version of the dev console script, if it's still present
|
||||||
if exist "Open Developer Console.cmd" del "Open Developer Console.cmd"
|
if exist "Open Developer Console.cmd" del "Open Developer Console.cmd"
|
||||||
|
if exist "ui\plugins\ui\merge.plugin.js" del "ui\plugins\ui\merge.plugin.js"
|
||||||
|
|
||||||
@rem create the stable-diffusion folder, to work with legacy installations
|
@rem create the stable-diffusion folder, to work with legacy installations
|
||||||
if not exist "stable-diffusion" mkdir stable-diffusion
|
if not exist "stable-diffusion" mkdir stable-diffusion
|
||||||
@ -52,73 +53,24 @@ if exist ldm rename ldm ldm-old
|
|||||||
if not exist "%INSTALL_ENV_DIR%\DLLs\libssl-1_1-x64.dll" copy "%INSTALL_ENV_DIR%\Library\bin\libssl-1_1-x64.dll" "%INSTALL_ENV_DIR%\DLLs\"
|
if not exist "%INSTALL_ENV_DIR%\DLLs\libssl-1_1-x64.dll" copy "%INSTALL_ENV_DIR%\Library\bin\libssl-1_1-x64.dll" "%INSTALL_ENV_DIR%\DLLs\"
|
||||||
if not exist "%INSTALL_ENV_DIR%\DLLs\libcrypto-1_1-x64.dll" copy "%INSTALL_ENV_DIR%\Library\bin\libcrypto-1_1-x64.dll" "%INSTALL_ENV_DIR%\DLLs\"
|
if not exist "%INSTALL_ENV_DIR%\DLLs\libcrypto-1_1-x64.dll" copy "%INSTALL_ENV_DIR%\Library\bin\libcrypto-1_1-x64.dll" "%INSTALL_ENV_DIR%\DLLs\"
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
@rem set any overrides
|
||||||
|
set HF_HUB_DISABLE_SYMLINKS_WARNING=true
|
||||||
|
|
||||||
@rem install or upgrade the required modules
|
@rem install or upgrade the required modules
|
||||||
set PATH=C:\Windows\System32;%PATH%
|
set PATH=C:\Windows\System32;%PATH%
|
||||||
|
|
||||||
@REM prevent from using packages from the user's home directory, to avoid conflicts
|
@REM prevent from using packages from the user's home directory, to avoid conflicts
|
||||||
set PYTHONNOUSERSITE=1
|
set PYTHONNOUSERSITE=1
|
||||||
set PYTHONPATH=%INSTALL_ENV_DIR%\lib\site-packages
|
|
||||||
|
|
||||||
@rem Download the required packages
|
|
||||||
call python ..\scripts\check_modules.py
|
|
||||||
if "%ERRORLEVEL%" NEQ "0" (
|
|
||||||
pause
|
|
||||||
exit /b
|
|
||||||
)
|
|
||||||
|
|
||||||
call WHERE uvicorn > .tmp
|
|
||||||
@>nul findstr /m "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/easydiffusion/easydiffusion/wiki/Troubleshooting" & 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/easydiffusion/easydiffusion/issues" & echo "Thanks!" & echo.
|
|
||||||
pause
|
|
||||||
exit /b
|
|
||||||
)
|
|
||||||
|
|
||||||
@>nul findstr /m "conda_sd_ui_deps_installed" ..\scripts\install_status.txt
|
|
||||||
@if "%ERRORLEVEL%" NEQ "0" (
|
|
||||||
@echo conda_sd_ui_deps_installed >> ..\scripts\install_status.txt
|
|
||||||
)
|
|
||||||
|
|
||||||
@>nul findstr /m "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 "Easy Diffusion installation complete! Starting the server!" & echo.
|
|
||||||
|
|
||||||
@set SD_DIR=%cd%
|
|
||||||
|
|
||||||
set PYTHONPATH=%INSTALL_ENV_DIR%\lib\site-packages
|
set PYTHONPATH=%INSTALL_ENV_DIR%\lib\site-packages
|
||||||
echo PYTHONPATH=%PYTHONPATH%
|
echo PYTHONPATH=%PYTHONPATH%
|
||||||
|
|
||||||
|
@rem Download the required packages
|
||||||
call where python
|
call where python
|
||||||
call python --version
|
call python --version
|
||||||
|
|
||||||
@cd ..
|
call python scripts\check_modules.py --launch-uvicorn
|
||||||
@set SD_UI_PATH=%cd%\ui
|
pause
|
||||||
|
exit /b
|
||||||
|
|
||||||
@FOR /F "tokens=* USEBACKQ" %%F IN (`python scripts\get_config.py --default=9000 net listen_port`) DO (
|
|
||||||
@SET ED_BIND_PORT=%%F
|
|
||||||
)
|
|
||||||
|
|
||||||
@FOR /F "tokens=* USEBACKQ" %%F IN (`python scripts\get_config.py --default=False net listen_to_network`) DO (
|
|
||||||
if "%%F" EQU "True" (
|
|
||||||
@FOR /F "tokens=* USEBACKQ" %%G IN (`python scripts\get_config.py --default=0.0.0.0 net bind_ip`) DO (
|
|
||||||
@SET ED_BIND_IP=%%G
|
|
||||||
)
|
|
||||||
) else (
|
|
||||||
@SET ED_BIND_IP=127.0.0.1
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@cd stable-diffusion
|
|
||||||
|
|
||||||
@rem set any overrides
|
|
||||||
set HF_HUB_DISABLE_SYMLINKS_WARNING=true
|
|
||||||
|
|
||||||
@python -m uvicorn main:server_api --app-dir "%SD_UI_PATH%" --port %ED_BIND_PORT% --host %ED_BIND_IP% --log-level error
|
|
||||||
|
|
||||||
|
|
||||||
@pause
|
|
||||||
|
@ -7,6 +7,7 @@ cp sd-ui-files/scripts/check_modules.py scripts/
|
|||||||
cp sd-ui-files/scripts/get_config.py scripts/
|
cp sd-ui-files/scripts/get_config.py scripts/
|
||||||
cp sd-ui-files/scripts/config.yaml.sample scripts/
|
cp sd-ui-files/scripts/config.yaml.sample scripts/
|
||||||
|
|
||||||
|
|
||||||
source ./scripts/functions.sh
|
source ./scripts/functions.sh
|
||||||
|
|
||||||
# activate the installer env
|
# activate the installer env
|
||||||
@ -20,6 +21,10 @@ if [ -e "open_dev_console.sh" ]; then
|
|||||||
rm "open_dev_console.sh"
|
rm "open_dev_console.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -e "ui/plugins/ui/merge.plugin.js" ]; then
|
||||||
|
rm "ui/plugins/ui/merge.plugin.js"
|
||||||
|
fi
|
||||||
|
|
||||||
# set the correct installer path (current vs legacy)
|
# set the correct installer path (current vs legacy)
|
||||||
if [ -e "installer_files/env" ]; then
|
if [ -e "installer_files/env" ]; then
|
||||||
export INSTALL_ENV_DIR="$(pwd)/installer_files/env"
|
export INSTALL_ENV_DIR="$(pwd)/installer_files/env"
|
||||||
@ -41,45 +46,8 @@ fi
|
|||||||
if [ -e "src" ]; then mv src src-old; fi
|
if [ -e "src" ]; then mv src src-old; fi
|
||||||
if [ -e "ldm" ]; then mv ldm ldm-old; fi
|
if [ -e "ldm" ]; then mv ldm ldm-old; fi
|
||||||
|
|
||||||
# Download the required packages
|
|
||||||
if ! python ../scripts/check_modules.py; then
|
|
||||||
read -p "Press any key to continue"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! command -v uvicorn &> /dev/null; then
|
|
||||||
fail "UI packages not found!"
|
|
||||||
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\nEasy Diffusion installation complete, starting the server!\n\n"
|
|
||||||
|
|
||||||
SD_PATH=`pwd`
|
|
||||||
|
|
||||||
export PYTORCH_ENABLE_MPS_FALLBACK=1
|
|
||||||
export PYTHONPATH="$INSTALL_ENV_DIR/lib/python3.8/site-packages"
|
|
||||||
echo "PYTHONPATH=$PYTHONPATH"
|
|
||||||
|
|
||||||
which python
|
|
||||||
python --version
|
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
export SD_UI_PATH=`pwd`/ui
|
# Download the required packages
|
||||||
export ED_BIND_PORT="$( python scripts/get_config.py --default=9000 net listen_port )"
|
python scripts/check_modules.py --launch-uvicorn
|
||||||
case "$( python scripts/get_config.py --default=False net listen_to_network )" in
|
|
||||||
"True")
|
|
||||||
export ED_BIND_IP=$( python scripts/get_config.py --default=0.0.0.0 net bind_ip)
|
|
||||||
;;
|
|
||||||
"False")
|
|
||||||
export ED_BIND_IP=127.0.0.1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
cd stable-diffusion
|
|
||||||
|
|
||||||
uvicorn main:server_api --app-dir "$SD_UI_PATH" --port "$ED_BIND_PORT" --host "$ED_BIND_IP" --log-level error
|
|
||||||
|
|
||||||
read -p "Press any key to continue"
|
read -p "Press any key to continue"
|
||||||
|
@ -11,7 +11,7 @@ if [ -f "on_sd_start.bat" ]; then
|
|||||||
echo download. This will not work.
|
echo download. This will not work.
|
||||||
echo
|
echo
|
||||||
echo Recommended: Please close this window and download the installer from
|
echo Recommended: Please close this window and download the installer from
|
||||||
echo https://stable-diffusion-ui.github.io/docs/installation/
|
echo https://easydiffusion.github.io/docs/installation/
|
||||||
echo
|
echo
|
||||||
echo ================================================================================
|
echo ================================================================================
|
||||||
echo
|
echo
|
||||||
|
@ -37,7 +37,6 @@ ROOT_DIR = os.path.abspath(os.path.join(SD_DIR, ".."))
|
|||||||
SD_UI_DIR = os.getenv("SD_UI_PATH", None)
|
SD_UI_DIR = os.getenv("SD_UI_PATH", None)
|
||||||
|
|
||||||
CONFIG_DIR = os.path.abspath(os.path.join(SD_UI_DIR, "..", "scripts"))
|
CONFIG_DIR = os.path.abspath(os.path.join(SD_UI_DIR, "..", "scripts"))
|
||||||
MODELS_DIR = os.path.abspath(os.path.join(SD_DIR, "..", "models"))
|
|
||||||
BUCKET_DIR = os.path.abspath(os.path.join(SD_DIR, "..", "bucket"))
|
BUCKET_DIR = os.path.abspath(os.path.join(SD_DIR, "..", "bucket"))
|
||||||
|
|
||||||
USER_PLUGINS_DIR = os.path.abspath(os.path.join(SD_DIR, "..", "plugins"))
|
USER_PLUGINS_DIR = os.path.abspath(os.path.join(SD_DIR, "..", "plugins"))
|
||||||
@ -61,7 +60,7 @@ APP_CONFIG_DEFAULTS = {
|
|||||||
"ui": {
|
"ui": {
|
||||||
"open_browser_on_start": True,
|
"open_browser_on_start": True,
|
||||||
},
|
},
|
||||||
"test_diffusers": True,
|
"use_v3_engine": True,
|
||||||
}
|
}
|
||||||
|
|
||||||
IMAGE_EXTENSIONS = [
|
IMAGE_EXTENSIONS = [
|
||||||
@ -92,14 +91,23 @@ CUSTOM_MODIFIERS_LANDSCAPE_EXTENSIONS = [
|
|||||||
"-landscape",
|
"-landscape",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
MODELS_DIR = os.path.abspath(os.path.join(SD_DIR, "..", "models"))
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
|
global MODELS_DIR
|
||||||
|
|
||||||
os.makedirs(USER_UI_PLUGINS_DIR, exist_ok=True)
|
os.makedirs(USER_UI_PLUGINS_DIR, exist_ok=True)
|
||||||
os.makedirs(USER_SERVER_PLUGINS_DIR, exist_ok=True)
|
os.makedirs(USER_SERVER_PLUGINS_DIR, exist_ok=True)
|
||||||
|
|
||||||
# https://pytorch.org/docs/stable/storage.html
|
# https://pytorch.org/docs/stable/storage.html
|
||||||
warnings.filterwarnings("ignore", category=UserWarning, message="TypedStorage is deprecated")
|
warnings.filterwarnings("ignore", category=UserWarning, message="TypedStorage is deprecated")
|
||||||
|
|
||||||
|
config = getConfig()
|
||||||
|
config_models_dir = config.get("models_dir", None)
|
||||||
|
if (config_models_dir is not None and config_models_dir != ""):
|
||||||
|
MODELS_DIR = config_models_dir
|
||||||
|
|
||||||
|
|
||||||
def init_render_threads():
|
def init_render_threads():
|
||||||
load_server_plugins()
|
load_server_plugins()
|
||||||
@ -116,9 +124,9 @@ def getConfig(default_val=APP_CONFIG_DEFAULTS):
|
|||||||
shutil.move(config_legacy_yaml, config_yaml_path)
|
shutil.move(config_legacy_yaml, config_yaml_path)
|
||||||
|
|
||||||
def set_config_on_startup(config: dict):
|
def set_config_on_startup(config: dict):
|
||||||
if getConfig.__test_diffusers_on_startup is None:
|
if getConfig.__use_v3_engine_on_startup is None:
|
||||||
getConfig.__test_diffusers_on_startup = config.get("test_diffusers", True)
|
getConfig.__use_v3_engine_on_startup = config.get("use_v3_engine", True)
|
||||||
config["config_on_startup"] = {"test_diffusers": getConfig.__test_diffusers_on_startup}
|
config["config_on_startup"] = {"use_v3_engine": getConfig.__use_v3_engine_on_startup}
|
||||||
|
|
||||||
if os.path.isfile(config_yaml_path):
|
if os.path.isfile(config_yaml_path):
|
||||||
try:
|
try:
|
||||||
@ -166,12 +174,15 @@ def getConfig(default_val=APP_CONFIG_DEFAULTS):
|
|||||||
return default_val
|
return default_val
|
||||||
|
|
||||||
|
|
||||||
getConfig.__test_diffusers_on_startup = None
|
getConfig.__use_v3_engine_on_startup = None
|
||||||
|
|
||||||
|
|
||||||
def setConfig(config):
|
def setConfig(config):
|
||||||
|
global MODELS_DIR
|
||||||
|
|
||||||
try: # config.yaml
|
try: # config.yaml
|
||||||
config_yaml_path = os.path.join(CONFIG_DIR, "..", "config.yaml")
|
config_yaml_path = os.path.join(CONFIG_DIR, "..", "config.yaml")
|
||||||
|
config_yaml_path = os.path.abspath(config_yaml_path)
|
||||||
yaml = YAML()
|
yaml = YAML()
|
||||||
|
|
||||||
if not hasattr(config, "_yaml_comment"):
|
if not hasattr(config, "_yaml_comment"):
|
||||||
@ -205,6 +216,9 @@ def setConfig(config):
|
|||||||
except:
|
except:
|
||||||
log.error(traceback.format_exc())
|
log.error(traceback.format_exc())
|
||||||
|
|
||||||
|
if config.get("models_dir"):
|
||||||
|
MODELS_DIR = config["models_dir"]
|
||||||
|
|
||||||
|
|
||||||
def save_to_config(ckpt_model_name, vae_model_name, hypernetwork_model_name, vram_usage_level):
|
def save_to_config(ckpt_model_name, vae_model_name, hypernetwork_model_name, vram_usage_level):
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
@ -55,8 +55,13 @@ def init():
|
|||||||
return bucketfiles
|
return bucketfiles
|
||||||
|
|
||||||
else:
|
else:
|
||||||
bucket_id = crud.get_bucket_by_path(db, path).id
|
bucket = crud.get_bucket_by_path(db, path)
|
||||||
|
if bucket == None:
|
||||||
|
raise HTTPException(status_code=404, detail="Bucket not found")
|
||||||
|
bucket_id = bucket.id
|
||||||
bucketfile = db.query(models.BucketFile).filter(models.BucketFile.bucket_id == bucket_id, models.BucketFile.filename == filename).first()
|
bucketfile = db.query(models.BucketFile).filter(models.BucketFile.bucket_id == bucket_id, models.BucketFile.filename == filename).first()
|
||||||
|
if bucketfile == None:
|
||||||
|
raise HTTPException(status_code=404, detail="File not found")
|
||||||
|
|
||||||
suffix = get_suffix_from_filename(filename)
|
suffix = get_suffix_from_filename(filename)
|
||||||
|
|
||||||
|
@ -243,7 +243,8 @@ def get_processor_name():
|
|||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
return platform.processor()
|
return platform.processor()
|
||||||
elif platform.system() == "Darwin":
|
elif platform.system() == "Darwin":
|
||||||
os.environ["PATH"] = os.environ["PATH"] + os.pathsep + "/usr/sbin"
|
if "/usr/sbin" not in os.environ["PATH"].split(os.pathsep):
|
||||||
|
os.environ["PATH"] = os.environ["PATH"] + os.pathsep + "/usr/sbin"
|
||||||
command = "sysctl -n machdep.cpu.brand_string"
|
command = "sysctl -n machdep.cpu.brand_string"
|
||||||
return subprocess.check_output(command, shell=True).decode().strip()
|
return subprocess.check_output(command, shell=True).decode().strip()
|
||||||
elif platform.system() == "Linux":
|
elif platform.system() == "Linux":
|
||||||
|
@ -193,9 +193,9 @@ def resolve_model_paths(models_data: ModelsData):
|
|||||||
skip_models = cn_filters + ["latent_upscaler", "nsfw_checker"]
|
skip_models = cn_filters + ["latent_upscaler", "nsfw_checker"]
|
||||||
if model_type in skip_models: # doesn't use model paths
|
if model_type in skip_models: # doesn't use model paths
|
||||||
continue
|
continue
|
||||||
if model_type == "codeformer":
|
if model_type == "codeformer" and model_paths[model_type]:
|
||||||
download_if_necessary("codeformer", "codeformer.pth", "codeformer-0.1.0")
|
download_if_necessary("codeformer", "codeformer.pth", "codeformer-0.1.0")
|
||||||
elif model_type == "controlnet":
|
elif model_type == "controlnet" and model_paths[model_type]:
|
||||||
model_id = model_paths[model_type]
|
model_id = model_paths[model_type]
|
||||||
model_info = get_model_info_from_db(model_type=model_type, model_id=model_id)
|
model_info = get_model_info_from_db(model_type=model_type, model_id=model_id)
|
||||||
if model_info:
|
if model_info:
|
||||||
@ -261,7 +261,24 @@ def make_model_folders():
|
|||||||
for model_type in KNOWN_MODEL_TYPES:
|
for model_type in KNOWN_MODEL_TYPES:
|
||||||
model_dir_path = os.path.join(app.MODELS_DIR, model_type)
|
model_dir_path = os.path.join(app.MODELS_DIR, model_type)
|
||||||
|
|
||||||
os.makedirs(model_dir_path, exist_ok=True)
|
try:
|
||||||
|
os.makedirs(model_dir_path, exist_ok=True)
|
||||||
|
except Exception as e:
|
||||||
|
from rich.console import Console
|
||||||
|
from rich.panel import Panel
|
||||||
|
|
||||||
|
Console().print(
|
||||||
|
Panel(
|
||||||
|
"\n"
|
||||||
|
+ f"Error while creating the models directory: '{model_dir_path}'\n"
|
||||||
|
+ f"Error: {e}\n\n"
|
||||||
|
+ f"[white]Check the 'models_dir:' line in the file '{os.path.join(app.ROOT_DIR, 'config.yaml')}'.[/white]\n",
|
||||||
|
title="Fatal Error starting Easy Diffusion",
|
||||||
|
style="bold yellow on red",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
input("Press Enter to terminate...")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
help_file_name = f"Place your {model_type} model files here.txt"
|
help_file_name = f"Place your {model_type} model files here.txt"
|
||||||
help_file_contents = f'Supported extensions: {" or ".join(MODEL_EXTENSIONS.get(model_type))}'
|
help_file_contents = f'Supported extensions: {" or ".join(MODEL_EXTENSIONS.get(model_type))}'
|
||||||
@ -305,7 +322,7 @@ def is_malicious_model(file_path):
|
|||||||
def getModels(scan_for_malicious: bool = True):
|
def getModels(scan_for_malicious: bool = True):
|
||||||
models = {
|
models = {
|
||||||
"options": {
|
"options": {
|
||||||
"stable-diffusion": [{"sd-v1-4": "SD 1.4"}],
|
"stable-diffusion": [],
|
||||||
"vae": [],
|
"vae": [],
|
||||||
"hypernetwork": [],
|
"hypernetwork": [],
|
||||||
"lora": [],
|
"lora": [],
|
||||||
|
@ -12,9 +12,9 @@ from easydiffusion import app
|
|||||||
manifest = {
|
manifest = {
|
||||||
"tensorrt": {
|
"tensorrt": {
|
||||||
"install": [
|
"install": [
|
||||||
"nvidia-cudnn --pre --extra-index-url=https://pypi.nvidia.com --trusted-host pypi.nvidia.com",
|
"wheel",
|
||||||
"tensorrt-libs --pre --extra-index-url=https://pypi.nvidia.com --trusted-host pypi.nvidia.com",
|
"nvidia-cudnn-cu11==8.9.4.25",
|
||||||
"tensorrt --pre --extra-index-url=https://pypi.nvidia.com --trusted-host pypi.nvidia.com",
|
"tensorrt==9.0.0.post11.dev1 --pre --extra-index-url=https://pypi.nvidia.com --trusted-host pypi.nvidia.com",
|
||||||
],
|
],
|
||||||
"uninstall": ["tensorrt"],
|
"uninstall": ["tensorrt"],
|
||||||
# TODO also uninstall tensorrt-libs and nvidia-cudnn, but do it upon restarting (avoid 'file in use' error)
|
# TODO also uninstall tensorrt-libs and nvidia-cudnn, but do it upon restarting (avoid 'file in use' error)
|
||||||
|
@ -30,7 +30,7 @@ def init(device):
|
|||||||
from easydiffusion import app
|
from easydiffusion import app
|
||||||
|
|
||||||
app_config = app.getConfig()
|
app_config = app.getConfig()
|
||||||
context.test_diffusers = app_config.get("test_diffusers", True)
|
context.test_diffusers = app_config.get("use_v3_engine", True)
|
||||||
|
|
||||||
log.info("Device usage during initialization:")
|
log.info("Device usage during initialization:")
|
||||||
get_device_usage(device, log_info=True, process_usage_only=False)
|
get_device_usage(device, log_info=True, process_usage_only=False)
|
||||||
|
@ -15,8 +15,10 @@ from easydiffusion.types import (
|
|||||||
FilterImageRequest,
|
FilterImageRequest,
|
||||||
MergeRequest,
|
MergeRequest,
|
||||||
TaskData,
|
TaskData,
|
||||||
|
RenderTaskData,
|
||||||
ModelsData,
|
ModelsData,
|
||||||
OutputFormatData,
|
OutputFormatData,
|
||||||
|
SaveToDiskData,
|
||||||
convert_legacy_render_req_to_new,
|
convert_legacy_render_req_to_new,
|
||||||
)
|
)
|
||||||
from easydiffusion.utils import log
|
from easydiffusion.utils import log
|
||||||
@ -36,6 +38,7 @@ NOCACHE_HEADERS = {
|
|||||||
"Pragma": "no-cache",
|
"Pragma": "no-cache",
|
||||||
"Expires": "0",
|
"Expires": "0",
|
||||||
}
|
}
|
||||||
|
PROTECTED_CONFIG_KEYS = ("block_nsfw",) # can't change these via the HTTP API
|
||||||
|
|
||||||
|
|
||||||
class NoCacheStaticFiles(StaticFiles):
|
class NoCacheStaticFiles(StaticFiles):
|
||||||
@ -63,7 +66,8 @@ class SetAppConfigRequest(BaseModel, extra=Extra.allow):
|
|||||||
ui_open_browser_on_start: bool = None
|
ui_open_browser_on_start: bool = None
|
||||||
listen_to_network: bool = None
|
listen_to_network: bool = None
|
||||||
listen_port: int = None
|
listen_port: int = None
|
||||||
test_diffusers: bool = True
|
use_v3_engine: bool = True
|
||||||
|
models_dir: str = None
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
@ -172,10 +176,11 @@ def set_app_config_internal(req: SetAppConfigRequest):
|
|||||||
config["net"] = {}
|
config["net"] = {}
|
||||||
config["net"]["listen_port"] = int(req.listen_port)
|
config["net"]["listen_port"] = int(req.listen_port)
|
||||||
|
|
||||||
config["test_diffusers"] = req.test_diffusers
|
config["use_v3_engine"] = req.use_v3_engine
|
||||||
|
config["models_dir"] = req.models_dir
|
||||||
|
|
||||||
for property, property_value in req.dict().items():
|
for property, property_value in req.dict().items():
|
||||||
if property_value is not None and property not in req.__fields__:
|
if property_value is not None and property not in req.__fields__ and property not in PROTECTED_CONFIG_KEYS:
|
||||||
config[property] = property_value
|
config[property] = property_value
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -204,7 +209,12 @@ def read_web_data_internal(key: str = None, **kwargs):
|
|||||||
if not key: # /get without parameters, stable-diffusion easter egg.
|
if not key: # /get without parameters, stable-diffusion easter egg.
|
||||||
raise HTTPException(status_code=418, detail="StableDiffusion is drawing a teapot!") # HTTP418 I'm a teapot
|
raise HTTPException(status_code=418, detail="StableDiffusion is drawing a teapot!") # HTTP418 I'm a teapot
|
||||||
elif key == "app_config":
|
elif key == "app_config":
|
||||||
return JSONResponse(app.getConfig(), headers=NOCACHE_HEADERS)
|
config = app.getConfig()
|
||||||
|
|
||||||
|
if "models_dir" not in config:
|
||||||
|
config["models_dir"] = app.MODELS_DIR
|
||||||
|
|
||||||
|
return JSONResponse(config, headers=NOCACHE_HEADERS)
|
||||||
elif key == "system_info":
|
elif key == "system_info":
|
||||||
config = app.getConfig()
|
config = app.getConfig()
|
||||||
|
|
||||||
@ -215,6 +225,7 @@ def read_web_data_internal(key: str = None, **kwargs):
|
|||||||
"hosts": app.getIPConfig(),
|
"hosts": app.getIPConfig(),
|
||||||
"default_output_dir": output_dir,
|
"default_output_dir": output_dir,
|
||||||
"enforce_output_dir": ("force_save_path" in config),
|
"enforce_output_dir": ("force_save_path" in config),
|
||||||
|
"enforce_output_metadata": ("force_save_metadata" in config),
|
||||||
}
|
}
|
||||||
system_info["devices"]["config"] = config.get("render_devices", "auto")
|
system_info["devices"]["config"] = config.get("render_devices", "auto")
|
||||||
return JSONResponse(system_info, headers=NOCACHE_HEADERS)
|
return JSONResponse(system_info, headers=NOCACHE_HEADERS)
|
||||||
@ -261,14 +272,15 @@ def render_internal(req: dict):
|
|||||||
|
|
||||||
# separate out the request data into rendering and task-specific data
|
# separate out the request data into rendering and task-specific data
|
||||||
render_req: GenerateImageRequest = GenerateImageRequest.parse_obj(req)
|
render_req: GenerateImageRequest = GenerateImageRequest.parse_obj(req)
|
||||||
task_data: TaskData = TaskData.parse_obj(req)
|
task_data: RenderTaskData = RenderTaskData.parse_obj(req)
|
||||||
models_data: ModelsData = ModelsData.parse_obj(req)
|
models_data: ModelsData = ModelsData.parse_obj(req)
|
||||||
output_format: OutputFormatData = OutputFormatData.parse_obj(req)
|
output_format: OutputFormatData = OutputFormatData.parse_obj(req)
|
||||||
|
save_data: SaveToDiskData = SaveToDiskData.parse_obj(req)
|
||||||
|
|
||||||
# Overwrite user specified save path
|
# Overwrite user specified save path
|
||||||
config = app.getConfig()
|
config = app.getConfig()
|
||||||
if "force_save_path" in config:
|
if "force_save_path" in config:
|
||||||
task_data.save_to_disk_path = config["force_save_path"]
|
save_data.save_to_disk_path = config["force_save_path"]
|
||||||
|
|
||||||
render_req.init_image_mask = req.get("mask") # hack: will rename this in the HTTP API in a future revision
|
render_req.init_image_mask = req.get("mask") # hack: will rename this in the HTTP API in a future revision
|
||||||
|
|
||||||
@ -280,7 +292,7 @@ def render_internal(req: dict):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# enqueue the task
|
# enqueue the task
|
||||||
task = RenderTask(render_req, task_data, models_data, output_format)
|
task = RenderTask(render_req, task_data, models_data, output_format, save_data)
|
||||||
return enqueue_task(task)
|
return enqueue_task(task)
|
||||||
except HTTPException as e:
|
except HTTPException as e:
|
||||||
raise e
|
raise e
|
||||||
@ -291,13 +303,14 @@ def render_internal(req: dict):
|
|||||||
|
|
||||||
def filter_internal(req: dict):
|
def filter_internal(req: dict):
|
||||||
try:
|
try:
|
||||||
session_id = req.get("session_id", "session")
|
|
||||||
filter_req: FilterImageRequest = FilterImageRequest.parse_obj(req)
|
filter_req: FilterImageRequest = FilterImageRequest.parse_obj(req)
|
||||||
|
task_data: TaskData = TaskData.parse_obj(req)
|
||||||
models_data: ModelsData = ModelsData.parse_obj(req)
|
models_data: ModelsData = ModelsData.parse_obj(req)
|
||||||
output_format: OutputFormatData = OutputFormatData.parse_obj(req)
|
output_format: OutputFormatData = OutputFormatData.parse_obj(req)
|
||||||
|
save_data: SaveToDiskData = SaveToDiskData.parse_obj(req)
|
||||||
|
|
||||||
# enqueue the task
|
# enqueue the task
|
||||||
task = FilterTask(filter_req, session_id, models_data, output_format)
|
task = FilterTask(filter_req, task_data, models_data, output_format, save_data)
|
||||||
return enqueue_task(task)
|
return enqueue_task(task)
|
||||||
except HTTPException as e:
|
except HTTPException as e:
|
||||||
raise e
|
raise e
|
||||||
@ -456,8 +469,8 @@ def modify_package_internal(package_name: str, req: dict):
|
|||||||
log.error(traceback.format_exc())
|
log.error(traceback.format_exc())
|
||||||
return HTTPException(status_code=500, detail=str(e))
|
return HTTPException(status_code=500, detail=str(e))
|
||||||
|
|
||||||
|
|
||||||
def get_sha256_internal(obj_path):
|
def get_sha256_internal(obj_path):
|
||||||
import hashlib
|
|
||||||
from easydiffusion.utils import sha256sum
|
from easydiffusion.utils import sha256sum
|
||||||
|
|
||||||
path = obj_path.split("/")
|
path = obj_path.split("/")
|
||||||
@ -477,4 +490,3 @@ def get_sha256_internal(obj_path):
|
|||||||
log.error(str(e))
|
log.error(str(e))
|
||||||
log.error(traceback.format_exc())
|
log.error(traceback.format_exc())
|
||||||
return HTTPException(status_code=500, detail=str(e))
|
return HTTPException(status_code=500, detail=str(e))
|
||||||
|
|
||||||
|
@ -1,12 +1,25 @@
|
|||||||
|
import os
|
||||||
import json
|
import json
|
||||||
import pprint
|
import pprint
|
||||||
|
import time
|
||||||
|
|
||||||
|
from numpy import base_repr
|
||||||
|
|
||||||
from sdkit.filter import apply_filters
|
from sdkit.filter import apply_filters
|
||||||
from sdkit.models import load_model
|
from sdkit.models import load_model
|
||||||
from sdkit.utils import img_to_base64_str, get_image, log
|
from sdkit.utils import img_to_base64_str, get_image, log, save_images
|
||||||
|
|
||||||
from easydiffusion import model_manager, runtime
|
from easydiffusion import model_manager, runtime
|
||||||
from easydiffusion.types import FilterImageRequest, FilterImageResponse, ModelsData, OutputFormatData
|
from easydiffusion.types import (
|
||||||
|
FilterImageRequest,
|
||||||
|
FilterImageResponse,
|
||||||
|
ModelsData,
|
||||||
|
OutputFormatData,
|
||||||
|
SaveToDiskData,
|
||||||
|
TaskData,
|
||||||
|
GenerateImageRequest,
|
||||||
|
)
|
||||||
|
from easydiffusion.utils.save_utils import format_folder_name
|
||||||
|
|
||||||
from .task import Task
|
from .task import Task
|
||||||
|
|
||||||
@ -15,13 +28,22 @@ class FilterTask(Task):
|
|||||||
"For applying filters to input images"
|
"For applying filters to input images"
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, req: FilterImageRequest, session_id: str, models_data: ModelsData, output_format: OutputFormatData
|
self,
|
||||||
|
req: FilterImageRequest,
|
||||||
|
task_data: TaskData,
|
||||||
|
models_data: ModelsData,
|
||||||
|
output_format: OutputFormatData,
|
||||||
|
save_data: SaveToDiskData,
|
||||||
):
|
):
|
||||||
super().__init__(session_id)
|
super().__init__(task_data.session_id)
|
||||||
|
|
||||||
|
task_data.request_id = self.id
|
||||||
|
|
||||||
self.request = req
|
self.request = req
|
||||||
|
self.task_data = task_data
|
||||||
self.models_data = models_data
|
self.models_data = models_data
|
||||||
self.output_format = output_format
|
self.output_format = output_format
|
||||||
|
self.save_data = save_data
|
||||||
|
|
||||||
# convert to multi-filter format, if necessary
|
# convert to multi-filter format, if necessary
|
||||||
if isinstance(req.filter, str):
|
if isinstance(req.filter, str):
|
||||||
@ -34,13 +56,15 @@ class FilterTask(Task):
|
|||||||
def run(self):
|
def run(self):
|
||||||
"Runs the image filtering task on the assigned thread"
|
"Runs the image filtering task on the assigned thread"
|
||||||
|
|
||||||
|
from easydiffusion import app
|
||||||
|
|
||||||
context = runtime.context
|
context = runtime.context
|
||||||
|
|
||||||
model_manager.resolve_model_paths(self.models_data)
|
model_manager.resolve_model_paths(self.models_data)
|
||||||
model_manager.reload_models_if_necessary(context, self.models_data)
|
model_manager.reload_models_if_necessary(context, self.models_data)
|
||||||
model_manager.fail_if_models_did_not_load(context)
|
model_manager.fail_if_models_did_not_load(context)
|
||||||
|
|
||||||
print_task_info(self.request, self.models_data, self.output_format)
|
print_task_info(self.request, self.models_data, self.output_format, self.save_data)
|
||||||
|
|
||||||
if isinstance(self.request.image, list):
|
if isinstance(self.request.image, list):
|
||||||
images = [get_image(img) for img in self.request.image]
|
images = [get_image(img) for img in self.request.image]
|
||||||
@ -50,6 +74,26 @@ class FilterTask(Task):
|
|||||||
images = filter_images(context, images, self.request.filter, self.request.filter_params)
|
images = filter_images(context, images, self.request.filter, self.request.filter_params)
|
||||||
|
|
||||||
output_format = self.output_format
|
output_format = self.output_format
|
||||||
|
|
||||||
|
if self.save_data.save_to_disk_path is not None:
|
||||||
|
app_config = app.getConfig()
|
||||||
|
folder_format = app_config.get("folder_format", "$id")
|
||||||
|
|
||||||
|
dummy_req = GenerateImageRequest()
|
||||||
|
img_id = base_repr(int(time.time() * 10000), 36)[-7:] # Base 36 conversion, 0-9, A-Z
|
||||||
|
|
||||||
|
save_dir_path = os.path.join(
|
||||||
|
self.save_data.save_to_disk_path, format_folder_name(folder_format, dummy_req, self.task_data)
|
||||||
|
)
|
||||||
|
save_images(
|
||||||
|
images,
|
||||||
|
save_dir_path,
|
||||||
|
file_name=img_id,
|
||||||
|
output_format=output_format.output_format,
|
||||||
|
output_quality=output_format.output_quality,
|
||||||
|
output_lossless=output_format.output_lossless,
|
||||||
|
)
|
||||||
|
|
||||||
images = [
|
images = [
|
||||||
img_to_base64_str(
|
img_to_base64_str(
|
||||||
img, output_format.output_format, output_format.output_quality, output_format.output_lossless
|
img, output_format.output_format, output_format.output_quality, output_format.output_lossless
|
||||||
@ -60,6 +104,7 @@ class FilterTask(Task):
|
|||||||
res = FilterImageResponse(self.request, self.models_data, images=images)
|
res = FilterImageResponse(self.request, self.models_data, images=images)
|
||||||
res = res.json()
|
res = res.json()
|
||||||
self.buffer_queue.put(json.dumps(res))
|
self.buffer_queue.put(json.dumps(res))
|
||||||
|
|
||||||
log.info("Filter task completed")
|
log.info("Filter task completed")
|
||||||
|
|
||||||
self.response = res
|
self.response = res
|
||||||
@ -105,11 +150,15 @@ def after_filter(context, filter_name, filter_params, previous_state):
|
|||||||
load_model(context, "realesrgan")
|
load_model(context, "realesrgan")
|
||||||
|
|
||||||
|
|
||||||
def print_task_info(req: FilterImageRequest, models_data: ModelsData, output_format: OutputFormatData):
|
def print_task_info(
|
||||||
|
req: FilterImageRequest, models_data: ModelsData, output_format: OutputFormatData, save_data: SaveToDiskData
|
||||||
|
):
|
||||||
req_str = pprint.pformat({"filter": req.filter, "filter_params": req.filter_params}).replace("[", "\[")
|
req_str = pprint.pformat({"filter": req.filter, "filter_params": req.filter_params}).replace("[", "\[")
|
||||||
models_data = pprint.pformat(models_data.dict()).replace("[", "\[")
|
models_data = pprint.pformat(models_data.dict()).replace("[", "\[")
|
||||||
output_format = pprint.pformat(output_format.dict()).replace("[", "\[")
|
output_format = pprint.pformat(output_format.dict()).replace("[", "\[")
|
||||||
|
save_data = pprint.pformat(save_data.dict()).replace("[", "\[")
|
||||||
|
|
||||||
log.info(f"request: {req_str}")
|
log.info(f"request: {req_str}")
|
||||||
log.info(f"models data: {models_data}")
|
log.info(f"models data: {models_data}")
|
||||||
log.info(f"output format: {output_format}")
|
log.info(f"output format: {output_format}")
|
||||||
|
log.info(f"save data: {save_data}")
|
||||||
|
@ -4,9 +4,9 @@ import queue
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from easydiffusion import model_manager, runtime
|
from easydiffusion import model_manager, runtime
|
||||||
from easydiffusion.types import GenerateImageRequest, ModelsData, OutputFormatData
|
from easydiffusion.types import GenerateImageRequest, ModelsData, OutputFormatData, SaveToDiskData
|
||||||
from easydiffusion.types import Image as ResponseImage
|
from easydiffusion.types import Image as ResponseImage
|
||||||
from easydiffusion.types import GenerateImageResponse, TaskData, UserInitiatedStop
|
from easydiffusion.types import GenerateImageResponse, RenderTaskData, UserInitiatedStop
|
||||||
from easydiffusion.utils import get_printable_request, log, save_images_to_disk
|
from easydiffusion.utils import get_printable_request, log, save_images_to_disk
|
||||||
from sdkit.generate import generate_images
|
from sdkit.generate import generate_images
|
||||||
from sdkit.utils import (
|
from sdkit.utils import (
|
||||||
@ -28,23 +28,38 @@ class RenderTask(Task):
|
|||||||
"For image generation"
|
"For image generation"
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, req: GenerateImageRequest, task_data: TaskData, models_data: ModelsData, output_format: OutputFormatData
|
self,
|
||||||
|
req: GenerateImageRequest,
|
||||||
|
task_data: RenderTaskData,
|
||||||
|
models_data: ModelsData,
|
||||||
|
output_format: OutputFormatData,
|
||||||
|
save_data: SaveToDiskData,
|
||||||
):
|
):
|
||||||
super().__init__(task_data.session_id)
|
super().__init__(task_data.session_id)
|
||||||
|
|
||||||
task_data.request_id = self.id
|
task_data.request_id = self.id
|
||||||
self.render_request: GenerateImageRequest = req # Initial Request
|
|
||||||
self.task_data: TaskData = task_data
|
self.render_request = req # Initial Request
|
||||||
|
self.task_data = task_data
|
||||||
self.models_data = models_data
|
self.models_data = models_data
|
||||||
self.output_format = output_format
|
self.output_format = output_format
|
||||||
|
self.save_data = save_data
|
||||||
|
|
||||||
self.temp_images: list = [None] * req.num_outputs * (1 if task_data.show_only_filtered_image else 2)
|
self.temp_images: list = [None] * req.num_outputs * (1 if task_data.show_only_filtered_image else 2)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"Runs the image generation task on the assigned thread"
|
"Runs the image generation task on the assigned thread"
|
||||||
|
|
||||||
from easydiffusion import task_manager
|
from easydiffusion import task_manager, app
|
||||||
|
|
||||||
context = runtime.context
|
context = runtime.context
|
||||||
|
config = app.getConfig()
|
||||||
|
|
||||||
|
if config.get("block_nsfw", False): # override if set on the server
|
||||||
|
self.task_data.block_nsfw = True
|
||||||
|
if "nsfw_checker" not in self.task_data.filters:
|
||||||
|
self.task_data.filters.append("nsfw_checker")
|
||||||
|
self.models_data.model_paths["nsfw_checker"] = "nsfw_checker"
|
||||||
|
|
||||||
def step_callback():
|
def step_callback():
|
||||||
task_manager.keep_task_alive(self)
|
task_manager.keep_task_alive(self)
|
||||||
@ -80,6 +95,7 @@ class RenderTask(Task):
|
|||||||
self.task_data,
|
self.task_data,
|
||||||
self.models_data,
|
self.models_data,
|
||||||
self.output_format,
|
self.output_format,
|
||||||
|
self.save_data,
|
||||||
self.buffer_queue,
|
self.buffer_queue,
|
||||||
self.temp_images,
|
self.temp_images,
|
||||||
step_callback,
|
step_callback,
|
||||||
@ -122,22 +138,23 @@ class RenderTask(Task):
|
|||||||
def make_images(
|
def make_images(
|
||||||
context,
|
context,
|
||||||
req: GenerateImageRequest,
|
req: GenerateImageRequest,
|
||||||
task_data: TaskData,
|
task_data: RenderTaskData,
|
||||||
models_data: ModelsData,
|
models_data: ModelsData,
|
||||||
output_format: OutputFormatData,
|
output_format: OutputFormatData,
|
||||||
|
save_data: SaveToDiskData,
|
||||||
data_queue: queue.Queue,
|
data_queue: queue.Queue,
|
||||||
task_temp_images: list,
|
task_temp_images: list,
|
||||||
step_callback,
|
step_callback,
|
||||||
):
|
):
|
||||||
context.stop_processing = False
|
context.stop_processing = False
|
||||||
print_task_info(req, task_data, models_data, output_format)
|
print_task_info(req, task_data, models_data, output_format, save_data)
|
||||||
|
|
||||||
images, seeds = make_images_internal(
|
images, seeds = make_images_internal(
|
||||||
context, req, task_data, models_data, output_format, data_queue, task_temp_images, step_callback
|
context, req, task_data, models_data, output_format, save_data, data_queue, task_temp_images, step_callback
|
||||||
)
|
)
|
||||||
|
|
||||||
res = GenerateImageResponse(
|
res = GenerateImageResponse(
|
||||||
req, task_data, models_data, output_format, images=construct_response(images, seeds, output_format)
|
req, task_data, models_data, output_format, save_data, images=construct_response(images, seeds, output_format)
|
||||||
)
|
)
|
||||||
res = res.json()
|
res = res.json()
|
||||||
data_queue.put(json.dumps(res))
|
data_queue.put(json.dumps(res))
|
||||||
@ -147,25 +164,32 @@ def make_images(
|
|||||||
|
|
||||||
|
|
||||||
def print_task_info(
|
def print_task_info(
|
||||||
req: GenerateImageRequest, task_data: TaskData, models_data: ModelsData, output_format: OutputFormatData
|
req: GenerateImageRequest,
|
||||||
|
task_data: RenderTaskData,
|
||||||
|
models_data: ModelsData,
|
||||||
|
output_format: OutputFormatData,
|
||||||
|
save_data: SaveToDiskData,
|
||||||
):
|
):
|
||||||
req_str = pprint.pformat(get_printable_request(req, task_data, output_format)).replace("[", "\[")
|
req_str = pprint.pformat(get_printable_request(req, task_data, models_data, output_format, save_data)).replace("[", "\[")
|
||||||
task_str = pprint.pformat(task_data.dict()).replace("[", "\[")
|
task_str = pprint.pformat(task_data.dict()).replace("[", "\[")
|
||||||
models_data = pprint.pformat(models_data.dict()).replace("[", "\[")
|
models_data = pprint.pformat(models_data.dict()).replace("[", "\[")
|
||||||
output_format = pprint.pformat(output_format.dict()).replace("[", "\[")
|
output_format = pprint.pformat(output_format.dict()).replace("[", "\[")
|
||||||
|
save_data = pprint.pformat(save_data.dict()).replace("[", "\[")
|
||||||
|
|
||||||
log.info(f"request: {req_str}")
|
log.info(f"request: {req_str}")
|
||||||
log.info(f"task data: {task_str}")
|
log.info(f"task data: {task_str}")
|
||||||
# log.info(f"models data: {models_data}")
|
# log.info(f"models data: {models_data}")
|
||||||
log.info(f"output format: {output_format}")
|
log.info(f"output format: {output_format}")
|
||||||
|
log.info(f"save data: {save_data}")
|
||||||
|
|
||||||
|
|
||||||
def make_images_internal(
|
def make_images_internal(
|
||||||
context,
|
context,
|
||||||
req: GenerateImageRequest,
|
req: GenerateImageRequest,
|
||||||
task_data: TaskData,
|
task_data: RenderTaskData,
|
||||||
models_data: ModelsData,
|
models_data: ModelsData,
|
||||||
output_format: OutputFormatData,
|
output_format: OutputFormatData,
|
||||||
|
save_data: SaveToDiskData,
|
||||||
data_queue: queue.Queue,
|
data_queue: queue.Queue,
|
||||||
task_temp_images: list,
|
task_temp_images: list,
|
||||||
step_callback,
|
step_callback,
|
||||||
@ -187,8 +211,8 @@ def make_images_internal(
|
|||||||
filters, filter_params = task_data.filters, task_data.filter_params
|
filters, filter_params = task_data.filters, task_data.filter_params
|
||||||
filtered_images = filter_images(context, images, filters, filter_params) if not user_stopped else images
|
filtered_images = filter_images(context, images, filters, filter_params) if not user_stopped else images
|
||||||
|
|
||||||
if task_data.save_to_disk_path is not None:
|
if save_data.save_to_disk_path is not None:
|
||||||
save_images_to_disk(images, filtered_images, req, task_data, output_format)
|
save_images_to_disk(images, filtered_images, req, task_data, models_data, output_format, save_data)
|
||||||
|
|
||||||
seeds = [*range(req.seed, req.seed + len(images))]
|
seeds = [*range(req.seed, req.seed + len(images))]
|
||||||
if task_data.show_only_filtered_image or filtered_images is images:
|
if task_data.show_only_filtered_image or filtered_images is images:
|
||||||
@ -200,7 +224,7 @@ def make_images_internal(
|
|||||||
def generate_images_internal(
|
def generate_images_internal(
|
||||||
context,
|
context,
|
||||||
req: GenerateImageRequest,
|
req: GenerateImageRequest,
|
||||||
task_data: TaskData,
|
task_data: RenderTaskData,
|
||||||
models_data: ModelsData,
|
models_data: ModelsData,
|
||||||
data_queue: queue.Queue,
|
data_queue: queue.Queue,
|
||||||
task_temp_images: list,
|
task_temp_images: list,
|
||||||
@ -254,6 +278,13 @@ def generate_images_internal(
|
|||||||
setattr(pipe.unet, "_allocate_trt_buffers_backup", pipe.unet._allocate_trt_buffers)
|
setattr(pipe.unet, "_allocate_trt_buffers_backup", pipe.unet._allocate_trt_buffers)
|
||||||
delattr(pipe.unet, "_allocate_trt_buffers")
|
delattr(pipe.unet, "_allocate_trt_buffers")
|
||||||
|
|
||||||
|
if task_data.enable_vae_tiling:
|
||||||
|
if hasattr(pipe, "enable_vae_tiling"):
|
||||||
|
pipe.enable_vae_tiling()
|
||||||
|
else:
|
||||||
|
if hasattr(pipe, "disable_vae_tiling"):
|
||||||
|
pipe.disable_vae_tiling()
|
||||||
|
|
||||||
images = generate_images(context, callback=callback, **req.dict())
|
images = generate_images(context, callback=callback, **req.dict())
|
||||||
user_stopped = False
|
user_stopped = False
|
||||||
except UserInitiatedStop:
|
except UserInitiatedStop:
|
||||||
@ -291,7 +322,7 @@ def construct_response(images: list, seeds: list, output_format: OutputFormatDat
|
|||||||
def make_step_callback(
|
def make_step_callback(
|
||||||
context,
|
context,
|
||||||
req: GenerateImageRequest,
|
req: GenerateImageRequest,
|
||||||
task_data: TaskData,
|
task_data: RenderTaskData,
|
||||||
data_queue: queue.Queue,
|
data_queue: queue.Queue,
|
||||||
task_temp_images: list,
|
task_temp_images: list,
|
||||||
step_callback,
|
step_callback,
|
||||||
|
@ -26,7 +26,7 @@ class GenerateImageRequest(BaseModel):
|
|||||||
sampler_name: str = None # "ddim", "plms", "heun", "euler", "euler_a", "dpm2", "dpm2_a", "lms"
|
sampler_name: str = None # "ddim", "plms", "heun", "euler", "euler_a", "dpm2", "dpm2_a", "lms"
|
||||||
hypernetwork_strength: float = 0
|
hypernetwork_strength: float = 0
|
||||||
lora_alpha: Union[float, List[float]] = 0
|
lora_alpha: Union[float, List[float]] = 0
|
||||||
tiling: str = "none" # "none", "x", "y", "xy"
|
tiling: str = None # None, "x", "y", "xy"
|
||||||
|
|
||||||
|
|
||||||
class FilterImageRequest(BaseModel):
|
class FilterImageRequest(BaseModel):
|
||||||
@ -58,10 +58,17 @@ class OutputFormatData(BaseModel):
|
|||||||
output_lossless: bool = False
|
output_lossless: bool = False
|
||||||
|
|
||||||
|
|
||||||
|
class SaveToDiskData(BaseModel):
|
||||||
|
save_to_disk_path: str = None
|
||||||
|
metadata_output_format: str = "txt" # or "json"
|
||||||
|
|
||||||
|
|
||||||
class TaskData(BaseModel):
|
class TaskData(BaseModel):
|
||||||
request_id: str = None
|
request_id: str = None
|
||||||
session_id: str = "session"
|
session_id: str = "session"
|
||||||
save_to_disk_path: str = None
|
|
||||||
|
|
||||||
|
class RenderTaskData(TaskData):
|
||||||
vram_usage_level: str = "balanced" # or "low" or "medium"
|
vram_usage_level: str = "balanced" # or "low" or "medium"
|
||||||
|
|
||||||
use_face_correction: Union[str, List[str]] = None # or "GFPGANv1.3"
|
use_face_correction: Union[str, List[str]] = None # or "GFPGANv1.3"
|
||||||
@ -77,10 +84,10 @@ class TaskData(BaseModel):
|
|||||||
filters: List[str] = []
|
filters: List[str] = []
|
||||||
filter_params: Dict[str, Dict[str, Any]] = {}
|
filter_params: Dict[str, Dict[str, Any]] = {}
|
||||||
control_filter_to_apply: Union[str, List[str]] = None
|
control_filter_to_apply: Union[str, List[str]] = None
|
||||||
|
enable_vae_tiling: bool = True
|
||||||
|
|
||||||
show_only_filtered_image: bool = False
|
show_only_filtered_image: bool = False
|
||||||
block_nsfw: bool = False
|
block_nsfw: bool = False
|
||||||
metadata_output_format: str = "txt" # or "json"
|
|
||||||
stream_image_progress: bool = False
|
stream_image_progress: bool = False
|
||||||
stream_image_progress_interval: int = 5
|
stream_image_progress_interval: int = 5
|
||||||
clip_skip: bool = False
|
clip_skip: bool = False
|
||||||
@ -126,12 +133,14 @@ class GenerateImageResponse:
|
|||||||
task_data: TaskData,
|
task_data: TaskData,
|
||||||
models_data: ModelsData,
|
models_data: ModelsData,
|
||||||
output_format: OutputFormatData,
|
output_format: OutputFormatData,
|
||||||
|
save_data: SaveToDiskData,
|
||||||
images: list,
|
images: list,
|
||||||
):
|
):
|
||||||
self.render_request = render_request
|
self.render_request = render_request
|
||||||
self.task_data = task_data
|
self.task_data = task_data
|
||||||
self.models_data = models_data
|
self.models_data = models_data
|
||||||
self.output_format = output_format
|
self.output_format = output_format
|
||||||
|
self.save_data = save_data
|
||||||
self.images = images
|
self.images = images
|
||||||
|
|
||||||
def json(self):
|
def json(self):
|
||||||
@ -141,6 +150,7 @@ class GenerateImageResponse:
|
|||||||
|
|
||||||
task_data = self.task_data.dict()
|
task_data = self.task_data.dict()
|
||||||
task_data.update(self.output_format.dict())
|
task_data.update(self.output_format.dict())
|
||||||
|
task_data.update(self.save_data.dict())
|
||||||
|
|
||||||
res = {
|
res = {
|
||||||
"status": "succeeded",
|
"status": "succeeded",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import hashlib
|
||||||
|
|
||||||
log = logging.getLogger("easydiffusion")
|
log = logging.getLogger("easydiffusion")
|
||||||
|
|
||||||
|
@ -7,7 +7,14 @@ from datetime import datetime
|
|||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
from easydiffusion import app
|
from easydiffusion import app
|
||||||
from easydiffusion.types import GenerateImageRequest, TaskData, OutputFormatData
|
from easydiffusion.types import (
|
||||||
|
GenerateImageRequest,
|
||||||
|
TaskData,
|
||||||
|
RenderTaskData,
|
||||||
|
OutputFormatData,
|
||||||
|
SaveToDiskData,
|
||||||
|
ModelsData,
|
||||||
|
)
|
||||||
from numpy import base_repr
|
from numpy import base_repr
|
||||||
from sdkit.utils import save_dicts, save_images
|
from sdkit.utils import save_dicts, save_images
|
||||||
from sdkit.models.model_loader.embeddings import get_embedding_token
|
from sdkit.models.model_loader.embeddings import get_embedding_token
|
||||||
@ -24,6 +31,7 @@ TASK_TEXT_MAPPING = {
|
|||||||
"clip_skip": "Clip Skip",
|
"clip_skip": "Clip Skip",
|
||||||
"use_controlnet_model": "ControlNet model",
|
"use_controlnet_model": "ControlNet model",
|
||||||
"control_filter_to_apply": "ControlNet Filter",
|
"control_filter_to_apply": "ControlNet Filter",
|
||||||
|
"control_alpha": "ControlNet Strength",
|
||||||
"use_vae_model": "VAE model",
|
"use_vae_model": "VAE model",
|
||||||
"sampler_name": "Sampler",
|
"sampler_name": "Sampler",
|
||||||
"width": "Width",
|
"width": "Width",
|
||||||
@ -95,7 +103,7 @@ def format_folder_name(format: str, req: GenerateImageRequest, task_data: TaskDa
|
|||||||
def format_file_name(
|
def format_file_name(
|
||||||
format: str,
|
format: str,
|
||||||
req: GenerateImageRequest,
|
req: GenerateImageRequest,
|
||||||
task_data: TaskData,
|
task_data: RenderTaskData,
|
||||||
now: float,
|
now: float,
|
||||||
batch_file_number: int,
|
batch_file_number: int,
|
||||||
folder_img_number: ImageNumber,
|
folder_img_number: ImageNumber,
|
||||||
@ -118,13 +126,19 @@ def format_file_name(
|
|||||||
|
|
||||||
|
|
||||||
def save_images_to_disk(
|
def save_images_to_disk(
|
||||||
images: list, filtered_images: list, req: GenerateImageRequest, task_data: TaskData, output_format: OutputFormatData
|
images: list,
|
||||||
|
filtered_images: list,
|
||||||
|
req: GenerateImageRequest,
|
||||||
|
task_data: RenderTaskData,
|
||||||
|
models_data: ModelsData,
|
||||||
|
output_format: OutputFormatData,
|
||||||
|
save_data: SaveToDiskData,
|
||||||
):
|
):
|
||||||
now = time.time()
|
now = time.time()
|
||||||
app_config = app.getConfig()
|
app_config = app.getConfig()
|
||||||
folder_format = app_config.get("folder_format", "$id")
|
folder_format = app_config.get("folder_format", "$id")
|
||||||
save_dir_path = os.path.join(task_data.save_to_disk_path, format_folder_name(folder_format, req, task_data))
|
save_dir_path = os.path.join(save_data.save_to_disk_path, format_folder_name(folder_format, req, task_data))
|
||||||
metadata_entries = get_metadata_entries_for_request(req, task_data, output_format)
|
metadata_entries = get_metadata_entries_for_request(req, task_data, models_data, output_format, save_data)
|
||||||
file_number = calculate_img_number(save_dir_path, task_data)
|
file_number = calculate_img_number(save_dir_path, task_data)
|
||||||
make_filename = make_filename_callback(
|
make_filename = make_filename_callback(
|
||||||
app_config.get("filename_format", "$p_$tsb64"),
|
app_config.get("filename_format", "$p_$tsb64"),
|
||||||
@ -143,8 +157,8 @@ def save_images_to_disk(
|
|||||||
output_quality=output_format.output_quality,
|
output_quality=output_format.output_quality,
|
||||||
output_lossless=output_format.output_lossless,
|
output_lossless=output_format.output_lossless,
|
||||||
)
|
)
|
||||||
if task_data.metadata_output_format:
|
if save_data.metadata_output_format:
|
||||||
for metadata_output_format in task_data.metadata_output_format.split(","):
|
for metadata_output_format in save_data.metadata_output_format.split(","):
|
||||||
if metadata_output_format.lower() in ["json", "txt", "embed"]:
|
if metadata_output_format.lower() in ["json", "txt", "embed"]:
|
||||||
save_dicts(
|
save_dicts(
|
||||||
metadata_entries,
|
metadata_entries,
|
||||||
@ -179,8 +193,8 @@ def save_images_to_disk(
|
|||||||
output_quality=output_format.output_quality,
|
output_quality=output_format.output_quality,
|
||||||
output_lossless=output_format.output_lossless,
|
output_lossless=output_format.output_lossless,
|
||||||
)
|
)
|
||||||
if task_data.metadata_output_format:
|
if save_data.metadata_output_format:
|
||||||
for metadata_output_format in task_data.metadata_output_format.split(","):
|
for metadata_output_format in save_data.metadata_output_format.split(","):
|
||||||
if metadata_output_format.lower() in ["json", "txt", "embed"]:
|
if metadata_output_format.lower() in ["json", "txt", "embed"]:
|
||||||
save_dicts(
|
save_dicts(
|
||||||
metadata_entries,
|
metadata_entries,
|
||||||
@ -191,11 +205,17 @@ def save_images_to_disk(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_metadata_entries_for_request(req: GenerateImageRequest, task_data: TaskData, output_format: OutputFormatData):
|
def get_metadata_entries_for_request(
|
||||||
metadata = get_printable_request(req, task_data, output_format)
|
req: GenerateImageRequest,
|
||||||
|
task_data: RenderTaskData,
|
||||||
|
models_data: ModelsData,
|
||||||
|
output_format: OutputFormatData,
|
||||||
|
save_data: SaveToDiskData,
|
||||||
|
):
|
||||||
|
metadata = get_printable_request(req, task_data, models_data, output_format, save_data)
|
||||||
|
|
||||||
# if text, format it in the text format expected by the UI
|
# if text, format it in the text format expected by the UI
|
||||||
is_txt_format = task_data.metadata_output_format and "txt" in task_data.metadata_output_format.lower().split(",")
|
is_txt_format = save_data.metadata_output_format and "txt" in save_data.metadata_output_format.lower().split(",")
|
||||||
if is_txt_format:
|
if is_txt_format:
|
||||||
|
|
||||||
def format_value(value):
|
def format_value(value):
|
||||||
@ -214,13 +234,20 @@ def get_metadata_entries_for_request(req: GenerateImageRequest, task_data: TaskD
|
|||||||
return entries
|
return entries
|
||||||
|
|
||||||
|
|
||||||
def get_printable_request(req: GenerateImageRequest, task_data: TaskData, output_format: OutputFormatData):
|
def get_printable_request(
|
||||||
|
req: GenerateImageRequest,
|
||||||
|
task_data: RenderTaskData,
|
||||||
|
models_data: ModelsData,
|
||||||
|
output_format: OutputFormatData,
|
||||||
|
save_data: SaveToDiskData,
|
||||||
|
):
|
||||||
req_metadata = req.dict()
|
req_metadata = req.dict()
|
||||||
task_data_metadata = task_data.dict()
|
task_data_metadata = task_data.dict()
|
||||||
task_data_metadata.update(output_format.dict())
|
task_data_metadata.update(output_format.dict())
|
||||||
|
task_data_metadata.update(save_data.dict())
|
||||||
|
|
||||||
app_config = app.getConfig()
|
app_config = app.getConfig()
|
||||||
using_diffusers = app_config.get("test_diffusers", True)
|
using_diffusers = app_config.get("use_v3_engine", True)
|
||||||
|
|
||||||
# Save the metadata in the order defined in TASK_TEXT_MAPPING
|
# Save the metadata in the order defined in TASK_TEXT_MAPPING
|
||||||
metadata = {}
|
metadata = {}
|
||||||
@ -230,25 +257,11 @@ def get_printable_request(req: GenerateImageRequest, task_data: TaskData, output
|
|||||||
elif key in task_data_metadata:
|
elif key in task_data_metadata:
|
||||||
metadata[key] = task_data_metadata[key]
|
metadata[key] = task_data_metadata[key]
|
||||||
|
|
||||||
if key == "use_embeddings_model" and using_diffusers:
|
if key == "use_embeddings_model" and task_data_metadata[key] and using_diffusers:
|
||||||
embeddings_extensions = {".pt", ".bin", ".safetensors"}
|
embeddings_used = models_data.model_paths["embeddings"]
|
||||||
|
embeddings_used = embeddings_used if isinstance(embeddings_used, list) else [embeddings_used]
|
||||||
|
|
||||||
def scan_directory(directory_path: str):
|
metadata["use_embeddings_model"] = embeddings_used if len(embeddings_used) > 0 else None
|
||||||
used_embeddings = []
|
|
||||||
for entry in os.scandir(directory_path):
|
|
||||||
if entry.is_file():
|
|
||||||
# Check if the filename has the right extension
|
|
||||||
if not any(map(lambda ext: entry.name.endswith(ext), embeddings_extensions)):
|
|
||||||
continue
|
|
||||||
embedding_name_regex = regex.compile(r"(^|[\s,])" + regex.escape(get_embedding_token(entry.name)) + r"([+-]*$|[\s,]|[+-]+[\s,])")
|
|
||||||
if embedding_name_regex.search(req.prompt) or embedding_name_regex.search(req.negative_prompt):
|
|
||||||
used_embeddings.append(entry.path)
|
|
||||||
elif entry.is_dir():
|
|
||||||
used_embeddings.extend(scan_directory(entry.path))
|
|
||||||
return used_embeddings
|
|
||||||
|
|
||||||
used_embeddings = scan_directory(os.path.join(app.MODELS_DIR, "embeddings"))
|
|
||||||
metadata["use_embeddings_model"] = used_embeddings if len(used_embeddings) > 0 else None
|
|
||||||
|
|
||||||
# Clean up the metadata
|
# Clean up the metadata
|
||||||
if req.init_image is None and "prompt_strength" in metadata:
|
if req.init_image is None and "prompt_strength" in metadata:
|
||||||
@ -269,7 +282,17 @@ def get_printable_request(req: GenerateImageRequest, task_data: TaskData, output
|
|||||||
del metadata[key]
|
del metadata[key]
|
||||||
else:
|
else:
|
||||||
for key in (
|
for key in (
|
||||||
x for x in ["use_lora_model", "lora_alpha", "clip_skip", "tiling", "latent_upscaler_steps", "use_controlnet_model", "control_filter_to_apply"] if x in metadata
|
x
|
||||||
|
for x in [
|
||||||
|
"use_lora_model",
|
||||||
|
"lora_alpha",
|
||||||
|
"clip_skip",
|
||||||
|
"tiling",
|
||||||
|
"latent_upscaler_steps",
|
||||||
|
"use_controlnet_model",
|
||||||
|
"control_filter_to_apply",
|
||||||
|
]
|
||||||
|
if x in metadata
|
||||||
):
|
):
|
||||||
del metadata[key]
|
del metadata[key]
|
||||||
|
|
||||||
@ -279,7 +302,7 @@ def get_printable_request(req: GenerateImageRequest, task_data: TaskData, output
|
|||||||
def make_filename_callback(
|
def make_filename_callback(
|
||||||
filename_format: str,
|
filename_format: str,
|
||||||
req: GenerateImageRequest,
|
req: GenerateImageRequest,
|
||||||
task_data: TaskData,
|
task_data: RenderTaskData,
|
||||||
folder_img_number: int,
|
folder_img_number: int,
|
||||||
suffix=None,
|
suffix=None,
|
||||||
now=None,
|
now=None,
|
||||||
@ -296,7 +319,7 @@ def make_filename_callback(
|
|||||||
return make_filename
|
return make_filename
|
||||||
|
|
||||||
|
|
||||||
def _calculate_img_number(save_dir_path: str, task_data: TaskData):
|
def _calculate_img_number(save_dir_path: str, task_data: RenderTaskData):
|
||||||
def get_highest_img_number(accumulator: int, file: os.DirEntry) -> int:
|
def get_highest_img_number(accumulator: int, file: os.DirEntry) -> int:
|
||||||
if not file.is_file:
|
if not file.is_file:
|
||||||
return accumulator
|
return accumulator
|
||||||
@ -340,5 +363,5 @@ def _calculate_img_number(save_dir_path: str, task_data: TaskData):
|
|||||||
_calculate_img_number.session_img_numbers = {}
|
_calculate_img_number.session_img_numbers = {}
|
||||||
|
|
||||||
|
|
||||||
def calculate_img_number(save_dir_path: str, task_data: TaskData):
|
def calculate_img_number(save_dir_path: str, task_data: RenderTaskData):
|
||||||
return ImageNumber(lambda: _calculate_img_number(save_dir_path, task_data))
|
return ImageNumber(lambda: _calculate_img_number(save_dir_path, task_data))
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
<h1>
|
<h1>
|
||||||
<img id="logo_img" src="/media/images/icon-512x512.png" >
|
<img id="logo_img" src="/media/images/icon-512x512.png" >
|
||||||
Easy Diffusion
|
Easy Diffusion
|
||||||
<small><span id="version">v3.0.2</span> <span id="updateBranchLabel"></span></small>
|
<small><span id="version">v3.0.9</span> <span id="updateBranchLabel"></span></small>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<div id="server-status">
|
<div id="server-status">
|
||||||
@ -155,11 +155,11 @@
|
|||||||
<div id="editor-settings-entries" class="collapsible-content">
|
<div id="editor-settings-entries" class="collapsible-content">
|
||||||
<div><table>
|
<div><table>
|
||||||
<tr><b class="settings-subheader">Image Settings</b></tr>
|
<tr><b class="settings-subheader">Image Settings</b></tr>
|
||||||
<tr class="pl-5"><td><label for="seed">Seed:</label></td><td><input id="seed" name="seed" size="10" value="0" onkeypress="preventNonNumericalInput(event)"> <input id="random_seed" name="random_seed" type="checkbox" checked><label for="random_seed">Random</label></td></tr>
|
<tr class="pl-5"><td><label for="seed">Seed:</label></td><td><input id="seed" name="seed" size="10" value="0" onkeypress="preventNonNumericalInput(event)" inputmode="numeric"> <input id="random_seed" name="random_seed" type="checkbox" checked><label for="random_seed">Random</label></td></tr>
|
||||||
<tr class="pl-5"><td><label for="num_outputs_total">Number of Images:</label></td>
|
<tr class="pl-5"><td><label for="num_outputs_total">Number of Images:</label></td>
|
||||||
<td><input id="num_outputs_total" name="num_outputs_total" value="1" type="number" value="1" min="1" step="1" onkeypres"="preventNonNumericalInput(event)">
|
<td><input id="num_outputs_total" name="num_outputs_total" value="1" type="number" value="1" min="1" step="1" onkeypres"="preventNonNumericalInput(event)" inputmode="numeric">
|
||||||
<label><small>(total)</small></label>
|
<label><small>(total)</small></label>
|
||||||
<input id="num_outputs_parallel" name="num_outputs_parallel" value="1" type="number" value="1" min="1" step="1" onkeypress="preventNonNumericalInput(event)">
|
<input id="num_outputs_parallel" name="num_outputs_parallel" value="1" type="number" value="1" min="1" step="1" onkeypress="preventNonNumericalInput(event)" inputmode="numeric">
|
||||||
<label id="num_outputs_parallel_label" for="num_outputs_parallel"><small>(in parallel)</small></label></td>
|
<label id="num_outputs_parallel_label" for="num_outputs_parallel"><small>(in parallel)</small></label></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="pl-5"><td><label for="stable_diffusion_model">Model:</label></td><td class="model-input">
|
<tr class="pl-5"><td><label for="stable_diffusion_model">Model:</label></td><td class="model-input">
|
||||||
@ -235,6 +235,8 @@
|
|||||||
<label for="controlnet_model"><small>Model:</small></label> <input id="controlnet_model" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
|
<label for="controlnet_model"><small>Model:</small></label> <input id="controlnet_model" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
|
||||||
<br/>
|
<br/>
|
||||||
<label><small>Will download the necessary models, the first time.</small></label>
|
<label><small>Will download the necessary models, the first time.</small></label>
|
||||||
|
<br/>
|
||||||
|
<label for="controlnet_alpha_slider"><small>Strength:</small></label> <input id="controlnet_alpha_slider" name="controlnet_alpha_slider" class="editor-slider" value="10" type="range" min="0" max="10"> <input id="controlnet_alpha" name="controlnet_alpha" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)" inputmode="decimal">
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -266,7 +268,7 @@
|
|||||||
<option value="unipc_tu_2" class="k_diffusion-only">UniPC TU 2</option>
|
<option value="unipc_tu_2" class="k_diffusion-only">UniPC TU 2</option>
|
||||||
<option value="unipc_tq" class="k_diffusion-only">UniPC TQ</option>
|
<option value="unipc_tq" class="k_diffusion-only">UniPC TQ</option>
|
||||||
</select>
|
</select>
|
||||||
<a href="https://github.com/easydiffusion/easydiffusion/wiki/How-to-Use#samplers" target="_blank"><i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Click to learn more about samplers</span></i></a>
|
<a href="https://github.com/easydiffusion/easydiffusion/wiki/Samplers" target="_blank"><i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Click to learn more about samplers</span></i></a>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr class="pl-5"><td><label>Image Size: </label></td><td id="image-size-options">
|
<tr class="pl-5"><td><label>Image Size: </label></td><td id="image-size-options">
|
||||||
<select id="width" name="width" value="512">
|
<select id="width" name="width" value="512">
|
||||||
@ -291,7 +293,9 @@
|
|||||||
<option value="2048">2048</option>
|
<option value="2048">2048</option>
|
||||||
</select>
|
</select>
|
||||||
<label id="widthLabel" for="width"><small><span>(width)</span></small></label>
|
<label id="widthLabel" for="width"><small><span>(width)</span></small></label>
|
||||||
<span id="swap-width-height" class="clickable smallButton" style="margin-left: 2px; margin-right:2px;"><i class="fa-solid fa-right-left"><span class="simple-tooltip top-left"> Swap width and height </span></i></span>
|
<div class="tooltip-container">
|
||||||
|
<span id="swap-width-height" class="clickable smallButton" style="margin-left: 2px; margin-right:2px;"><i class="fa-solid fa-right-left"><span class="simple-tooltip top-left"> Swap width and height </span></i></span>
|
||||||
|
</div>
|
||||||
<select id="height" name="height" value="512">
|
<select id="height" name="height" value="512">
|
||||||
<option value="128">128</option>
|
<option value="128">128</option>
|
||||||
<option value="192">192</option>
|
<option value="192">192</option>
|
||||||
@ -318,9 +322,9 @@
|
|||||||
<span id="recent-resolutions-button" class="clickable"><i class="fa-solid fa-sliders"><span class="simple-tooltip top-left"> Advanced sizes </span></i></span>
|
<span id="recent-resolutions-button" class="clickable"><i class="fa-solid fa-sliders"><span class="simple-tooltip top-left"> Advanced sizes </span></i></span>
|
||||||
<div id="recent-resolutions-popup" class="displayNone">
|
<div id="recent-resolutions-popup" class="displayNone">
|
||||||
<small>Custom size:</small><br>
|
<small>Custom size:</small><br>
|
||||||
<input id="custom-width" name="custom-width" type="number" min="128" value="512" onkeypress="preventNonNumericalInput(event)">
|
<input id="custom-width" name="custom-width" type="number" min="128" value="512" onkeypress="preventNonNumericalInput(event)" inputmode="numeric">
|
||||||
×
|
×
|
||||||
<input id="custom-height" name="custom-height" type="number" min="128" value="512" onkeypress="preventNonNumericalInput(event)"><br>
|
<input id="custom-height" name="custom-height" type="number" min="128" value="512" onkeypress="preventNonNumericalInput(event)" inputmode="numeric"><br>
|
||||||
<small>Resize:</small><br>
|
<small>Resize:</small><br>
|
||||||
<input id="resize-slider" name="resize-slider" class="editor-slider" value="1" type="range" min="0.4" max="2" step="0.005" style="width:100%;"><br>
|
<input id="resize-slider" name="resize-slider" class="editor-slider" value="1" type="range" min="0.4" max="2" step="0.005" style="width:100%;"><br>
|
||||||
<div id="enlarge-buttons"><button data-factor="0.5" class="tertiaryButton smallButton">×0.5</button> <button data-factor="1.2" class="tertiaryButton smallButton">×1.2</button> <button data-factor="1.5" class="tertiaryButton smallButton">×1.5</button> <button data-factor="2" class="tertiaryButton smallButton">×2</button> <button data-factor="3" class="tertiaryButton smallButton">×3</button></div>
|
<div id="enlarge-buttons"><button data-factor="0.5" class="tertiaryButton smallButton">×0.5</button> <button data-factor="1.2" class="tertiaryButton smallButton">×1.2</button> <button data-factor="1.5" class="tertiaryButton smallButton">×1.5</button> <button data-factor="2" class="tertiaryButton smallButton">×2</button> <button data-factor="3" class="tertiaryButton smallButton">×3</button></div>
|
||||||
@ -342,9 +346,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="small_image_warning" class="displayNone">Small image sizes can cause bad image quality</div>
|
<div id="small_image_warning" class="displayNone">Small image sizes can cause bad image quality</div>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr class="pl-5"><td><label for="num_inference_steps">Inference Steps:</label></td><td> <input id="num_inference_steps" name="num_inference_steps" type="number" min="1" step="1" style="width: 42pt" value="25" onkeypress="preventNonNumericalInput(event)"></td></tr>
|
<tr class="pl-5"><td><label for="num_inference_steps">Inference Steps:</label></td><td> <input id="num_inference_steps" name="num_inference_steps" type="number" min="1" step="1" style="width: 42pt" value="25" onkeypress="preventNonNumericalInput(event)" inputmode="numeric"></td></tr>
|
||||||
<tr class="pl-5"><td><label for="guidance_scale_slider">Guidance Scale:</label></td><td> <input id="guidance_scale_slider" name="guidance_scale_slider" class="editor-slider" value="75" type="range" min="11" max="500"> <input id="guidance_scale" name="guidance_scale" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)"></td></tr>
|
<tr class="pl-5"><td><label for="guidance_scale_slider">Guidance Scale:</label></td><td> <input id="guidance_scale_slider" name="guidance_scale_slider" class="editor-slider" value="75" type="range" min="11" max="500"> <input id="guidance_scale" name="guidance_scale" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)" inputmode="decimal"></td></tr>
|
||||||
<tr id="prompt_strength_container" class="pl-5"><td><label for="prompt_strength_slider">Prompt Strength:</label></td><td> <input id="prompt_strength_slider" name="prompt_strength_slider" class="editor-slider" value="80" type="range" min="0" max="99"> <input id="prompt_strength" name="prompt_strength" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)"><br/></td></tr>
|
<tr id="prompt_strength_container" class="pl-5"><td><label for="prompt_strength_slider">Prompt Strength:</label></td><td> <input id="prompt_strength_slider" name="prompt_strength_slider" class="editor-slider" value="80" type="range" min="0" max="99"> <input id="prompt_strength" name="prompt_strength" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)" inputmode="decimal"><br/></td></tr>
|
||||||
<tr id="lora_model_container" class="pl-5">
|
<tr id="lora_model_container" class="pl-5">
|
||||||
<td>
|
<td>
|
||||||
<label for="lora_model">LoRA:</label>
|
<label for="lora_model">LoRA:</label>
|
||||||
@ -358,7 +362,7 @@
|
|||||||
</td></tr>
|
</td></tr>
|
||||||
<tr id="hypernetwork_strength_container" class="pl-5">
|
<tr id="hypernetwork_strength_container" class="pl-5">
|
||||||
<td><label for="hypernetwork_strength_slider">Hypernetwork Strength:</label></td>
|
<td><label for="hypernetwork_strength_slider">Hypernetwork Strength:</label></td>
|
||||||
<td> <input id="hypernetwork_strength_slider" name="hypernetwork_strength_slider" class="editor-slider" value="100" type="range" min="0" max="100"> <input id="hypernetwork_strength" name="hypernetwork_strength" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)"><br/></td>
|
<td> <input id="hypernetwork_strength_slider" name="hypernetwork_strength_slider" class="editor-slider" value="100" type="range" min="0" max="100"> <input id="hypernetwork_strength" name="hypernetwork_strength" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)" inputmode="decimal"><br/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr id="tiling_container" class="pl-5">
|
<tr id="tiling_container" class="pl-5">
|
||||||
<td><label for="tiling">Seamless Tiling:</label></td>
|
<td><label for="tiling">Seamless Tiling:</label></td>
|
||||||
@ -383,8 +387,15 @@
|
|||||||
</span>
|
</span>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr class="pl-5" id="output_quality_row"><td><label for="output_quality">Image Quality:</label></td><td>
|
<tr class="pl-5" id="output_quality_row"><td><label for="output_quality">Image Quality:</label></td><td>
|
||||||
<input id="output_quality_slider" name="output_quality" class="editor-slider" value="75" type="range" min="10" max="95"> <input id="output_quality" name="output_quality" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)">
|
<input id="output_quality_slider" name="output_quality" class="editor-slider" value="75" type="range" min="10" max="95"> <input id="output_quality" name="output_quality" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)" inputmode="numeric">
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
<tr class="pl-5">
|
||||||
|
<td><label for="tiling">Enable VAE Tiling:</label></td>
|
||||||
|
<td class="diffusers-restart-needed">
|
||||||
|
<input id="enable_vae_tiling" name="enable_vae_tiling" type="checkbox" checked>
|
||||||
|
<label><small>Optimizes memory for larger images</small></label>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table></div>
|
</table></div>
|
||||||
|
|
||||||
<div><ul>
|
<div><ul>
|
||||||
@ -393,7 +404,7 @@
|
|||||||
<li class="pl-5" id="use_face_correction_container">
|
<li class="pl-5" id="use_face_correction_container">
|
||||||
<input id="use_face_correction" name="use_face_correction" type="checkbox"> <label for="use_face_correction">Fix incorrect faces and eyes</label> <div style="display:inline-block;"><input id="gfpgan_model" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" /></div>
|
<input id="use_face_correction" name="use_face_correction" type="checkbox"> <label for="use_face_correction">Fix incorrect faces and eyes</label> <div style="display:inline-block;"><input id="gfpgan_model" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" /></div>
|
||||||
<table id="codeformer_settings" class="displayNone sub-settings">
|
<table id="codeformer_settings" class="displayNone sub-settings">
|
||||||
<tr class="pl-5"><td><label for="codeformer_fidelity_slider">Strength:</label></td><td><input id="codeformer_fidelity_slider" name="codeformer_fidelity_slider" class="editor-slider" value="5" type="range" min="0" max="10"> <input id="codeformer_fidelity" name="codeformer_fidelity" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)"></td></tr>
|
<tr class="pl-5"><td><label for="codeformer_fidelity_slider">Strength:</label></td><td><input id="codeformer_fidelity_slider" name="codeformer_fidelity_slider" class="editor-slider" value="5" type="range" min="0" max="10"> <input id="codeformer_fidelity" name="codeformer_fidelity" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)" inputmode="decimal"></td></tr>
|
||||||
<tr class="pl-5"><td><label for="codeformer_upscale_faces">Upscale Faces:</label></td><td><input id="codeformer_upscale_faces" name="codeformer_upscale_faces" type="checkbox" checked> <label><small>(improves the resolution of faces)</small></label></td></tr>
|
<tr class="pl-5"><td><label for="codeformer_upscale_faces">Upscale Faces:</label></td><td><input id="codeformer_upscale_faces" name="codeformer_upscale_faces" type="checkbox" checked> <label><small>(improves the resolution of faces)</small></label></td></tr>
|
||||||
</table>
|
</table>
|
||||||
</li>
|
</li>
|
||||||
@ -410,7 +421,7 @@
|
|||||||
<option value="latent_upscaler">Latent Upscaler 2x</option>
|
<option value="latent_upscaler">Latent Upscaler 2x</option>
|
||||||
</select>
|
</select>
|
||||||
<table id="latent_upscaler_settings" class="displayNone sub-settings">
|
<table id="latent_upscaler_settings" class="displayNone sub-settings">
|
||||||
<tr class="pl-5"><td><label for="latent_upscaler_steps_slider">Upscaling Steps:</label></td><td><input id="latent_upscaler_steps_slider" name="latent_upscaler_steps_slider" class="editor-slider" value="10" type="range" min="1" max="50"> <input id="latent_upscaler_steps" name="latent_upscaler_steps" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)"></td></tr>
|
<tr class="pl-5"><td><label for="latent_upscaler_steps_slider">Upscaling Steps:</label></td><td><input id="latent_upscaler_steps_slider" name="latent_upscaler_steps_slider" class="editor-slider" value="10" type="range" min="1" max="50"> <input id="latent_upscaler_steps" name="latent_upscaler_steps" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)" inputmode="numeric"></td></tr>
|
||||||
</table>
|
</table>
|
||||||
</li>
|
</li>
|
||||||
<li class="pl-5"><input id="show_only_filtered_image" name="show_only_filtered_image" type="checkbox" checked> <label for="show_only_filtered_image">Show only the corrected/upscaled image</label></li>
|
<li class="pl-5"><input id="show_only_filtered_image" name="show_only_filtered_image" type="checkbox" checked> <label for="show_only_filtered_image">Show only the corrected/upscaled image</label></li>
|
||||||
@ -455,14 +466,14 @@
|
|||||||
<div class="dropdown-content">
|
<div class="dropdown-content">
|
||||||
<div class="dropdown-item">
|
<div class="dropdown-item">
|
||||||
<input id="thumbnail_size" name="thumbnail_size" class="editor-slider" type="range" value="70" min="5" max="200" oninput="sliderUpdate(event)">
|
<input id="thumbnail_size" name="thumbnail_size" class="editor-slider" type="range" value="70" min="5" max="200" oninput="sliderUpdate(event)">
|
||||||
<input id="thumbnail_size-input" name="thumbnail_size-input" size="3" value="70" pattern="^[0-9.]+$" onkeypress="preventNonNumericalInput(event)" oninput="sliderUpdate(event)"> %
|
<input id="thumbnail_size-input" name="thumbnail_size-input" size="3" value="70" pattern="^[0-9.]+$" onkeypress="preventNonNumericalInput(event)" oninput="sliderUpdate(event)" inputmode="numeric"> %
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfix" style="clear: both;"></div>
|
<div class="clearfix" style="clear: both;"></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="supportBanner" class="displayNone">
|
<div id="supportBanner" class="displayNone">
|
||||||
If you found this project useful and want to help keep it alive, please consider <a href="https://ko-fi.com/easydiffusion" target="_blank">buying me a coffee</a> or <a href="https://www.patreon.com/EasyDiffusion" target="_blank">supporting me on Patreon</a> to help cover the cost of development and maintenance! Or even better, <a href="https://cmdr2.itch.io/easydiffusion" target="_blank">purchasing it at the full price</a>. Thank you for your support!
|
If you found this project useful and want to help keep it alive, please consider <a href="https://ko-fi.com/easydiffusion" target="_blank">buying me a coffee</a> to help cover the cost of development and maintenance! Thanks for your support!
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -508,28 +519,44 @@
|
|||||||
<div class="float-container">
|
<div class="float-container">
|
||||||
<div class="float-child">
|
<div class="float-child">
|
||||||
<h1>Help</h1>
|
<h1>Help</h1>
|
||||||
<ul id="help-links">
|
<div id="help-links">
|
||||||
<li><span class="help-section">Using the software</span>
|
<h4><span class="help-section"><b>Basics</b></span></h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/How-To-Use" target="_blank"><i class="fa-solid fa-book fa-fw"></i> How to use</a>
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/How-To-Use" target="_blank">How to use</a></li>
|
||||||
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/UI-Overview" target="_blank"><i class="fa-solid fa-list fa-fw"></i> UI Overview</a>
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Writing-Prompts" target="_blank">Writing prompts</a></li>
|
||||||
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Writing-Prompts" target="_blank"><i class="fa-solid fa-pen-to-square fa-fw"></i> Writing prompts</a>
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Image-Modifiers" target="_blank">Image Modifiers</a></li>
|
||||||
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Inpainting" target="_blank"><i class="fa-solid fa-paintbrush fa-fw"></i> Inpainting</a>
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Inpainting" target="_blank">Inpainting</a></li>
|
||||||
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Run-on-Multiple-GPUs" target="_blank"><i class="fa-solid fa-paintbrush fa-fw"></i> Run on Multiple GPUs</a>
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Samplers" target="_blank">Samplers</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/UI-Overview" target="_blank">Summary of every UI option</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Troubleshooting" target="_blank">Common error messages (and solutions)</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<li><span class="help-section">Installation</span>
|
<h4><span class="help-section"><b>Intermediate</b></span></h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Troubleshooting" target="_blank"><i class="fa-solid fa-circle-question fa-fw"></i> Troubleshooting</a>
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Custom-Models" target="_blank">Custom Models</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Prompt-Syntax" target="_blank">Prompt Syntax (weights, emphasis etc)</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/UI-Plugins" target="_blank">UI Plugins</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Embeddings" target="_blank">Embeddings</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/LoRA" target="_blank">LoRA</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/SDXL" target="_blank">SDXL</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/ControlNet" target="_blank">ControlNet</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Seamless-Tiling" target="_blank">Seamless Tiling</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/xFormers" target="_blank">xFormers</a></li>
|
||||||
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/The-beta-channel" target="_blank">The beta channel</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<li><span class="help-section">Downloadable Content</span>
|
<h4><span class="help-section"><b>Advanced topics</b></span></h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Custom-Models" target="_blank"><i class="fa-solid fa-images fa-fw"></i> Custom Models</a>
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Run-on-Multiple-GPUs" target="_blank">Run on Multiple GPUs</a></li>
|
||||||
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/UI-Plugins" target="_blank"><i class="fa-solid fa-puzzle-piece fa-fw"></i> UI Plugins</a>
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Model-Merging" target="_blank">Model Merging</a></li>
|
||||||
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/VAE-Variational-Auto-Encoder" target="_blank"><i class="fa-solid fa-hand-sparkles fa-fw"></i> VAE Variational Auto Encoder</a>
|
<li> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Custom-Modifiers" target="_blank">Custom Modifiers</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</ul>
|
|
||||||
|
<h4><span class="help-section"><b>Misc</b></span></h4>
|
||||||
|
<ul>
|
||||||
|
<li> <a href="https://theally.notion.site/The-Definitive-Stable-Diffusion-Glossary-1d1e6d15059c41e6a6b4306b4ecd9df9" target="_blank">Glossary of Stable Diffusion related terms</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="float-child">
|
<div class="float-child">
|
||||||
@ -712,7 +739,7 @@
|
|||||||
<span class="embeddings-action-text">Expand Categories</span>
|
<span class="embeddings-action-text">Expand Categories</span>
|
||||||
</button>
|
</button>
|
||||||
<i class="fa-solid fa-magnifying-glass"></i>
|
<i class="fa-solid fa-magnifying-glass"></i>
|
||||||
<input id="embeddings-search-box" type="text" spellcheck="false" autocomplete="off" placeholder="Search...">
|
<input id="embeddings-search-box" type="text" spellcheck="false" autocomplete="off" placeholder="Search..." inputmode="search">
|
||||||
<label for="embedding-card-size-selector"><small>Thumbnail Size:</small></label>
|
<label for="embedding-card-size-selector"><small>Thumbnail Size:</small></label>
|
||||||
<select id="embedding-card-size-selector" name="embedding-card-size-selector">
|
<select id="embedding-card-size-selector" name="embedding-card-size-selector">
|
||||||
<option value="-2">0</option>
|
<option value="-2">0</option>
|
||||||
@ -798,6 +825,7 @@
|
|||||||
<p>This license of this software forbids you from sharing any content that violates any laws, produce any harm to a person, disseminate any personal information that would be meant for harm, <br/>spread misinformation and target vulnerable groups. For the full list of restrictions please read <a href="https://github.com/easydiffusion/easydiffusion/blob/main/LICENSE" target="_blank">the license</a>.</p>
|
<p>This license of this software forbids you from sharing any content that violates any laws, produce any harm to a person, disseminate any personal information that would be meant for harm, <br/>spread misinformation and target vulnerable groups. For the full list of restrictions please read <a href="https://github.com/easydiffusion/easydiffusion/blob/main/LICENSE" target="_blank">the license</a>.</p>
|
||||||
<p>By using this software, you consent to the terms and conditions of the license.</p>
|
<p>By using this software, you consent to the terms and conditions of the license.</p>
|
||||||
</div>
|
</div>
|
||||||
|
<input id="test_diffusers" type="checkbox" style="display: none" checked />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
@ -609,11 +609,18 @@ div.img-preview img {
|
|||||||
margin: auto;
|
margin: auto;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
}
|
}
|
||||||
|
#help-links ul {
|
||||||
|
list-style-type: disc;
|
||||||
|
padding-left: 12pt;
|
||||||
|
}
|
||||||
#help-links li {
|
#help-links li {
|
||||||
padding-bottom: 12pt;
|
padding-bottom: 6pt;
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 10pt;
|
font-size: 10pt;
|
||||||
}
|
}
|
||||||
|
#help-links ul li {
|
||||||
|
display: list-item;
|
||||||
|
}
|
||||||
#help-links li .fa-fw {
|
#help-links li .fa-fw {
|
||||||
padding-right: 2pt;
|
padding-right: 2pt;
|
||||||
}
|
}
|
||||||
@ -1207,6 +1214,12 @@ input::file-selector-button {
|
|||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tooltip-container {
|
||||||
|
display: inline-block;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
.simple-tooltip.right {
|
.simple-tooltip.right {
|
||||||
right: 0px;
|
right: 0px;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
|
@ -56,6 +56,8 @@ const SETTINGS_IDS_LIST = [
|
|||||||
"extract_lora_from_prompt",
|
"extract_lora_from_prompt",
|
||||||
"embedding-card-size-selector",
|
"embedding-card-size-selector",
|
||||||
"lora_model",
|
"lora_model",
|
||||||
|
"enable_vae_tiling",
|
||||||
|
"controlnet_alpha",
|
||||||
]
|
]
|
||||||
|
|
||||||
const IGNORE_BY_DEFAULT = ["prompt"]
|
const IGNORE_BY_DEFAULT = ["prompt"]
|
||||||
|
@ -268,7 +268,11 @@ const TASK_MAPPING = {
|
|||||||
tiling: {
|
tiling: {
|
||||||
name: "Tiling",
|
name: "Tiling",
|
||||||
setUI: (val) => {
|
setUI: (val) => {
|
||||||
tilingField.value = val
|
if (val === null || val === "None") {
|
||||||
|
tilingField.value = "none"
|
||||||
|
} else {
|
||||||
|
tilingField.value = val
|
||||||
|
}
|
||||||
},
|
},
|
||||||
readUI: () => tilingField.value,
|
readUI: () => tilingField.value,
|
||||||
parse: (val) => val,
|
parse: (val) => val,
|
||||||
@ -305,10 +309,21 @@ const TASK_MAPPING = {
|
|||||||
readUI: () => controlImageFilterField.value,
|
readUI: () => controlImageFilterField.value,
|
||||||
parse: (val) => val,
|
parse: (val) => val,
|
||||||
},
|
},
|
||||||
|
control_alpha: {
|
||||||
|
name: "ControlNet Strength",
|
||||||
|
setUI: (control_alpha) => {
|
||||||
|
control_alpha = control_alpha || 1.0
|
||||||
|
controlAlphaField.value = control_alpha
|
||||||
|
updateControlAlphaSlider()
|
||||||
|
},
|
||||||
|
readUI: () => parseFloat(controlAlphaField.value),
|
||||||
|
parse: (val) => val === null ? 1.0 : parseFloat(val),
|
||||||
|
},
|
||||||
use_lora_model: {
|
use_lora_model: {
|
||||||
name: "LoRA model",
|
name: "LoRA model",
|
||||||
setUI: (use_lora_model) => {
|
setUI: (use_lora_model) => {
|
||||||
let modelPaths = []
|
let modelPaths = []
|
||||||
|
use_lora_model = use_lora_model === null ? "" : use_lora_model
|
||||||
use_lora_model = Array.isArray(use_lora_model) ? use_lora_model : [use_lora_model]
|
use_lora_model = Array.isArray(use_lora_model) ? use_lora_model : [use_lora_model]
|
||||||
use_lora_model.forEach((m) => {
|
use_lora_model.forEach((m) => {
|
||||||
if (m.includes("models\\lora\\")) {
|
if (m.includes("models\\lora\\")) {
|
||||||
@ -525,6 +540,11 @@ function restoreTaskToUI(task, fieldsToSkip) {
|
|||||||
// listen for inpainter loading event, which happens AFTER the main image loads (which reloads the inpai
|
// listen for inpainter loading event, which happens AFTER the main image loads (which reloads the inpai
|
||||||
controlImagePreview.src = task.reqBody.control_image
|
controlImagePreview.src = task.reqBody.control_image
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ("use_controlnet_model" in task.reqBody && task.reqBody.use_controlnet_model && !("control_alpha" in task.reqBody)) {
|
||||||
|
controlAlphaField.value = 1.0
|
||||||
|
updateControlAlphaSlider()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function readUI() {
|
function readUI() {
|
||||||
const reqBody = {}
|
const reqBody = {}
|
||||||
@ -583,6 +603,8 @@ const TASK_TEXT_MAPPING = {
|
|||||||
lora_alpha: "LoRA Strength",
|
lora_alpha: "LoRA Strength",
|
||||||
use_controlnet_model: "ControlNet model",
|
use_controlnet_model: "ControlNet model",
|
||||||
control_filter_to_apply: "ControlNet Filter",
|
control_filter_to_apply: "ControlNet Filter",
|
||||||
|
control_alpha: "ControlNet Strength",
|
||||||
|
tiling: "Seamless Tiling",
|
||||||
}
|
}
|
||||||
function parseTaskFromText(str) {
|
function parseTaskFromText(str) {
|
||||||
const taskReqBody = {}
|
const taskReqBody = {}
|
||||||
|
@ -22,7 +22,8 @@ const taskConfigSetup = {
|
|||||||
},
|
},
|
||||||
tiling: {
|
tiling: {
|
||||||
label: "Tiling",
|
label: "Tiling",
|
||||||
visible: ({ reqBody }) => reqBody?.tiling != "none",
|
visible: ({ reqBody }) =>
|
||||||
|
reqBody?.tiling != "none" && reqBody?.tiling !== null && reqBody?.tiling !== undefined,
|
||||||
value: ({ reqBody }) => reqBody?.tiling,
|
value: ({ reqBody }) => reqBody?.tiling,
|
||||||
},
|
},
|
||||||
use_vae_model: {
|
use_vae_model: {
|
||||||
@ -50,6 +51,10 @@ const taskConfigSetup = {
|
|||||||
preserve_init_image_color_profile: "Preserve Color Profile",
|
preserve_init_image_color_profile: "Preserve Color Profile",
|
||||||
strict_mask_border: "Strict Mask Border",
|
strict_mask_border: "Strict Mask Border",
|
||||||
use_controlnet_model: "ControlNet Model",
|
use_controlnet_model: "ControlNet Model",
|
||||||
|
control_alpha: {
|
||||||
|
label: "ControlNet Strength",
|
||||||
|
visible: ({ reqBody }) => !!reqBody?.use_controlnet_model,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
pluginTaskConfig: {},
|
pluginTaskConfig: {},
|
||||||
getCSSKey: (key) =>
|
getCSSKey: (key) =>
|
||||||
@ -98,6 +103,8 @@ let controlImagePreview = document.querySelector("#control_image_preview")
|
|||||||
let controlImageClearBtn = document.querySelector(".control_image_clear")
|
let controlImageClearBtn = document.querySelector(".control_image_clear")
|
||||||
let controlImageContainer = document.querySelector("#control_image_wrapper")
|
let controlImageContainer = document.querySelector("#control_image_wrapper")
|
||||||
let controlImageFilterField = document.querySelector("#control_image_filter")
|
let controlImageFilterField = document.querySelector("#control_image_filter")
|
||||||
|
let controlAlphaSlider = document.querySelector("#controlnet_alpha_slider")
|
||||||
|
let controlAlphaField = document.querySelector("#controlnet_alpha")
|
||||||
let applyColorCorrectionField = document.querySelector("#apply_color_correction")
|
let applyColorCorrectionField = document.querySelector("#apply_color_correction")
|
||||||
let strictMaskBorderField = document.querySelector("#strict_mask_border")
|
let strictMaskBorderField = document.querySelector("#strict_mask_border")
|
||||||
let colorCorrectionSetting = document.querySelector("#apply_color_correction_setting")
|
let colorCorrectionSetting = document.querySelector("#apply_color_correction_setting")
|
||||||
@ -128,6 +135,7 @@ let hypernetworkStrengthField = document.querySelector("#hypernetwork_strength")
|
|||||||
let outputFormatField = document.querySelector("#output_format")
|
let outputFormatField = document.querySelector("#output_format")
|
||||||
let outputLosslessField = document.querySelector("#output_lossless")
|
let outputLosslessField = document.querySelector("#output_lossless")
|
||||||
let outputLosslessContainer = document.querySelector("#output_lossless_container")
|
let outputLosslessContainer = document.querySelector("#output_lossless_container")
|
||||||
|
let enableVAETilingField = document.querySelector("#enable_vae_tiling")
|
||||||
let blockNSFWField = document.querySelector("#block_nsfw")
|
let blockNSFWField = document.querySelector("#block_nsfw")
|
||||||
let showOnlyFilteredImageField = document.querySelector("#show_only_filtered_image")
|
let showOnlyFilteredImageField = document.querySelector("#show_only_filtered_image")
|
||||||
let updateBranchLabel = document.querySelector("#updateBranchLabel")
|
let updateBranchLabel = document.querySelector("#updateBranchLabel")
|
||||||
@ -513,7 +521,7 @@ function showImages(reqBody, res, outputContainer, livePreview) {
|
|||||||
{
|
{
|
||||||
text: "Use as Thumbnail",
|
text: "Use as Thumbnail",
|
||||||
on_click: onUseAsThumbnailClick,
|
on_click: onUseAsThumbnailClick,
|
||||||
filter: (req, img) => "use_embeddings_model" in req,
|
filter: (req, img) => "use_embeddings_model" in req || "use_lora_model" in req
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -680,7 +688,7 @@ function getAllModelNames(type) {
|
|||||||
|
|
||||||
// gets a flattened list of all models of a certain type. e.g. "path/subpath/modelname"
|
// gets a flattened list of all models of a certain type. e.g. "path/subpath/modelname"
|
||||||
// use the filter to search for all models having a certain name.
|
// use the filter to search for all models having a certain name.
|
||||||
function getAllModelPathes(type,filter="") {
|
function getAllModelPathes(type, filter = "") {
|
||||||
function f(tree, prefix) {
|
function f(tree, prefix) {
|
||||||
if (tree == undefined) {
|
if (tree == undefined) {
|
||||||
return []
|
return []
|
||||||
@ -690,7 +698,7 @@ function getAllModelPathes(type,filter="") {
|
|||||||
if (typeof e == "object") {
|
if (typeof e == "object") {
|
||||||
result = result.concat(f(e[1], prefix + e[0] + "/"))
|
result = result.concat(f(e[1], prefix + e[0] + "/"))
|
||||||
} else {
|
} else {
|
||||||
if (filter=="" || e==filter) {
|
if (filter == "" || e == filter) {
|
||||||
result.push(prefix + e)
|
result.push(prefix + e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -700,7 +708,6 @@ function getAllModelPathes(type,filter="") {
|
|||||||
return f(modelsOptions[type], "")
|
return f(modelsOptions[type], "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function onUseAsThumbnailClick(req, img) {
|
function onUseAsThumbnailClick(req, img) {
|
||||||
let scale = 1
|
let scale = 1
|
||||||
let targetWidth = img.naturalWidth
|
let targetWidth = img.naturalWidth
|
||||||
@ -748,25 +755,45 @@ function onUseAsThumbnailClick(req, img) {
|
|||||||
onUseAsThumbnailClick.croppr.setImage(img.src)
|
onUseAsThumbnailClick.croppr.setImage(img.src)
|
||||||
}
|
}
|
||||||
|
|
||||||
let embeddings = req.use_embeddings_model.map((e) => e.split("/").pop())
|
useAsThumbSelect.innerHTML=""
|
||||||
let LORA = []
|
|
||||||
|
|
||||||
if ("use_lora_model" in req) {
|
if ("use_embeddings_model" in req) {
|
||||||
LORA = req.use_lora_model
|
let embeddings = req.use_embeddings_model.map((e) => e.split("/").pop())
|
||||||
|
|
||||||
|
let embOptions = document.createElement("optgroup")
|
||||||
|
embOptions.label = "Embeddings"
|
||||||
|
embOptions.replaceChildren(
|
||||||
|
...embeddings.map((e) => {
|
||||||
|
let option = document.createElement("option")
|
||||||
|
option.innerText = e
|
||||||
|
option.dataset["type"] = "embeddings"
|
||||||
|
return option
|
||||||
|
})
|
||||||
|
)
|
||||||
|
useAsThumbSelect.appendChild(embOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
let optgroup = document.createElement("optgroup")
|
|
||||||
optgroup.label = "Embeddings"
|
|
||||||
optgroup.replaceChildren(
|
|
||||||
...embeddings.map((e) => {
|
|
||||||
let option = document.createElement("option")
|
|
||||||
option.innerText = e
|
|
||||||
option.dataset["type"] = "embeddings"
|
|
||||||
return option
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
useAsThumbSelect.replaceChildren(optgroup)
|
if ("use_lora_model" in req) {
|
||||||
|
let LORA = req.use_lora_model
|
||||||
|
if (typeof LORA == "string") {
|
||||||
|
LORA = [LORA]
|
||||||
|
}
|
||||||
|
LORA = LORA.map((e) => e.split("/").pop())
|
||||||
|
|
||||||
|
let loraOptions = document.createElement("optgroup")
|
||||||
|
loraOptions.label = "LORA"
|
||||||
|
loraOptions.replaceChildren(
|
||||||
|
...LORA.map((e) => {
|
||||||
|
let option = document.createElement("option")
|
||||||
|
option.innerText = e
|
||||||
|
option.dataset["type"] = "lora"
|
||||||
|
return option
|
||||||
|
})
|
||||||
|
)
|
||||||
|
useAsThumbSelect.appendChild(loraOptions)
|
||||||
|
}
|
||||||
|
|
||||||
useAsThumbDialog.showModal()
|
useAsThumbDialog.showModal()
|
||||||
onUseAsThumbnailClick.scale = scale
|
onUseAsThumbnailClick.scale = scale
|
||||||
}
|
}
|
||||||
@ -782,6 +809,50 @@ useAsThumbCancelBtn.addEventListener("click", () => {
|
|||||||
useAsThumbDialog.close()
|
useAsThumbDialog.close()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const Bucket = {
|
||||||
|
upload(path, blob) {
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append("file", blob)
|
||||||
|
return fetch(`bucket/${path}`, {
|
||||||
|
method: "POST",
|
||||||
|
body: formData,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
getImageAsDataURL(path) {
|
||||||
|
return fetch(`bucket/${path}`)
|
||||||
|
.then((response) => {
|
||||||
|
if (response.status == 200) {
|
||||||
|
return response.blob()
|
||||||
|
} else {
|
||||||
|
throw new Error("Bucket error")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((blob) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const reader = new FileReader()
|
||||||
|
reader.onload = () => resolve(reader.result)
|
||||||
|
reader.onerror = reject
|
||||||
|
reader.readAsDataURL(blob)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
getList(path) {
|
||||||
|
return fetch(`bucket/${path}`)
|
||||||
|
.then((response) => (response.status == 200 ? response.json() : []))
|
||||||
|
},
|
||||||
|
|
||||||
|
store(path, data) {
|
||||||
|
return Bucket.upload(`${path}.json`, JSON.stringify(data))
|
||||||
|
},
|
||||||
|
|
||||||
|
retrieve(path) {
|
||||||
|
return fetch(`bucket/${path}.json`)
|
||||||
|
.then((response) => (response.status == 200 ? response.json() : null))
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
useAsThumbSaveBtn.addEventListener("click", (e) => {
|
useAsThumbSaveBtn.addEventListener("click", (e) => {
|
||||||
let scale = 1 / onUseAsThumbnailClick.scale
|
let scale = 1 / onUseAsThumbnailClick.scale
|
||||||
let crop = onUseAsThumbnailClick.croppr.getValue()
|
let crop = onUseAsThumbnailClick.croppr.getValue()
|
||||||
@ -793,22 +864,18 @@ useAsThumbSaveBtn.addEventListener("click", (e) => {
|
|||||||
.then((thumb) => fetch(thumb))
|
.then((thumb) => fetch(thumb))
|
||||||
.then((response) => response.blob())
|
.then((response) => response.blob())
|
||||||
.then(async function(blob) {
|
.then(async function(blob) {
|
||||||
const formData = new FormData()
|
|
||||||
formData.append("file", blob)
|
|
||||||
let options = useAsThumbSelect.selectedOptions
|
let options = useAsThumbSelect.selectedOptions
|
||||||
let promises = []
|
let promises = []
|
||||||
for (let embedding of options) {
|
for (let embedding of options) {
|
||||||
promises.push(
|
promises.push(
|
||||||
fetch(`bucket/${profileName}/${embedding.dataset["type"]}/${embedding.value}.png`, {
|
Bucket.upload(`${profileName}/${embedding.dataset["type"]}/${embedding.value}.png`, blob)
|
||||||
method: "POST",
|
|
||||||
body: formData,
|
|
||||||
})
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return Promise.all(promises)
|
return Promise.all(promises)
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
useAsThumbDialog.close()
|
useAsThumbDialog.close()
|
||||||
|
document.dispatchEvent(new CustomEvent("saveThumb", { detail: useAsThumbSelect.selectedOptions }))
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
@ -852,6 +919,10 @@ function applyInlineFilter(filterName, path, filterParams, img, statusText, tool
|
|||||||
}
|
}
|
||||||
filterReq.model_paths[filterName] = path
|
filterReq.model_paths[filterName] = path
|
||||||
|
|
||||||
|
if (saveToDiskField.checked && diskPathField.value.trim() !== "") {
|
||||||
|
filterReq.save_to_disk_path = diskPathField.value.trim()
|
||||||
|
}
|
||||||
|
|
||||||
tools.spinnerStatus.innerText = statusText
|
tools.spinnerStatus.innerText = statusText
|
||||||
tools.spinner.classList.remove("displayNone")
|
tools.spinner.classList.remove("displayNone")
|
||||||
|
|
||||||
@ -1237,7 +1308,6 @@ function getCurrentUserRequest() {
|
|||||||
//render_device: undefined, // Set device affinity. Prefer this device, but wont activate.
|
//render_device: undefined, // Set device affinity. Prefer this device, but wont activate.
|
||||||
use_stable_diffusion_model: stableDiffusionModelField.value,
|
use_stable_diffusion_model: stableDiffusionModelField.value,
|
||||||
clip_skip: clipSkipField.checked,
|
clip_skip: clipSkipField.checked,
|
||||||
tiling: tilingField.value,
|
|
||||||
use_vae_model: vaeModelField.value,
|
use_vae_model: vaeModelField.value,
|
||||||
stream_progress_updates: true,
|
stream_progress_updates: true,
|
||||||
stream_image_progress: numOutputsTotal > 50 ? false : streamImageProgressField.checked,
|
stream_image_progress: numOutputsTotal > 50 ? false : streamImageProgressField.checked,
|
||||||
@ -1302,6 +1372,11 @@ function getCurrentUserRequest() {
|
|||||||
newTask.reqBody.use_lora_model = modelNames
|
newTask.reqBody.use_lora_model = modelNames
|
||||||
newTask.reqBody.lora_alpha = modelStrengths
|
newTask.reqBody.lora_alpha = modelStrengths
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tilingField.value !== "none") {
|
||||||
|
newTask.reqBody.tiling = tilingField.value
|
||||||
|
}
|
||||||
|
newTask.reqBody.enable_vae_tiling = enableVAETilingField.checked
|
||||||
}
|
}
|
||||||
if (testDiffusers.checked && document.getElementById("toggle-tensorrt-install").innerHTML == "Uninstall") {
|
if (testDiffusers.checked && document.getElementById("toggle-tensorrt-install").innerHTML == "Uninstall") {
|
||||||
// TRT is installed
|
// TRT is installed
|
||||||
@ -1326,6 +1401,7 @@ function getCurrentUserRequest() {
|
|||||||
if (controlnetModelField.value !== "" && IMAGE_REGEX.test(controlImagePreview.src)) {
|
if (controlnetModelField.value !== "" && IMAGE_REGEX.test(controlImagePreview.src)) {
|
||||||
newTask.reqBody.use_controlnet_model = controlnetModelField.value
|
newTask.reqBody.use_controlnet_model = controlnetModelField.value
|
||||||
newTask.reqBody.control_image = controlImagePreview.src
|
newTask.reqBody.control_image = controlImagePreview.src
|
||||||
|
newTask.reqBody.control_alpha = parseFloat(controlAlphaField.value)
|
||||||
if (controlImageFilterField.value !== "") {
|
if (controlImageFilterField.value !== "") {
|
||||||
newTask.reqBody.control_filter_to_apply = controlImageFilterField.value
|
newTask.reqBody.control_filter_to_apply = controlImageFilterField.value
|
||||||
}
|
}
|
||||||
@ -1338,7 +1414,7 @@ function setEmbeddings(task) {
|
|||||||
let prompt = task.reqBody.prompt
|
let prompt = task.reqBody.prompt
|
||||||
let negativePrompt = task.reqBody.negative_prompt
|
let negativePrompt = task.reqBody.negative_prompt
|
||||||
let overallPrompt = (prompt + " " + negativePrompt).toLowerCase()
|
let overallPrompt = (prompt + " " + negativePrompt).toLowerCase()
|
||||||
overallPrompt = overallPrompt.replaceAll(/[^a-z0-9\.]/g, " ") // only allow alpha-numeric and dots
|
overallPrompt = overallPrompt.replaceAll(/[^a-z0-9\-_\.]/g, " ") // only allow alpha-numeric, dots and hyphens
|
||||||
overallPrompt = overallPrompt.split(" ")
|
overallPrompt = overallPrompt.split(" ")
|
||||||
|
|
||||||
let embeddingsTree = modelsOptions["embeddings"]
|
let embeddingsTree = modelsOptions["embeddings"]
|
||||||
@ -1562,7 +1638,7 @@ function updateInitialText() {
|
|||||||
|
|
||||||
const countBeforeBanner = localStorage.getItem("countBeforeBanner") || 1
|
const countBeforeBanner = localStorage.getItem("countBeforeBanner") || 1
|
||||||
if (countBeforeBanner <= 0) {
|
if (countBeforeBanner <= 0) {
|
||||||
// supportBanner.classList.remove("displayNone")
|
supportBanner.classList.remove("displayNone")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1946,6 +2022,27 @@ function updateHypernetworkStrengthContainer() {
|
|||||||
hypernetworkModelField.addEventListener("change", updateHypernetworkStrengthContainer)
|
hypernetworkModelField.addEventListener("change", updateHypernetworkStrengthContainer)
|
||||||
updateHypernetworkStrengthContainer()
|
updateHypernetworkStrengthContainer()
|
||||||
|
|
||||||
|
/********************* Controlnet Alpha **************************/
|
||||||
|
function updateControlAlpha() {
|
||||||
|
controlAlphaField.value = controlAlphaSlider.value / 10
|
||||||
|
controlAlphaField.dispatchEvent(new Event("change"))
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateControlAlphaSlider() {
|
||||||
|
if (controlAlphaField.value < 0) {
|
||||||
|
controlAlphaField.value = 0
|
||||||
|
} else if (controlAlphaField.value > 10) {
|
||||||
|
controlAlphaField.value = 10
|
||||||
|
}
|
||||||
|
|
||||||
|
controlAlphaSlider.value = controlAlphaField.value * 10
|
||||||
|
controlAlphaSlider.dispatchEvent(new Event("change"))
|
||||||
|
}
|
||||||
|
|
||||||
|
controlAlphaSlider.addEventListener("input", updateControlAlpha)
|
||||||
|
controlAlphaField.addEventListener("input", updateControlAlphaSlider)
|
||||||
|
updateControlAlpha()
|
||||||
|
|
||||||
/********************* JPEG/WEBP Quality **********************/
|
/********************* JPEG/WEBP Quality **********************/
|
||||||
function updateOutputQuality() {
|
function updateOutputQuality() {
|
||||||
outputQualityField.value = 0 | outputQualitySlider.value
|
outputQualityField.value = 0 | outputQualitySlider.value
|
||||||
@ -2355,20 +2452,10 @@ function loadThumbnailImageFromFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateEmbeddingsList(filter = "") {
|
function updateEmbeddingsList(filter = "") {
|
||||||
function html(model, iconlist = [], prefix = "", filter = "") {
|
function html(model, iconMap = {}, prefix = "", filter = "") {
|
||||||
filter = filter.toLowerCase()
|
filter = filter.toLowerCase()
|
||||||
let toplevel = document.createElement("div")
|
let toplevel = document.createElement("div")
|
||||||
let folders = document.createElement("div")
|
let folders = document.createElement("div")
|
||||||
let embIcon = Object.assign(
|
|
||||||
{},
|
|
||||||
...iconlist.map((x) => ({
|
|
||||||
[x
|
|
||||||
.toLowerCase()
|
|
||||||
.split(".")
|
|
||||||
.slice(0, -1)
|
|
||||||
.join(".")]: x,
|
|
||||||
}))
|
|
||||||
)
|
|
||||||
|
|
||||||
let profileName = profileNameField.value
|
let profileName = profileNameField.value
|
||||||
model?.forEach((m) => {
|
model?.forEach((m) => {
|
||||||
@ -2376,13 +2463,9 @@ function updateEmbeddingsList(filter = "") {
|
|||||||
let token = m.toLowerCase()
|
let token = m.toLowerCase()
|
||||||
if (token.search(filter) != -1) {
|
if (token.search(filter) != -1) {
|
||||||
let button
|
let button
|
||||||
// if (iconlist.length==0) {
|
|
||||||
// button = document.createElement("button")
|
|
||||||
// button.innerText = m
|
|
||||||
// } else {
|
|
||||||
let img = "/media/images/noimg.png"
|
let img = "/media/images/noimg.png"
|
||||||
if (token in embIcon) {
|
if (token in iconMap) {
|
||||||
img = `/bucket/${profileName}/embeddings/${embIcon[token]}`
|
img = `/bucket/${profileName}/${iconMap[token]}`
|
||||||
}
|
}
|
||||||
button = createModifierCard(m, [img, img], true)
|
button = createModifierCard(m, [img, img], true)
|
||||||
// }
|
// }
|
||||||
@ -2391,7 +2474,7 @@ function updateEmbeddingsList(filter = "") {
|
|||||||
toplevel.appendChild(button)
|
toplevel.appendChild(button)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let subdir = html(m[1], iconlist, prefix + m[0] + "/", filter)
|
let subdir = html(m[1], iconMap, prefix + m[0] + "/", filter)
|
||||||
if (typeof subdir == "object") {
|
if (typeof subdir == "object") {
|
||||||
let div1 = document.createElement("div")
|
let div1 = document.createElement("div")
|
||||||
let div2 = document.createElement("div")
|
let div2 = document.createElement("div")
|
||||||
@ -2450,11 +2533,44 @@ function updateEmbeddingsList(filter = "") {
|
|||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
|
||||||
|
let loraTokens = []
|
||||||
let profileName = profileNameField.value
|
let profileName = profileNameField.value
|
||||||
fetch(`/bucket/${profileName}/embeddings/`)
|
let iconMap = {}
|
||||||
.then((response) => (response.status == 200 ? response.json() : []))
|
|
||||||
.then(async function(iconlist) {
|
Bucket.getList(`${profileName}/embeddings/`)
|
||||||
embeddingsList.replaceChildren(html(modelsOptions.embeddings, iconlist, "", filter))
|
.then((icons) => {
|
||||||
|
iconMap = Object.assign(
|
||||||
|
{},
|
||||||
|
...icons.map((x) => ({
|
||||||
|
[x
|
||||||
|
.toLowerCase()
|
||||||
|
.split(".")
|
||||||
|
.slice(0, -1)
|
||||||
|
.join(".")]: `embeddings/${x}`,
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
|
||||||
|
return Bucket.getList(`${profileName}/lora/`)
|
||||||
|
})
|
||||||
|
.then(async function (icons) {
|
||||||
|
for (let lora of loraModelField.value.modelNames) {
|
||||||
|
let keywords = await getLoraKeywords(lora)
|
||||||
|
loraTokens = loraTokens.concat(keywords)
|
||||||
|
let loraname = lora.split("/").pop()
|
||||||
|
|
||||||
|
if (icons.includes(`${loraname}.png`)) {
|
||||||
|
keywords.forEach((kw) => {
|
||||||
|
iconMap[kw.toLowerCase()] = `lora/${loraname}.png`
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let tokenList = [...modelsOptions.embeddings]
|
||||||
|
if (loraTokens.length != 0) {
|
||||||
|
tokenList.unshift(['LORA Keywords', loraTokens])
|
||||||
|
}
|
||||||
|
embeddingsList.replaceChildren(html(tokenList, iconMap, "", filter))
|
||||||
createCollapsibles(embeddingsList)
|
createCollapsibles(embeddingsList)
|
||||||
if (filter != "") {
|
if (filter != "") {
|
||||||
embeddingsExpandAll()
|
embeddingsExpandAll()
|
||||||
|
@ -97,6 +97,17 @@ var PARAMETERS = [
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "models_dir",
|
||||||
|
type: ParameterType.custom,
|
||||||
|
icon: "fa-folder-tree",
|
||||||
|
label: "Models Folder",
|
||||||
|
note: "Path to the 'models' folder. Please save and refresh the page after changing this.",
|
||||||
|
saveInAppConfig: true,
|
||||||
|
render: (parameter) => {
|
||||||
|
return `<input id="${parameter.id}" name="${parameter.id}" size="30">`
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: "block_nsfw",
|
id: "block_nsfw",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
@ -238,7 +249,7 @@ var PARAMETERS = [
|
|||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "test_diffusers",
|
id: "use_v3_engine",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
label: "Use the new v3 engine (diffusers)",
|
label: "Use the new v3 engine (diffusers)",
|
||||||
note:
|
note:
|
||||||
@ -420,8 +431,9 @@ let listenPortField = document.querySelector("#listen_port")
|
|||||||
let useBetaChannelField = document.querySelector("#use_beta_channel")
|
let useBetaChannelField = document.querySelector("#use_beta_channel")
|
||||||
let uiOpenBrowserOnStartField = document.querySelector("#ui_open_browser_on_start")
|
let uiOpenBrowserOnStartField = document.querySelector("#ui_open_browser_on_start")
|
||||||
let confirmDangerousActionsField = document.querySelector("#confirm_dangerous_actions")
|
let confirmDangerousActionsField = document.querySelector("#confirm_dangerous_actions")
|
||||||
let testDiffusers = document.querySelector("#test_diffusers")
|
let testDiffusers = document.querySelector("#use_v3_engine")
|
||||||
let profileNameField = document.querySelector("#profileName")
|
let profileNameField = document.querySelector("#profileName")
|
||||||
|
let modelsDirField = document.querySelector("#models_dir")
|
||||||
|
|
||||||
let saveSettingsBtn = document.querySelector("#save-system-settings-btn")
|
let saveSettingsBtn = document.querySelector("#save-system-settings-btn")
|
||||||
|
|
||||||
@ -463,15 +475,17 @@ async function getAppConfig() {
|
|||||||
if (config.net && config.net.listen_port !== undefined) {
|
if (config.net && config.net.listen_port !== undefined) {
|
||||||
listenPortField.value = config.net.listen_port
|
listenPortField.value = config.net.listen_port
|
||||||
}
|
}
|
||||||
|
modelsDirField.value = config.models_dir
|
||||||
|
|
||||||
let testDiffusersEnabled = true
|
let testDiffusersEnabled = true
|
||||||
if (config.test_diffusers === false) {
|
if (config.use_v3_engine === false) {
|
||||||
testDiffusersEnabled = false
|
testDiffusersEnabled = false
|
||||||
}
|
}
|
||||||
testDiffusers.checked = testDiffusersEnabled
|
testDiffusers.checked = testDiffusersEnabled
|
||||||
|
document.querySelector("#test_diffusers").checked = testDiffusers.checked // don't break plugins
|
||||||
|
|
||||||
if (config.config_on_startup) {
|
if (config.config_on_startup) {
|
||||||
if (config.config_on_startup?.test_diffusers) {
|
if (config.config_on_startup?.use_v3_engine) {
|
||||||
document.body.classList.add("diffusers-enabled-on-startup")
|
document.body.classList.add("diffusers-enabled-on-startup")
|
||||||
document.body.classList.remove("diffusers-disabled-on-startup")
|
document.body.classList.remove("diffusers-disabled-on-startup")
|
||||||
} else {
|
} else {
|
||||||
@ -511,6 +525,10 @@ async function getAppConfig() {
|
|||||||
customHeightField.step = IMAGE_STEP_SIZE
|
customHeightField.step = IMAGE_STEP_SIZE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.force_save_metadata) {
|
||||||
|
metadataOutputFormatField.value = config.force_save_metadata
|
||||||
|
}
|
||||||
|
|
||||||
console.log("get config status response", config)
|
console.log("get config status response", config)
|
||||||
|
|
||||||
return config
|
return config
|
||||||
@ -722,10 +740,13 @@ async function getSystemInfo() {
|
|||||||
force = res["enforce_output_dir"]
|
force = res["enforce_output_dir"]
|
||||||
if (force == true) {
|
if (force == true) {
|
||||||
saveToDiskField.checked = true
|
saveToDiskField.checked = true
|
||||||
metadataOutputFormatField.disabled = false
|
metadataOutputFormatField.disabled = res["enforce_output_metadata"]
|
||||||
|
diskPathField.disabled = true
|
||||||
}
|
}
|
||||||
saveToDiskField.disabled = force
|
saveToDiskField.disabled = force
|
||||||
diskPathField.disabled = force
|
} else {
|
||||||
|
diskPathField.disabled = !saveToDiskField.checked
|
||||||
|
metadataOutputFormatField.disabled = !saveToDiskField.checked
|
||||||
}
|
}
|
||||||
setDiskPath(res["default_output_dir"], force)
|
setDiskPath(res["default_output_dir"], force)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -1,454 +0,0 @@
|
|||||||
;(function() {
|
|
||||||
"use strict"
|
|
||||||
|
|
||||||
///////////////////// Function section
|
|
||||||
function smoothstep(x) {
|
|
||||||
return x * x * (3 - 2 * x)
|
|
||||||
}
|
|
||||||
|
|
||||||
function smootherstep(x) {
|
|
||||||
return x * x * x * (x * (x * 6 - 15) + 10)
|
|
||||||
}
|
|
||||||
|
|
||||||
function smootheststep(x) {
|
|
||||||
let y = -20 * Math.pow(x, 7)
|
|
||||||
y += 70 * Math.pow(x, 6)
|
|
||||||
y -= 84 * Math.pow(x, 5)
|
|
||||||
y += 35 * Math.pow(x, 4)
|
|
||||||
return y
|
|
||||||
}
|
|
||||||
function getCurrentTime() {
|
|
||||||
const now = new Date()
|
|
||||||
let hours = now.getHours()
|
|
||||||
let minutes = now.getMinutes()
|
|
||||||
let seconds = now.getSeconds()
|
|
||||||
|
|
||||||
hours = hours < 10 ? `0${hours}` : hours
|
|
||||||
minutes = minutes < 10 ? `0${minutes}` : minutes
|
|
||||||
seconds = seconds < 10 ? `0${seconds}` : seconds
|
|
||||||
|
|
||||||
return `${hours}:${minutes}:${seconds}`
|
|
||||||
}
|
|
||||||
|
|
||||||
function addLogMessage(message) {
|
|
||||||
const logContainer = document.getElementById("merge-log")
|
|
||||||
logContainer.innerHTML += `<i>${getCurrentTime()}</i> ${message}<br>`
|
|
||||||
|
|
||||||
// Scroll to the bottom of the log
|
|
||||||
logContainer.scrollTop = logContainer.scrollHeight
|
|
||||||
|
|
||||||
document.querySelector("#merge-log-container").style.display = "block"
|
|
||||||
}
|
|
||||||
|
|
||||||
function addLogSeparator() {
|
|
||||||
const logContainer = document.getElementById("merge-log")
|
|
||||||
logContainer.innerHTML += "<hr>"
|
|
||||||
|
|
||||||
logContainer.scrollTop = logContainer.scrollHeight
|
|
||||||
}
|
|
||||||
|
|
||||||
function drawDiagram(fn) {
|
|
||||||
const SIZE = 300
|
|
||||||
const canvas = document.getElementById("merge-canvas")
|
|
||||||
canvas.height = canvas.width = SIZE
|
|
||||||
const ctx = canvas.getContext("2d")
|
|
||||||
|
|
||||||
// Draw coordinate system
|
|
||||||
ctx.scale(1, -1)
|
|
||||||
ctx.translate(0, -canvas.height)
|
|
||||||
ctx.lineWidth = 1
|
|
||||||
ctx.beginPath()
|
|
||||||
|
|
||||||
ctx.strokeStyle = "white"
|
|
||||||
ctx.moveTo(0, 0)
|
|
||||||
ctx.lineTo(0, SIZE)
|
|
||||||
ctx.lineTo(SIZE, SIZE)
|
|
||||||
ctx.lineTo(SIZE, 0)
|
|
||||||
ctx.lineTo(0, 0)
|
|
||||||
ctx.lineTo(SIZE, SIZE)
|
|
||||||
ctx.stroke()
|
|
||||||
ctx.beginPath()
|
|
||||||
ctx.setLineDash([1, 2])
|
|
||||||
const n = SIZE / 10
|
|
||||||
for (let i = n; i < SIZE; i += n) {
|
|
||||||
ctx.moveTo(0, i)
|
|
||||||
ctx.lineTo(SIZE, i)
|
|
||||||
ctx.moveTo(i, 0)
|
|
||||||
ctx.lineTo(i, SIZE)
|
|
||||||
}
|
|
||||||
ctx.stroke()
|
|
||||||
ctx.beginPath()
|
|
||||||
ctx.setLineDash([])
|
|
||||||
ctx.beginPath()
|
|
||||||
ctx.strokeStyle = "black"
|
|
||||||
ctx.lineWidth = 3
|
|
||||||
// Plot function
|
|
||||||
const numSamples = 20
|
|
||||||
for (let i = 0; i <= numSamples; i++) {
|
|
||||||
const x = i / numSamples
|
|
||||||
const y = fn(x)
|
|
||||||
|
|
||||||
const canvasX = x * SIZE
|
|
||||||
const canvasY = y * SIZE
|
|
||||||
|
|
||||||
if (i === 0) {
|
|
||||||
ctx.moveTo(canvasX, canvasY)
|
|
||||||
} else {
|
|
||||||
ctx.lineTo(canvasX, canvasY)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ctx.stroke()
|
|
||||||
// Plot alpha values (yellow boxes)
|
|
||||||
let start = parseFloat(document.querySelector("#merge-start").value)
|
|
||||||
let step = parseFloat(document.querySelector("#merge-step").value)
|
|
||||||
let iterations = document.querySelector("#merge-count").value >> 0
|
|
||||||
ctx.beginPath()
|
|
||||||
ctx.fillStyle = "yellow"
|
|
||||||
for (let i = 0; i < iterations; i++) {
|
|
||||||
const alpha = (start + i * step) / 100
|
|
||||||
const x = alpha * SIZE
|
|
||||||
const y = fn(alpha) * SIZE
|
|
||||||
if (x <= SIZE) {
|
|
||||||
ctx.rect(x - 3, y - 3, 6, 6)
|
|
||||||
ctx.fill()
|
|
||||||
} else {
|
|
||||||
ctx.strokeStyle = "red"
|
|
||||||
ctx.moveTo(0, 0)
|
|
||||||
ctx.lineTo(0, SIZE)
|
|
||||||
ctx.lineTo(SIZE, SIZE)
|
|
||||||
ctx.lineTo(SIZE, 0)
|
|
||||||
ctx.lineTo(0, 0)
|
|
||||||
ctx.lineTo(SIZE, SIZE)
|
|
||||||
ctx.stroke()
|
|
||||||
addLogMessage("<i>Warning: maximum ratio is ≥ 100%</i>")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateChart() {
|
|
||||||
let fn = (x) => x
|
|
||||||
switch (document.querySelector("#merge-interpolation").value) {
|
|
||||||
case "SmoothStep":
|
|
||||||
fn = smoothstep
|
|
||||||
break
|
|
||||||
case "SmootherStep":
|
|
||||||
fn = smootherstep
|
|
||||||
break
|
|
||||||
case "SmoothestStep":
|
|
||||||
fn = smootheststep
|
|
||||||
break
|
|
||||||
}
|
|
||||||
drawDiagram(fn)
|
|
||||||
}
|
|
||||||
createTab({
|
|
||||||
id: "merge",
|
|
||||||
icon: "fa-code-merge",
|
|
||||||
label: "Merge models",
|
|
||||||
css: `
|
|
||||||
#tab-content-merge .tab-content-inner {
|
|
||||||
max-width: 100%;
|
|
||||||
padding: 10pt;
|
|
||||||
}
|
|
||||||
.merge-container {
|
|
||||||
margin-left: 15%;
|
|
||||||
margin-right: 15%;
|
|
||||||
text-align: left;
|
|
||||||
display: inline-grid;
|
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
grid-template-rows: auto auto auto;
|
|
||||||
gap: 0px 0px;
|
|
||||||
grid-auto-flow: row;
|
|
||||||
grid-template-areas:
|
|
||||||
"merge-input merge-config"
|
|
||||||
"merge-buttons merge-buttons";
|
|
||||||
}
|
|
||||||
.merge-container p {
|
|
||||||
margin-top: 3pt;
|
|
||||||
margin-bottom: 3pt;
|
|
||||||
}
|
|
||||||
.merge-config .tab-content {
|
|
||||||
background: var(--background-color1);
|
|
||||||
border-radius: 3pt;
|
|
||||||
}
|
|
||||||
.merge-config .tab-content-inner {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.merge-input {
|
|
||||||
grid-area: merge-input;
|
|
||||||
padding-left:1em;
|
|
||||||
}
|
|
||||||
.merge-config {
|
|
||||||
grid-area: merge-config;
|
|
||||||
padding:1em;
|
|
||||||
}
|
|
||||||
.merge-config input {
|
|
||||||
margin-bottom: 3px;
|
|
||||||
}
|
|
||||||
.merge-config select {
|
|
||||||
margin-bottom: 3px;
|
|
||||||
}
|
|
||||||
.merge-buttons {
|
|
||||||
grid-area: merge-buttons;
|
|
||||||
padding:1em;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
#merge-button {
|
|
||||||
padding: 8px;
|
|
||||||
width:20em;
|
|
||||||
}
|
|
||||||
div#merge-log {
|
|
||||||
height:150px;
|
|
||||||
overflow-x:hidden;
|
|
||||||
overflow-y:scroll;
|
|
||||||
background:var(--background-color1);
|
|
||||||
border-radius: 3pt;
|
|
||||||
}
|
|
||||||
div#merge-log i {
|
|
||||||
color: hsl(var(--accent-hue), 100%, calc(2*var(--accent-lightness)));
|
|
||||||
font-family: monospace;
|
|
||||||
}
|
|
||||||
.disabled {
|
|
||||||
background: var(--background-color4);
|
|
||||||
color: var(--text-color);
|
|
||||||
}
|
|
||||||
#merge-type-tabs {
|
|
||||||
border-bottom: 1px solid black;
|
|
||||||
}
|
|
||||||
#merge-log-container {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
.merge-container #merge-warning {
|
|
||||||
color: rgb(153, 153, 153);
|
|
||||||
}`,
|
|
||||||
content: `
|
|
||||||
<div class="merge-container panel-box">
|
|
||||||
<div class="merge-input">
|
|
||||||
<p><label for="#mergeModelA">Select Model A:</label></p>
|
|
||||||
<input id="mergeModelA" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
|
|
||||||
<p><label for="#mergeModelB">Select Model B:</label></p>
|
|
||||||
<input id="mergeModelB" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
|
|
||||||
<br/><br/>
|
|
||||||
<p id="merge-warning"><small><b>Important:</b> Please merge models of similar type.<br/>For e.g. <code>SD 1.4</code> models with only <code>SD 1.4/1.5</code> models,<br/><code>SD 2.0</code> with <code>SD 2.0</code>-type, and <code>SD 2.1</code> with <code>SD 2.1</code>-type models.</small></p>
|
|
||||||
<br/>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td><label for="#merge-filename">Output file name:</label></td>
|
|
||||||
<td><input id="merge-filename" size=24> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Base name of the output file.<br>Mix ratio and file suffix will be appended to this.</span></i></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><label for="#merge-fp">Output precision:</label></td>
|
|
||||||
<td><select id="merge-fp">
|
|
||||||
<option value="fp16">fp16 (smaller file size)</option>
|
|
||||||
<option value="fp32">fp32 (larger file size)</option>
|
|
||||||
</select>
|
|
||||||
<i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Image generation uses fp16, so it's a good choice.<br>Use fp32 if you want to use the result models for more mixes</span></i>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><label for="#merge-format">Output file format:</label></td>
|
|
||||||
<td><select id="merge-format">
|
|
||||||
<option value="safetensors">Safetensors (recommended)</option>
|
|
||||||
<option value="ckpt">CKPT/Pickle (legacy format)</option>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br/>
|
|
||||||
<div id="merge-log-container">
|
|
||||||
<p><label for="#merge-log">Log messages:</label></p>
|
|
||||||
<div id="merge-log"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="merge-config">
|
|
||||||
<div class="tab-container">
|
|
||||||
<span id="tab-merge-opts-single" class="tab active">
|
|
||||||
<span>Make a single file</small></span>
|
|
||||||
</span>
|
|
||||||
<span id="tab-merge-opts-batch" class="tab">
|
|
||||||
<span>Make multiple variations</small></span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div id="tab-content-merge-opts-single" class="tab-content active">
|
|
||||||
<div class="tab-content-inner">
|
|
||||||
<small>Saves a single merged model file, at the specified merge ratio.</small><br/><br/>
|
|
||||||
<label for="#single-merge-ratio-slider">Merge ratio:</label>
|
|
||||||
<input id="single-merge-ratio-slider" name="single-merge-ratio-slider" class="editor-slider" value="50" type="range" min="1" max="1000">
|
|
||||||
<input id="single-merge-ratio" size=2 value="5">%
|
|
||||||
<i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Model A's contribution to the mix. The rest will be from Model B.</span></i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="tab-content-merge-opts-batch" class="tab-content">
|
|
||||||
<div class="tab-content-inner">
|
|
||||||
<small>Saves multiple variations of the model, at different merge ratios.<br/>Each variation will be saved as a separate file.</small><br/><br/>
|
|
||||||
<table>
|
|
||||||
<tr><td><label for="#merge-count">Number of variations:</label></td>
|
|
||||||
<td> <input id="merge-count" size=2 value="5"></td>
|
|
||||||
<td> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Number of models to create</span></i></td></tr>
|
|
||||||
<tr><td><label for="#merge-start">Starting merge ratio:</label></td>
|
|
||||||
<td> <input id="merge-start" size=2 value="5">%</td>
|
|
||||||
<td> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Smallest share of model A in the mix</span></i></td></tr>
|
|
||||||
<tr><td><label for="#merge-step">Increment each step:</label></td>
|
|
||||||
<td> <input id="merge-step" size=2 value="10">%</td>
|
|
||||||
<td> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Share of model A added into the mix per step</span></i></td></tr>
|
|
||||||
<tr><td><label for="#merge-interpolation">Interpolation model:</label></td>
|
|
||||||
<td> <select id="merge-interpolation">
|
|
||||||
<option>Exact</option>
|
|
||||||
<option>SmoothStep</option>
|
|
||||||
<option>SmootherStep</option>
|
|
||||||
<option>SmoothestStep</option>
|
|
||||||
</select></td>
|
|
||||||
<td> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Sigmoid function to be applied to the model share before mixing</span></i></td></tr>
|
|
||||||
</table>
|
|
||||||
<br/>
|
|
||||||
<small>Preview of variation ratios:</small><br/>
|
|
||||||
<canvas id="merge-canvas" width="400" height="400"></canvas>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="merge-buttons">
|
|
||||||
<button id="merge-button" class="primaryButton">Merge models</button>
|
|
||||||
</div>
|
|
||||||
</div>`,
|
|
||||||
onOpen: ({ firstOpen }) => {
|
|
||||||
if (!firstOpen) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const tabSettingsSingle = document.querySelector("#tab-merge-opts-single")
|
|
||||||
const tabSettingsBatch = document.querySelector("#tab-merge-opts-batch")
|
|
||||||
linkTabContents(tabSettingsSingle)
|
|
||||||
linkTabContents(tabSettingsBatch)
|
|
||||||
|
|
||||||
console.log("Activate")
|
|
||||||
let mergeModelAField = new ModelDropdown(document.querySelector("#mergeModelA"), "stable-diffusion")
|
|
||||||
let mergeModelBField = new ModelDropdown(document.querySelector("#mergeModelB"), "stable-diffusion")
|
|
||||||
updateChart()
|
|
||||||
|
|
||||||
// slider
|
|
||||||
const singleMergeRatioField = document.querySelector("#single-merge-ratio")
|
|
||||||
const singleMergeRatioSlider = document.querySelector("#single-merge-ratio-slider")
|
|
||||||
|
|
||||||
function updateSingleMergeRatio() {
|
|
||||||
singleMergeRatioField.value = singleMergeRatioSlider.value / 10
|
|
||||||
singleMergeRatioField.dispatchEvent(new Event("change"))
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateSingleMergeRatioSlider() {
|
|
||||||
if (singleMergeRatioField.value < 0) {
|
|
||||||
singleMergeRatioField.value = 0
|
|
||||||
} else if (singleMergeRatioField.value > 100) {
|
|
||||||
singleMergeRatioField.value = 100
|
|
||||||
}
|
|
||||||
|
|
||||||
singleMergeRatioSlider.value = singleMergeRatioField.value * 10
|
|
||||||
singleMergeRatioSlider.dispatchEvent(new Event("change"))
|
|
||||||
}
|
|
||||||
|
|
||||||
singleMergeRatioSlider.addEventListener("input", updateSingleMergeRatio)
|
|
||||||
singleMergeRatioField.addEventListener("input", updateSingleMergeRatioSlider)
|
|
||||||
updateSingleMergeRatio()
|
|
||||||
|
|
||||||
document.querySelector(".merge-config").addEventListener("change", updateChart)
|
|
||||||
|
|
||||||
document.querySelector("#merge-button").addEventListener("click", async function(e) {
|
|
||||||
// Build request template
|
|
||||||
let model0 = mergeModelAField.value
|
|
||||||
let model1 = mergeModelBField.value
|
|
||||||
let request = { model0: model0, model1: model1 }
|
|
||||||
request["use_fp16"] = document.querySelector("#merge-fp").value == "fp16"
|
|
||||||
let iterations = document.querySelector("#merge-count").value >> 0
|
|
||||||
let start = parseFloat(document.querySelector("#merge-start").value)
|
|
||||||
let step = parseFloat(document.querySelector("#merge-step").value)
|
|
||||||
|
|
||||||
if (isTabActive(tabSettingsSingle)) {
|
|
||||||
start = parseFloat(singleMergeRatioField.value)
|
|
||||||
step = 0
|
|
||||||
iterations = 1
|
|
||||||
addLogMessage(`merge ratio = ${start}%`)
|
|
||||||
} else {
|
|
||||||
addLogMessage(`start = ${start}%`)
|
|
||||||
addLogMessage(`step = ${step}%`)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (start + (iterations - 1) * step >= 100) {
|
|
||||||
addLogMessage("<i>Aborting: maximum ratio is ≥ 100%</i>")
|
|
||||||
addLogMessage("Reduce the number of variations or the step size")
|
|
||||||
addLogSeparator()
|
|
||||||
document.querySelector("#merge-count").focus()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (document.querySelector("#merge-filename").value == "") {
|
|
||||||
addLogMessage("<i>Aborting: No output file name specified</i>")
|
|
||||||
addLogSeparator()
|
|
||||||
document.querySelector("#merge-filename").focus()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable merge button
|
|
||||||
e.target.disabled = true
|
|
||||||
e.target.classList.add("disabled")
|
|
||||||
let cursor = $("body").css("cursor")
|
|
||||||
let label = document.querySelector("#merge-button").innerHTML
|
|
||||||
$("body").css("cursor", "progress")
|
|
||||||
document.querySelector("#merge-button").innerHTML = "Merging models ..."
|
|
||||||
|
|
||||||
addLogMessage("Merging models")
|
|
||||||
addLogMessage("Model A: " + model0)
|
|
||||||
addLogMessage("Model B: " + model1)
|
|
||||||
|
|
||||||
// Batch main loop
|
|
||||||
for (let i = 0; i < iterations; i++) {
|
|
||||||
let alpha = (start + i * step) / 100
|
|
||||||
|
|
||||||
if (isTabActive(tabSettingsBatch)) {
|
|
||||||
switch (document.querySelector("#merge-interpolation").value) {
|
|
||||||
case "SmoothStep":
|
|
||||||
alpha = smoothstep(alpha)
|
|
||||||
break
|
|
||||||
case "SmootherStep":
|
|
||||||
alpha = smootherstep(alpha)
|
|
||||||
break
|
|
||||||
case "SmoothestStep":
|
|
||||||
alpha = smootheststep(alpha)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
addLogMessage(`merging batch job ${i + 1}/${iterations}, alpha = ${alpha.toFixed(5)}...`)
|
|
||||||
|
|
||||||
request["out_path"] = document.querySelector("#merge-filename").value
|
|
||||||
request["out_path"] += "-" + alpha.toFixed(5) + "." + document.querySelector("#merge-format").value
|
|
||||||
addLogMessage(` filename: ${request["out_path"]}`)
|
|
||||||
|
|
||||||
// sdkit documentation: "ratio - the ratio of the second model. 1 means only the second model will be used."
|
|
||||||
request["ratio"] = 1-alpha
|
|
||||||
let res = await fetch("/model/merge", {
|
|
||||||
method: "POST",
|
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
body: JSON.stringify(request),
|
|
||||||
})
|
|
||||||
const data = await res.json()
|
|
||||||
addLogMessage(JSON.stringify(data))
|
|
||||||
}
|
|
||||||
addLogMessage(
|
|
||||||
"<b>Done.</b> The models have been saved to your <tt>models/stable-diffusion</tt> folder."
|
|
||||||
)
|
|
||||||
addLogSeparator()
|
|
||||||
// Re-enable merge button
|
|
||||||
$("body").css("cursor", cursor)
|
|
||||||
document.querySelector("#merge-button").innerHTML = label
|
|
||||||
e.target.disabled = false
|
|
||||||
e.target.classList.remove("disabled")
|
|
||||||
|
|
||||||
// Update model list
|
|
||||||
stableDiffusionModelField.innerHTML = ""
|
|
||||||
vaeModelField.innerHTML = ""
|
|
||||||
hypernetworkModelField.innerHTML = ""
|
|
||||||
await getModels()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})()
|
|
770
ui/plugins/ui/model-tools.plugin.js
Normal file
770
ui/plugins/ui/model-tools.plugin.js
Normal file
@ -0,0 +1,770 @@
|
|||||||
|
;(function() {
|
||||||
|
"use strict"
|
||||||
|
|
||||||
|
let mergeCSS = `
|
||||||
|
/*********** Main tab ***********/
|
||||||
|
.tab-centered {
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#model-tool-tab-content {
|
||||||
|
background-color: var(--background-color3);
|
||||||
|
}
|
||||||
|
|
||||||
|
#model-tool-tab-content .tab-content-inner {
|
||||||
|
text-align: initial;
|
||||||
|
}
|
||||||
|
|
||||||
|
#model-tool-tab-bar .tab {
|
||||||
|
margin-bottom: 0px;
|
||||||
|
border-top-left-radius: var(--input-border-radius);
|
||||||
|
background-color: var(--background-color3);
|
||||||
|
padding: 6px 6px 0.8em 6px;
|
||||||
|
}
|
||||||
|
#tab-content-merge .tab-content-inner {
|
||||||
|
max-width: 100%;
|
||||||
|
padding: 10pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********** Merge UI ***********/
|
||||||
|
.merge-model-container {
|
||||||
|
margin-left: 15%;
|
||||||
|
margin-right: 15%;
|
||||||
|
text-align: left;
|
||||||
|
display: inline-grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
grid-template-rows: auto auto auto;
|
||||||
|
gap: 0px 0px;
|
||||||
|
grid-auto-flow: row;
|
||||||
|
grid-template-areas:
|
||||||
|
"merge-input merge-config"
|
||||||
|
"merge-buttons merge-buttons";
|
||||||
|
}
|
||||||
|
.merge-model-container p {
|
||||||
|
margin-top: 3pt;
|
||||||
|
margin-bottom: 3pt;
|
||||||
|
}
|
||||||
|
.merge-config .tab-content {
|
||||||
|
background: var(--background-color1);
|
||||||
|
border-radius: 3pt;
|
||||||
|
}
|
||||||
|
.merge-config .tab-content-inner {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.merge-input {
|
||||||
|
grid-area: merge-input;
|
||||||
|
padding-left:1em;
|
||||||
|
}
|
||||||
|
.merge-config {
|
||||||
|
grid-area: merge-config;
|
||||||
|
padding:1em;
|
||||||
|
}
|
||||||
|
.merge-config input {
|
||||||
|
margin-bottom: 3px;
|
||||||
|
}
|
||||||
|
.merge-config select {
|
||||||
|
margin-bottom: 3px;
|
||||||
|
}
|
||||||
|
.merge-buttons {
|
||||||
|
grid-area: merge-buttons;
|
||||||
|
padding:1em;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
#merge-button {
|
||||||
|
padding: 8px;
|
||||||
|
width:20em;
|
||||||
|
}
|
||||||
|
div#merge-log {
|
||||||
|
height:150px;
|
||||||
|
overflow-x:hidden;
|
||||||
|
overflow-y:scroll;
|
||||||
|
background:var(--background-color1);
|
||||||
|
border-radius: 3pt;
|
||||||
|
}
|
||||||
|
div#merge-log i {
|
||||||
|
color: hsl(var(--accent-hue), 100%, calc(2*var(--accent-lightness)));
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
.disabled {
|
||||||
|
background: var(--background-color4);
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
#merge-type-tabs {
|
||||||
|
border-bottom: 1px solid black;
|
||||||
|
}
|
||||||
|
#merge-log-container {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.merge-model-container #merge-warning {
|
||||||
|
color: var(--small-label-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********** LORA UI ***********/
|
||||||
|
.lora-manager-grid {
|
||||||
|
display: grid;
|
||||||
|
gap: 0px 8px;
|
||||||
|
grid-auto-flow: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 1501px) {
|
||||||
|
.lora-manager-grid textarea {
|
||||||
|
height:350px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lora-manager-grid {
|
||||||
|
grid-template-columns: auto 1fr 1fr;
|
||||||
|
grid-template-rows: auto 1fr;
|
||||||
|
grid-template-areas:
|
||||||
|
"selector selector selector"
|
||||||
|
"thumbnail keywords notes";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 1001px) and (max-width: 1500px) {
|
||||||
|
.lora-manager-grid textarea {
|
||||||
|
height:250px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lora-manager-grid {
|
||||||
|
grid-template-columns: auto auto;
|
||||||
|
grid-template-rows: auto auto auto;
|
||||||
|
grid-template-areas:
|
||||||
|
"selector selector"
|
||||||
|
"thumbnail keywords"
|
||||||
|
"thumbnail notes";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 1000px) {
|
||||||
|
.lora-manager-grid textarea {
|
||||||
|
height:200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lora-manager-grid {
|
||||||
|
grid-template-columns: auto;
|
||||||
|
grid-template-rows: auto auto auto auto;
|
||||||
|
grid-template-areas:
|
||||||
|
"selector"
|
||||||
|
"keywords"
|
||||||
|
"thumbnail"
|
||||||
|
"notes";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.lora-manager-grid-selector {
|
||||||
|
grid-area: selector;
|
||||||
|
justify-self: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lora-manager-grid-thumbnail {
|
||||||
|
grid-area: thumbnail;
|
||||||
|
justify-self: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lora-manager-grid-keywords {
|
||||||
|
grid-area: keywords;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lora-manager-grid-notes {
|
||||||
|
grid-area: notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lora-manager-grid p {
|
||||||
|
margin-bottom: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
`
|
||||||
|
|
||||||
|
let mergeUI = `
|
||||||
|
<div class="merge-model-container panel-box">
|
||||||
|
<div class="merge-input">
|
||||||
|
<p><label for="#mergeModelA">Select Model A:</label></p>
|
||||||
|
<input id="mergeModelA" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
|
||||||
|
<p><label for="#mergeModelB">Select Model B:</label></p>
|
||||||
|
<input id="mergeModelB" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
|
||||||
|
<br/><br/>
|
||||||
|
<p id="merge-warning"><small><b>Important:</b> Please merge models of similar type.<br/>For e.g. <code>SD 1.4</code> models with only <code>SD 1.4/1.5</code> models,<br/><code>SD 2.0</code> with <code>SD 2.0</code>-type, and <code>SD 2.1</code> with <code>SD 2.1</code>-type models.</small></p>
|
||||||
|
<br/>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><label for="#merge-filename">Output file name:</label></td>
|
||||||
|
<td><input id="merge-filename" size=24> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Base name of the output file.<br>Mix ratio and file suffix will be appended to this.</span></i></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="#merge-fp">Output precision:</label></td>
|
||||||
|
<td><select id="merge-fp">
|
||||||
|
<option value="fp16">fp16 (smaller file size)</option>
|
||||||
|
<option value="fp32">fp32 (larger file size)</option>
|
||||||
|
</select>
|
||||||
|
<i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Image generation uses fp16, so it's a good choice.<br>Use fp32 if you want to use the result models for more mixes</span></i>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><label for="#merge-format">Output file format:</label></td>
|
||||||
|
<td><select id="merge-format">
|
||||||
|
<option value="safetensors">Safetensors (recommended)</option>
|
||||||
|
<option value="ckpt">CKPT/Pickle (legacy format)</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br/>
|
||||||
|
<div id="merge-log-container">
|
||||||
|
<p><label for="#merge-log">Log messages:</label></p>
|
||||||
|
<div id="merge-log"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="merge-config">
|
||||||
|
<div class="tab-container">
|
||||||
|
<span id="tab-merge-opts-single" class="tab active">
|
||||||
|
<span>Make a single file</small></span>
|
||||||
|
</span>
|
||||||
|
<span id="tab-merge-opts-batch" class="tab">
|
||||||
|
<span>Make multiple variations</small></span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div id="tab-content-merge-opts-single" class="tab-content active">
|
||||||
|
<div class="tab-content-inner">
|
||||||
|
<small>Saves a single merged model file, at the specified merge ratio.</small><br/><br/>
|
||||||
|
<label for="#single-merge-ratio-slider">Merge ratio:</label>
|
||||||
|
<input id="single-merge-ratio-slider" name="single-merge-ratio-slider" class="editor-slider" value="50" type="range" min="1" max="1000">
|
||||||
|
<input id="single-merge-ratio" size=2 value="5">%
|
||||||
|
<i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Model A's contribution to the mix. The rest will be from Model B.</span></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="tab-content-merge-opts-batch" class="tab-content">
|
||||||
|
<div class="tab-content-inner">
|
||||||
|
<small>Saves multiple variations of the model, at different merge ratios.<br/>Each variation will be saved as a separate file.</small><br/><br/>
|
||||||
|
<table>
|
||||||
|
<tr><td><label for="#merge-count">Number of variations:</label></td>
|
||||||
|
<td> <input id="merge-count" size=2 value="5"></td>
|
||||||
|
<td> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Number of models to create</span></i></td></tr>
|
||||||
|
<tr><td><label for="#merge-start">Starting merge ratio:</label></td>
|
||||||
|
<td> <input id="merge-start" size=2 value="5">%</td>
|
||||||
|
<td> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Smallest share of model A in the mix</span></i></td></tr>
|
||||||
|
<tr><td><label for="#merge-step">Increment each step:</label></td>
|
||||||
|
<td> <input id="merge-step" size=2 value="10">%</td>
|
||||||
|
<td> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Share of model A added into the mix per step</span></i></td></tr>
|
||||||
|
<tr><td><label for="#merge-interpolation">Interpolation model:</label></td>
|
||||||
|
<td> <select id="merge-interpolation">
|
||||||
|
<option>Exact</option>
|
||||||
|
<option>SmoothStep</option>
|
||||||
|
<option>SmootherStep</option>
|
||||||
|
<option>SmoothestStep</option>
|
||||||
|
</select></td>
|
||||||
|
<td> <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Sigmoid function to be applied to the model share before mixing</span></i></td></tr>
|
||||||
|
</table>
|
||||||
|
<br/>
|
||||||
|
<small>Preview of variation ratios:</small><br/>
|
||||||
|
<canvas id="merge-canvas" width="400" height="400"></canvas>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="merge-buttons">
|
||||||
|
<button id="merge-button" class="primaryButton">Merge models</button>
|
||||||
|
</div>
|
||||||
|
</div>`
|
||||||
|
|
||||||
|
|
||||||
|
let loraUI=`
|
||||||
|
<div class="panel-box lora-manager-grid">
|
||||||
|
<div class="lora-manager-grid-selector">
|
||||||
|
<label for="#loraModel">Select Lora:</label>
|
||||||
|
<input id="loraModel" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
|
||||||
|
</div>
|
||||||
|
<div class="lora-manager-grid-thumbnail">
|
||||||
|
<p style="height:2em;">Thumbnail:</p>
|
||||||
|
<div style="position:relative; height:256px; width:256px;background-color:#222;border-radius:1em;margin-bottom:1em;">
|
||||||
|
<i id="lora-manager-image-placeholder" class="fa-regular fa-image" style="font-size:500%;color:#555;position:absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);"></i>
|
||||||
|
<img id="lora-manager-image" class="displayNone" style="border-radius:6px;max-height:256px;max-width:256px;"/>
|
||||||
|
</div>
|
||||||
|
<div style="text-align:center;">
|
||||||
|
<button class="tertiaryButton" id="lora-manager-upload-button"><i class="fa-solid fa-upload"></i> Upload new thumbnail</button>
|
||||||
|
<input id="lora-manager-upload-input" name="lora-manager-upload-input" type="file" class="displayNone">
|
||||||
|
<!-- button class="tertiaryButton"><i class="fa-solid fa-trash-can"></i> Remove</button -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="lora-manager-grid-keywords">
|
||||||
|
<p style="height:2em;">Keywords:
|
||||||
|
<span style="float:right;margin-bottom:4px;"><button id="lora-keyword-from-civitai" class="tertiaryButton smallButton">Import from Civitai</button></span></p>
|
||||||
|
<textarea style="width:100%;resize:vertical;" id="lora-manager-keywords" placeholder="Put LORA specific keywords here..."></textarea>
|
||||||
|
<p style="color:var(--small-label-color);">
|
||||||
|
<b>LORA model keywords</b> can be used via the <code>+ Embeddings</code> button. They get added to the embedding
|
||||||
|
keyword menu when the LORA has been selected in the image settings.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="lora-manager-grid-notes">
|
||||||
|
<p style="height:2em;">Notes:</p>
|
||||||
|
<textarea style="width:100%;resize:vertical;" id="lora-manager-notes" placeholder="Place for things you want to remember..."></textarea>
|
||||||
|
<p id="civitai-section" class="displayNone">
|
||||||
|
<b>Civitai model page:</b>
|
||||||
|
<a id="civitai-model-page" target="_blank"></a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>`
|
||||||
|
|
||||||
|
let tabHTML=`
|
||||||
|
<div id="model-tool-tab-bar" class="tab-container tab-centered">
|
||||||
|
<span id="tab-model-loraUI" class="tab active">
|
||||||
|
<span><i class="fa-solid fa-key"></i> Lora Keywords</small></span>
|
||||||
|
</span>
|
||||||
|
<span id="tab-model-mergeUI" class="tab">
|
||||||
|
<span><i class="fa-solid fa-code-merge"></i> Merge Models</small></span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div id="model-tool-tab-content" class="panel-box">
|
||||||
|
<div id="tab-content-model-loraUI" class="tab-content active">
|
||||||
|
<div class="tab-content-inner">
|
||||||
|
${loraUI}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="tab-content-model-mergeUI" class="tab-content">
|
||||||
|
<div class="tab-content-inner">
|
||||||
|
${mergeUI}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>`
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////// Function section
|
||||||
|
function smoothstep(x) {
|
||||||
|
return x * x * (3 - 2 * x)
|
||||||
|
}
|
||||||
|
|
||||||
|
function smootherstep(x) {
|
||||||
|
return x * x * x * (x * (x * 6 - 15) + 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
function smootheststep(x) {
|
||||||
|
let y = -20 * Math.pow(x, 7)
|
||||||
|
y += 70 * Math.pow(x, 6)
|
||||||
|
y -= 84 * Math.pow(x, 5)
|
||||||
|
y += 35 * Math.pow(x, 4)
|
||||||
|
return y
|
||||||
|
}
|
||||||
|
function getCurrentTime() {
|
||||||
|
const now = new Date()
|
||||||
|
let hours = now.getHours()
|
||||||
|
let minutes = now.getMinutes()
|
||||||
|
let seconds = now.getSeconds()
|
||||||
|
|
||||||
|
hours = hours < 10 ? `0${hours}` : hours
|
||||||
|
minutes = minutes < 10 ? `0${minutes}` : minutes
|
||||||
|
seconds = seconds < 10 ? `0${seconds}` : seconds
|
||||||
|
|
||||||
|
return `${hours}:${minutes}:${seconds}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function addLogMessage(message) {
|
||||||
|
const logContainer = document.getElementById("merge-log")
|
||||||
|
logContainer.innerHTML += `<i>${getCurrentTime()}</i> ${message}<br>`
|
||||||
|
|
||||||
|
// Scroll to the bottom of the log
|
||||||
|
logContainer.scrollTop = logContainer.scrollHeight
|
||||||
|
|
||||||
|
document.querySelector("#merge-log-container").style.display = "block"
|
||||||
|
}
|
||||||
|
|
||||||
|
function addLogSeparator() {
|
||||||
|
const logContainer = document.getElementById("merge-log")
|
||||||
|
logContainer.innerHTML += "<hr>"
|
||||||
|
|
||||||
|
logContainer.scrollTop = logContainer.scrollHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawDiagram(fn) {
|
||||||
|
const SIZE = 300
|
||||||
|
const canvas = document.getElementById("merge-canvas")
|
||||||
|
canvas.height = canvas.width = SIZE
|
||||||
|
const ctx = canvas.getContext("2d")
|
||||||
|
|
||||||
|
// Draw coordinate system
|
||||||
|
ctx.scale(1, -1)
|
||||||
|
ctx.translate(0, -canvas.height)
|
||||||
|
ctx.lineWidth = 1
|
||||||
|
ctx.beginPath()
|
||||||
|
|
||||||
|
ctx.strokeStyle = "white"
|
||||||
|
ctx.moveTo(0, 0)
|
||||||
|
ctx.lineTo(0, SIZE)
|
||||||
|
ctx.lineTo(SIZE, SIZE)
|
||||||
|
ctx.lineTo(SIZE, 0)
|
||||||
|
ctx.lineTo(0, 0)
|
||||||
|
ctx.lineTo(SIZE, SIZE)
|
||||||
|
ctx.stroke()
|
||||||
|
ctx.beginPath()
|
||||||
|
ctx.setLineDash([1, 2])
|
||||||
|
const n = SIZE / 10
|
||||||
|
for (let i = n; i < SIZE; i += n) {
|
||||||
|
ctx.moveTo(0, i)
|
||||||
|
ctx.lineTo(SIZE, i)
|
||||||
|
ctx.moveTo(i, 0)
|
||||||
|
ctx.lineTo(i, SIZE)
|
||||||
|
}
|
||||||
|
ctx.stroke()
|
||||||
|
ctx.beginPath()
|
||||||
|
ctx.setLineDash([])
|
||||||
|
ctx.beginPath()
|
||||||
|
ctx.strokeStyle = "black"
|
||||||
|
ctx.lineWidth = 3
|
||||||
|
// Plot function
|
||||||
|
const numSamples = 20
|
||||||
|
for (let i = 0; i <= numSamples; i++) {
|
||||||
|
const x = i / numSamples
|
||||||
|
const y = fn(x)
|
||||||
|
|
||||||
|
const canvasX = x * SIZE
|
||||||
|
const canvasY = y * SIZE
|
||||||
|
|
||||||
|
if (i === 0) {
|
||||||
|
ctx.moveTo(canvasX, canvasY)
|
||||||
|
} else {
|
||||||
|
ctx.lineTo(canvasX, canvasY)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx.stroke()
|
||||||
|
// Plot alpha values (yellow boxes)
|
||||||
|
let start = parseFloat(document.querySelector("#merge-start").value)
|
||||||
|
let step = parseFloat(document.querySelector("#merge-step").value)
|
||||||
|
let iterations = document.querySelector("#merge-count").value >> 0
|
||||||
|
ctx.beginPath()
|
||||||
|
ctx.fillStyle = "yellow"
|
||||||
|
for (let i = 0; i < iterations; i++) {
|
||||||
|
const alpha = (start + i * step) / 100
|
||||||
|
const x = alpha * SIZE
|
||||||
|
const y = fn(alpha) * SIZE
|
||||||
|
if (x <= SIZE) {
|
||||||
|
ctx.rect(x - 3, y - 3, 6, 6)
|
||||||
|
ctx.fill()
|
||||||
|
} else {
|
||||||
|
ctx.strokeStyle = "red"
|
||||||
|
ctx.moveTo(0, 0)
|
||||||
|
ctx.lineTo(0, SIZE)
|
||||||
|
ctx.lineTo(SIZE, SIZE)
|
||||||
|
ctx.lineTo(SIZE, 0)
|
||||||
|
ctx.lineTo(0, 0)
|
||||||
|
ctx.lineTo(SIZE, SIZE)
|
||||||
|
ctx.stroke()
|
||||||
|
addLogMessage("<i>Warning: maximum ratio is ≥ 100%</i>")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateChart() {
|
||||||
|
let fn = (x) => x
|
||||||
|
switch (document.querySelector("#merge-interpolation").value) {
|
||||||
|
case "SmoothStep":
|
||||||
|
fn = smoothstep
|
||||||
|
break
|
||||||
|
case "SmootherStep":
|
||||||
|
fn = smootherstep
|
||||||
|
break
|
||||||
|
case "SmoothestStep":
|
||||||
|
fn = smootheststep
|
||||||
|
break
|
||||||
|
}
|
||||||
|
drawDiagram(fn)
|
||||||
|
}
|
||||||
|
|
||||||
|
function initMergeUI() {
|
||||||
|
const tabSettingsSingle = document.querySelector("#tab-merge-opts-single")
|
||||||
|
const tabSettingsBatch = document.querySelector("#tab-merge-opts-batch")
|
||||||
|
linkTabContents(tabSettingsSingle)
|
||||||
|
linkTabContents(tabSettingsBatch)
|
||||||
|
|
||||||
|
let mergeModelAField = new ModelDropdown(document.querySelector("#mergeModelA"), "stable-diffusion")
|
||||||
|
let mergeModelBField = new ModelDropdown(document.querySelector("#mergeModelB"), "stable-diffusion")
|
||||||
|
updateChart()
|
||||||
|
|
||||||
|
// slider
|
||||||
|
const singleMergeRatioField = document.querySelector("#single-merge-ratio")
|
||||||
|
const singleMergeRatioSlider = document.querySelector("#single-merge-ratio-slider")
|
||||||
|
|
||||||
|
function updateSingleMergeRatio() {
|
||||||
|
singleMergeRatioField.value = singleMergeRatioSlider.value / 10
|
||||||
|
singleMergeRatioField.dispatchEvent(new Event("change"))
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateSingleMergeRatioSlider() {
|
||||||
|
if (singleMergeRatioField.value < 0) {
|
||||||
|
singleMergeRatioField.value = 0
|
||||||
|
} else if (singleMergeRatioField.value > 100) {
|
||||||
|
singleMergeRatioField.value = 100
|
||||||
|
}
|
||||||
|
|
||||||
|
singleMergeRatioSlider.value = singleMergeRatioField.value * 10
|
||||||
|
singleMergeRatioSlider.dispatchEvent(new Event("change"))
|
||||||
|
}
|
||||||
|
|
||||||
|
singleMergeRatioSlider.addEventListener("input", updateSingleMergeRatio)
|
||||||
|
singleMergeRatioField.addEventListener("input", updateSingleMergeRatioSlider)
|
||||||
|
updateSingleMergeRatio()
|
||||||
|
|
||||||
|
document.querySelector(".merge-config").addEventListener("change", updateChart)
|
||||||
|
|
||||||
|
document.querySelector("#merge-button").addEventListener("click", async function(e) {
|
||||||
|
// Build request template
|
||||||
|
let model0 = mergeModelAField.value
|
||||||
|
let model1 = mergeModelBField.value
|
||||||
|
let request = { model0: model0, model1: model1 }
|
||||||
|
request["use_fp16"] = document.querySelector("#merge-fp").value == "fp16"
|
||||||
|
let iterations = document.querySelector("#merge-count").value >> 0
|
||||||
|
let start = parseFloat(document.querySelector("#merge-start").value)
|
||||||
|
let step = parseFloat(document.querySelector("#merge-step").value)
|
||||||
|
|
||||||
|
if (isTabActive(tabSettingsSingle)) {
|
||||||
|
start = parseFloat(singleMergeRatioField.value)
|
||||||
|
step = 0
|
||||||
|
iterations = 1
|
||||||
|
addLogMessage(`merge ratio = ${start}%`)
|
||||||
|
} else {
|
||||||
|
addLogMessage(`start = ${start}%`)
|
||||||
|
addLogMessage(`step = ${step}%`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start + (iterations - 1) * step >= 100) {
|
||||||
|
addLogMessage("<i>Aborting: maximum ratio is ≥ 100%</i>")
|
||||||
|
addLogMessage("Reduce the number of variations or the step size")
|
||||||
|
addLogSeparator()
|
||||||
|
document.querySelector("#merge-count").focus()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.querySelector("#merge-filename").value == "") {
|
||||||
|
addLogMessage("<i>Aborting: No output file name specified</i>")
|
||||||
|
addLogSeparator()
|
||||||
|
document.querySelector("#merge-filename").focus()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable merge button
|
||||||
|
e.target.disabled = true
|
||||||
|
e.target.classList.add("disabled")
|
||||||
|
let cursor = $("body").css("cursor")
|
||||||
|
let label = document.querySelector("#merge-button").innerHTML
|
||||||
|
$("body").css("cursor", "progress")
|
||||||
|
document.querySelector("#merge-button").innerHTML = "Merging models ..."
|
||||||
|
|
||||||
|
addLogMessage("Merging models")
|
||||||
|
addLogMessage("Model A: " + model0)
|
||||||
|
addLogMessage("Model B: " + model1)
|
||||||
|
|
||||||
|
// Batch main loop
|
||||||
|
for (let i = 0; i < iterations; i++) {
|
||||||
|
let alpha = (start + i * step) / 100
|
||||||
|
|
||||||
|
if (isTabActive(tabSettingsBatch)) {
|
||||||
|
switch (document.querySelector("#merge-interpolation").value) {
|
||||||
|
case "SmoothStep":
|
||||||
|
alpha = smoothstep(alpha)
|
||||||
|
break
|
||||||
|
case "SmootherStep":
|
||||||
|
alpha = smootherstep(alpha)
|
||||||
|
break
|
||||||
|
case "SmoothestStep":
|
||||||
|
alpha = smootheststep(alpha)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addLogMessage(`merging batch job ${i + 1}/${iterations}, alpha = ${alpha.toFixed(5)}...`)
|
||||||
|
|
||||||
|
request["out_path"] = document.querySelector("#merge-filename").value
|
||||||
|
request["out_path"] += "-" + alpha.toFixed(5) + "." + document.querySelector("#merge-format").value
|
||||||
|
addLogMessage(` filename: ${request["out_path"]}`)
|
||||||
|
|
||||||
|
// sdkit documentation: "ratio - the ratio of the second model. 1 means only the second model will be used."
|
||||||
|
request["ratio"] = 1-alpha
|
||||||
|
let res = await fetch("/model/merge", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify(request),
|
||||||
|
})
|
||||||
|
const data = await res.json()
|
||||||
|
addLogMessage(JSON.stringify(data))
|
||||||
|
}
|
||||||
|
addLogMessage(
|
||||||
|
"<b>Done.</b> The models have been saved to your <tt>models/stable-diffusion</tt> folder."
|
||||||
|
)
|
||||||
|
addLogSeparator()
|
||||||
|
// Re-enable merge button
|
||||||
|
$("body").css("cursor", cursor)
|
||||||
|
document.querySelector("#merge-button").innerHTML = label
|
||||||
|
e.target.disabled = false
|
||||||
|
e.target.classList.remove("disabled")
|
||||||
|
|
||||||
|
// Update model list
|
||||||
|
stableDiffusionModelField.innerHTML = ""
|
||||||
|
vaeModelField.innerHTML = ""
|
||||||
|
hypernetworkModelField.innerHTML = ""
|
||||||
|
await getModels()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const LoraUI = {
|
||||||
|
modelField: undefined,
|
||||||
|
keywordsField: undefined,
|
||||||
|
notesField: undefined,
|
||||||
|
civitaiImportBtn: undefined,
|
||||||
|
civitaiSecion: undefined,
|
||||||
|
civitaiAnchor: undefined,
|
||||||
|
image: undefined,
|
||||||
|
imagePlaceholder: undefined,
|
||||||
|
|
||||||
|
init() {
|
||||||
|
LoraUI.modelField = new ModelDropdown(document.querySelector("#loraModel"), "lora", "None")
|
||||||
|
LoraUI.keywordsField = document.querySelector("#lora-manager-keywords")
|
||||||
|
LoraUI.notesField = document.querySelector("#lora-manager-notes")
|
||||||
|
LoraUI.civitaiImportBtn = document.querySelector("#lora-keyword-from-civitai")
|
||||||
|
LoraUI.civitaiSection = document.querySelector("#civitai-section")
|
||||||
|
LoraUI.civitaiAnchor = document.querySelector("#civitai-model-page")
|
||||||
|
LoraUI.image = document.querySelector("#lora-manager-image")
|
||||||
|
LoraUI.imagePlaceholder = document.querySelector("#lora-manager-image-placeholder")
|
||||||
|
LoraUI.uploadBtn = document.querySelector("#lora-manager-upload-button")
|
||||||
|
LoraUI.uploadInput = document.querySelector("#lora-manager-upload-input")
|
||||||
|
|
||||||
|
LoraUI.modelField.addEventListener("change", LoraUI.updateFields)
|
||||||
|
LoraUI.keywordsField.addEventListener("focusout", LoraUI.saveInfos)
|
||||||
|
LoraUI.notesField.addEventListener("focusout", LoraUI.saveInfos)
|
||||||
|
LoraUI.civitaiImportBtn.addEventListener("click", LoraUI.importFromCivitai)
|
||||||
|
|
||||||
|
LoraUI.uploadBtn.addEventListener("click", (e) => LoraUI.uploadInput.click())
|
||||||
|
LoraUI.uploadInput.addEventListener("change", LoraUI.uploadLoraThumb)
|
||||||
|
|
||||||
|
document.addEventListener("saveThumb", LoraUI.updateFields)
|
||||||
|
|
||||||
|
LoraUI.updateFields()
|
||||||
|
},
|
||||||
|
|
||||||
|
uploadLoraThumb(e) {
|
||||||
|
console.log(e)
|
||||||
|
if (LoraUI.uploadInput.files.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let reader = new FileReader()
|
||||||
|
let file = LoraUI.uploadInput.files[0]
|
||||||
|
|
||||||
|
reader.addEventListener("load", (event) => {
|
||||||
|
let img = document.createElement("img")
|
||||||
|
img.src = reader.result
|
||||||
|
onUseAsThumbnailClick(
|
||||||
|
{
|
||||||
|
use_lora_model: LoraUI.modelField.value,
|
||||||
|
},
|
||||||
|
img
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
if (file) {
|
||||||
|
reader.readAsDataURL(file)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
updateFields() {
|
||||||
|
document.getElementById("civitai-section").classList.add("displayNone")
|
||||||
|
Bucket.retrieve(`modelinfo/lora/${LoraUI.modelField.value}`)
|
||||||
|
.then((info) => {
|
||||||
|
if (info == null) {
|
||||||
|
LoraUI.keywordsField.value = ""
|
||||||
|
LoraUI.notesField.value = ""
|
||||||
|
LoraUI.hideCivitaiLink()
|
||||||
|
} else {
|
||||||
|
LoraUI.keywordsField.value = info.keywords.join("\n")
|
||||||
|
LoraUI.notesField.value = info.notes
|
||||||
|
if ("civitai" in info && info["civitai"] != null) {
|
||||||
|
LoraUI.showCivitaiLink(info.civitai)
|
||||||
|
} else {
|
||||||
|
LoraUI.hideCivitaiLink()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Bucket.getImageAsDataURL(`${profileNameField.value}/lora/${LoraUI.modelField.value}.png`)
|
||||||
|
.then((data) => {
|
||||||
|
LoraUI.image.src=data
|
||||||
|
LoraUI.image.classList.remove("displayNone")
|
||||||
|
LoraUI.imagePlaceholder.classList.add("displayNone")
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
LoraUI.image.classList.add("displayNone")
|
||||||
|
LoraUI.imagePlaceholder.classList.remove("displayNone")
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
saveInfos() {
|
||||||
|
let info = {
|
||||||
|
keywords: LoraUI.keywordsField.value
|
||||||
|
.split("\n")
|
||||||
|
.filter((x) => (x != "")),
|
||||||
|
notes: LoraUI.notesField.value,
|
||||||
|
civitai: LoraUI.civitaiSection.checkVisibility() ? LoraUI.civitaiAnchor.href : null,
|
||||||
|
}
|
||||||
|
Bucket.store(`modelinfo/lora/${LoraUI.modelField.value}`, info)
|
||||||
|
},
|
||||||
|
|
||||||
|
importFromCivitai() {
|
||||||
|
document.body.style["cursor"] = "progress"
|
||||||
|
fetch("/sha256/lora/"+LoraUI.modelField.value)
|
||||||
|
.then((result) => result.json())
|
||||||
|
.then((json) => fetch("https://civitai.com/api/v1/model-versions/by-hash/" + json.digest))
|
||||||
|
.then((result) => result.json())
|
||||||
|
.then((json) => {
|
||||||
|
document.body.style["cursor"] = "default"
|
||||||
|
if (json == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ("trainedWords" in json) {
|
||||||
|
LoraUI.keywordsField.value = json["trainedWords"].join("\n")
|
||||||
|
} else {
|
||||||
|
showToast("No keyword info found.")
|
||||||
|
}
|
||||||
|
if ("modelId" in json) {
|
||||||
|
LoraUI.showCivitaiLink("https://civitai.com/models/" + json.modelId)
|
||||||
|
} else {
|
||||||
|
LoraUI.hideCivitaiLink()
|
||||||
|
}
|
||||||
|
|
||||||
|
LoraUI.saveInfos()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
showCivitaiLink(href) {
|
||||||
|
LoraUI.civitaiSection.classList.remove("displayNone")
|
||||||
|
LoraUI.civitaiAnchor.href = href
|
||||||
|
LoraUI.civitaiAnchor.innerHTML = LoraUI.civitaiAnchor.href
|
||||||
|
},
|
||||||
|
|
||||||
|
hideCivitaiLink() {
|
||||||
|
LoraUI.civitaiSection.classList.add("displayNone")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
createTab({
|
||||||
|
id: "merge",
|
||||||
|
icon: "fa-toolbox",
|
||||||
|
label: "Model tools",
|
||||||
|
css: mergeCSS,
|
||||||
|
content: tabHTML,
|
||||||
|
onOpen: ({ firstOpen }) => {
|
||||||
|
if (!firstOpen) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
initMergeUI()
|
||||||
|
LoraUI.init()
|
||||||
|
const tabMergeUI = document.querySelector("#tab-model-mergeUI")
|
||||||
|
const tabLoraUI = document.querySelector("#tab-model-loraUI")
|
||||||
|
linkTabContents(tabMergeUI)
|
||||||
|
linkTabContents(tabLoraUI)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})()
|
||||||
|
async function getLoraKeywords(model) {
|
||||||
|
return Bucket.retrieve(`modelinfo/lora/${model}`)
|
||||||
|
.then((info) => info ? info.keywords : [])
|
||||||
|
}
|
Reference in New Issue
Block a user