Compare commits

...

296 Commits

Author SHA1 Message Date
b93c624efa sdkit 1.0.142 - fix live preview for sdxl 2023-07-27 17:51:52 +05:30
d118443a94 sdkit 1.0.141 - allow sdxl vae 2023-07-27 17:34:41 +05:30
064a55f587 sdkit 1.0.140 - fix broken gfpgan and realesrgan 2023-07-27 16:50:58 +05:30
de3b43647a changelog 2023-07-27 15:38:10 +05:30
0b054b58d4 sdkit 1.0.139 - SD-XL full support, diffusers 0.19.0, compel 2.0.0 2023-07-27 15:35:43 +05:30
7b5e2b4a12 Display Test Diffusers checkbox when enabling beta (#1430)
* Display Test Diffusers checkbox when enabling beta

* remove debug
2023-07-25 07:39:30 +05:30
b408fc7cd2 sdkit 1.0.137 - Fix DPM single step solver with non-unique timesteps 2023-07-24 19:59:57 +05:30
a8ed1ebf52 sdkit 1.0.136 - unify unipc tu and tu2, don't reuse sampler instances between image generation to avoid image artifacts 2023-07-24 16:41:35 +05:30
357ab9596e formatting 2023-07-24 16:38:45 +05:30
cba1cfbbef changelog 2023-07-24 16:38:16 +05:30
c402867d45 Hide the samplers that won't be supported in the new diffusers version 2023-07-24 16:36:34 +05:30
158591bdcf changelog 2023-07-22 18:24:22 +05:30
8857249b48 sdkit 1.0.135 - fix broken inpainting models after the latest diffusers upgrade 2023-07-22 18:22:13 +05:30
c71d7ea14f Merge branch 'beta' of github.com:cmdr2/stable-diffusion-ui into beta 2023-07-22 15:10:44 +05:30
721ab8a0c7 Silly error, don't delete a key if it doesn't exist 2023-07-22 15:10:33 +05:30
d0d9c185f1 Merge pull request #1428 from ogmaresca/fix-synatax-warning-on-startup
Fix SyntaxWarning on startup
2023-07-22 12:10:53 +05:30
ade0912ba1 Fix for endlessly nesting config.yaml 2023-07-22 11:47:48 +05:30
192520eafe Fix SyntaxWarning on startup 2023-07-21 21:15:21 -04:00
9fd69b2519 Merge pull request #1421 from JeLuF/contrast
Improve embedding readability
2023-07-18 22:59:45 +05:30
636c3e5c02 restore hover 2023-07-18 18:39:49 +02:00
0dbc195770 Improve embedding readability 2023-07-18 18:37:14 +02:00
d03f16cbd3 Merge pull request #1416 from JeLuF/mvemb
Move embeddings and modifiers buttons
2023-07-18 09:11:26 +05:30
eac0d49880 Merge branch 'beta' into mvemb 2023-07-18 09:11:19 +05:30
0ad97b8aa5 Merge pull request #1419 from JeLuF/embcollapse
Collapsibles for the embeddings dialog
2023-07-18 09:09:32 +05:30
8ce5ebe885 Merge pull request #1420 from JeLuF/errortext
Help texts for common errors
2023-07-18 09:08:42 +05:30
fa2a929796 Help texts for common errors
- Using an Embedding on 'Low'
- Using LORAs and models with mismatching versions
2023-07-18 00:41:47 +02:00
7debd2cd97 Collapsibles for the embeddings dialog
Harmonization with the modifiers dialog
2023-07-18 00:08:38 +02:00
ca59866d52 sdkit 1.0.134 - don't prevent a lycoris from loading, use it partially, and warn the user in the logs 2023-07-17 23:30:36 +05:30
4832c67167 sdkit 1.0.133 - some more keys for lora 2023-07-17 21:35:06 +05:30
6ec7b78d96 sdkit 1.0.132 - fix for some loras - #1417 2023-07-17 20:44:30 +05:30
14c1d17632 Move the remove button to the left side of the lora, to increase the space for the model name 2023-07-16 15:46:24 +05:30
5bd98d4aa0 Revert "Fix for rabbit hole"
This reverts commit a7b427c5ff.
2023-07-16 15:17:46 +05:30
a7b427c5ff Fix for rabbit hole 2023-07-16 14:51:50 +05:30
de36489444 Merge beta 2023-07-16 11:16:58 +02:00
de6fec5fd7 Move embeddings and modifiers buttons 2023-07-16 11:00:45 +02:00
47b157c24a wording 2023-07-16 13:28:54 +05:30
e358a72925 Merge pull request #1397 from ogmaresca/restart-needed
Add Restart needed to diffusers-only fields if you enable diffusers then refresh without restarting EasyDiffusion
2023-07-16 13:23:04 +05:30
6201ed30ff Merge pull request #1414 from ogmaresca/multi-lora-text-metadata
Format LoRA model/strength as comma separated string in text metadata
2023-07-16 13:20:09 +05:30
ace53d211f changelog 2023-07-16 12:59:18 +05:30
812fc20c39 sdkit 1.0.131 - Fix loras ignoring several layers 2023-07-16 12:58:01 +05:30
08ff52235e Merge remote-tracking branch 'origin/beta' into restart-needed 2023-07-15 17:17:57 -04:00
66624f4011 sdkit 1.0.130 - 2x multiplier for lora 2023-07-16 02:31:01 +05:30
b58b7660ab sdkit 1.0.129 - 1.6x multiplier for lora 2023-07-16 02:27:32 +05:30
ef1e42dd7b Add and remove buttons for arbitrary number of LoRA models 2023-07-16 02:12:42 +05:30
6f065918e9 sdkit 1.0.128 - don't fail if local alpha is different in loras 2023-07-16 01:12:49 +05:30
0f7f52fbc2 sdkit 1.0.127 - tweak 1.5x multiplier for lora 2023-07-15 23:28:12 +05:30
721f826376 sdkit 1.0.126 - 1.5x multiplier for lora 2023-07-15 23:18:03 +05:30
74e7c35885 Remove the buggy slider hover hide, prevents text selection from working correctly 2023-07-15 23:15:39 +05:30
d61bc5958e Remove leading space 2023-07-15 13:24:14 -04:00
3461bb669d Merge remote-tracking branch 'origin/beta' into restart-needed 2023-07-15 13:22:41 -04:00
8151bc57b1 Format LoRA model/strength as comma separated string in text metadata 2023-07-15 12:57:37 -04:00
0d610c5393 Remove the +/- 2 limit on lora strengths 2023-07-15 21:48:51 +05:30
7c358c2842 changelog 2023-07-15 19:34:32 +05:30
f5b8044bad UI changes for multiple LoRA files 2023-07-15 19:33:49 +05:30
92ffbb5ed8 sdkit 1.0.125 - remove the 2x multiplier on lora 2023-07-15 19:27:18 +05:30
0cc2d26e97 sdkit 1.0.124 - make loras twice as sensitive to alpha 2023-07-15 18:52:14 +05:30
bb5487efb8 sdkit 1.0.123 - fix for missing network alpha or rank in a lora 2023-07-15 18:38:42 +05:30
0139111d49 formatting 2023-07-15 16:35:48 +05:30
fe6991c703 Dark theme for input spinner buttons 2023-07-15 16:28:31 +05:30
17c9d9b447 pull-to-refresh on android needs this field in the body 2023-07-15 13:01:08 +05:30
318136f4eb Merge pull request #1413 from cmdrgrunt/beta
Update main.css to fix over scroll behavior on mobile devices
2023-07-15 12:49:38 +05:30
5344cb9723 Update main.css to fix over scroll behavior on mobile devices 2023-07-15 03:03:28 -04:00
959c1a196e Allow the UI to send (and resolve) multiple model paths 2023-07-15 12:09:20 +05:30
c5a06eedbc Merge pull request #1401 from rbertus2000/dpmpp_sde
enable DPM++ SDE, DPM++ 2s a and add DPM++ 2m SDE
2023-07-15 11:11:28 +05:30
025ee49680 Merge branch 'beta' of github.com:cmdr2/stable-diffusion-ui into beta 2023-07-15 10:55:50 +05:30
935c75bcab sdkit 1.0.122 - multiple lora file support; more SDE samplers; diffusers 0.18.2 upgrade to fix broken SD 2 checkpoint loading 2023-07-15 10:55:09 +05:30
7b632fe441 dpmpp_2s_a 2023-07-13 18:25:59 +02:00
1e4cca54b6 Merge pull request #1405 from JeLuF/bindip
Add Bind IP option
2023-07-13 14:51:20 +05:30
4b89c3e7a5 fix typo 2023-07-13 10:14:46 +02:00
837ad5b68c Merge pull request #1396 from JeLuF/dlgclose
Fix dialog closing when interacting with <select> child
2023-07-13 13:00:07 +05:30
3980625be6 Merge pull request #1398 from ogmaresca/save-embeddings-to-metadata
Add embeddings to metadata
2023-07-13 12:57:56 +05:30
2242a76fed Merge pull request #1403 from JeLuF/lowwarning
Warn about low vram profile when using embeddings
2023-07-13 12:40:19 +05:30
0661b9ba5b Merge pull request #1406 from JeLuF/relocate
Fix uvicorn issues after reloacting install dir
2023-07-13 12:17:55 +05:30
fa457ad476 Fix uvicorn issues after reloacting install dir
Fixes https://discord.com/channels/1014774730907209781/1014774732018683926/1128441748637626499
2023-07-11 23:56:03 +02:00
b005332840 Add Bind IP option 2023-07-11 23:03:11 +02:00
ab52a95e45 Warn about low vram profile when using embeddings 2023-07-11 09:44:45 +02:00
ed59402e48 enable DPM++ SDE and add DPM++ 2m SDE 2023-07-10 22:51:46 +02:00
5e0839531e sdkit 1.0.121 - fix live preview, wasn't decoding the vae 2023-07-10 13:27:48 +05:30
1c7acf7bcf sdkit 1.0.120 - pick the correct AMD gpu if an integrated GPU exists at device id 0 2023-07-10 13:06:56 +05:30
d143e85760 Use the local profile folder for dev console 2023-07-10 12:37:49 +05:30
2612c274d3 sdkit 1.0.119 - another fix for live preview 2023-07-10 10:50:10 +05:30
764ad1b8db sdkit 1.0.118 - fix live preview in img2img 2023-07-10 10:40:00 +05:30
b1dcfbd017 sdkit 1.0.117 - fix directml/tensorrt for diffusers 0.18.1 2023-07-10 09:56:28 +05:30
e43bf2b93a Revert the speed up from starting the browser early. Not sure why the fastapi server isn't ready to serve static html by this point, will need to investigate later 2023-07-10 09:01:48 +05:30
ab75527df2 Formatting 2023-07-09 22:14:07 -04:00
b5a661eec8 Add embeddings to metadata 2023-07-09 22:13:20 -04:00
df655eb2d7 Rename method 2023-07-09 16:58:51 -04:00
db55064bb2 Add Restart needed to diffusers-only fields if you enable diffusers then refresh without restarting EasyDiffusion 2023-07-09 16:54:25 -04:00
b4c3c4c650 Fix dialog closing when interacting with <select> child
https://discord.com/channels/1014774730907209781/1021695193499582494/1127653577360425042
'The.QCC: Embedding window. Switching between at end and at cursor closes the Embedding window'
2023-07-09 21:18:07 +02:00
6dfabb692d changelog 2023-07-09 22:34:42 +05:30
09f747a68e Merge pull request #1362 from JeLuF/textualinv
Basic embeddings support
2023-07-09 22:03:22 +05:30
6d6a07f830 2.5.43 2023-07-09 21:09:37 +05:30
4313e7e701 changelog for 2.5.42 2023-07-09 21:06:47 +05:30
2b9f5eb627 sdkit 1.0.116 - diffusers 0.18.1 upgrade; compel upgrade; embeddings support; AMD-on-Windows and TensorRT acceleration - preliminary support; faster sdkit import time to improve startup time of ED's UI 2023-07-09 20:45:11 +05:30
d4c1155ac3 Missing return 2023-07-09 20:32:55 +05:30
37e8158175 Improve responsiveness of UI startup by not waiting for render threads to start up before showing the UI. Errors while starting the render thread will be logged anyway, so there's no need to block the main thread for this 2023-07-08 23:28:47 +05:30
c6c025353a Merge branch 'beta' into textualinv 2023-07-07 22:50:12 +02:00
21946ff824 Update ui/media/js/main.js
Co-authored-by: rbertus2000 <91765399+rbertus2000@users.noreply.github.com>
2023-07-07 22:49:21 +02:00
2bd1cceb24 Potential fix for image modifiers plugin 2023-07-04 15:36:40 +05:30
82561268ea Fix for broken Rabbit Hole plugin 2023-07-04 14:59:50 +05:30
99ab2d2a81 Merge pull request #1387 from JeLuF/picker
Keyboard shortcuts for the image editor
2023-07-04 14:34:52 +05:30
f9ff184b89 Keyboard shortcuts for the image editor 2023-07-02 20:35:10 +02:00
0118c7c808 Keyboard shortcuts for the image editor 2023-07-02 20:31:38 +02:00
d17ee88ced Merge branch 'beta' into picker 2023-07-02 18:40:20 +02:00
84574367b3 Hotkeys for img editor 2023-07-02 18:38:16 +02:00
afdbcf267b Merge pull request #1381 from JeLuF/themefix
Rollback --backdrop-color var, to fix themes dialog
2023-07-01 09:06:29 +05:30
4dd254263f Merge pull request #1382 from JeLuF/remoteclflr
Don't show copy button without clipboard access
2023-07-01 09:06:05 +05:30
2f9b492f5b Don't show copy button without clipboard access 2023-07-01 00:15:18 +02:00
0d9d01c9f5 backdrop and drag handlers 2023-06-30 23:28:24 +02:00
36c4c0c8d7 Rollback --backdrop-color var, to fix themes dialog 2023-06-30 21:44:35 +02:00
c6d6446606 Merge branch 'beta' into textualinv 2023-06-30 20:21:49 +02:00
fa6716345d hide embeddings UI if not test_diffusers 2023-06-30 20:17:46 +02:00
2dfa482b24 Update get_config.py 2023-06-30 18:33:16 +05:30
4959e52559 Remove the old config.json file 2023-06-30 16:51:18 +05:30
95334715ab Don't use the same filename, will confuse our code later 2023-06-30 16:44:07 +05:30
5511d1090f Put a redirection notice at the old config.json location 2023-06-30 16:40:57 +05:30
9d319fd279 Merge branch 'beta' of github.com:cmdr2/stable-diffusion-ui into beta 2023-06-30 16:36:35 +05:30
d023fd07b0 Move config.yaml to the root folder of ED 2023-06-30 16:36:24 +05:30
311ade1281 Merge pull request #1376 from JeLuF/dlg2
Download dialog redesign, moveable dialogs, code cleanup
2023-06-30 16:02:25 +05:30
5a643c383b Verify a newly written config file before setting that as the actual config file. Helps prevent a corrupted write from overwriting the config file 2023-06-30 13:22:23 +05:30
8618708fd1 Try closing the config file explicitly, to avoid null byte errors 2023-06-30 12:39:36 +05:30
f09c50ec90 Merge branch 'beta' into textualinv 2023-06-30 09:01:34 +02:00
75c57f646d embedding support popup 2023-06-30 08:41:15 +02:00
45f99ab48a Include comments in config.yaml even when converting from config.json 2023-06-30 11:53:38 +05:30
26042b1e26 Don't use YAML as a singleton, seems to be stateful; Use ruamel in get_config for consistency 2023-06-30 10:37:25 +05:30
ec353ba90d Don't create thumbnail if preview is undefined (not just null) 2023-06-30 09:45:18 +05:30
084ef5a28c Formatting 2023-06-30 09:44:44 +05:30
81a24249e6 Force move the old config.json to .bak, even if one exists. This is required for recovering from inconsistent states 2023-06-30 09:44:23 +05:30
6df9a38a65 Remove debug output 2023-06-28 22:17:09 +02:00
4c52dcb8a0 Make dialogs draggable 2023-06-28 22:12:32 +02:00
7306ac0168 Merge branch 'beta' into textualinv 2023-06-28 19:55:25 +02:00
9c34d42a50 Download dialog redesign, code cleanup 2023-06-28 19:11:37 +02:00
fdc6a4d94b Shrink the vertical height of modifiers subheader, unnecessary space 2023-06-28 16:52:36 +05:30
cc475f26f4 sdkit 1.0.115 - check for upcasting precision only if using half-precision (e.g. skip for cpu) 2023-06-28 11:31:52 +05:30
f252ca75e9 temp rollback 2023-06-28 10:52:54 +05:30
05b608831c sdkit 1.0.113 - check for upcasting precision only if using half-precision (e.g. skip for cpu) 2023-06-28 10:33:41 +05:30
7adf25ef97 Fix #1372 - disable pull-to-refresh on mobile browsers 2023-06-28 09:52:14 +05:30
837069648f Merge branch 'beta' of github.com:cmdr2/stable-diffusion-ui into beta 2023-06-28 09:36:48 +05:30
1286e2d03c Allow dropping images from folders 2023-06-28 09:36:37 +05:30
c425811b45 Merge pull request #1370 from AssassinJN/patch-6
change event trigger to mousedown
2023-06-27 19:27:28 +05:30
4b3de4c656 change event trigger to mousedown
This will fix an issue where the box is accidentally closed when attempting to quickly select text in the textarea.
2023-06-27 09:29:58 -04:00
d6b996b28e Move thumbnail settings to the Image Modifiers panel, instead of the settings 2023-06-27 17:50:41 +05:30
3081a20bd0 Fix panel header for Rabbit Hole plugin 2023-06-27 17:37:30 +05:30
fda30b1ecd Use Patrice's Image Editor improvements plugin as a core plugin 2023-06-27 17:26:07 +05:30
74aa1a9db1 Image Modifiers popup shouldn't break the scrolling panes plugin 2023-06-27 17:06:49 +05:30
1f9a429a62 Fix Image Settings header margin 2023-06-27 16:13:07 +05:30
dbf9482303 Merge pull request #1368 from JeLuF/modifdlg
Modifier settings dialog improvements
2023-06-27 16:08:18 +05:30
845e6d1528 Merge pull request #1369 from JeLuF/css
move (some) hardcoded colors to variables
2023-06-27 16:05:32 +05:30
2e4807312a move (some) hardcoded colors to variables 2023-06-27 00:31:48 +02:00
4bbb4b5e1e Modifier settings dialog improvements
- Use <dialog> for the Modifier settings (solves z-order issues)
- Harmonize dialog design. Use similar header style for modifier settings and tiled image download dialogs
2023-06-27 00:00:27 +02:00
3a7281df3c Fix for prompt number calculation with empty or single-element set 2023-06-26 20:36:59 +05:30
800f275e91 Fix for plugin: make-image-button-always-visible.plugin.js 2023-06-26 20:30:57 +05:30
ae930f3993 note about modifiers placement 2023-06-26 20:23:27 +05:30
417daa264f Temporarily comment out the plugin manager code, which seems to be conflicting with the plugin manager plugin 2023-06-26 20:07:15 +05:30
19b42c91c0 temporarily disable plugins tab 2023-06-26 17:17:28 +05:30
aa53b868fc Temporarily disable plugins manager until the runtime error is figured out 2023-06-26 17:08:46 +05:30
ab0d08b7a3 debug log 2023-06-26 17:08:28 +05:30
de0b082810 Merge pull request #890 from JeLuF/yaml
Use yaml instead of json for the config file
2023-06-26 17:01:28 +05:30
913550295c Install ruamel.yaml 0.17.21 2023-06-26 17:01:01 +05:30
bce0373b11 Merge branch 'beta' of github.com:cmdr2/stable-diffusion-ui into beta 2023-06-26 16:58:17 +05:30
95768cdb05 Bump version 2023-06-26 16:57:51 +05:30
af7073d9b6 Merge branch 'beta' into yaml 2023-06-26 16:57:35 +05:30
d56c23be9a Merge pull request #1301 from patriceac/plugin-manager
Plugin manager
2023-06-26 16:43:24 +05:30
5867baea35 Merge branch 'beta' into plugin-manager 2023-06-26 16:41:43 +05:30
f6bd05bcf1 Link to ED-hosted community repo, to provide a stable and continuous home incase a community owner is no longer active 2023-06-26 16:35:31 +05:30
13056f87d3 Merge pull request #1342 from ManInDark/beta
Prevent UI freeze caused by intensive prompts
2023-06-26 16:25:18 +05:30
a72bae9cd2 Merge pull request #1355 from Hakorr/beta
Image Modifier UI Overhaul
2023-06-26 16:23:20 +05:30
df416a6a17 link 2023-06-26 16:11:10 +05:30
672571a36c Merge pull request #1191 from JeLuF/splash
Add splash screen for testDiffusers users
2023-06-26 16:07:58 +05:30
848ff35e85 Update index.html 2023-06-26 16:04:18 +05:30
f05b815c5d Merge branch 'beta' into splash 2023-06-26 16:02:29 +05:30
e1e2a2a249 Update index.html 2023-06-26 16:00:55 +05:30
817436b65c Merge pull request #1361 from JeLuF/patch-28
Run dev console in ED directory
2023-06-26 15:53:38 +05:30
c9a5ad9c3a Update Developer Console.cmd 2023-06-26 12:20:34 +02:00
c480b615ce Merge pull request #1363 from JeLuF/comspec
Show COMSPEC variable in logs
2023-06-26 15:41:13 +05:30
881fdc58ec debug logging 2023-06-26 15:34:25 +05:30
569431dc72 Merge pull request #1357 from JeLuF/savesettings
Fix saving of network settings
2023-06-26 15:22:35 +05:30
c74be07c33 sdkit 1.0.112 - fix broken inpainting in low vram mode 2023-06-24 15:46:03 +05:30
887d871d26 changelog 2023-06-24 15:22:09 +05:30
4dd1a46efa sdkit 1.0.111 - don't apply a negative lora when testing a newly loaded SD model 2023-06-24 15:21:13 +05:30
eb301a67d4 changelog 2023-06-23 21:43:36 +05:30
d9bddffc42 sdkit 1.0.110 - don't offload latent upscaler to the CPU if not running on a GPU 2023-06-23 21:42:11 +05:30
a5898aaf3b Show COMSPEC variable in logs 2023-06-22 23:54:45 +02:00
3dc62a8857 Basic embeddings support 2023-06-22 23:48:55 +02:00
7811929b5b Run dev console in ED directory 2023-06-22 01:15:07 +02:00
a43bd2fd3b changelog 2023-06-20 10:50:28 +05:30
aac9acf068 sdkit 1.0.109 - auto-set fp32 attention precision in diffusers if required 2023-06-20 10:49:34 +05:30
65bb01892f remove old code 2023-06-19 21:58:58 +02:00
5b35c47360 Fix saving of network settings 2023-06-19 21:50:56 +02:00
4bf78521ce changelog 2023-06-19 19:58:59 +05:30
2a5b3040e2 sdkit 1.0.108 - potential fix for multi-gpu bug while rendering - the sampler instances weren't thread-local 2023-06-19 19:58:17 +05:30
ac4651c241 Image Modifier UI Overhaul
Additionally also fixed body overflowing when on mobile. This is unrelated to the overhaul.
2023-06-19 17:24:31 +03:00
2c4cd21c8f sdkit 1.0.107 - fix a bug where low VRAM usage mode wasn't working with multiple GPUs 2023-06-16 16:46:32 +05:30
31a7e178a1 Applied changes suggested by @cmdr2 2023-06-14 16:59:30 +02:00
ed59972b03 Changed all links as mentioned in #1339 2023-06-14 11:57:06 +02:00
6ae4314b79 Incorporated proposal by @JeLuF in #1324 2023-06-13 16:09:54 +02:00
5e07432ae9 Merge branch 'easydiffusion:beta' into beta 2023-06-13 15:34:26 +02:00
41d8847592 changelog 2023-06-13 13:39:58 +05:30
eb96bfe8a4 sdkit 1.0.106 - fix errors with multi-gpu in low vram mode 2023-06-13 13:39:23 +05:30
3037cceab3 Merge branch 'beta' of github.com:cmdr2/stable-diffusion-ui into beta 2023-06-12 17:22:29 +05:30
324ffdefba changelog 2023-06-12 16:58:11 +05:30
9a81d17d33 Fix for multi-gpu bug in codeformer 2023-06-12 16:57:36 +05:30
3e34cdc884 Added sets to the readme 2023-06-12 13:25:12 +02:00
e213f6cb95 Added calculation as to how many images will be generated with given prompts. 2023-06-12 12:50:39 +02:00
0ba9f0549e Merge pull request #1341 from JeLuF/beta
Set PYTHONNOUSERSITE=y in dev console
2023-06-12 14:48:00 +05:30
f83af28e42 Set PYTHONNOUSERSITE=y in dev console
Make behaviour consistent with on_env_start.sh
2023-06-11 21:12:22 +02:00
924fee394a A better way to make gfpgan show up at the top 2023-06-08 16:09:11 +05:30
e349fb1a23 fix 2023-06-08 15:55:36 +05:30
4f799a2bf0 Use gfpgan as the default model for face restoration 2023-06-08 15:52:41 +05:30
5398765fd7 Tighten the image editor (to reduce unnecessary empty space and reduce mouse travel) - Thanks @fdwr - #1307 2023-06-08 15:21:16 +05:30
48edce72a9 Log the version numbers of only a few important modules 2023-06-07 16:38:15 +05:30
267c7b85ea Use only realesrgan_x4 (not anime) for upscaling in codeformer 2023-06-07 16:37:44 +05:30
e23f66a697 Fix #1333 - listen_port isn't always present in the config file 2023-06-07 15:45:21 +05:30
9a0031c47b Don't copy check_models.py, it doesn't exist anymore 2023-06-07 15:21:16 +05:30
0d8e73b206 sdkit 1.0.104 - Not all pipelines have vae slicing 2023-06-07 15:10:57 +05:30
9486c03a89 Don't use the default SD model (if the desired model was not found), unless the UI is starting up 2023-06-06 17:10:38 +05:30
c09512bf12 dead code 2023-06-06 16:57:25 +05:30
05c2de9450 Fail with an error if the desired model (non-Stable Diffusion) wasn't found 2023-06-06 16:56:37 +05:30
6ae5cb28cf Set the default codeformer strength to 0.5 2023-06-06 16:37:17 +05:30
cf6c1add1d Merge branch 'beta' of github.com:cmdr2/stable-diffusion-ui into beta 2023-06-06 16:24:42 +05:30
d0184a1598 Allow changing the strength of the codeformer model (1 - fidelity); Improve the styling of the sub-settings 2023-06-06 16:16:21 +05:30
79d6ab9915 Update CHANGES.md 2023-06-06 15:22:27 +05:30
047390873c changelog; show labels next to the lora strength slider 2023-06-05 16:53:18 +05:30
4b36ca75cb Merge pull request #1313 from JeLuF/cloudflared
Share ED via Cloudflare's ArgoTunnel
2023-06-05 16:20:40 +05:30
f7c52b700e Merge pull request #1328 from ogmaresca/negative-lora-strength
Allow LoRA strengths between -2 and 2
2023-06-05 16:18:28 +05:30
c81d98ad0f Merge pull request #1325 from JeLuF/tildl
Tiled image download plugin
2023-06-05 16:17:23 +05:30
046c00d844 changelog 2023-06-05 16:13:41 +05:30
b14653cb9e sdkit 1.0.103 - Pin the versions of diffusers models used; Use cpu offloading for balanced and low while upscaling using latent upscaler 2023-06-05 16:11:48 +05:30
c72b287c82 Show a more helpful error message in the logs when the system runs out of RAM 2023-06-05 15:22:37 +05:30
a10aa92634 Fix a bug where the realesrgan model would get unloaded after the first request in a batch while using Codeformer with upscaling of faces 2023-06-05 15:08:57 +05:30
8a2c09c6de Fix for rabbit hole plugin 2023-06-05 09:00:50 +05:30
401fc30617 Allow LoRA strengths between -2 and 2 2023-06-03 14:54:17 -04:00
6ca7247c02 Enable face upscaling by default 2023-06-03 10:11:03 +05:30
1d5309decb changelog 2023-06-03 10:04:06 +05:30
ab0218050c Merge pull request #1322 from cmdr2/cf
CodeFormer
2023-06-03 09:55:21 +05:30
6dcf7539bb close window 2023-06-03 00:04:13 +02:00
51d52d3a07 Tiled image download plugin 2023-06-02 23:41:53 +02:00
dd95df8f02 Refactor the default model download code, remove check_models.py, don't check in legacy paths since that's already migrated during initialization; Download CodeFormer's model only when it's used for the first time 2023-06-02 16:34:29 +05:30
0860e35d17 sdkit 1.0.101 - CodeFormer as an option to improve faces 2023-06-01 16:50:01 +05:30
32c4f10626 Merge pull request #1274 from patriceac/beta
Support for CodeFormer face restoration
2023-06-01 15:28:25 +05:30
3e90eafafb Merge branch 'cf' into beta 2023-06-01 15:27:37 +05:30
16fcb4ed79 Merge pull request #1314 from JeLuF/dndgan
Fix GFPGAN settings import
2023-05-29 15:46:28 +05:30
9be48b3fc5 Merge pull request #1317 from ogmaresca/fix-metadata-SyntaxWarning
Fix SyntaxWarning on startup
2023-05-29 10:15:29 +05:30
7830ec7ca2 Fix SyntaxWarning on startup
Fixes
```
/ssd2/easydiffusion/ui/easydiffusion/utils/save_utils.py:222: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if task_data.use_upscale is not "latent_upscaler" and "latent_upscaler_steps" in metadata:
  ```
2023-05-28 14:39:36 -04:00
0ebf9df207 Merge pull request #1316 from JeLuF/fix1312
Fix #1312 - invert model A and B ratio in merge
2023-05-28 17:33:26 +05:30
40682405cc Merge pull request #1309 from ogmaresca/add-tiling-to-metadata
Add tiling and latent upscaler steps to metadata
2023-05-28 17:33:00 +05:30
9fdd482811 Merge pull request #1311 from patriceac/patch-3
Fix regression in restore task to UI flow
2023-05-28 17:32:26 +05:30
7202ffba6e Fix #1312 - invert model A and B ratio in merge 2023-05-28 02:36:56 +02:00
30dcc7477f Fix GFPGAN settings import
The word None which many txt metadata files contain as value for the GFPGAN field should not be considered to be a model name.
If the value is None, disable the checkbox
2023-05-28 01:43:58 +02:00
9ce076eb0d Copy address button 2023-05-28 01:18:39 +02:00
2080d6e27b Share ED via Cloudflare's ArgoTunnel
Shares the Easy Diffusion instance via https://try.cloudflare.com/
2023-05-28 00:50:23 +02:00
6826435046 Fix restore task to UI flow
Fixes a regression introduced by https://github.com/cmdr2/stable-diffusion-ui/pull/1304
2023-05-27 00:26:25 -07:00
69d937e0b1 Add tiling and latent upscaler steps to metadata
Also fix txt metadata labels when also embedding metadata
2023-05-26 19:51:30 -04:00
edd92b724f UniPC TU 2 isn't working with diffusers either 2023-05-26 19:47:00 +05:30
0990d8fc4d Merge pull request #1304 from JeLuF/dndfix
Remove warning when reusing settings - Fixes #1290
2023-05-26 15:24:56 +05:30
1da35e89f6 Capitalization 2023-05-25 18:38:40 +05:30
d818107953 Remove warning when reusing settings - Fixes #1290 2023-05-25 13:36:45 +02:00
b3f65c0b3c changelog 2023-05-25 15:52:05 +05:30
59c322dc3b Show seamless tiling only in diffusers mode 2023-05-25 15:41:41 +05:30
096f9ad3a6 Merge branch 'beta' of github.com:cmdr2/stable-diffusion-ui into beta 2023-05-25 15:39:02 +05:30
5c8965b3ab changelog 2023-05-25 15:38:49 +05:30
090f8f6070 Merge pull request #1300 from JeLuF/tile
Add seamless tiling support
2023-05-25 15:38:15 +05:30
5f4fc63645 Merge branch 'beta' of github.com:cmdr2/stable-diffusion-ui into beta 2023-05-25 15:37:37 +05:30
a0b3b5af53 sdkit 1.0.98 - seamless tiling 2023-05-25 15:36:27 +05:30
351dd97500 Merge pull request #1303 from cmdr2/main
Main
2023-05-25 15:05:05 +05:30
b511000441 Merge pull request #1302 from cmdr2/beta
Beta
2023-05-25 14:57:51 +05:30
3a059bb919 Revert "Support for CodeFormer"
This reverts commit a25364732b.
2023-05-25 00:32:57 -07:00
a548c026b1 Revert "Fix face restoration model selection"
This reverts commit a5a1d33589.
2023-05-25 00:32:48 -07:00
99c99ee9e3 Plugin Manager
An easy-to-use UI plugin manager. Pulls plugins from multiple repos, installs and updates plugins seamlessly, gives precedence to locally installed plugins (based on file names). Hope this one works for you.

If you want to test-drive it before merging, you can download the below as a plugin here: https://github.com/patriceac/Easy-Diffusion-Plugins/blob/main/plugin-manager.plugin.js

The URLs at the top of plugins.js might need to be updated.
2023-05-25 00:31:17 -07:00
523131de79 Merge pull request #1298 from JeLuF/confix
Fix confirmation dialog
2023-05-25 07:19:21 +05:30
17e731dfe3 Merge branch 'beta' into splash 2023-05-25 00:30:47 +02:00
9dfa300083 Add seamless tiling support 2023-05-25 00:16:14 +02:00
3ea74af76d Fix confirmation dialog
By splitting the confirmation function into two halves, the closure was lost
2023-05-24 19:29:54 +02:00
3d7e16cfd9 changelog 2023-05-24 16:29:58 +05:30
db265309a5 Show an explanation for why the CPU toggle is disabled; utility class for alert() and confirm() that matches the ED theme; code formatting 2023-05-24 16:24:29 +05:30
8554b0eab2 Better reporting of model load errors - sends the report to the browser UI during the next image rendering task 2023-05-24 16:02:53 +05:30
f641e6e69d Merge branch 'beta' of github.com:cmdr2/stable-diffusion-ui into beta 2023-05-24 15:40:26 +05:30
30c07eab6b Cleaner reporting of errors in the UI; Suggest increasing the page size if that's the error 2023-05-24 15:30:55 +05:30
eba83386c1 make a note about a flood fill library 2023-05-24 10:08:00 +05:30
d3334f9dfa Merge branch 'beta' of github.com:cmdr2/stable-diffusion-ui into beta 2023-05-23 16:55:52 +05:30
a87dca1ef4 changelog 2023-05-23 16:55:42 +05:30
2bab4341a3 Add 'Latent Upscaler' as an option in the upscaling dropdown 2023-05-23 16:53:53 +05:30
01fb2fde47 Merge pull request #1293 from JeLuF/edready
Add 'ED is ready, go to localhost:9000' msg to log
2023-05-23 15:15:08 +05:30
0127714929 Add 'ED is ready, go to localhost:9000' msg to log
Sometimes the browser window does not open (esp. on Linux and Mac).
Show a prominent message to the log so that users don't wait for hours.
2023-05-22 21:19:31 +02:00
a5a1d33589 Fix face restoration model selection 2023-05-21 18:32:48 -07:00
cca6dd9230 2.5.37 updates 2023-05-21 21:30:29 +02:00
7d936c72a4 Merge branch 'beta' into splash 2023-05-21 21:02:06 +02:00
a25364732b Support for CodeFormer
Depends on https://github.com/easydiffusion/sdkit/pull/34.
2023-05-17 02:04:20 -07:00
0adaf6c0a0 Merge branch 'beta' of https://github.com/patriceac/stable-diffusion-ui into beta 2023-05-16 18:20:46 -07:00
654749de40 Revert "Toast notifications for ED"
This reverts commit dde51c0cef.
2023-04-29 19:26:11 -07:00
dde51c0cef Toast notifications for ED
Adding support for toast notifications for use in Core and user plugins.
2023-04-29 19:25:10 -07:00
991f9cda42 Add splash screen for testDiffusers users
The splash screen will only be shown once.

The splash screen version number can be used to roll out a new splash screen, which will also be shown only once.

Clicking on the EasyAndroidLady icon shows the splash screen again.
2023-04-22 11:42:42 +02:00
67746981e7 Merge beta 2023-03-29 15:39:37 +02:00
8149f97388 Linux ruamel.yaml installation 2023-03-29 15:28:05 +02:00
bbda097aa8 Merge branch 'beta' into yaml 2023-02-19 21:11:28 +01:00
932ee11c91 Use yaml instead of json for the config file 2023-02-16 01:19:36 +01:00
50 changed files with 7222 additions and 763 deletions

View File

@ -8,13 +8,13 @@
- **Full support for Stable Diffusion 2.1 (including CPU)** - supports loading v1.4 or v2.0 or v2.1 models seamlessly. No need to enable "Test SD2", and no need to add `sd2_` to your SD 2.0 model file names. Works on CPU as well.
- **Memory optimized Stable Diffusion 2.1** - you can now use Stable Diffusion 2.1 models, with the same low VRAM optimizations that we've always had for SD 1.4. Please note, the SD 2.0 and 2.1 models require more GPU and System RAM, as compared to the SD 1.4 and 1.5 models.
- **11 new samplers!** - explore the new samplers, some of which can generate great images in less than 10 inference steps! We've added the Karras and UniPC samplers. Thanks @Schorny for the UniPC samplers.
- **Model Merging** - You can now merge two models (`.ckpt` or `.safetensors`) and output `.ckpt` or `.safetensors` models, optionally in `fp16` precision. Details: https://github.com/cmdr2/stable-diffusion-ui/wiki/Model-Merging . Thanks @JeLuf.
- **Model Merging** - You can now merge two models (`.ckpt` or `.safetensors`) and output `.ckpt` or `.safetensors` models, optionally in `fp16` precision. Details: https://github.com/easydiffusion/easydiffusion/wiki/Model-Merging . Thanks @JeLuf.
- **Fast loading/unloading of VAEs** - No longer needs to reload the entire Stable Diffusion model, each time you change the VAE
- **Database of known models** - automatically picks the right configuration for known models. E.g. we automatically detect and apply "v" parameterization (required for some SD 2.0 models), and "fp32" attention precision (required for some SD 2.1 models).
- **Color correction for img2img** - an option to preserve the color profile (histogram) of the initial image. This is especially useful if you're getting red-tinted images after inpainting/masking.
- **Three GPU Memory Usage Settings** - `High` (fastest, maximum VRAM usage), `Balanced` (default - almost as fast, significantly lower VRAM usage), `Low` (slowest, very low VRAM usage). The `Low` setting is applied automatically for GPUs with less than 4 GB of VRAM.
- **Find models in sub-folders** - This allows you to organize your models into sub-folders inside `models/stable-diffusion`, instead of keeping them all in a single folder. Thanks @patriceac and @ogmaresca.
- **Custom Modifier Categories** - Ability to create custom modifiers with thumbnails, and custom categories (and hierarchy of categories). Details: https://github.com/cmdr2/stable-diffusion-ui/wiki/Custom-Modifiers . Thanks @ogmaresca.
- **Custom Modifier Categories** - Ability to create custom modifiers with thumbnails, and custom categories (and hierarchy of categories). Details: https://github.com/easydiffusion/easydiffusion/wiki/Custom-Modifiers . Thanks @ogmaresca.
- **Embed metadata, or save as TXT/JSON** - You can now embed the metadata directly into the images, or save them as text or json files (choose in the Settings tab). Thanks @patriceac.
- **Major rewrite of the code** - Most of the codebase has been reorganized and rewritten, to make it more manageable and easier for new developers to contribute features. We've separated our core engine into a new project called `sdkit`, which allows anyone to easily integrate Stable Diffusion (and related modules like GFPGAN etc) into their programming projects (via a simple `pip install sdkit`): https://github.com/easydiffusion/sdkit/
- **Name change** - Last, and probably the least, the UI is now called "Easy Diffusion". It indicates the focus of this project - an easy way for people to play with Stable Diffusion.
@ -22,6 +22,35 @@
Our focus continues to remain on an easy installation experience, and an easy user-interface. While still remaining pretty powerful, in terms of features and speed.
### Detailed changelog
* 2.5.46 - 27 Jul 2023 - (beta-only) Full support for SD-XL models (base and refiner)!
* 2.5.45 - 24 Jul 2023 - (beta-only) Hide the samplers that won't be supported in the new diffusers version.
* 2.5.45 - 22 Jul 2023 - (beta-only) Fix the recently-broken inpainting models.
* 2.5.45 - 16 Jul 2023 - (beta-only) Fix the image quality of LoRAs, which had degraded in v2.5.44.
* 2.5.44 - 15 Jul 2023 - (beta-only) Support for multiple LoRA files.
* 2.5.43 - 9 Jul 2023 - (beta-only) Support for loading Textual Inversion embeddings. You can find the option in the Image Settings panel. Thanks @JeLuf.
* 2.5.43 - 9 Jul 2023 - Improve the startup time of the UI.
* 2.5.42 - 4 Jul 2023 - Keyboard shortcuts for the Image Editor. Thanks @JeLuf.
* 2.5.42 - 28 Jun 2023 - Allow dropping images from folders to use as an Initial Image.
* 2.5.42 - 26 Jun 2023 - Show a popup for Image Modifiers, allowing a larger screen space, better UX on mobile screens, and more room for us to develop and improve the Image Modifiers panel. Thanks @Hakorr.
* 2.5.42 - 26 Jun 2023 - (beta-only) Show a welcome screen for users of the diffusers beta, with instructions on how to use the new prompt syntax, and known bugs. Thanks @JeLuf.
* 2.5.42 - 26 Jun 2023 - Use YAML files for config. You can now edit the `config.yaml` file (using a text editor, like Notepad). This file is present inside the Easy Diffusion folder, and is easier to read and edit (for humans) than JSON. Thanks @JeLuf.
* 2.5.41 - 24 Jun 2023 - (beta-only) Fix broken inpainting in low VRAM usage mode.
* 2.5.41 - 24 Jun 2023 - (beta-only) Fix a recent regression where the LoRA would not get applied when changing SD models.
* 2.5.41 - 23 Jun 2023 - Fix a regression where latent upscaler stopped working on PCs without a graphics card.
* 2.5.41 - 20 Jun 2023 - Automatically fix black images if fp32 attention precision is required in diffusers.
* 2.5.41 - 19 Jun 2023 - Another fix for multi-gpu rendering (in all VRAM usage modes).
* 2.5.41 - 13 Jun 2023 - Fix multi-gpu bug with "low" VRAM usage mode while generating images.
* 2.5.41 - 12 Jun 2023 - Fix multi-gpu bug with CodeFormer.
* 2.5.41 - 6 Jun 2023 - Allow changing the strength of CodeFormer, and slightly improved styling of the CodeFormer options.
* 2.5.41 - 5 Jun 2023 - Allow sharing an Easy Diffusion instance via https://try.cloudflare.com/ . You can find this option at the bottom of the Settings tab. Thanks @JeLuf.
* 2.5.41 - 5 Jun 2023 - Show an option to download for tiled images. Shows a button on the generated image. Creates larger images by tiling them with the image generated by Easy Diffusion. Thanks @JeLuf.
* 2.5.41 - 5 Jun 2023 - (beta-only) Allow LoRA strengths between -2 and 2. Thanks @ogmaresca.
* 2.5.40 - 5 Jun 2023 - Reduce the VRAM usage of Latent Upscaling when using "balanced" VRAM usage mode.
* 2.5.40 - 5 Jun 2023 - Fix the "realesrgan" key error when using CodeFormer with more than 1 image in a batch.
* 2.5.40 - 3 Jun 2023 - Added CodeFormer as another option for fixing faces and eyes. CodeFormer tends to perform better than GFPGAN for many images. Thanks @patriceac for the implementation, and for contacting the CodeFormer team (who were supportive of it being integrated into Easy Diffusion).
* 2.5.39 - 25 May 2023 - (beta-only) Seamless Tiling - make seamlessly tiled images, e.g. rock and grass textures. Thanks @JeLuf.
* 2.5.38 - 24 May 2023 - Better reporting of errors, and show an explanation if the user cannot disable the "Use CPU" setting.
* 2.5.38 - 23 May 2023 - Add Latent Upscaler as another option for upscaling images. Thanks @JeLuf for the implementation of the Latent Upscaler model.
* 2.5.37 - 19 May 2023 - (beta-only) Two more samplers: DDPM and DEIS. Also disables the samplers that aren't working yet in the Diffusers version. Thanks @ogmaresca.
* 2.5.37 - 19 May 2023 - (beta-only) Support CLIP-Skip. You can set this option under the models dropdown. Thanks @JeLuf.
* 2.5.37 - 19 May 2023 - (beta-only) More VRAM optimizations for all modes in diffusers. The VRAM usage for diffusers in "low" and "balanced" should now be equal or less than the non-diffusers version. Performs softmax in half precision, like sdkit does.
@ -55,7 +84,7 @@ Our focus continues to remain on an easy installation experience, and an easy us
* 2.5.24 - 11 Mar 2023 - Button to load an image mask from a file.
* 2.5.24 - 10 Mar 2023 - Logo change. Image credit: @lazlo_vii.
* 2.5.23 - 8 Mar 2023 - Experimental support for Mac M1/M2. Thanks @michaelgallacher, @JeLuf and vishae!
* 2.5.23 - 8 Mar 2023 - Ability to create custom modifiers with thumbnails, and custom categories (and hierarchy of categories). More details - https://github.com/cmdr2/stable-diffusion-ui/wiki/Custom-Modifiers . Thanks @ogmaresca.
* 2.5.23 - 8 Mar 2023 - Ability to create custom modifiers with thumbnails, and custom categories (and hierarchy of categories). More details - https://github.com/easydiffusion/easydiffusion/wiki/Custom-Modifiers . Thanks @ogmaresca.
* 2.5.22 - 28 Feb 2023 - Minor styling changes to UI buttons, and the models dropdown.
* 2.5.22 - 28 Feb 2023 - Lots of UI-related bug fixes. Thanks @patriceac.
* 2.5.21 - 22 Feb 2023 - An option to control the size of the image thumbnails. You can use the `Display options` in the top-right corner to change this. Thanks @JeLuf.
@ -80,7 +109,7 @@ Our focus continues to remain on an easy installation experience, and an easy us
* 2.5.14 - 3 Feb 2023 - Fix the 'Make Similar Images' button, which was producing incorrect images (weren't very similar).
* 2.5.13 - 1 Feb 2023 - Fix the remaining GPU memory leaks, including a better fix (more comprehensive) for the change in 2.5.12 (27 Jan).
* 2.5.12 - 27 Jan 2023 - Fix a memory leak, which made the UI unresponsive after an out-of-memory error. The allocated memory is now freed-up after an error.
* 2.5.11 - 25 Jan 2023 - UI for Merging Models. Thanks @JeLuf. More info: https://github.com/cmdr2/stable-diffusion-ui/wiki/Model-Merging
* 2.5.11 - 25 Jan 2023 - UI for Merging Models. Thanks @JeLuf. More info: https://github.com/easydiffusion/easydiffusion/wiki/Model-Merging
* 2.5.10 - 24 Jan 2023 - Reduce the VRAM usage for img2img in 'balanced' mode (without reducing the rendering speed), to make it similar to v2.4 of this UI.
* 2.5.9 - 23 Jan 2023 - Fix a bug where img2img would produce poorer-quality images for the same settings, as compared to version 2.4 of this UI.
* 2.5.9 - 23 Jan 2023 - Reduce the VRAM usage for 'balanced' mode (without reducing the rendering speed), to make it similar to v2.4 of the UI.
@ -109,8 +138,8 @@ Our focus continues to remain on an easy installation experience, and an easy us
- **Automatic scanning for malicious model files** - using `picklescan`, and support for `safetensor` model format. Thanks @JeLuf
- **Image Editor** - for drawing simple images for guiding the AI. Thanks @mdiller
- **Use pre-trained hypernetworks** - for improving the quality of images. Thanks @C0bra5
- **Support for custom VAE models**. You can place your VAE files in the `models/vae` folder, and refresh the browser page to use them. More info: https://github.com/cmdr2/stable-diffusion-ui/wiki/VAE-Variational-Auto-Encoder
- **Experimental support for multiple GPUs!** It should work automatically. Just open one browser tab per GPU, and spread your tasks across your GPUs. For e.g. open our UI in two browser tabs if you have two GPUs. You can customize which GPUs it should use in the "Settings" tab, otherwise let it automatically pick the best GPUs. Thanks @madrang . More info: https://github.com/cmdr2/stable-diffusion-ui/wiki/Run-on-Multiple-GPUs
- **Support for custom VAE models**. You can place your VAE files in the `models/vae` folder, and refresh the browser page to use them. More info: https://github.com/easydiffusion/easydiffusion/wiki/VAE-Variational-Auto-Encoder
- **Experimental support for multiple GPUs!** It should work automatically. Just open one browser tab per GPU, and spread your tasks across your GPUs. For e.g. open our UI in two browser tabs if you have two GPUs. You can customize which GPUs it should use in the "Settings" tab, otherwise let it automatically pick the best GPUs. Thanks @madrang . More info: https://github.com/easydiffusion/easydiffusion/wiki/Run-on-Multiple-GPUs
- **Cleaner UI design** - Show settings and help in new tabs, instead of dropdown popups (which were buggy). Thanks @mdiller
- **Progress bar.** Thanks @mdiller
- **Custom Image Modifiers** - You can now save your custom image modifiers! Your saved modifiers can include special characters like `{}, (), [], |`

View File

@ -1,6 +1,6 @@
Hi there, these instructions are meant for the developers of this project.
If you only want to use the Stable Diffusion UI, you've downloaded the wrong file. In that case, please download and follow the instructions at https://github.com/cmdr2/stable-diffusion-ui#installation
If you only want to use the Stable Diffusion UI, you've downloaded the wrong file. In that case, please download and follow the instructions at https://github.com/easydiffusion/easydiffusion#installation
Thanks
@ -13,7 +13,7 @@ If you would like to contribute to this project, there is a discord for discussi
This is in-flux, but one way to get a development environment running for editing the UI of this project is:
(swap `.sh` or `.bat` in instructions depending on your environment, and be sure to adjust any paths to match where you're working)
1) Install the project to a new location using the [usual installation process](https://github.com/cmdr2/stable-diffusion-ui#installation), e.g. to `/projects/stable-diffusion-ui-archive`
1) Install the project to a new location using the [usual installation process](https://github.com/easydiffusion/easydiffusion#installation), e.g. to `/projects/stable-diffusion-ui-archive`
2) Start the newly installed project, and check that you can view and generate images on `localhost:9000`
3) Next, please clone the project repository using `git clone` (e.g. to `/projects/stable-diffusion-ui-repo`)
4) Close the server (started in step 2), and edit `/projects/stable-diffusion-ui-archive/scripts/on_env_start.sh` (or `on_env_start.bat`)

View File

@ -1,6 +1,6 @@
Congrats on downloading Stable Diffusion UI, version 2!
If you haven't downloaded Stable Diffusion UI yet, please download from https://github.com/cmdr2/stable-diffusion-ui#installation
If you haven't downloaded Stable Diffusion UI yet, please download from https://github.com/easydiffusion/easydiffusion#installation
After downloading, to install please follow these instructions:
@ -16,9 +16,9 @@ To start the UI in the future, please run the same command mentioned above.
If you have any problems, please:
1. Try the troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting
1. Try the troubleshooting steps at https://github.com/easydiffusion/easydiffusion/wiki/Troubleshooting
2. Or, seek help from the community at https://discord.com/invite/u9yhsFmEkB
3. Or, file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues
3. Or, file an issue at https://github.com/easydiffusion/easydiffusion/issues
Thanks
cmdr2 (and contributors to the project)

View File

@ -3,7 +3,7 @@
This is a summary of whether Easy Diffusion uses your data or tracks you:
* The short answer is - Easy Diffusion does *not* use your data, and does *not* track you.
* Easy Diffusion does not send your prompts or usage or analytics to anyone. There is no tracking. We don't even know how many people use Easy Diffusion, let alone their prompts.
* Easy Diffusion fetches updates to the code whenever it starts up. It does this by contacting GitHub directly, via SSL (secure connection). Only your computer and GitHub and [this repository](https://github.com/cmdr2/stable-diffusion-ui) are involved, and no third party is involved. Some countries intercepts SSL connections, that's not something we can do much about. GitHub does *not* share statistics (even with me) about how many people fetched code updates.
* Easy Diffusion fetches updates to the code whenever it starts up. It does this by contacting GitHub directly, via SSL (secure connection). Only your computer and GitHub and [this repository](https://github.com/easydiffusion/easydiffusion) are involved, and no third party is involved. Some countries intercepts SSL connections, that's not something we can do much about. GitHub does *not* share statistics (even with me) about how many people fetched code updates.
* Easy Diffusion fetches the models from huggingface.co and github.com, if they don't exist on your PC. For e.g. if the safety checker (NSFW) model doesn't exist, it'll try to download it.
* Easy Diffusion fetches code packages from pypi.org, which is the standard hosting service for all Python projects. That's where packages installed via `pip install` are stored.
* Occasionally, antivirus software are known to *incorrectly* flag and delete some model files, which will result in Easy Diffusion re-downloading `pytorch_model.bin`. This *incorrect deletion* affects other Stable Diffusion UIs as well, like Invoke AI - https://itch.io/post/7509488

View File

@ -3,6 +3,6 @@ Hi there,
What you have downloaded is meant for the developers of this project, not for users.
If you only want to use the Stable Diffusion UI, you've downloaded the wrong file.
Please download and follow the instructions at https://github.com/cmdr2/stable-diffusion-ui#installation
Please download and follow the instructions at https://github.com/easydiffusion/easydiffusion#installation
Thanks

View File

@ -3,7 +3,7 @@
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/cmdr2/stable-diffusion-ui/wiki/Troubleshooting) | <sub>[![Discord Server](https://img.shields.io/discord/1014774730907209781?label=Discord)](https://discord.com/invite/u9yhsFmEkB)</sub> <sup>(for support queries, and development discussions)</sup>
[Installation guide](#installation) | [Troubleshooting guide](https://github.com/easydiffusion/easydiffusion/wiki/Troubleshooting) | <sub>[![Discord Server](https://img.shields.io/discord/1014774730907209781?label=Discord)](https://discord.com/invite/u9yhsFmEkB)</sub> <sup>(for support queries, and development discussions)</sup>
![t2i](https://raw.githubusercontent.com/Stability-AI/stablediffusion/main/assets/stable-samples/txt2img/768/merged-0006.png)
@ -11,9 +11,9 @@ Does not require technical knowledge, does not require pre-installed software. 1
Click the download button for your operating system:
<p float="left">
<a href="https://github.com/cmdr2/stable-diffusion-ui/releases/download/v2.5.24/Easy-Diffusion-Windows.exe"><img src="https://github.com/cmdr2/stable-diffusion-ui/raw/main/media/download-win.png" width="200" /></a>
<a href="https://github.com/cmdr2/stable-diffusion-ui/releases/download/v2.5.24/Easy-Diffusion-Linux.zip"><img src="https://github.com/cmdr2/stable-diffusion-ui/raw/main/media/download-linux.png" width="200" /></a>
<a href="https://github.com/cmdr2/stable-diffusion-ui/releases/download/v2.5.24/Easy-Diffusion-Mac.zip"><img src="https://github.com/cmdr2/stable-diffusion-ui/raw/main/media/download-mac.png" width="200" /></a>
<a href="https://github.com/easydiffusion/easydiffusion/releases/download/v2.5.24/Easy-Diffusion-Windows.exe"><img src="https://github.com/easydiffusion/easydiffusion/raw/main/media/download-win.png" width="200" /></a>
<a href="https://github.com/easydiffusion/easydiffusion/releases/download/v2.5.24/Easy-Diffusion-Linux.zip"><img src="https://github.com/easydiffusion/easydiffusion/raw/main/media/download-linux.png" width="200" /></a>
<a href="https://github.com/easydiffusion/easydiffusion/releases/download/v2.5.24/Easy-Diffusion-Mac.zip"><img src="https://github.com/easydiffusion/easydiffusion/raw/main/media/download-mac.png" width="200" /></a>
</p>
**Hardware requirements:**
@ -70,6 +70,7 @@ Just delete the `EasyDiffusion` folder to uninstall all the downloaded packages.
- **Attention/Emphasis**: () in the prompt increases the model's attention to enclosed words, and [] decreases it.
- **Weighted Prompts**: Use weights for specific words in your prompt to change their importance, e.g. `red:2.4 dragon:1.2`.
- **Prompt Matrix**: Quickly create multiple variations of your prompt, e.g. `a photograph of an astronaut riding a horse | illustration | cinematic lighting`.
- **Prompt Set**: Quickly create multiple variations of your prompt, e.g. `a photograph of an astronaut on the {moon,earth}`
- **1-click Upscale/Face Correction**: Upscale or correct an image after it has been generated.
- **Make Similar Images**: Click to generate multiple variations of a generated image.
- **NSFW Setting**: A setting in the UI to control *NSFW content*.
@ -82,7 +83,7 @@ Just delete the `EasyDiffusion` folder to uninstall all the downloaded packages.
- **Use custom VAE models**
- **Use pre-trained Hypernetworks**
- **Use custom GFPGAN models**
- **UI Plugins**: Choose from a growing list of [community-generated UI plugins](https://github.com/cmdr2/stable-diffusion-ui/wiki/UI-Plugins), or write your own plugin to add features to the project!
- **UI Plugins**: Choose from a growing list of [community-generated UI plugins](https://github.com/easydiffusion/easydiffusion/wiki/UI-Plugins), or write your own plugin to add features to the project!
### Performance and security
- **Fast**: Creates a 512x512 image with euler_a in 5 seconds, on an NVIDIA 3060 12GB.
@ -118,10 +119,10 @@ Useful for judging (and stopping) an image quickly, without waiting for it to fi
----
# How to use?
Please refer to our [guide](https://github.com/cmdr2/stable-diffusion-ui/wiki/How-to-Use) to understand how to use the features in this UI.
Please refer to our [guide](https://github.com/easydiffusion/easydiffusion/wiki/How-to-Use) to understand how to use the features in this UI.
# Bugs reports and code contributions welcome
If there are any problems or suggestions, please feel free to ask on the [discord server](https://discord.com/invite/u9yhsFmEkB) or [file an issue](https://github.com/cmdr2/stable-diffusion-ui/issues).
If there are any problems or suggestions, please feel free to ask on the [discord server](https://discord.com/invite/u9yhsFmEkB) or [file an issue](https://github.com/easydiffusion/easydiffusion/issues).
We could really use help on these aspects (click to view tasks that need your help):
* [User Interface](https://github.com/users/cmdr2/projects/1/views/1)

View File

@ -2,7 +2,7 @@
@echo "Hi there, what you are running is meant for the developers of this project, not for users." & echo.
@echo "If you only want to use the Stable Diffusion UI, you've downloaded the wrong file."
@echo "Please download and follow the instructions at https://github.com/cmdr2/stable-diffusion-ui#installation" & echo.
@echo "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.
set /p answer=Are you a developer of this project (Y/N)?
@ -15,6 +15,7 @@ mkdir dist\win\stable-diffusion-ui\scripts
copy scripts\on_env_start.bat dist\win\stable-diffusion-ui\scripts\
copy scripts\bootstrap.bat dist\win\stable-diffusion-ui\scripts\
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\

View File

@ -2,7 +2,7 @@
printf "Hi there, what you are running is meant for the developers of this project, not for users.\n\n"
printf "If you only want to use the Stable Diffusion UI, you've downloaded the wrong file.\n"
printf "Please download and follow the instructions at https://github.com/cmdr2/stable-diffusion-ui#installation\n\n"
printf "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"
read -p "Are you a developer of this project (Y/N) " yn
@ -29,6 +29,7 @@ mkdir -p dist/linux-mac/stable-diffusion-ui/scripts
cp scripts/on_env_start.sh dist/linux-mac/stable-diffusion-ui/scripts/
cp scripts/bootstrap.sh dist/linux-mac/stable-diffusion-ui/scripts/
cp scripts/functions.sh dist/linux-mac/stable-diffusion-ui/scripts/
cp scripts/config.yaml.sample dist/linux-mac/stable-diffusion-ui/scripts/config.yaml
cp scripts/start.sh dist/linux-mac/stable-diffusion-ui/
cp LICENSE dist/linux-mac/stable-diffusion-ui/
cp "CreativeML Open RAIL-M License" dist/linux-mac/stable-diffusion-ui/

View File

@ -2,6 +2,8 @@
echo "Opening Stable Diffusion UI - Developer Console.." & echo.
cd /d %~dp0
set PATH=C:\Windows\System32;%PATH%
@rem set legacy and new installer's PATH, if they exist
@ -21,6 +23,8 @@ call git --version
call where conda
call conda --version
echo.
echo COMSPEC=%COMSPEC%
echo.
@rem activate the legacy environment (if present) and set PYTHONPATH
@ -37,6 +41,10 @@ call python --version
echo PYTHONPATH=%PYTHONPATH%
if exist "%cd%\profile" (
set HF_HOME=%cd%\profile\.cache\huggingface
)
@rem done
echo.

View File

@ -36,8 +36,9 @@ call git --version
call where conda
call conda --version
echo .
echo COMSPEC=%COMSPEC%
@rem Download the rest of the installer and UI
call scripts\on_env_start.bat
@pause

View File

@ -11,7 +11,7 @@ setlocal enabledelayedexpansion
set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba
set INSTALL_ENV_DIR=%cd%\installer_files\env
set LEGACY_INSTALL_ENV_DIR=%cd%\installer
set MICROMAMBA_DOWNLOAD_URL=https://github.com/cmdr2/stable-diffusion-ui/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 OLD_APPDATA=%APPDATA%

View File

@ -1,101 +0,0 @@
# this script runs inside the legacy "stable-diffusion" folder
from sdkit.models import download_model, get_model_info_from_db
from sdkit.utils import hash_file_quick
import os
import shutil
from glob import glob
import traceback
models_base_dir = os.path.abspath(os.path.join("..", "models"))
models_to_check = {
"stable-diffusion": [
{"file_name": "sd-v1-4.ckpt", "model_id": "1.4"},
],
"gfpgan": [
{"file_name": "GFPGANv1.4.pth", "model_id": "1.4"},
],
"realesrgan": [
{"file_name": "RealESRGAN_x4plus.pth", "model_id": "x4plus"},
{"file_name": "RealESRGAN_x4plus_anime_6B.pth", "model_id": "x4plus_anime_6"},
],
"vae": [
{"file_name": "vae-ft-mse-840000-ema-pruned.ckpt", "model_id": "vae-ft-mse-840000-ema-pruned"},
],
}
MODEL_EXTENSIONS = { # copied from easydiffusion/model_manager.py
"stable-diffusion": [".ckpt", ".safetensors"],
"vae": [".vae.pt", ".ckpt", ".safetensors"],
"hypernetwork": [".pt", ".safetensors"],
"gfpgan": [".pth"],
"realesrgan": [".pth"],
"lora": [".ckpt", ".safetensors"],
}
def download_if_necessary(model_type: str, file_name: str, model_id: str):
model_path = os.path.join(models_base_dir, model_type, file_name)
expected_hash = get_model_info_from_db(model_type=model_type, model_id=model_id)["quick_hash"]
other_models_exist = any_model_exists(model_type)
known_model_exists = os.path.exists(model_path)
known_model_is_corrupt = known_model_exists and hash_file_quick(model_path) != expected_hash
if known_model_is_corrupt or (not other_models_exist and not known_model_exists):
print("> download", model_type, model_id)
download_model(model_type, model_id, download_base_dir=models_base_dir)
def init():
migrate_legacy_model_location()
for model_type, models in models_to_check.items():
for model in models:
try:
download_if_necessary(model_type, model["file_name"], model["model_id"])
except:
traceback.print_exc()
fail(model_type)
print(model_type, "model(s) found.")
### utilities
def any_model_exists(model_type: str) -> bool:
extensions = MODEL_EXTENSIONS.get(model_type, [])
for ext in extensions:
if any(glob(f"{models_base_dir}/{model_type}/**/*{ext}", recursive=True)):
return True
return False
def migrate_legacy_model_location():
'Move the models inside the legacy "stable-diffusion" folder, to their respective folders'
for model_type, models in models_to_check.items():
for model in models:
file_name = model["file_name"]
if os.path.exists(file_name):
dest_dir = os.path.join(models_base_dir, model_type)
os.makedirs(dest_dir, exist_ok=True)
shutil.move(file_name, os.path.join(dest_dir, file_name))
def fail(model_name):
print(
f"""Error downloading the {model_name} model. Sorry about that, please try to:
1. Run this installer again.
2. If that doesn't fix it, please try to download the file manually. The address to download from, and the destination to save to are printed above this message.
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
4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues
Thanks!"""
)
exit(1)
### start
init()

View File

@ -18,13 +18,16 @@ os_name = platform.system()
modules_to_check = {
"torch": ("1.11.0", "1.13.1", "2.0.0"),
"torchvision": ("0.12.0", "0.14.1", "0.15.1"),
"sdkit": "1.0.97",
"sdkit": "1.0.142",
"stable-diffusion-sdkit": "2.1.4",
"rich": "12.6.0",
"uvicorn": "0.19.0",
"fastapi": "0.85.1",
"pycloudflared": "0.2.0",
"ruamel.yaml": "0.17.21",
# "xformers": "0.0.16",
}
modules_to_log = ["torch", "torchvision", "sdkit", "stable-diffusion-sdkit"]
def version(module_name: str) -> str:
@ -89,7 +92,8 @@ def init():
traceback.print_exc()
fail(module_name)
print(f"{module_name}: {version(module_name)}")
if module_name in modules_to_log:
print(f"{module_name}: {version(module_name)}")
### utilities
@ -145,9 +149,9 @@ def fail(module_name):
print(
f"""Error installing {module_name}. Sorry about that, please try to:
1. Run this installer again.
2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting
2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/easydiffusion/easydiffusion/wiki/Troubleshooting
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
4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues
4. If that doesn't solve the problem, please file an issue at https://github.com/easydiffusion/easydiffusion/issues
Thanks!"""
)
exit(1)

View File

@ -0,0 +1,24 @@
# Change listen_port if port 9000 is already in use on your system
# Set listen_to_network to true to make Easy Diffusion accessibble on your local network
net:
listen_port: 9000
listen_to_network: false
# Multi GPU setup
render_devices: auto
# Set open_browser_on_start to false to disable opening a new browser tab on each restart
ui:
open_browser_on_start: true
# set update_branch to main to use the stable version, or to beta to use the experimental
# beta version.
update_branch: main
# Set force_save_path to enforce an auto save path. Clients will not be able to change or
# disable auto save when this option is set. Please adapt the path in the examples to your
# needs.
# Windows:
# force_save_path: C:\\Easy Diffusion Images\\
# Linux:
# force_save_path: /data/easy-diffusion-images/

View File

@ -39,6 +39,8 @@ if [ "$0" == "bash" ]; then
export PYTHONPATH="$(pwd)/stable-diffusion/env/lib/python3.8/site-packages"
fi
export PYTHONNOUSERSITE=y
which python
python --version

View File

@ -15,9 +15,9 @@ fail() {
Error downloading Stable Diffusion UI. Sorry about that, please try to:
1. Run this installer again.
2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting
2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/easydiffusion/easydiffusion/wiki/Troubleshooting
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
4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues
4. If that doesn't solve the problem, please file an issue at https://github.com/easydiffusion/easydiffusion/issues
Thanks!

View File

@ -1,10 +1,11 @@
import os
import argparse
import sys
import shutil
# The config file is in the same directory as this script
config_directory = os.path.dirname(__file__)
config_yaml = os.path.join(config_directory, "config.yaml")
config_yaml = os.path.join(config_directory, "..", "config.yaml")
config_json = os.path.join(config_directory, "config.json")
parser = argparse.ArgumentParser(description='Get values from config file')
@ -15,15 +16,21 @@ parser.add_argument('key', metavar='key', nargs='+',
args = parser.parse_args()
config = None
# migrate the old config yaml location
config_legacy_yaml = os.path.join(config_directory, "config.yaml")
if os.path.isfile(config_legacy_yaml):
shutil.move(config_legacy_yaml, config_yaml)
if os.path.isfile(config_yaml):
import yaml
from ruamel.yaml import YAML
yaml = YAML(typ='safe')
with open(config_yaml, 'r') as configfile:
try:
config = yaml.safe_load(configfile)
config = yaml.load(configfile)
except Exception as e:
print(e, file=sys.stderr)
config = {}
elif os.path.isfile(config_json):
import json
with open(config_json, 'r') as configfile:
@ -31,8 +38,8 @@ elif os.path.isfile(config_json):
config = json.load(configfile)
except Exception as e:
print(e, file=sys.stderr)
config = {}
else:
if config is None:
config = {}
for k in args.key:

View File

@ -55,10 +55,10 @@ if "%update_branch%"=="" (
@echo. & echo "Downloading Easy Diffusion..." & echo.
@echo "Using the %update_branch% channel" & echo.
@call git clone -b "%update_branch%" https://github.com/cmdr2/stable-diffusion-ui.git sd-ui-files && (
@call git clone -b "%update_branch%" https://github.com/easydiffusion/easydiffusion.git sd-ui-files && (
@echo sd_ui_git_cloned >> scripts\install_status.txt
) || (
@echo "Error downloading Easy Diffusion. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/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/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!"
@echo "Error downloading Easy Diffusion. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/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!"
pause
@exit /b
)
@ -67,8 +67,8 @@ if "%update_branch%"=="" (
@xcopy sd-ui-files\ui ui /s /i /Y /q
@copy sd-ui-files\scripts\on_sd_start.bat scripts\ /Y
@copy sd-ui-files\scripts\check_modules.py scripts\ /Y
@copy sd-ui-files\scripts\check_models.py scripts\ /Y
@copy sd-ui-files\scripts\get_config.py scripts\ /Y
@copy sd-ui-files\scripts\config.yaml.sample scripts\ /Y
@copy "sd-ui-files\scripts\Start Stable Diffusion UI.cmd" . /Y
@copy "sd-ui-files\scripts\Developer Console.cmd" . /Y

View File

@ -38,7 +38,7 @@ else
printf "\n\nDownloading Easy Diffusion..\n\n"
printf "Using the $update_branch channel\n\n"
if git clone -b "$update_branch" https://github.com/cmdr2/stable-diffusion-ui.git sd-ui-files ; then
if git clone -b "$update_branch" https://github.com/easydiffusion/easydiffusion.git sd-ui-files ; then
echo sd_ui_git_cloned >> scripts/install_status.txt
else
fail "git clone failed"
@ -50,8 +50,8 @@ cp -Rf sd-ui-files/ui .
cp sd-ui-files/scripts/on_sd_start.sh scripts/
cp sd-ui-files/scripts/bootstrap.sh scripts/
cp sd-ui-files/scripts/check_modules.py scripts/
cp sd-ui-files/scripts/check_models.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/start.sh .
cp sd-ui-files/scripts/developer_console.sh .
cp sd-ui-files/scripts/functions.sh scripts/

View File

@ -5,8 +5,8 @@
@copy sd-ui-files\scripts\on_env_start.bat scripts\ /Y
@copy sd-ui-files\scripts\check_modules.py scripts\ /Y
@copy sd-ui-files\scripts\check_models.py scripts\ /Y
@copy sd-ui-files\scripts\get_config.py scripts\ /Y
@copy sd-ui-files\scripts\config.yaml.sample scripts\ /Y
if exist "%cd%\profile" (
set HF_HOME=%cd%\profile\.cache\huggingface
@ -27,7 +27,7 @@ if exist "%cd%\stable-diffusion\env" (
@rem activate the installer env
call conda activate
@if "%ERRORLEVEL%" NEQ "0" (
@echo. & echo "Error activating conda for Easy Diffusion. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/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/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo.
@echo. & echo "Error activating conda for Easy Diffusion. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/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
)
@ -69,7 +69,7 @@ if "%ERRORLEVEL%" NEQ "0" (
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/cmdr2/stable-diffusion-ui/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/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo.
@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
)
@ -79,13 +79,6 @@ call WHERE uvicorn > .tmp
@echo conda_sd_ui_deps_installed >> ..\scripts\install_status.txt
)
@rem Download the required models
call python ..\scripts\check_models.py
if "%ERRORLEVEL%" NEQ "0" (
pause
exit /b
)
@>nul findstr /m "sd_install_complete" ..\scripts\install_status.txt
@if "%ERRORLEVEL%" NEQ "0" (
@echo sd_weights_downloaded >> ..\scripts\install_status.txt
@ -111,18 +104,21 @@ call python --version
@FOR /F "tokens=* USEBACKQ" %%F IN (`python scripts\get_config.py --default=False net listen_to_network`) DO (
if "%%F" EQU "True" (
@SET ED_BIND_IP=0.0.0.0
@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
@uvicorn main:server_api --app-dir "%SD_UI_PATH%" --port %ED_BIND_PORT% --host %ED_BIND_IP% --log-level error
@python -m uvicorn main:server_api --app-dir "%SD_UI_PATH%" --port %ED_BIND_PORT% --host %ED_BIND_IP% --log-level error
@pause

View File

@ -4,8 +4,8 @@ cp sd-ui-files/scripts/functions.sh scripts/
cp sd-ui-files/scripts/on_env_start.sh scripts/
cp sd-ui-files/scripts/bootstrap.sh scripts/
cp sd-ui-files/scripts/check_modules.py scripts/
cp sd-ui-files/scripts/check_models.py scripts/
cp sd-ui-files/scripts/get_config.py scripts/
cp sd-ui-files/scripts/config.yaml.sample scripts/
source ./scripts/functions.sh
@ -51,12 +51,6 @@ if ! command -v uvicorn &> /dev/null; then
fail "UI packages not found!"
fi
# Download the required models
if ! python ../scripts/check_models.py; then
read -p "Press any key to continue"
exit 1
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
@ -78,7 +72,7 @@ export SD_UI_PATH=`pwd`/ui
export ED_BIND_PORT="$( python scripts/get_config.py --default=9000 net listen_port )"
case "$( python scripts/get_config.py --default=False net listen_to_network )" in
"True")
export ED_BIND_IP=0.0.0.0
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

View File

@ -1,15 +1,21 @@
import json
import logging
import os
import shutil
import socket
import sys
import traceback
import copy
from ruamel.yaml import YAML
import urllib
import warnings
from easydiffusion import task_manager
from easydiffusion.utils import log
from rich.logging import RichHandler
from rich.console import Console
from rich.panel import Panel
from sdkit.utils import log as sdkit_log # hack, so we can overwrite the log config
# Remove all handlers associated with the root logger object.
@ -88,38 +94,110 @@ def init():
os.makedirs(USER_SERVER_PLUGINS_DIR, exist_ok=True)
# 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")
def init_render_threads():
load_server_plugins()
update_render_threads()
def getConfig(default_val=APP_CONFIG_DEFAULTS):
try:
config_json_path = os.path.join(CONFIG_DIR, "config.json")
if not os.path.exists(config_json_path):
config = default_val
else:
config_yaml_path = os.path.join(CONFIG_DIR, "..", "config.yaml")
# migrate the old config yaml location
config_legacy_yaml = os.path.join(CONFIG_DIR, "config.yaml")
if os.path.isfile(config_legacy_yaml):
shutil.move(config_legacy_yaml, config_yaml_path)
def set_config_on_startup(config: dict):
if getConfig.__test_diffusers_on_startup is None:
getConfig.__test_diffusers_on_startup = config.get("test_diffusers", False)
config["config_on_startup"] = {"test_diffusers": getConfig.__test_diffusers_on_startup}
if os.path.isfile(config_yaml_path):
try:
yaml = YAML()
with open(config_yaml_path, "r", encoding="utf-8") as f:
config = yaml.load(f)
if "net" not in config:
config["net"] = {}
if os.getenv("SD_UI_BIND_PORT") is not None:
config["net"]["listen_port"] = int(os.getenv("SD_UI_BIND_PORT"))
else:
config["net"]["listen_port"] = 9000
if os.getenv("SD_UI_BIND_IP") is not None:
config["net"]["listen_to_network"] = os.getenv("SD_UI_BIND_IP") == "0.0.0.0"
else:
config["net"]["listen_to_network"] = True
set_config_on_startup(config)
return config
except Exception as e:
log.warn(traceback.format_exc())
set_config_on_startup(default_val)
return default_val
else:
try:
config_json_path = os.path.join(CONFIG_DIR, "config.json")
if not os.path.exists(config_json_path):
return default_val
log.info("Converting old json config file to yaml")
with open(config_json_path, "r", encoding="utf-8") as f:
config = json.load(f)
if "net" not in config:
config["net"] = {}
if os.getenv("SD_UI_BIND_PORT") is not None:
config["net"]["listen_port"] = int(os.getenv("SD_UI_BIND_PORT"))
if os.getenv("SD_UI_BIND_IP") is not None:
config["net"]["listen_to_network"] = os.getenv("SD_UI_BIND_IP") == "0.0.0.0"
return config
except Exception:
log.warn(traceback.format_exc())
return default_val
# Save config in new format
setConfig(config)
with open(config_json_path + ".txt", "w") as f:
f.write("Moved to config.yaml inside the Easy Diffusion folder. You can open it in any text editor.")
os.remove(config_json_path)
return getConfig(default_val)
except Exception as e:
log.warn(traceback.format_exc())
set_config_on_startup(default_val)
return default_val
getConfig.__test_diffusers_on_startup = None
def setConfig(config):
try: # config.json
config_json_path = os.path.join(CONFIG_DIR, "config.json")
with open(config_json_path, "w", encoding="utf-8") as f:
json.dump(config, f)
try: # config.yaml
config_yaml_path = os.path.join(CONFIG_DIR, "..", "config.yaml")
yaml = YAML()
if not hasattr(config, "_yaml_comment"):
config_yaml_sample_path = os.path.join(CONFIG_DIR, "config.yaml.sample")
if os.path.exists(config_yaml_sample_path):
with open(config_yaml_sample_path, "r", encoding="utf-8") as f:
commented_config = yaml.load(f)
for k in config:
commented_config[k] = config[k]
config = commented_config
yaml.indent(mapping=2, sequence=4, offset=2)
if "config_on_startup" in config:
del config["config_on_startup"]
try:
f = open(config_yaml_path + ".tmp", "w", encoding="utf-8")
yaml.dump(config, f)
finally:
f.close() # do this explicitly to avoid NUL bytes (possible rare bug when using 'with')
# verify that the new file is valid, and only then overwrite the old config file
# helps prevent the rare NUL bytes error from corrupting the config file
yaml = YAML()
with open(config_yaml_path + ".tmp", "r", encoding="utf-8") as f:
yaml.load(f)
shutil.move(config_yaml_path + ".tmp", config_yaml_path)
except:
log.error(traceback.format_exc())
@ -155,10 +233,12 @@ def update_render_threads():
def getUIPlugins():
plugins = []
file_names = set()
for plugins_dir, dir_prefix in UI_PLUGINS_SOURCES:
for file in os.listdir(plugins_dir):
if file.endswith(".plugin.js"):
if file.endswith(".plugin.js") and file not in file_names:
plugins.append(f"/plugins/{dir_prefix}/{file}")
file_names.add(file)
return plugins
@ -213,11 +293,50 @@ def open_browser():
ui = config.get("ui", {})
net = config.get("net", {})
port = net.get("listen_port", 9000)
if ui.get("open_browser_on_start", True):
import webbrowser
log.info("Opening browser..")
webbrowser.open(f"http://localhost:{port}")
Console().print(
Panel(
"\n"
+ "[white]Easy Diffusion is ready to serve requests.\n\n"
+ "A new browser tab should have been opened by now.\n"
+ f"If not, please open your web browser and navigate to [bold yellow underline]http://localhost:{port}/\n",
title="Easy Diffusion is ready",
style="bold yellow on blue",
)
)
def fail_and_die(fail_type: str, data: str):
suggestions = [
"Run this installer again.",
"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",
"If that doesn't solve the problem, please file an issue at https://github.com/easydiffusion/easydiffusion/issues",
]
if fail_type == "model_download":
fail_label = f"Error downloading the {data} model"
suggestions.insert(
1,
"If that doesn't fix it, please try to download the file manually. The address to download from, and the destination to save to are printed above this message.",
)
else:
fail_label = "Error while installing Easy Diffusion"
msg = [f"{fail_label}. Sorry about that, please try to:"]
for i, suggestion in enumerate(suggestions):
msg.append(f"{i+1}. {suggestion}")
msg.append("Thanks!")
print("\n".join(msg))
exit(1)
def get_image_modifiers():
modifiers_json_path = os.path.join(SD_UI_DIR, "modifiers.json")

View File

@ -1,10 +1,15 @@
import os
import shutil
from glob import glob
import traceback
from typing import Union
from easydiffusion import app
from easydiffusion.types import TaskData
from easydiffusion.utils import log
from sdkit import Context
from sdkit.models import load_model, scan_model, unload_model
from sdkit.models import load_model, scan_model, unload_model, download_model, get_model_info_from_db
from sdkit.utils import hash_file_quick
KNOWN_MODEL_TYPES = [
"stable-diffusion",
@ -13,6 +18,7 @@ KNOWN_MODEL_TYPES = [
"gfpgan",
"realesrgan",
"lora",
"codeformer",
]
MODEL_EXTENSIONS = {
"stable-diffusion": [".ckpt", ".safetensors"],
@ -21,14 +27,23 @@ MODEL_EXTENSIONS = {
"gfpgan": [".pth"],
"realesrgan": [".pth"],
"lora": [".ckpt", ".safetensors"],
"codeformer": [".pth"],
"embeddings": [".pt", ".bin", ".safetensors"],
}
DEFAULT_MODELS = {
"stable-diffusion": [ # needed to support the legacy installations
"custom-model", # only one custom model file was supported initially, creatively named 'custom-model'
"sd-v1-4", # Default fallback.
"stable-diffusion": [
{"file_name": "sd-v1-4.ckpt", "model_id": "1.4"},
],
"gfpgan": [
{"file_name": "GFPGANv1.4.pth", "model_id": "1.4"},
],
"realesrgan": [
{"file_name": "RealESRGAN_x4plus.pth", "model_id": "x4plus"},
{"file_name": "RealESRGAN_x4plus_anime_6B.pth", "model_id": "x4plus_anime_6"},
],
"vae": [
{"file_name": "vae-ft-mse-840000-ema-pruned.ckpt", "model_id": "vae-ft-mse-840000-ema-pruned"},
],
"gfpgan": ["GFPGANv1.3"],
"realesrgan": ["RealESRGAN_x4plus"],
}
MODELS_TO_LOAD_ON_START = ["stable-diffusion", "vae", "hypernetwork", "lora"]
@ -37,15 +52,19 @@ known_models = {}
def init():
make_model_folders()
getModels() # run this once, to cache the picklescan results
migrate_legacy_model_location() # if necessary
download_default_models_if_necessary()
def load_default_models(context: Context):
set_vram_optimizations(context)
config = app.getConfig()
context.embeddings_path = os.path.join(app.MODELS_DIR, "embeddings")
# init default model paths
for model_type in MODELS_TO_LOAD_ON_START:
context.model_paths[model_type] = resolve_model_to_use(model_type=model_type)
context.model_paths[model_type] = resolve_model_to_use(model_type=model_type, fail_if_not_found=False)
try:
load_model(
context,
@ -53,23 +72,41 @@ def load_default_models(context: Context):
scan_model=context.model_paths[model_type] != None
and not context.model_paths[model_type].endswith(".safetensors"),
)
if model_type in context.model_load_errors:
del context.model_load_errors[model_type]
except Exception as e:
log.error(f"[red]Error while loading {model_type} model: {context.model_paths[model_type]}[/red]")
log.exception(e)
if "DefaultCPUAllocator: not enough memory" in str(e):
log.error(
f"[red]Your PC is low on system RAM. Please add some virtual memory (or swap space) by following the instructions at this link: https://www.ibm.com/docs/en/opw/8.2.0?topic=tuning-optional-increasing-paging-file-size-windows-computers[/red]"
)
else:
log.exception(e)
del context.model_paths[model_type]
context.model_load_errors[model_type] = str(e) # storing the entire Exception can lead to memory leaks
def unload_all(context: Context):
for model_type in KNOWN_MODEL_TYPES:
unload_model(context, model_type)
if model_type in context.model_load_errors:
del context.model_load_errors[model_type]
def resolve_model_to_use(model_name: str = None, model_type: str = None):
def resolve_model_to_use(model_name: Union[str, list] = None, model_type: str = None, fail_if_not_found: bool = True):
model_names = model_name if isinstance(model_name, list) else [model_name]
model_paths = [resolve_model_to_use_single(m, model_type, fail_if_not_found) for m in model_names]
return model_paths[0] if len(model_paths) == 1 else model_paths
def resolve_model_to_use_single(model_name: str = None, model_type: str = None, fail_if_not_found: bool = True):
model_extensions = MODEL_EXTENSIONS.get(model_type, [])
default_models = DEFAULT_MODELS.get(model_type, [])
config = app.getConfig()
model_dirs = [os.path.join(app.MODELS_DIR, model_type), app.SD_DIR]
model_dir = os.path.join(app.MODELS_DIR, model_type)
if not model_name: # When None try user configured model.
# config = getConfig()
if "model" in config and model_type in config["model"]:
@ -77,42 +114,42 @@ def resolve_model_to_use(model_name: str = None, model_type: str = None):
if model_name:
# Check models directory
models_dir_path = os.path.join(app.MODELS_DIR, model_type, model_name)
model_path = os.path.join(model_dir, model_name)
if os.path.exists(model_path):
return model_path
for model_extension in model_extensions:
if os.path.exists(models_dir_path + model_extension):
return models_dir_path + model_extension
if os.path.exists(model_path + model_extension):
return model_path + model_extension
if os.path.exists(model_name + model_extension):
return os.path.abspath(model_name + model_extension)
# Default locations
if model_name in default_models:
default_model_path = os.path.join(app.SD_DIR, model_name)
for model_extension in model_extensions:
if os.path.exists(default_model_path + model_extension):
return default_model_path + model_extension
# Can't find requested model, check the default paths.
for default_model in default_models:
for model_dir in model_dirs:
default_model_path = os.path.join(model_dir, default_model)
for model_extension in model_extensions:
if os.path.exists(default_model_path + model_extension):
if model_name is not None:
log.warn(
f"Could not find the configured custom model {model_name}{model_extension}. Using the default one: {default_model_path}{model_extension}"
)
return default_model_path + model_extension
if model_type == "stable-diffusion" and not fail_if_not_found:
for default_model in default_models:
default_model_path = os.path.join(model_dir, default_model["file_name"])
if os.path.exists(default_model_path):
if model_name is not None:
log.warn(
f"Could not find the configured custom model {model_name}. Using the default one: {default_model_path}"
)
return default_model_path
return None
if model_name and fail_if_not_found:
raise Exception(f"Could not find the desired model {model_name}! Is it present in the {model_dir} folder?")
def reload_models_if_necessary(context: Context, task_data: TaskData):
face_fix_lower = task_data.use_face_correction.lower() if task_data.use_face_correction else ""
upscale_lower = task_data.use_upscale.lower() if task_data.use_upscale else ""
model_paths_in_req = {
"stable-diffusion": task_data.use_stable_diffusion_model,
"vae": task_data.use_vae_model,
"hypernetwork": task_data.use_hypernetwork_model,
"gfpgan": task_data.use_face_correction,
"realesrgan": task_data.use_upscale,
"codeformer": task_data.use_face_correction if "codeformer" in face_fix_lower else None,
"gfpgan": task_data.use_face_correction if "gfpgan" in face_fix_lower else None,
"realesrgan": task_data.use_upscale if "realesrgan" in upscale_lower else None,
"latent_upscaler": True if "latent_upscaler" in upscale_lower else None,
"nsfw_checker": True if task_data.block_nsfw else None,
"lora": task_data.use_lora_model,
}
@ -122,6 +159,13 @@ def reload_models_if_necessary(context: Context, task_data: TaskData):
if context.model_paths.get(model_type) != path
}
if task_data.codeformer_upscale_faces:
if "realesrgan" not in models_to_reload and "realesrgan" not in context.models:
default_realesrgan = DEFAULT_MODELS["realesrgan"][0]["file_name"]
models_to_reload["realesrgan"] = resolve_model_to_use(default_realesrgan, "realesrgan")
elif "realesrgan" in models_to_reload and models_to_reload["realesrgan"] is None:
del models_to_reload["realesrgan"] # don't unload realesrgan
if set_vram_optimizations(context) or set_clip_skip(context, task_data): # reload SD
models_to_reload["stable-diffusion"] = model_paths_in_req["stable-diffusion"]
@ -129,7 +173,14 @@ def reload_models_if_necessary(context: Context, task_data: TaskData):
context.model_paths[model_type] = model_path_in_req
action_fn = unload_model if context.model_paths[model_type] is None else load_model
action_fn(context, model_type, scan_model=False) # we've scanned them already
try:
action_fn(context, model_type, scan_model=False) # we've scanned them already
if model_type in context.model_load_errors:
del context.model_load_errors[model_type]
except Exception as e:
log.exception(e)
if action_fn == load_model:
context.model_load_errors[model_type] = str(e) # storing the entire Exception can lead to memory leaks
def resolve_model_paths(task_data: TaskData):
@ -141,11 +192,49 @@ def resolve_model_paths(task_data: TaskData):
task_data.use_lora_model = resolve_model_to_use(task_data.use_lora_model, model_type="lora")
if task_data.use_face_correction:
task_data.use_face_correction = resolve_model_to_use(task_data.use_face_correction, "gfpgan")
if task_data.use_upscale:
if "gfpgan" in task_data.use_face_correction.lower():
model_type = "gfpgan"
elif "codeformer" in task_data.use_face_correction.lower():
model_type = "codeformer"
download_if_necessary("codeformer", "codeformer.pth", "codeformer-0.1.0")
task_data.use_face_correction = resolve_model_to_use(task_data.use_face_correction, model_type)
if task_data.use_upscale and "realesrgan" in task_data.use_upscale.lower():
task_data.use_upscale = resolve_model_to_use(task_data.use_upscale, "realesrgan")
def fail_if_models_did_not_load(context: Context):
for model_type in KNOWN_MODEL_TYPES:
if model_type in context.model_load_errors:
e = context.model_load_errors[model_type]
raise Exception(f"Could not load the {model_type} model! Reason: " + e)
def download_default_models_if_necessary():
for model_type, models in DEFAULT_MODELS.items():
for model in models:
try:
download_if_necessary(model_type, model["file_name"], model["model_id"])
except:
traceback.print_exc()
app.fail_and_die(fail_type="model_download", data=model_type)
print(model_type, "model(s) found.")
def download_if_necessary(model_type: str, file_name: str, model_id: str):
model_path = os.path.join(app.MODELS_DIR, model_type, file_name)
expected_hash = get_model_info_from_db(model_type=model_type, model_id=model_id)["quick_hash"]
other_models_exist = any_model_exists(model_type)
known_model_exists = os.path.exists(model_path)
known_model_is_corrupt = known_model_exists and hash_file_quick(model_path) != expected_hash
if known_model_is_corrupt or (not other_models_exist and not known_model_exists):
print("> download", model_type, model_id)
download_model(model_type, model_id, download_base_dir=app.MODELS_DIR)
def set_vram_optimizations(context: Context):
config = app.getConfig()
vram_usage_level = config.get("vram_usage_level", "balanced")
@ -157,6 +246,26 @@ def set_vram_optimizations(context: Context):
return False
def migrate_legacy_model_location():
'Move the models inside the legacy "stable-diffusion" folder, to their respective folders'
for model_type, models in DEFAULT_MODELS.items():
for model in models:
file_name = model["file_name"]
legacy_path = os.path.join(app.SD_DIR, file_name)
if os.path.exists(legacy_path):
shutil.move(legacy_path, os.path.join(app.MODELS_DIR, model_type, file_name))
def any_model_exists(model_type: str) -> bool:
extensions = MODEL_EXTENSIONS.get(model_type, [])
for ext in extensions:
if any(glob(f"{app.MODELS_DIR}/{model_type}/**/*{ext}", recursive=True)):
return True
return False
def set_clip_skip(context: Context, task_data: TaskData):
clip_skip = task_data.clip_skip
@ -212,19 +321,15 @@ def is_malicious_model(file_path):
return False
def getModels():
def getModels(scan_for_malicious: bool = True):
models = {
"active": {
"stable-diffusion": "sd-v1-4",
"vae": "",
"hypernetwork": "",
"lora": "",
},
"options": {
"stable-diffusion": ["sd-v1-4"],
"vae": [],
"hypernetwork": [],
"lora": [],
"codeformer": ["codeformer"],
"embeddings": [],
},
}
@ -250,9 +355,10 @@ def getModels():
mod_time = known_models[entry.path] if entry.path in known_models else -1
if mod_time != mtime:
models_scanned += 1
if is_malicious_model(entry.path):
if scan_for_malicious and is_malicious_model(entry.path):
raise MaliciousModelException(entry.path)
known_models[entry.path] = mtime
if scan_for_malicious:
known_models[entry.path] = mtime
tree.append(entry.name[: -len(matching_suffix)])
elif entry.is_dir():
scan = scan_directory(entry.path, suffixes, directoriesFirst=False)
@ -272,22 +378,19 @@ def getModels():
try:
models["options"][model_type] = scan_directory(models_dir, model_extensions)
except MaliciousModelException as e:
models["scan-error"] = e
models["scan-error"] = str(e)
log.info(f"[green]Scanning all model folders for models...[/]")
if scan_for_malicious:
log.info(f"[green]Scanning all model folders for models...[/]")
# custom models
listModels(model_type="stable-diffusion")
listModels(model_type="vae")
listModels(model_type="hypernetwork")
listModels(model_type="gfpgan")
listModels(model_type="lora")
listModels(model_type="embeddings")
if models_scanned > 0:
if scan_for_malicious and models_scanned > 0:
log.info(f"[green]Scanned {models_scanned} models. Nothing infected[/]")
# legacy
custom_weight_path = os.path.join(app.SD_DIR, "custom-model.ckpt")
if os.path.exists(custom_weight_path):
models["options"]["stable-diffusion"].append("custom-model")
return models

View File

@ -7,10 +7,12 @@ from easydiffusion import device_manager
from easydiffusion.types import GenerateImageRequest
from easydiffusion.types import Image as ResponseImage
from easydiffusion.types import Response, TaskData, UserInitiatedStop
from easydiffusion.model_manager import DEFAULT_MODELS, resolve_model_to_use
from easydiffusion.utils import get_printable_request, log, save_images_to_disk
from sdkit import Context
from sdkit.filter import apply_filters
from sdkit.generate import generate_images
from sdkit.models import load_model
from sdkit.utils import (
diffusers_latent_samples_to_images,
gc,
@ -33,6 +35,8 @@ def init(device):
context.stop_processing = False
context.temp_images = {}
context.partial_x_samples = None
context.model_load_errors = {}
context.enable_codeformer = True
from easydiffusion import app
@ -95,7 +99,7 @@ def make_images_internal(
task_data.stream_image_progress_interval,
)
gc(context)
filtered_images = filter_images(task_data, images, user_stopped)
filtered_images = filter_images(req, task_data, images, user_stopped)
if task_data.save_to_disk_path is not None:
save_images_to_disk(images, filtered_images, req, task_data)
@ -151,22 +155,55 @@ def generate_images_internal(
return images, user_stopped
def filter_images(task_data: TaskData, images: list, user_stopped):
def filter_images(req: GenerateImageRequest, task_data: TaskData, images: list, user_stopped):
if user_stopped:
return images
filters_to_apply = []
if task_data.block_nsfw:
filters_to_apply.append("nsfw_checker")
if task_data.use_face_correction and "gfpgan" in task_data.use_face_correction.lower():
filters_to_apply.append("gfpgan")
if task_data.use_upscale and "realesrgan" in task_data.use_upscale.lower():
filters_to_apply.append("realesrgan")
images = apply_filters(context, "nsfw_checker", images)
if len(filters_to_apply) == 0:
return images
if task_data.use_face_correction and "codeformer" in task_data.use_face_correction.lower():
default_realesrgan = DEFAULT_MODELS["realesrgan"][0]["file_name"]
prev_realesrgan_path = None
if task_data.codeformer_upscale_faces and default_realesrgan not in context.model_paths["realesrgan"]:
prev_realesrgan_path = context.model_paths["realesrgan"]
context.model_paths["realesrgan"] = resolve_model_to_use(default_realesrgan, "realesrgan")
load_model(context, "realesrgan")
return apply_filters(context, filters_to_apply, images, scale=task_data.upscale_amount)
try:
images = apply_filters(
context,
"codeformer",
images,
upscale_faces=task_data.codeformer_upscale_faces,
codeformer_fidelity=task_data.codeformer_fidelity,
)
finally:
if prev_realesrgan_path:
context.model_paths["realesrgan"] = prev_realesrgan_path
load_model(context, "realesrgan")
elif task_data.use_face_correction and "gfpgan" in task_data.use_face_correction.lower():
images = apply_filters(context, "gfpgan", images)
if task_data.use_upscale:
if "realesrgan" in task_data.use_upscale.lower():
images = apply_filters(context, "realesrgan", images, scale=task_data.upscale_amount)
elif task_data.use_upscale == "latent_upscaler":
images = apply_filters(
context,
"latent_upscaler",
images,
scale=task_data.upscale_amount,
latent_upscaler_options={
"prompt": req.prompt,
"negative_prompt": req.negative_prompt,
"seed": req.seed,
"num_inference_steps": task_data.latent_upscaler_steps,
"guidance_scale": 0,
},
)
return images
def construct_response(images: list, seeds: list, task_data: TaskData, base_seed: int):

View File

@ -15,6 +15,7 @@ from fastapi import FastAPI, HTTPException
from fastapi.staticfiles import StaticFiles
from pydantic import BaseModel, Extra
from starlette.responses import FileResponse, JSONResponse, StreamingResponse
from pycloudflared import try_cloudflare
log.info(f"started in {app.SD_DIR}")
log.info(f"started at {datetime.datetime.now():%x %X}")
@ -85,8 +86,8 @@ def init():
return set_app_config_internal(req)
@server_api.get("/get/{key:path}")
def read_web_data(key: str = None):
return read_web_data_internal(key)
def read_web_data(key: str = None, scan_for_malicious: bool = True):
return read_web_data_internal(key, scan_for_malicious=scan_for_malicious)
@server_api.get("/ping") # Get server and optionally session status.
def ping(session_id: str = None):
@ -113,6 +114,14 @@ def init():
def get_image(task_id: int, img_id: int):
return get_image_internal(task_id, img_id)
@server_api.post("/tunnel/cloudflare/start")
def start_cloudflare_tunnel(req: dict):
return start_cloudflare_tunnel_internal(req)
@server_api.post("/tunnel/cloudflare/stop")
def stop_cloudflare_tunnel(req: dict):
return stop_cloudflare_tunnel_internal(req)
@server_api.get("/")
def read_root():
return FileResponse(os.path.join(app.SD_UI_DIR, "index.html"), headers=NOCACHE_HEADERS)
@ -170,7 +179,7 @@ def update_render_devices_in_config(config, render_devices):
config["render_devices"] = render_devices
def read_web_data_internal(key: str = None):
def read_web_data_internal(key: str = None, **kwargs):
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
elif key == "app_config":
@ -189,7 +198,8 @@ def read_web_data_internal(key: str = None):
system_info["devices"]["config"] = config.get("render_devices", "auto")
return JSONResponse(system_info, headers=NOCACHE_HEADERS)
elif key == "models":
return JSONResponse(model_manager.getModels(), headers=NOCACHE_HEADERS)
scan_for_malicious = kwargs.get("scan_for_malicious", True)
return JSONResponse(model_manager.getModels(scan_for_malicious), headers=NOCACHE_HEADERS)
elif key == "modifiers":
return JSONResponse(app.get_image_modifiers(), headers=NOCACHE_HEADERS)
elif key == "ui_plugins":
@ -211,6 +221,8 @@ def ping_internal(session_id: str = None):
session = task_manager.get_cached_session(session_id, update_ttl=True)
response["tasks"] = {id(t): t.status for t in session.tasks}
response["devices"] = task_manager.get_devices()
if cloudflare.address != None:
response["cloudflare"] = cloudflare.address
return JSONResponse(response, headers=NOCACHE_HEADERS)
@ -322,3 +334,50 @@ def get_image_internal(task_id: int, img_id: int):
return StreamingResponse(img_data, media_type="image/jpeg")
except KeyError as e:
raise HTTPException(status_code=500, detail=str(e))
# ---- Cloudflare Tunnel ----
class CloudflareTunnel:
def __init__(self):
config = app.getConfig()
self.urls = None
self.port = config.get("net", {}).get("listen_port")
def start(self):
if self.port:
self.urls = try_cloudflare(self.port)
def stop(self):
if self.urls:
try_cloudflare.terminate(self.port)
self.urls = None
@property
def address(self):
if self.urls:
return self.urls.tunnel
else:
return None
cloudflare = CloudflareTunnel()
def start_cloudflare_tunnel_internal(req: dict):
try:
cloudflare.start()
log.info(f"- Started cloudflare tunnel. Using address: {cloudflare.address}")
return JSONResponse({"address": cloudflare.address})
except Exception as e:
log.error(str(e))
log.error(traceback.format_exc())
return HTTPException(status_code=500, detail=str(e))
def stop_cloudflare_tunnel_internal(req: dict):
try:
cloudflare.stop()
except Exception as e:
log.error(str(e))
log.error(traceback.format_exc())
return HTTPException(status_code=500, detail=str(e))

View File

@ -336,6 +336,7 @@ def thread_render(device):
current_state = ServerStates.LoadingModel
model_manager.resolve_model_paths(task.task_data)
model_manager.reload_models_if_necessary(renderer.context, task.task_data)
model_manager.fail_if_models_did_not_load(renderer.context)
current_state = ServerStates.Rendering
task.response = renderer.make_images(

View File

@ -1,4 +1,4 @@
from typing import Any
from typing import Any, List, Union
from pydantic import BaseModel
@ -22,7 +22,8 @@ class GenerateImageRequest(BaseModel):
sampler_name: str = None # "ddim", "plms", "heun", "euler", "euler_a", "dpm2", "dpm2_a", "lms"
hypernetwork_strength: float = 0
lora_alpha: float = 0
lora_alpha: Union[float, List[float]] = 0
tiling: str = "none" # "none", "x", "y", "xy"
class TaskData(BaseModel):
@ -31,14 +32,14 @@ class TaskData(BaseModel):
save_to_disk_path: str = None
vram_usage_level: str = "balanced" # or "low" or "medium"
use_face_correction: str = None # or "GFPGANv1.3"
use_upscale: str = None # or "RealESRGAN_x4plus" or "RealESRGAN_x4plus_anime_6B"
use_face_correction: Union[str, List[str]] = None # or "GFPGANv1.3"
use_upscale: Union[str, List[str]] = None
upscale_amount: int = 4 # or 2
use_stable_diffusion_model: str = "sd-v1-4"
# use_stable_diffusion_config: str = "v1-inference"
use_vae_model: str = None
use_hypernetwork_model: str = None
use_lora_model: str = None
latent_upscaler_steps: int = 10
use_stable_diffusion_model: Union[str, List[str]] = "sd-v1-4"
use_vae_model: Union[str, List[str]] = None
use_hypernetwork_model: Union[str, List[str]] = None
use_lora_model: Union[str, List[str]] = None
show_only_filtered_image: bool = False
block_nsfw: bool = False
@ -49,6 +50,8 @@ class TaskData(BaseModel):
stream_image_progress: bool = False
stream_image_progress_interval: int = 5
clip_skip: bool = False
codeformer_upscale_faces: bool = False
codeformer_fidelity: float = 0.5
class MergeRequest(BaseModel):

View File

@ -1,6 +1,8 @@
import os
import re
import time
import regex
from datetime import datetime
from functools import reduce
@ -30,9 +32,12 @@ TASK_TEXT_MAPPING = {
"lora_alpha": "LoRA Strength",
"use_hypernetwork_model": "Hypernetwork model",
"hypernetwork_strength": "Hypernetwork Strength",
"use_embedding_models": "Embedding models",
"tiling": "Seamless Tiling",
"use_face_correction": "Use Face Correction",
"use_upscale": "Use Upscaling",
"upscale_amount": "Upscale By",
"latent_upscaler_steps": "Latent Upscaler Steps",
}
time_placeholders = {
@ -169,23 +174,32 @@ def save_images_to_disk(images: list, filtered_images: list, req: GenerateImageR
output_quality=task_data.output_quality,
output_lossless=task_data.output_lossless,
)
if task_data.metadata_output_format.lower() in ["json", "txt", "embed"]:
save_dicts(
metadata_entries,
save_dir_path,
file_name=make_filter_filename,
output_format=task_data.metadata_output_format,
file_format=task_data.output_format,
)
if task_data.metadata_output_format:
for metadata_output_format in task_data.metadata_output_format.split(","):
if metadata_output_format.lower() in ["json", "txt", "embed"]:
save_dicts(
metadata_entries,
save_dir_path,
file_name=make_filter_filename,
output_format=task_data.metadata_output_format,
file_format=task_data.output_format,
)
def get_metadata_entries_for_request(req: GenerateImageRequest, task_data: TaskData):
metadata = get_printable_request(req, task_data)
# if text, format it in the text format expected by the UI
is_txt_format = task_data.metadata_output_format.lower() == "txt"
is_txt_format = task_data.metadata_output_format and "txt" in task_data.metadata_output_format.lower().split(",")
if is_txt_format:
metadata = {TASK_TEXT_MAPPING[key]: val for key, val in metadata.items() if key in TASK_TEXT_MAPPING}
def format_value(value):
if isinstance(value, list):
return ", ".join([ str(it) for it in value ])
return value
metadata = {
TASK_TEXT_MAPPING[key]: format_value(val) for key, val in metadata.items() if key in TASK_TEXT_MAPPING
}
entries = [metadata.copy() for _ in range(req.num_outputs)]
for i, entry in enumerate(entries):
@ -198,6 +212,9 @@ def get_printable_request(req: GenerateImageRequest, task_data: TaskData):
req_metadata = req.dict()
task_data_metadata = task_data.dict()
app_config = app.getConfig()
using_diffusers = app_config.get("test_diffusers", False)
# Save the metadata in the order defined in TASK_TEXT_MAPPING
metadata = {}
for key in TASK_TEXT_MAPPING.keys():
@ -205,6 +222,24 @@ def get_printable_request(req: GenerateImageRequest, task_data: TaskData):
metadata[key] = req_metadata[key]
elif key in task_data_metadata:
metadata[key] = task_data_metadata[key]
elif key == "use_embedding_models" and using_diffusers:
embeddings_extensions = {".pt", ".bin", ".safetensors"}
def scan_directory(directory_path: str):
used_embeddings = []
for entry in os.scandir(directory_path):
if entry.is_file():
entry_extension = os.path.splitext(entry.name)[1]
if entry_extension not in embeddings_extensions:
continue
embedding_name_regex = regex.compile(r"(^|[\s,])" + regex.escape(os.path.splitext(entry.name)[0]) + 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_embedding_models"] = used_embeddings if len(used_embeddings) > 0 else None
# Clean up the metadata
if req.init_image is None and "prompt_strength" in metadata:
@ -215,10 +250,11 @@ def get_printable_request(req: GenerateImageRequest, task_data: TaskData):
del metadata["hypernetwork_strength"]
if task_data.use_lora_model is None and "lora_alpha" in metadata:
del metadata["lora_alpha"]
if task_data.use_upscale != "latent_upscaler" and "latent_upscaler_steps" in metadata:
del metadata["latent_upscaler_steps"]
app_config = app.getConfig()
if not app_config.get("test_diffusers", False):
for key in (x for x in ["use_lora_model", "lora_alpha", "clip_skip"] if x in metadata):
if not using_diffusers:
for key in (x for x in ["use_lora_model", "lora_alpha", "clip_skip", "tiling", "latent_upscaler_steps"] if x in metadata):
del metadata[key]
return metadata

View File

@ -16,6 +16,7 @@
<link rel="stylesheet" href="/media/css/image-editor.css">
<link rel="stylesheet" href="/media/css/searchable-models.css">
<link rel="stylesheet" href="/media/css/image-modal.css">
<link rel="stylesheet" href="/media/css/plugins.css">
<link rel="manifest" href="/media/manifest.webmanifest">
<script src="/media/js/jquery-3.6.1.min.js"></script>
<script src="/media/js/jquery-confirm.min.js"></script>
@ -30,7 +31,7 @@
<h1>
<img id="logo_img" src="/media/images/icon-512x512.png" >
Easy Diffusion
<small>v2.5.37 <span id="updateBranchLabel"></span></small>
<small><span id="version">v2.5.46</span> <span id="updateBranchLabel"></span></small>
</h1>
</div>
<div id="server-status">
@ -55,14 +56,23 @@
<div id="editor">
<div id="editor-inputs">
<div id="editor-inputs-prompt" class="row">
<label for="prompt"><b>Enter Prompt</b></label> <small>or</small> <button id="promptsFromFileBtn" class="tertiaryButton">Load from a file</button>
<div id="prompt-toolbar" class="split-toolbar">
<div id="prompt-toolbar-left" class="toolbar-left">
<label for="prompt"><b>Enter Prompt</b></label> <small>or</small> <button id="promptsFromFileBtn" class="tertiaryButton smallButton">Load from a file</button>
</div>
<div id="prompt-toolbar-right" class="toolbar-right">
<button id="image-modifier-dropdown" class="tertiaryButton smallButton">+ Image Modifiers</button>
<button id="embeddings-button" class="tertiaryButton smallButton displayNone">+ Embedding</button>
</div>
</div>
<textarea id="prompt" class="col-free">a photograph of an astronaut riding a horse</textarea>
<input id="prompt_from_file" name="prompt_from_file" type="file" /> <!-- hidden -->
<label for="negative_prompt" class="collapsible" id="negative_prompt_handle">
Negative Prompt
<a href="https://github.com/cmdr2/stable-diffusion-ui/wiki/Writing-prompts#negative-prompts" target="_blank"><i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top">Click to learn more about Negative Prompts</span></i></a>
<a href="https://github.com/easydiffusion/easydiffusion/wiki/Writing-prompts#negative-prompts" target="_blank"><i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top">Click to learn more about Negative Prompts</span></i></a>
<small>(optional)</small>
</label>
<button id="negative-embeddings-button" class="tertiaryButton smallButton displayNone">+ Embedding</button>
<div class="collapsible-content">
<textarea id="negative_prompt" name="negative_prompt" placeholder="list the things to remove from the image (e.g. fog, green)"></textarea>
</div>
@ -73,7 +83,7 @@
<div id="init_image_preview_container" class="image_preview_container">
<div id="init_image_wrapper">
<img id="init_image_preview" src="" />
<img id="init_image_preview" src="" crossorigin="anonymous" />
<span id="init_image_size_box" class="img_bottom_label"></span>
<button class="init_image_clear image_clear_btn"><i class="fa-solid fa-xmark"></i></button>
</div>
@ -102,7 +112,7 @@
</div>
<div id="editor-inputs-tags-container" class="row">
<label>Image Modifiers <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip right">click an Image Modifier to remove it, right-click to temporarily disable it, use Ctrl+Mouse Wheel to adjust its weight</span></i></label>
<label>Image Modifiers <i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip right">Click an Image Modifier to remove it, right-click to temporarily disable it, use Ctrl+Mouse Wheel to adjust its weight</span></i></label>
<div id="editor-inputs-tags-list"></div>
</div>
@ -133,18 +143,18 @@
<tr class="pl-5"><td><label for="stable_diffusion_model">Model:</label></td><td class="model-input">
<input id="stable_diffusion_model" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
<button id="reload-models" class="secondaryButton reloadModels"><i class='fa-solid fa-rotate'></i></button>
<a href="https://github.com/cmdr2/stable-diffusion-ui/wiki/Custom-Models" target="_blank"><i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Click to learn more about custom models</span></i></a>
<a href="https://github.com/easydiffusion/easydiffusion/wiki/Custom-Models" target="_blank"><i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Click to learn more about custom models</span></i></a>
</td></tr>
<tr class="pl-5 displayNone" id="clip_skip_config">
<td><label for="clip_skip">Clip Skip:</label></td>
<td>
<td class="diffusers-restart-needed">
<input id="clip_skip" name="clip_skip" type="checkbox">
<a href="https://github.com/cmdr2/stable-diffusion-ui/wiki/Clip-Skip" target="_blank"><i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Click to learn more about Clip Skip</span></i></a>
<a href="https://github.com/easydiffusion/easydiffusion/wiki/Clip-Skip" target="_blank"><i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Click to learn more about Clip Skip</span></i></a>
</td>
</tr>
<tr class="pl-5"><td><label for="vae_model">Custom VAE:</label></td><td>
<input id="vae_model" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
<a href="https://github.com/cmdr2/stable-diffusion-ui/wiki/VAE-Variational-Auto-Encoder" target="_blank"><i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Click to learn more about VAEs</span></i></a>
<a href="https://github.com/easydiffusion/easydiffusion/wiki/VAE-Variational-Auto-Encoder" target="_blank"><i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Click to learn more about VAEs</span></i></a>
</td></tr>
<tr id="samplerSelection" class="pl-5"><td><label for="sampler_name">Sampler:</label></td><td>
<select id="sampler_name" name="sampler_name">
@ -157,20 +167,20 @@
<option value="dpm2_a">DPM2 Ancestral</option>
<option value="lms">LMS</option>
<option value="dpm_solver_stability">DPM Solver (Stability AI)</option>
<option value="dpmpp_2s_a" class="k_diffusion-only">DPM++ 2s Ancestral (Karras)</option>
<option value="dpmpp_2s_a">DPM++ 2s Ancestral (Karras)</option>
<option value="dpmpp_2m">DPM++ 2m (Karras)</option>
<option value="dpmpp_sde" class="k_diffusion-only">DPM++ SDE (Karras)</option>
<option value="dpm_fast" class="k_diffusion-only">DPM Fast (Karras)</option>
<option value="dpmpp_2m_sde" class="diffusers-only">DPM++ 2m SDE (Karras)</option>
<option value="dpmpp_sde">DPM++ SDE (Karras)</option>
<option value="dpm_adaptive" class="k_diffusion-only">DPM Adaptive (Karras)</option>
<option value="ddpm" class="diffusers-only">DDPM</option>
<option value="deis" class="diffusers-only">DEIS</option>
<option value="unipc_snr" class="k_diffusion-only">UniPC SNR</option>
<option value="unipc_tu">UniPC TU</option>
<option value="unipc_snr_2" class="k_diffusion-only">UniPC SNR 2</option>
<option value="unipc_tu_2">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>
</select>
<a href="https://github.com/cmdr2/stable-diffusion-ui/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/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>
</td></tr>
<tr class="pl-5"><td><label>Image Size: </label></td><td>
<select id="width" name="width" value="512">
@ -219,15 +229,17 @@
<label for="height"><small>(height)</small></label>
<div id="small_image_warning" class="displayNone">Small image sizes can cause bad image quality</div>
</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" size="4" 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)"></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 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="lora_model_container" class="pl-5"><td><label for="lora_model">LoRA:</label></td><td>
<input id="lora_model" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
</td></tr>
<tr id="lora_alpha_container" class="pl-5">
<td><label for="lora_alpha_slider">LoRA Strength:</label></td>
<td> <input id="lora_alpha_slider" name="lora_alpha_slider" class="editor-slider" value="50" type="range" min="0" max="100"> <input id="lora_alpha" name="lora_alpha" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)"><br/></td>
<tr id="lora_model_container" class="pl-5">
<td>
<label for="lora_model">LoRA:</label>
</td>
<td class="diffusers-restart-needed">
<div class="model_entries"></div>
<button class="add_model_entry"><i class="fa-solid fa-plus"></i> add another LoRA</button>
</td>
</tr>
<tr class="pl-5"><td><label for="hypernetwork_model">Hypernetwork:</label></td><td>
<input id="hypernetwork_model" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
@ -236,6 +248,18 @@
<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>
</tr>
<tr id="tiling_container" class="pl-5">
<td><label for="tiling">Seamless Tiling:</label></td>
<td class="diffusers-restart-needed">
<select id="tiling" name="tiling">
<option value="none" selected>None</option>
<option value="x">Horizontal</option>
<option value="y">Vertical</option>
<option value="xy">Both</option>
</select>
<a href="https://github.com/easydiffusion/easydiffusion/wiki/Seamless-Tiling" target="_blank"><i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Click to learn more about Seamless Tiling</span></i></a>
</td>
</tr>
<tr class="pl-5"><td><label for="output_format">Output Format:</label></td><td>
<select id="output_format" name="output_format">
<option value="jpeg" selected>jpeg</option>
@ -254,46 +278,35 @@
<div><ul>
<li><b class="settings-subheader">Render Settings</b></li>
<li class="pl-5"><input id="stream_image_progress" name="stream_image_progress" type="checkbox"> <label for="stream_image_progress">Show a live preview <small>(uses more VRAM, slower images)</small></label></li>
<li class="pl-5"><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></li>
<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>
<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_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>
</li>
<li class="pl-5">
<input id="use_upscale" name="use_upscale" type="checkbox"> <label for="use_upscale">Scale up by</label>
<select id="upscale_amount" name="upscale_amount">
<option value="2">2x</option>
<option value="4" selected>4x</option>
<option id="upscale_amount_2x" value="2">2x</option>
<option id="upscale_amount_4x" value="4" selected>4x</option>
</select>
with
<select id="upscale_model" name="upscale_model">
<option value="RealESRGAN_x4plus" selected>RealESRGAN_x4plus</option>
<option value="RealESRGAN_x4plus_anime_6B">RealESRGAN_x4plus_anime_6B</option>
<option value="latent_upscaler">Latent Upscaler 2x</option>
</select>
<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>
</table>
</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>
</ul></div>
</div>
</div>
<div id="editor-modifiers" class="panel-box">
<h4 class="collapsible">
Image Modifiers (art styles, tags etc)
<i id="modifier-settings-btn" class="fa-solid fa-gear section-button">
<span class="simple-tooltip left">
Add Custom Modifiers
</span>
</i>
</h4>
<div id="editor-modifiers-entries" class="collapsible-content">
<div id="editor-modifiers-entries-toolbar">
<label for="preview-image">Image Style:</label>
<select id="preview-image" name="preview-image" value="portrait">
<option value="portrait" selected="">Face</option>
<option value="landscape">Landscape</option>
</select>
&nbsp;
<label for="modifier-card-size-slider">Thumbnail Size:</label>
<input id="modifier-card-size-slider" name="modifier-card-size-slider" value="0" type="range" min="-3" max="5">
</div>
</div>
</div>
<label><small><b>Note:</b> The Image Modifiers section has moved to the <code>+ Image Modifiers</code> button at the top, just below the Prompt textbox.</small></label>
</div>
<div id="preview" class="col-free">
@ -343,10 +356,16 @@
<div id="tab-content-settings" class="tab-content">
<div id="system-settings" class="tab-content-inner">
<h1>System Settings</h1>
<div class="parameters-table"></div>
<div class="parameters-table" id="system-settings-table"></div>
<br/>
<button id="save-system-settings-btn" class="primaryButton">Save</button>
<br/><br/>
<div id="share-easy-diffusion">
<h3><i class="fa fa-user-group"></i> Share Easy Diffusion</h3>
<div class="parameters-table" id="system-settings-network-table">
</div>
</div>
<br/><br/>
<div>
<h3><i class="fa fa-microchip icon"></i> System Info</h3>
<div id="system-info">
@ -370,23 +389,23 @@
<ul id="help-links">
<li><span class="help-section">Using the software</span>
<ul>
<li> <a href="https://github.com/cmdr2/stable-diffusion-ui/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/cmdr2/stable-diffusion-ui/wiki/UI-Overview" target="_blank"><i class="fa-solid fa-list fa-fw"></i> UI Overview</a>
<li> <a href="https://github.com/cmdr2/stable-diffusion-ui/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/cmdr2/stable-diffusion-ui/wiki/Inpainting" target="_blank"><i class="fa-solid fa-paintbrush fa-fw"></i> Inpainting</a>
<li> <a href="https://github.com/cmdr2/stable-diffusion-ui/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/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/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"><i class="fa-solid fa-pen-to-square fa-fw"></i> Writing prompts</a>
<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/Run-on-Multiple-GPUs" target="_blank"><i class="fa-solid fa-paintbrush fa-fw"></i> Run on Multiple GPUs</a>
</ul>
<li><span class="help-section">Installation</span>
<ul>
<li> <a href="https://github.com/cmdr2/stable-diffusion-ui/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/Troubleshooting" target="_blank"><i class="fa-solid fa-circle-question fa-fw"></i> Troubleshooting</a>
</ul>
<li><span class="help-section">Downloadable Content</span>
<ul>
<li> <a href="https://github.com/cmdr2/stable-diffusion-ui/wiki/Custom-Models" target="_blank"><i class="fa-solid fa-images fa-fw"></i> Custom Models</a>
<li> <a href="https://github.com/cmdr2/stable-diffusion-ui/wiki/UI-Plugins" target="_blank"><i class="fa-solid fa-puzzle-piece fa-fw"></i> UI Plugins</a>
<li> <a href="https://github.com/cmdr2/stable-diffusion-ui/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-Models" target="_blank"><i class="fa-solid fa-images fa-fw"></i> Custom Models</a>
<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/VAE-Variational-Auto-Encoder" target="_blank"><i class="fa-solid fa-hand-sparkles fa-fw"></i> VAE Variational Auto Encoder</a>
</ul>
</ul>
</div>
@ -396,7 +415,7 @@
<ul id="community-links">
<li><a href="https://discord.com/invite/u9yhsFmEkB" target="_blank"><i class="fa-brands fa-discord fa-fw"></i> Discord user community</a></li>
<li><a href="https://www.reddit.com/r/StableDiffusionUI/" target="_blank"><i class="fa-brands fa-reddit fa-fw"></i> Reddit community</a></li>
<li><a href="https://github.com/cmdr2/stable-diffusion-ui" target="_blank"><i class="fa-brands fa-github fa-fw"></i> Source code on GitHub</a></li>
<li><a href="https://github.com/easydiffusion/easydiffusion" target="_blank"><i class="fa-brands fa-github fa-fw"></i> Source code on GitHub</a></li>
</ul>
</div>
</div>
@ -404,32 +423,85 @@
</div>
</div>
<div class="popup" id="download-images-popup">
<div class="popup" id="splash-screen" data-version="1">
<div>
<i class="close-button fa-solid fa-xmark"></i>
<h1>Download all images</h1>
<div class="parameters-table">
<div>
<div><i class="fa fa-file-zipper"></i></div>
<div><label for="theme">Download as a ZIP file</label><small>Instead of downloading individual files, generate one zip file with all images</small></div>
<div><div class="input-toggle"><input id="zip_toggle" name="zip_toggle" checked="" type="checkbox"><label for="zip_toggle"></label></div></div>
</div>
<div id="download-add-folders">
<div><i class="fa fa-folder-tree"></i></div>
<div><label for="theme">Add per-job folders</label><small>Place images into job folders</small></div>
<div><div class="input-toggle"><input id="tree_toggle" name="tree_toggle" checked="" type="checkbox"><label for="tree_toggle"></label></div></div>
</div>
<div>
<div><i class="fa fa-sliders"></i></div>
<div><label for="theme">Add metadata files</label><small>For each image, also download a JSON file with all the settings used to generate the image</small></div>
<div><div class="input-toggle"><input id="json_toggle" name="json_toggle" checked="" type="checkbox"><label for="json_toggle"></label></div></div>
</div>
</div>
<br/>
<button id="save-all-images" class="primaryButton"><i class="fa-solid fa-images"></i> Start download</button>
<img class="splash-img" src="/media/images/icon-512x512.png" width="128" height="128">
<h1>Diffusers Tech Preview</h1>
<p>The Diffusers Tech Preview allows early access to the new features based on <a href="https://huggingface.co/docs/diffusers/index" target="_blank">Diffusers</a>.</p>
<p>This is under active development, and is missing a few features. It is experimental! Please report any bugs to the #beta channel in our <a href="https://discord.gg/QUcNZufQNZ" target="_blank">Discord</a> server!</p>
<h2>New upcoming features in our new engine</h2>
<ul>
<li><a href="https://huggingface.co/blog/lora" target="_blank">LORA</a> support - Place LORA files in the <tt>models/lora</tt> folder.</li>
<li><a href="https://github.com/damian0815/compel/blob/main/Reference.md" target="_blank">Compel Prompt Parser</a> - New, more powerful parser. In short:
<ul>
<li> no limit to the length of prompts (i.e. long prompts are supported)</li>
<li> Use <tt>+</tt> and <tt>-</tt> to increase/decrease the weight. E.g. <tt>apple</tt>, <tt>apple+</tt>, <tt>apple++</tt>, <tt>apple+++</tt>,
or <tt>apple-</tt>, <tt>apple--</tt> for different weights.</li>
<li> Use exact weights - 0.0 to 1.0 reduces the weight, 1.0 to 2.0 increases the weight.
Think of it like a multiplier, like 1.5x or 0.5x: E.g. <tt>(apple)0.8 falling from a tree</tt>,
<tt>(apple)1.5 falling from a tree</tt>, <tt>(apple falling)1.4 from a tree</tt></li>
<li> You can group tokens together using parentheses/round-brackets. E.g. <tt>(apple falling)++
from a tree</tt>. Nested parentheses are supported.</li>
</ul>
This clarifies a few things:
<ul>
<li> colon (<tt>:</tt>) is NOT used for blending. Neither is it used for weights. It has no impact and
will be considered a part of the prompt.</li>
<li> <tt>(())</tt> and <tt>[]</tt> do not affect the prompt's weights.</li>
</ul>
</li>
<li> More choices for img2img samplers</li>
<li> Support for official inpainting models</li>
<li> Generate images that tile seamlessly</li>
<li> <a href="https://github.com/cmdr2/stable-diffusion-ui/wiki/Clip-Skip" target="_blank">Clip Skip</a> support allows to skip the last CLIP layer (recommended by some LORA models)</li>
<li> New samplers: DDPM and DEIS</li>
<li> Memory optimizations that allow the use of 2GB GPUs</li>
</ul>
<h2>Known issues</h2>
<ul>
<li> Some LoRA consistently fail to load in EasyDiffusion</li>
<li> Some LoRA are far more sensitive to alpha (compared to a11)</li>
<li> Hangs sometimes on "compel is ready", while making the token.</li>
<li> Some custom inpainting models don't work</li>
<li> These samplers don't work yet: Unipc SNR, Unipc TQ, Unipc SNR2, DPM++ 2s Ancestral, DPM++ SDE, DPM Fast, DPM Adaptive, DPM2</li>
<li> Hypernetwork doesn't work</li>
<li> The time remaining in browser differs from the one in the console</li>
</ul>
</div>
</div>
<dialog id="download-images-dialog">
<div class="dialog-header">
<div class="dialog-header-left">
<h4>Download all images</h4>
<span></span>
</div>
<div>
<i id="download-images-close-button" class="fa-solid fa-xmark fa-lg"></i>
</div>
</div>
<div class="parameters-table">
<div>
<div><i class="fa fa-file-zipper"></i></div>
<div><label for="theme">Download as a ZIP file</label><small>Instead of downloading individual files, generate one zip file with all images</small></div>
<div><div class="input-toggle"><input id="zip_toggle" name="zip_toggle" checked="" type="checkbox"><label for="zip_toggle"></label></div></div>
</div>
<div id="download-add-folders">
<div><i class="fa fa-folder-tree"></i></div>
<div><label for="theme">Add per-job folders</label><small>Place images into job folders</small></div>
<div><div class="input-toggle"><input id="tree_toggle" name="tree_toggle" checked="" type="checkbox"><label for="tree_toggle"></label></div></div>
</div>
<div>
<div><i class="fa fa-sliders"></i></div>
<div><label for="theme">Add metadata files</label><small>For each image, also download a JSON file with all the settings used to generate the image</small></div>
<div><div class="input-toggle"><input id="json_toggle" name="json_toggle" checked="" type="checkbox"><label for="json_toggle"></label></div></div>
</div>
</div>
<div class="center">
<button id="save-all-images" class="primaryButton"><i class="fa-solid fa-images"></i> Start download</button>
</div>
</dialog>
<div id="save-settings-config" class="popup">
<div>
<i class="close-button fa-solid fa-xmark"></i>
@ -440,16 +512,90 @@
</div>
</div>
<div id="modifier-settings-config" class="popup" tabindex="0">
<div>
<i class="close-button fa-solid fa-xmark"></i>
<h1>Modifier Settings</h1>
<p>Set your custom modifiers (one per line)</p>
<textarea id="custom-modifiers-input" placeholder="Enter your custom modifiers, one-per-line" spellcheck="false"></textarea>
<p><small><b>Tip:</b> You can include special characters like {} () [] and |. You can also put multiple comma-separated phrases in a single line, to make a single modifier that combines all of those.</small></p>
<div id="editor-modifiers">
<div id="editor-modifiers-header" class="dialog-header">
<div id="modifiers-header-left" class="dialog-header-left">
<h4>Image Modifiers</h4>
<span>(drawing style, camera, etc.)</span>
</div>
<div id="modifiers-header-right">
<i id="modifier-settings-btn" class="fa-solid fa-gear section-button">
<span class="simple-tooltip left">
Add Custom Modifiers
</span>
</i>
<i id="modifiers-container-size-btn" class="fa-solid fa-expand"></i>
<i id="modifiers-close-button" class="fa-solid fa-xmark fa-lg"></i>
</div>
</div>
<div id="editor-modifiers-subheader">
<div id="modifiers-action-collapsibles-btn">
<i class="modifiers-action-icon fa-solid fa-square-plus"></i>
<span class="modifiers-action-text">
Expand Categories
</span>
</div>
<div>
<label for="preview-image">Image Style:</label>
<select id="preview-image" name="preview-image" value="portrait">
<option value="portrait" selected="">Face</option>
<option value="landscape">Landscape</option>
</select>
</div>
<div>
<label for="modifier-card-size-slider">Thumbnail Size:</label>
<input id="modifier-card-size-slider" name="modifier-card-size-slider" value="0" type="range" min="-2" max="3">
</div>
</div>
<div id="editor-modifiers-entries" class="collapsible-content"></div>
</div>
<dialog id="modifier-settings-config">
<div id="modifier-settings-header" class="dialog-header">
<div id="modifier-settings-header-left" class="dialog-header-left">
<h4>Custom Modifiers</h4>
<span>Set your custom modifiers (one per line)</span>
</div>
<div id="modifier-settings-header-right">
<i id="modifier-settings-close-button" class="fa-solid fa-xmark fa-lg"></i>
</div>
</div>
<textarea id="custom-modifiers-input" placeholder="Enter your custom modifiers, one-per-line" spellcheck="false"></textarea>
<div>
<small>
<b>Tip:</b> You can include special characters like {} () [] and |. You can also put multiple comma-separated
phrases in a single line, to make a single modifier that combines all of those.
</small>
</div>
</dialog>
<dialog id="embeddings-dialog">
<div id="embeddings-dialog-header" class="dialog-header">
<div id="embeddings-dialog-header-left" class="dialog-header-left">
<h4>Embeddings</h4>
<span>
<span class="displayNone" id="positive-embedding-text"> Add embeddings to the prompt (click) or negative prompt (shift-click)</span>
<span class="displayNone" id="negative-embedding-text"> Add embeddings to the negative prompt</span>
<span>
</div>
<div id="embeddings-dialog-header-right">
<i id="embeddings-dialog-close-button" class="fa-solid fa-xmark fa-lg"></i>
</div>
</div>
<div>
<button id="embeddings-action-collapsibles-btn" class="tertiaryButton smallButton">
<i class="embeddings-action-icon fa-solid fa-square-plus"></i>
<span class="embeddings-action-text">Expand Categories</span>
</button>
<i class="fa-solid fa-magnifying-glass"></i>
<input id="embeddings-search-box" type="text" spellcheck="false" autocomplete="off" placeholder="Search...">
<span style="float:right;"><label>Mode:</label>&nbsp;<select id="embeddings-mode"><option value="insert">Insert at cursor position</option><option value="append">Append at the end</option></select>
</div>
<div id="embeddings-list">
</div>
</div>
</dialog>
<div id="image-editor" class="popup image-editor-popup">
<div>
<i class="close-button fa-solid fa-xmark"></i>
@ -486,10 +632,10 @@
<div id="footer">
<div class="line-separator">&nbsp;</div>
<p>If you found this project useful and want to help keep it alive, please <a href="https://ko-fi.com/cmdr2_stablediffusion_ui" target="_blank"><img src="/media/images/kofi.png" id="coffeeButton"></a> to help cover the cost of development and maintenance! Thank you for your support!</p>
<p>Please feel free to join the <a href="https://discord.com/invite/u9yhsFmEkB" target="_blank">discord community</a> or <a href="https://github.com/cmdr2/stable-diffusion-ui/issues" target="_blank">file an issue</a> if you have any problems or suggestions in using this interface.</p>
<p>Please feel free to join the <a href="https://discord.com/invite/u9yhsFmEkB" target="_blank">discord community</a> or <a href="https://github.com/easydiffusion/easydiffusion/issues" target="_blank">file an issue</a> if you have any problems or suggestions in using this interface.</p>
<div id="footer-legal">
<p><b>Disclaimer:</b> The authors of this project are not responsible for any content generated using this interface.</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/cmdr2/stable-diffusion-ui/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>
</div>
</div>
@ -498,13 +644,13 @@
<script src="media/js/utils.js"></script>
<script src="media/js/engine.js"></script>
<script src="media/js/parameters.js"></script>
<script src="media/js/plugins.js"></script>
<script src="media/js/image-modifiers.js"></script>
<script src="media/js/auto-save.js"></script>
<script src="media/js/searchable-models.js"></script>
<script src="media/js/main.js"></script>
<script src="media/js/plugins.js"></script>
<script src="media/js/themes.js"></script>
<script src="media/js/dnd.js"></script>
<script src="media/js/image-editor.js"></script>
@ -512,18 +658,24 @@
<script>
async function init() {
await initSettings()
await getModels()
await getModels(false)
await getAppConfig()
await loadUIPlugins()
await loadModifiers()
await getSystemInfo()
// await initPlugins()
SD.init({
events: {
statusChange: setServerStatus,
idle: onIdle
idle: onIdle,
ping: tunnelUpdate
}
})
splashScreen()
// load models again, but scan for malicious this time
await getModels(true)
// playSound()
}

View File

@ -1,10 +1,12 @@
from easydiffusion import model_manager, app, server
from easydiffusion.server import server_api # required for uvicorn
from easydiffusion.server import server_api # required for uvicorn
server.init()
# Init the app
model_manager.init()
app.init()
server.init()
app.init_render_threads()
# start the browser ui
app.open_browser()

View File

@ -69,13 +69,16 @@
}
.parameters-table > div:first-child {
border-radius: 12px 12px 0px 0px;
border-top-left-radius: 12px;
border-top-right-radius: 12px;
}
.parameters-table > div:last-child {
border-radius: 0px 0px 12px 12px;
border-bottom-left-radius: 12px;
border-bottom-right-radius: 12px;
}
.parameters-table .fa-fire {
.parameters-table .fa-fire,
.parameters-table .fa-bolt {
color: #F7630C;
}
}

View File

@ -96,7 +96,7 @@
.editor-controls-center {
/* background: var(--background-color2); */
flex: 1;
flex: 0;
display: flex;
justify-content: center;
align-items: center;
@ -105,6 +105,8 @@
.editor-controls-center > div {
position: relative;
background: black;
margin: 20pt;
margin-top: 40pt;
}
.editor-controls-center canvas {
@ -164,8 +166,10 @@
margin: var(--popup-margin);
padding: var(--popup-padding);
min-height: calc(99h - (2 * var(--popup-margin)));
max-width: none;
max-width: fit-content;
min-width: fit-content;
margin-left: auto;
margin-right: auto;
}
.image-editor-popup h1 {

View File

@ -5,6 +5,8 @@
html {
position: relative;
overscroll-behavior-y: none;
color-scheme: dark !important;
}
body {
@ -12,12 +14,13 @@ body {
font-size: 11pt;
background-color: var(--background-color1);
color: var(--text-color);
overscroll-behavior-y: contain;
}
a {
color: rgb(0, 102, 204);
color: var(--link-color);
}
a:visited {
color: rgb(0, 102, 204);
color: var(--link-color);
}
label {
font-size: 10pt;
@ -144,7 +147,7 @@ code {
opacity: 0;
}
.imgPreviewItemClearBtn:hover {
background: rgb(177, 27, 0);
background: var(--button-hover-background);
}
.imgContainer:hover > .imgItemInfo {
opacity: 1;
@ -184,7 +187,7 @@ code {
#editor label {
font-weight: normal;
}
#editor h4 {
.dialog-header h4 {
margin: 0px;
white-space: nowrap;
}
@ -192,7 +195,7 @@ code {
width: 100%;
}
.settings-box label small {
color: rgb(153, 153, 153);
color: var(--small-label-color);
margin-right: 10px;
}
#preview {
@ -211,10 +214,6 @@ code {
#makeImage {
border-radius: 6px;
}
#editor-modifiers h5 {
padding: 5pt 0;
margin: 0;
}
#makeImage {
flex: 0 0 70px;
background: var(--accent-color);
@ -224,11 +223,11 @@ code {
height: 30pt;
}
#makeImage:hover {
background: hsl(var(--accent-hue), 100%, calc(var(--accent-lightness) + 6%));
background: var(--button-hover-background);
}
#stopImage {
flex: 0 0 70px;
background: rgb(132, 8, 0);
background: var(--secondary-button-background);
border: 2px solid rgb(122, 29, 0);
color: rgb(255, 221, 255);
height: 30pt;
@ -236,7 +235,7 @@ code {
flex-grow: 2;
}
#stopImage:hover {
background: rgb(177, 27, 0);
background: var(--secondary-button-hover-background);
}
#undo {
float: right;
@ -284,14 +283,212 @@ button#resume {
.collapsible:not(.active) ~ .collapsible-content {
display: none !important;
}
#image-modifier-dropdown {
margin-left: 1em;
position: relative;
cursor: pointer;
}
#editor-modifiers {
overflow-y: auto;
max-width: 75vw;
min-width: 50vw;
max-height: fit-content;
overflow-y: hidden;
overflow-x: hidden;
display: none;
background: var(--background-color1);
border: solid 1px var(--background-color3);
z-index: 1999;
border-radius: 6px;
box-shadow: 0px 0px 30px black;
border: 2px solid rgb(255 255 255 / 10%);
margin-top: 150pt;
}
@media screen and (max-height: 500px) {
#editor-modifiers {
margin-top: 50pt;
}
}
#editor-modifiers.active {
display: flex;
flex-direction: column;
position: absolute;
left: 5vw;
}
.modifiers-maximized {
position: fixed !important;
top: 0 !important;
bottom: 0px !important;
left: 0px !important;
right: 0px !important;
margin: 0px !important;
max-width: unset !important;
max-height: unset !important;
border: 0px !important;
border-radius: 0px !important;
}
.modifiers-maximized #editor-modifiers-entries {
max-height: 100%;
flex: 1;
}
.dialog-header {
background-color: var(--background-color4);
padding: 0.5em;
border-bottom: 1px solid rgb(255 255 255 / 10%);
display: flex;
justify-content: space-between;
align-items: center;
user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
}
#editor-modifiers-subheader {
background-color: var(--background-color4);
padding: 0.5em;
border-bottom: 1px solid rgb(255 255 255 / 10%);
display: flex;
align-items: center;
grid-gap: 0.8em;
flex-direction: row;
position: relative;
user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
transition: all 0.1s ease;
}
#editor-modifiers-subheader::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.02);
opacity: 1;
pointer-events: none;
}
#modifiers-header-left {
display: flex;
flex-direction: column;
grid-gap: 0.1em;
}
.dialog-header-left span {
font-size: 0.8em;
color: rgb(127 127 127);
font-weight: 200;
}
#modifiers-header-right {
display: flex;
align-items: center;
align-content: center;
justify-content: center;
grid-gap: 0.8em;
margin-right: 0.3em;
}
#editor-modifiers-subheader i,
#modifiers-header-right i {
cursor: pointer;
margin: 0;
padding: 0;
}
#modifiers-header-right .section-button,
#editor-modifiers-subheader .section-button {
margin-top: 0.3em;
}
#modifiers-action-collapsibles-btn {
display: flex;
grid-gap: 0.5em;
cursor: pointer;
}
.modifiers-action-text {
font-size: 0.8em;
color: rgb(192 192 192);
}
#modifiers-expand-btn {
z-index: 2;
}
#modifiers-expand-btn .simple-tooltip {
background-color: var(--background-color3);
border-radius: 50px;
}
.modifier-category .collapsible {
position: relative;
}
.modifier-category .collapsible::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.1);
opacity: 0;
transition: opacity 0.1s ease;
pointer-events: none;
}
.modifier-category:hover .collapsible::after {
opacity: 1;
pointer-events: none;
}
#editor-modifiers-entries {
overflow: auto scroll;
max-height: 50vh;
height: fit-content;
margin-bottom: 0.1em;
padding-left: 0px;
}
#editor-modifiers-entries .collapsible {
transition: opacity 0.1s ease;
padding-left: 0.5em;
}
#editor-modifiers-entries .modifier-category:nth-child(odd) .collapsible::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.02);
opacity: 1;
pointer-events: none;
}
#editor-modifiers .editor-modifiers-leaf {
padding-top: 10pt;
padding-bottom: 10pt;
}
#editor-modifiers h5 {
padding: 5pt 0;
margin: 0;
position: sticky;
top: -2px;
z-index: 10;
background-color: var(--background-color3);
border-bottom: 1px solid rgb(255 255 255 / 4%);
user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
}
dialog {
background: var(--background-color2);
color: var(--text-color);
border-radius: 6px;
border: 2px solid rgb(255 255 255 / 10%);
padding: 0px;
}
dialog::backdrop {
background: rgba(32, 33, 36, 50%);
}
dialog > div {
padding: 0.5em;
}
img {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.15), 0 6px 20px 0 rgba(0, 0, 0, 0.15);
}
@ -310,6 +507,9 @@ div.img-preview img {
margin-top: 5pt;
display: none;
}
#editor-inputs-tags-list {
max-height: 30em;
}
#server-status {
position: absolute;
right: 16px;
@ -318,11 +518,11 @@ div.img-preview img {
}
#server-status-color {
font-size: 14pt;
color: rgb(200, 139, 0);
color: var(--status-orange);
display: inline;
}
#server-status-msg {
color: rgb(200, 139, 0);
color: var(--status-orange);
padding-left: 2pt;
font-size: 10pt;
}
@ -529,14 +729,14 @@ div.img-preview img {
padding: 3pt 6pt;
}
.secondaryButton {
background: rgb(132, 8, 0);
background: var(--secondary-button-background);
border: 1px solid rgb(122, 29, 0);
color: rgb(255, 221, 255);
padding: 3pt 6pt;
border-radius: 5px;
}
.secondaryButton:hover {
background: rgb(177, 27, 0);
background: var(--secondary-button-hover-background);
}
.tertiaryButton {
background: var(--tertiary-background-color);
@ -546,12 +746,12 @@ div.img-preview img {
border-radius: 5px;
}
.tertiaryButton:hover {
background: hsl(var(--accent-hue), 100%, calc(var(--accent-lightness) + 6%));
background: var(--button-hover-background);
color: var(--accent-text-color);
}
.tertiaryButton.pressed {
border-style: inset;
background: hsl(var(--accent-hue), 100%, calc(var(--accent-lightness) + 6%));
background: var(--button-hover-background);
color: var(--accent-text-color);
}
.useSettings {
@ -672,6 +872,9 @@ div.img-preview img {
#editor-settings {
min-width: 350px;
}
.panel-box > h4 {
margin: 0;
}
#editor-settings-entries {
display: flex;
@ -697,6 +900,10 @@ div.img-preview img {
white-space: nowrap;
}
#editor-settings-entries table {
width: 93%;
}
#negative_prompt {
width: 100%;
}
@ -771,7 +978,7 @@ input::file-selector-button,
button:hover,
.button:hover {
transition-duration: 0.1s;
background: hsl(var(--accent-hue), 100%, calc(var(--accent-lightness) + 6%));
background: var(--button-hover-background);
}
input::file-selector-button {
@ -779,7 +986,6 @@ input::file-selector-button {
height: 19px;
}
.input-toggle {
display: inline-block;
position: relative;
@ -937,7 +1143,7 @@ input::file-selector-button {
position: relative;
}
#promptsFromFileBtn {
.smallButton {
font-size: 9pt;
display: inline;
padding: 2pt;
@ -1083,6 +1289,7 @@ input::file-selector-button {
/* POPUPS */
.popup:not(.active) {
visibility: hidden;
overflow-x: hidden; /* fix overflow from body */
opacity: 0;
}
@ -1241,10 +1448,18 @@ button#save-system-settings-btn {
line-height: 200%;
}
#download-images-popup .parameters-table > div {
#download-images-dialog .parameters-table > div {
background: var(--background-color1);
}
.center {
text-align: center;
}
.fa-xmark {
cursor: pointer;;
}
/* SCROLLBARS */
:root {
--scrollbar-width: 14px;
@ -1292,6 +1507,49 @@ body.wait-pause {
100% { border: solid 12px var(--accent-color); }
}
#splash-screen div {
text-align: left;
max-width: 70vw;
}
#splash-screen .splash-img {
float: right;
box-shadow: none;
margin-left: 6px;
}
#splash-screen tt {
font-family: monospace;
background: var(--input-background-color);
padding: 1px 4px 1px 4px;
border-radius: 5px;
}
#splash-screen li {
margin-bottom: 6px;
}
#splash-screen a
{
color: #ccf;
text-decoration: none;
font-weight: bold;
}
#splash-screen a[href^="http"]::after,
#splash-screen a[href^="https://"]::after
{
content: "";
width: 11px;
height: 11px;
margin-left: 4px;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='lightblue' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a1.5 1.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5z'/%3E%3Cpath fill-rule='evenodd' d='M16 .5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h3.793L6.146 9.146a.5.5 0 1 0 .708.708L15 1.707V5.5a.5.5 0 0 0 1 0v-5z'/%3E%3C/svg%3E");
background-position: center;
background-repeat: no-repeat;
background-size: contain;
display: inline-block;
}
.jconfirm.jconfirm-modern .jconfirm-box div.jconfirm-title-c {
color: var(--button-text-color);
}
@ -1303,6 +1561,36 @@ body.wait-pause {
display:none !important;
}
.sub-settings {
padding-top: 3pt;
padding-bottom: 3pt;
padding-left: 5pt;
}
#cloudflare-address {
background-color: var(--background-color3);
padding: 6px;
border-radius: var(--input-border-radius);
border: var(--input-border-size) solid var(--input-border-color);
margin-top: 0.2em;
margin-bottom: 0.2em;
display: inline-block;
width: 80%;
}
#copy-cloudflare-address {
padding: 4px 8px;
margin-left: 0.5em;
}
.expandedSettingRow {
background: var(--background-color1);
width: 95%;
border-radius: 4pt;
margin-top: 5pt;
margin-bottom: 3pt;
}
/* TOAST NOTIFICATIONS */
.toast-notification {
position: fixed;
@ -1316,13 +1604,21 @@ body.wait-pause {
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
z-index: 9999;
animation: slideInRight 0.5s ease forwards;
transition: bottom 0.5s ease; // Add a transition to smoothly reposition the toasts
transition: bottom 0.5s ease; /* Add a transition to smoothly reposition the toasts */
}
.toast-notification-error {
color: red;
}
.image-editor-button-label {
display: inline-block;
}
.image-editor-button-label::first-letter {
text-decoration: underline;
}
@keyframes slideInRight {
from {
right: -300px;
@ -1353,3 +1649,107 @@ body.wait-pause {
bottom: 0;
}
}
#embeddings-dialog {
overflow: clip;
}
#embeddings-list {
height: 70vH;
width: 50vW;
margin-left: 0px;
margin-right: 0px;
padding-left: 0px;
padding-right: 0px;
overflow-y: scroll;
}
#embeddings-list button {
margin: 2px;
color: var(--button-color);
background: var(--button-text-color);
font-weight: 700;
}
#embeddings-list button:hover {
background: var(--accent-color);
color: var(--button-text-color);
}
#embeddings-list .collapsible {
background: var(--background-color3);
margin: 0px;
padding: 0.5em;
position: sticky;
}
#embeddings-list .embedding-category:nth-child(odd) .collapsible::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.02);
opacity: 1;
pointer-events: none;
}
#embeddings-list .collapsible-content {
padding-top: 0.4em;
padding-bottom: 0.4em;
}
#embeddings-list::-webkit-scrollbar-thumb {
background: var(--background-color3);
}
.model_entry .model_name {
width: 73%;
}
.model_entry {
position: relative;
}
.model_entry .remove_model_btn {
position: absolute;
left: -23pt;
top: 4pt;
}
.split-toolbar { display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr;
gap: 0px 0px;
grid-auto-flow: row;
grid-template-areas: "toolbar-left toolbar-right";
}
.toolbar-left {
justify-self: start;
align-self: center;
grid-area: toolbar-left;
}
.toolbar-right {
justify-self: end;
align-self: center;
grid-area: toolbar-right;
}
#negative-embeddings-button {
float: right;
}
.diffusers-disabled-on-startup .diffusers-restart-needed {
font-size: 0;
}
.diffusers-disabled-on-startup .diffusers-restart-needed * {
display: none;
}
.diffusers-disabled-on-startup .diffusers-restart-needed::after {
content: "Please restart Easy Diffusion!";
font-size: 10pt;
}

View File

@ -1,14 +1,16 @@
.modifier-card {
position: relative;
box-sizing: content-box; /* fixes border misalignment */
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
transition: 0.1s;
border-radius: 7px;
margin: 3pt 3pt;
float: left;
width: 8em;
height: 11.5em;
width: 6em;
height: 9.5em;
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 8em 3.5em;
grid-template-rows: 6em 3.5em;
gap: 0px 0px;
grid-auto-flow: row;
grid-template-areas:
@ -16,82 +18,71 @@
"modifier-card-container";
border: 2px solid rgba(255, 255, 255, .05);
cursor: pointer;
}
.modifier-card-size_5 {
width: 18em;
grid-template-rows: 18em 3.5em;
height: 21.5em;
}
.modifier-card-size_5 .modifier-card-image-overlay {
font-size: 8em;
}
.modifier-card-size_4 {
width: 14em;
grid-template-rows: 14em 3.5em;
height: 17.5em;
}
.modifier-card-size_4 .modifier-card-image-overlay {
font-size: 7em;
z-index: 2;
}
.modifier-card-size_3 {
width: 11em;
grid-template-rows: 11em 3.5em;
height: 14.5em;
}
.modifier-card-size_3 .modifier-card-image-overlay {
font-size: 6em;
}
.modifier-card-size_2 {
width: 10em;
grid-template-rows: 10em 3.5em;
height: 13.5em;
}
.modifier-card-size_2 .modifier-card-image-overlay {
.modifier-card-size_3 .modifier-card-image-overlay {
font-size: 6em;
}
.modifier-card-size_1 {
.modifier-card-size_3 .modifier-card-label {
font-size: 1.2em;
}
.modifier-card-size_2 {
width: 9em;
grid-template-rows: 9em 3.5em;
height: 12.5em;
}
.modifier-card-size_1 .modifier-card-image-overlay {
.modifier-card-size_2 .modifier-card-image-overlay {
font-size: 5em;
}
.modifier-card-size_-1 {
.modifier-card-size_2 .modifier-card-label {
font-size: 1.1em;
}
.modifier-card-size_1 {
width: 7em;
grid-template-rows: 7em 3.5em;
height: 10.5em;
}
.modifier-card-size_-1 .modifier-card-image-overlay {
.modifier-card-size_1 .modifier-card-image-overlay {
font-size: 4em;
}
.modifier-card-size_-2 {
width: 6em;
grid-template-rows: 6em 3.5em;
height: 9.5em;
}
.modifier-card-size_-2 .modifier-card-image-overlay {
font-size: 3em;
}
.modifier-card-size_-3 {
.modifier-card-size_-1 {
width: 5em;
grid-template-rows: 5em 3.5em;
height: 8.5em;
}
.modifier-card-size_-3 .modifier-card-image-overlay {
.modifier-card-size_-1 .modifier-card-image-overlay {
font-size: 3em;
}
.modifier-card-size_-3 .modifier-card-label {
font-size: 0.8em;
.modifier-card-size_-1 .modifier-card-label {
font-size: 0.9em;
}
.modifier-card-size_-2 {
width: 4em;
grid-template-rows: 3.5em 3em;
height: 6.5em;
}
.modifier-card-size_-2 .modifier-card-image-overlay {
font-size: 2em;
}
.modifier-card-size_-2 .modifier-card-label {
font-size: 0.7em;
}
.modifier-card-tiny {
width: 6em;
height: 9.5em;
grid-template-rows: 6em 3.5em;
width: 5em;
grid-template-rows: 5em 3.5em;
height: 8.5em;
}
.modifier-card-tiny .modifier-card-image-overlay {
font-size: 4em;
}
.modifier-card-tiny .modifier-card-label {
font-size: 0.9em;
}
.modifier-card:hover {
transform: scale(1.05);
box-shadow: 0 5px 16px 5px rgba(0, 0, 0, 0.25);
@ -115,6 +106,7 @@
}
.modifier-card-image-container * {
position: absolute;
text-align: center;
}
.modifier-card-container {
text-align: center;
@ -131,6 +123,7 @@
.modifier-card-label {
padding: 4px;
word-break: break-word;
text-transform: capitalize;
}
.modifier-card-image-overlay {
width: inherit;
@ -140,7 +133,7 @@
position: absolute;
border-radius: 5px 5px 0 0;
opacity: 0;
font-size: 5em;
font-size: 4em;
font-weight: 900;
color: rgb(255 255 255 / 50%);
display: flex;
@ -153,9 +146,8 @@
position: absolute;
z-index: 3;
}
.modifier-card-overlay:hover ~ .modifier-card-container .modifier-card-label.tooltip .tooltip-text {
visibility: visible;
opacity: 1;
.modifier-card-active .modifier-card-overlay {
background-color: rgb(169 78 241 / 40%);
}
.modifier-card:hover > .modifier-card-image-container .modifier-card-image-overlay {
opacity: 1;
@ -167,61 +159,30 @@
transform: scale(0.95);
box-shadow: 0 5px 16px 5px rgba(0, 0, 0, 0.5);
}
#preview-image {
margin-top: 0.5em;
margin-bottom: 0.5em;
}
.modifier-card-active {
border: 2px solid rgb(179 82 255 / 94%);
box-shadow: 0 0px 10px 0 rgb(170 0 229 / 58%);
}
.tooltip {
position: relative;
display: inline-block;
}
.tooltip .tooltip-text {
visibility: hidden;
width: 120px;
background: rgb(101,97,181);
background: linear-gradient(180deg, rgba(101,97,181,1) 0%, rgba(47,45,85,1) 100%);
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px;
position: absolute;
z-index: 1;
top: 105%;
left: 39%;
margin-left: -60px;
opacity: 0;
transition: opacity 0.3s;
border: 2px solid rgb(90 100 177 / 94%);
box-shadow: 0px 10px 20px 5px rgb(11 0 58 / 55%);
width: 10em;
}
.tooltip .tooltip-text::after {
content: "";
position: absolute;
top: -0.9em;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent transparent rgb(90 100 177 / 94%) transparent;
}
.tooltip:hover .tooltip-text {
visibility: visible;
opacity: 1;
}
#modifier-card-size-slider {
width: 6em;
margin-bottom: 0.5em;
height: 4pt;
vertical-align: middle;
}
#modifier-settings-btn {
float: right;
}
#modifier-settings-config textarea {
margin-left: 5%;
margin-top: 2ex;
width: 90%;
height: 150px;
}
.modifier-card .hidden {
display: none;
}
.support-long-label .modifier-card-overlay:hover ~ .modifier-card-container .modifier-card-label {
font-size: 0.7em;
}
.support-long-label .modifier-card-overlay:hover ~ .modifier-card-container .long-label {
display: block;
}
.support-long-label .modifier-card-overlay:hover ~ .modifier-card-container .regular-label {
display: none;
}

288
ui/media/css/plugins.css Normal file
View File

@ -0,0 +1,288 @@
.plugins-table {
display: flex;
flex-direction: column;
gap: 1px;
}
.plugins-table > div {
background: var(--background-color2);
display: flex;
padding: 0px 4px;
}
.plugins-table > div > div {
padding: 10px;
display: flex;
align-items: center;
justify-content: center;
}
.plugins-table small {
color: rgb(153, 153, 153);
}
.plugins-table > div > div:nth-child(1) {
font-size: 20px;
width: 45px;
}
.plugins-table > div > div:nth-child(2) {
flex: 1;
flex-direction: column;
text-align: left;
justify-content: center;
align-items: start;
gap: 4px;
}
.plugins-table > div > div:nth-child(3) {
text-align: right;
}
.plugins-table > div:first-child {
border-radius: 12px 12px 0px 0px;
}
.plugins-table > div:last-child {
border-radius: 0px 0px 12px 12px;
}
.notifications-table {
display: flex;
flex-direction: column;
gap: 1px;
}
.notifications-table > div {
background: var(--background-color2);
display: flex;
padding: 0px 4px;
}
.notifications-table > div > div {
padding: 10px;
display: flex;
align-items: center;
justify-content: center;
}
.notifications-table small {
color: rgb(153, 153, 153);
}
.notifications-table > div > div:nth-child(1) {
flex: 1;
flex-direction: column;
text-align: left;
justify-content: center;
align-items: start;
gap: 4px;
}
.notifications-table > div > div:nth-child(2) {
width: auto;
}
.notifications-table > div:first-child {
border-radius: 12px 12px 0px 0px;
}
.notifications-table > div:last-child {
border-radius: 0px 0px 12px 12px;
}
.notification-error {
color: red;
}
DIV.no-notification {
padding-top: 16px;
font-style: italic;
}
.plugin-manager-intro {
margin: 0 0 16px 0;
}
#plugin-filter {
box-sizing: border-box;
width: 100%;
margin: 4px 0 6px 0;
padding: 10px;
}
#refresh-plugins {
box-sizing: border-box;
width: 100%;
padding: 0px;
}
#refresh-plugins a {
cursor: pointer;
}
#refresh-plugins a:active {
transition-duration: 0.1s;
position: relative;
top: 1px;
left: 1px;
}
.plugin-installed-locally {
font-style: italic;
font-size: small;
}
.plugin-source {
font-size: x-small;
}
.plugin-warning {
color: orange;
font-size: smaller;
}
.plugin-warning.hide {
display: none;
}
.plugin-warning ul {
list-style: square;
margin: 0 0 8px 16px;
padding: 0;
}
.plugin-warning li {
margin-left: 8px;
padding: 0;
}
/* MODAL DIALOG */
#pluginDialog-input-dialog {
position: fixed;
z-index: 1000;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: none;
}
.pluginDialog-dialog-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(32, 33, 36, 50%);
}
.pluginDialog-dialog-box {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 80%;
max-width: 600px;
background: var(--background-color2);
border: solid 1px var(--background-color3);
border-radius: 6px;
box-shadow: 0px 0px 30px black;
}
.pluginDialog-dialog-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px;
}
.pluginDialog-dialog-header h2 {
margin: 0;
}
.pluginDialog-dialog-close-button {
font-size: 24px;
font-weight: bold;
line-height: 1;
border: none;
background-color: transparent;
cursor: pointer;
}
.pluginDialog-dialog-close-button:hover {
color: #555;
}
.pluginDialog-dialog-content {
padding: 0 16px 0 16px;
}
.pluginDialog-dialog-content textarea {
width: 100%;
height: 300px;
border-radius: var(--input-border-radius);
padding: 4px;
accent-color: var(--accent-color);
background: var(--input-background-color);
border: var(--input-border-size) solid var(--input-border-color);
color: var(--input-text-color);
font-size: 9pt;
resize: none;
}
.pluginDialog-dialog-buttons {
display: flex;
justify-content: flex-end;
padding: 16px;
}
.pluginDialog-dialog-buttons button {
margin-left: 8px;
padding: 8px 16px;
font-size: 16px;
border-radius: 4px;
/*background: var(--accent-color);*/
/*border: var(--primary-button-border);*/
/*color: rgb(255, 221, 255);*/
background-color: #3071a9;
border: none;
cursor: pointer;
}
.pluginDialog-dialog-buttons button:hover {
/*background: hsl(var(--accent-hue), 100%, 50%);*/
background-color: #428bca;
}
/* NOTIFICATION CENTER */
#plugin-notification-button {
float: right;
margin-top: 30px;
}
#plugin-notification-button:hover {
background: unset;
}
#plugin-notification-button:active {
transition-duration: 0.1s;
position: relative;
top: 1px;
left: 1px;
}
.plugin-notification-pill {
background-color: red;
border-radius: 50%;
color: white;
font-size: 10px;
font-weight: bold;
height: 12px;
line-height: 12px;
position: relative;
right: -8px;
text-align: center;
top: -20px;
width: 12px;
}

View File

@ -13,6 +13,8 @@
--accent-lightness-hover: 40%;
--text-color: #eee;
--link-color: rgb(0, 102, 204);
--small-label-color: rgb(153, 153, 153);
--input-text-color: #eee;
--input-background-color: hsl(var(--main-hue), var(--main-saturation), calc(var(--value-base) - (0.7 * var(--value-step))));
@ -21,6 +23,9 @@
--button-text-color: var(--input-text-color);
--button-color: var(--input-background-color);
--button-border: none;
--button-hover-background: hsl(var(--accent-hue), 100%, calc(var(--accent-lightness) + 6%));
--secondary-button-background: rgb(132, 8, 0);
--secondary-button-hover-background: rgb(177, 27, 0);
/* other */
--input-border-radius: 4px;

View File

@ -16,7 +16,6 @@ const SETTINGS_IDS_LIST = [
"clip_skip",
"vae_model",
"hypernetwork_model",
"lora_model",
"sampler_name",
"width",
"height",
@ -24,7 +23,7 @@ const SETTINGS_IDS_LIST = [
"guidance_scale",
"prompt_strength",
"hypernetwork_strength",
"lora_alpha",
"tiling",
"output_format",
"output_quality",
"output_lossless",
@ -34,6 +33,7 @@ const SETTINGS_IDS_LIST = [
"gfpgan_model",
"use_upscale",
"upscale_amount",
"latent_upscaler_steps",
"block_nsfw",
"show_only_filtered_image",
"upscale_model",
@ -174,13 +174,14 @@ function loadSettings() {
// So this is likely the first time Easy Diffusion is running.
// Initialize vram_usage_level based on the available VRAM
function initGPUProfile(event) {
if ( "detail" in event
&& "active" in event.detail
&& "cuda:0" in event.detail.active
&& event.detail.active["cuda:0"].mem_total <4.5 )
{
vramUsageLevelField.value = "low"
vramUsageLevelField.dispatchEvent(new Event("change"))
if (
"detail" in event &&
"active" in event.detail &&
"cuda:0" in event.detail.active &&
event.detail.active["cuda:0"].mem_total < 4.5
) {
vramUsageLevelField.value = "low"
vramUsageLevelField.dispatchEvent(new Event("change"))
}
document.removeEventListener("system_info_update", initGPUProfile)
}

View File

@ -79,6 +79,7 @@ const TASK_MAPPING = {
if (!widthField.value) {
widthField.value = oldVal
}
widthField.dispatchEvent(new Event("change"))
},
readUI: () => parseInt(widthField.value),
parse: (val) => parseInt(val),
@ -91,6 +92,7 @@ const TASK_MAPPING = {
if (!heightField.value) {
heightField.value = oldVal
}
heightField.dispatchEvent(new Event("change"))
},
readUI: () => parseInt(heightField.value),
parse: (val) => parseInt(val),
@ -172,16 +174,22 @@ const TASK_MAPPING = {
name: "Use Face Correction",
setUI: (use_face_correction) => {
const oldVal = gfpganModelField.value
gfpganModelField.value = getModelPath(use_face_correction, [".pth"])
if (gfpganModelField.value) {
// Is a valid value for the field.
useFaceCorrectionField.checked = true
gfpganModelField.disabled = false
} else {
// Not a valid value, restore the old value and disable the filter.
console.log("use face correction", use_face_correction)
if (use_face_correction == null || use_face_correction == "None") {
gfpganModelField.disabled = true
gfpganModelField.value = oldVal
useFaceCorrectionField.checked = false
} else {
gfpganModelField.value = getModelPath(use_face_correction, [".pth"])
if (gfpganModelField.value) {
// Is a valid value for the field.
useFaceCorrectionField.checked = true
gfpganModelField.disabled = false
} else {
// Not a valid value, restore the old value and disable the filter.
gfpganModelField.disabled = true
gfpganModelField.value = oldVal
useFaceCorrectionField.checked = false
}
}
//useFaceCorrectionField.checked = parseBoolean(use_face_correction)
@ -218,6 +226,14 @@ const TASK_MAPPING = {
readUI: () => upscaleAmountField.value,
parse: (val) => val,
},
latent_upscaler_steps: {
name: "Latent Upscaler Steps",
setUI: (latent_upscaler_steps) => {
latentUpscalerStepsField.value = latent_upscaler_steps
},
readUI: () => latentUpscalerStepsField.value,
parse: (val) => val,
},
sampler_name: {
name: "Sampler",
setUI: (sampler_name) => {
@ -249,6 +265,14 @@ const TASK_MAPPING = {
readUI: () => clip_skip.checked,
parse: (val) => Boolean(val),
},
tiling: {
name: "Tiling",
setUI: (val) => {
tilingField.value = val
},
readUI: () => tilingField.value,
parse: (val) => val,
},
use_vae_model: {
name: "VAE model",
setUI: (use_vae_model) => {
@ -268,29 +292,75 @@ const TASK_MAPPING = {
use_lora_model: {
name: "LoRA model",
setUI: (use_lora_model) => {
const oldVal = loraModelField.value
use_lora_model =
use_lora_model === undefined || use_lora_model === null || use_lora_model === "None"
? ""
: use_lora_model
if (use_lora_model !== "") {
use_lora_model = getModelPath(use_lora_model, [".ckpt", ".safetensors"])
use_lora_model = use_lora_model !== "" ? use_lora_model : oldVal
// create rows
for (let i = loraModels.length; i < use_lora_model.length; i++) {
createLoraEntry()
}
loraModelField.value = use_lora_model
use_lora_model.forEach((model_name, i) => {
let field = loraModels[i][0]
const oldVal = field.value
if (model_name !== "") {
model_name = getModelPath(model_name, [".ckpt", ".safetensors"])
model_name = model_name !== "" ? model_name : oldVal
}
field.value = model_name
})
// clear the remaining entries
let container = document.querySelector("#lora_model_container .model_entries")
for (let i = use_lora_model.length; i < loraModels.length; i++) {
let modelEntry = loraModels[i][2]
container.removeChild(modelEntry)
}
loraModels.splice(use_lora_model.length)
},
readUI: () => {
let values = loraModels.map((e) => e[0].value)
values = values.filter((e) => e.trim() !== "")
values = values.length > 0 ? values : "None"
return values
},
parse: (val) => {
val = !val || val === "None" ? "" : val
val = Array.isArray(val) ? val : [val]
return val
},
readUI: () => loraModelField.value,
parse: (val) => val,
},
lora_alpha: {
name: "LoRA Strength",
setUI: (lora_alpha) => {
loraAlphaField.value = lora_alpha
updateLoraAlphaSlider()
for (let i = loraModels.length; i < lora_alpha.length; i++) {
createLoraEntry()
}
lora_alpha.forEach((model_strength, i) => {
let field = loraModels[i][1]
field.value = model_strength
})
// clear the remaining entries
let container = document.querySelector("#lora_model_container .model_entries")
for (let i = lora_alpha.length; i < loraModels.length; i++) {
let modelEntry = loraModels[i][2]
container.removeChild(modelEntry)
}
loraModels.splice(lora_alpha.length)
},
readUI: () => {
let models = loraModels.filter((e) => e[0].value.trim() !== "")
let values = models.map((e) => e[1].value)
values = values.length > 0 ? values : 0
return values
},
parse: (val) => {
val = Array.isArray(val) ? val : [val]
val = val.map((e) => parseFloat(e))
return val
},
readUI: () => parseFloat(loraAlphaField.value),
parse: (val) => parseFloat(val),
},
use_hypernetwork_model: {
name: "Hypernetwork model",
@ -402,8 +472,11 @@ function restoreTaskToUI(task, fieldsToSkip) {
}
if (!("use_lora_model" in task.reqBody)) {
loraModelField.value = ""
loraModelField.dispatchEvent(new Event("change"))
loraModels.forEach((e) => {
e[0].value = ""
e[1].value = 0
e[0].dispatchEvent(new Event("change"))
})
}
// restore the original prompt if provided (e.g. use settings), fallback to prompt as needed (e.g. copy/paste or d&d)
@ -411,6 +484,7 @@ function restoreTaskToUI(task, fieldsToSkip) {
if (!("original_prompt" in task.reqBody)) {
promptField.value = task.reqBody.prompt
}
promptField.dispatchEvent(new Event("input"))
// properly reset checkboxes
if (!("use_face_correction" in task.reqBody)) {

View File

@ -186,6 +186,7 @@
const EVENT_TASK_START = "taskStart"
const EVENT_TASK_END = "taskEnd"
const EVENT_TASK_ERROR = "task_error"
const EVENT_PING = "ping"
const EVENT_UNEXPECTED_RESPONSE = "unexpectedResponse"
const EVENTS_TYPES = [
EVENT_IDLE,
@ -196,6 +197,7 @@
EVENT_TASK_START,
EVENT_TASK_END,
EVENT_TASK_ERROR,
EVENT_PING,
EVENT_UNEXPECTED_RESPONSE,
]
@ -240,6 +242,7 @@
setServerStatus("error", "offline")
return false
}
// Set status
switch (serverState.status) {
case ServerStates.init:
@ -261,6 +264,7 @@
break
}
serverState.time = Date.now()
await eventSource.fireEvent(EVENT_PING, serverState)
return true
} catch (e) {
console.error(e)
@ -789,9 +793,10 @@
use_hypernetwork_model: "string",
hypernetwork_strength: "number",
output_lossless: "boolean",
tiling: "string",
}
// Higer values will result in...
// Higher values will result in...
// pytorch_lightning/utilities/seed.py:60: UserWarning: X is not in bounds, numpy accepts from 0 to 4294967295
const MAX_SEED_VALUE = 4294967295
@ -1116,13 +1121,13 @@
return systemInfo.hosts
}
async function getModels() {
async function getModels(scanForMalicious = true) {
let models = {
"stable-diffusion": [],
vae: [],
}
try {
const res = await fetch("/get/models")
const res = await fetch("/get/models?scan_for_malicious=" + scanForMalicious)
if (!res.ok) {
console.error("Invalid response fetching models", res.statusText)
return models

View File

@ -47,6 +47,7 @@ const IMAGE_EDITOR_TOOLS = [
begin: defaultToolBegin,
move: defaultToolMove,
end: defaultToolEnd,
hotkey: "d",
},
{
id: "erase",
@ -77,6 +78,7 @@ const IMAGE_EDITOR_TOOLS = [
setBrush: (editor, layer) => {
layer.ctx.globalCompositeOperation = "destination-out"
},
hotkey: "e",
},
{
id: "fill",
@ -92,6 +94,7 @@ const IMAGE_EDITOR_TOOLS = [
},
move: toolDoNothing,
end: toolDoNothing,
hotkey: "f",
},
{
id: "colorpicker",
@ -113,6 +116,7 @@ const IMAGE_EDITOR_TOOLS = [
},
move: toolDoNothing,
end: toolDoNothing,
hotkey: "p",
},
]
@ -208,7 +212,10 @@ var IMAGE_EDITOR_SECTIONS = [
var icon = document.createElement("i")
tool_info.icon.split(" ").forEach((c) => icon.classList.add(c))
sub_element.appendChild(icon)
sub_element.append(tool_info.name)
var label_element = document.createElement("div")
label_element.classList.add("image-editor-button-label")
label_element.textContent=tool_info.name
sub_element.appendChild(label_element)
element.appendChild(sub_element)
},
},
@ -702,15 +709,22 @@ class ImageEditor {
event.stopPropagation()
event.preventDefault()
}
if (event.key == "y" && event.ctrlKey) {
else if (event.key == "y" && event.ctrlKey) {
this.history.redo()
event.stopPropagation()
event.preventDefault()
}
if (event.key === "Escape") {
else if (event.key === "Escape") {
this.hide()
event.stopPropagation()
event.preventDefault()
} else {
let toolIndex = IMAGE_EDITOR_TOOLS.findIndex( t => t.hotkey ==event.key )
if (toolIndex != -1) {
this.selectOption("tool", toolIndex)
event.stopPropagation()
event.preventDefault()
}
}
}
@ -834,6 +848,7 @@ function pixelCompare(int1, int2) {
}
// adapted from https://ben.akrin.com/canvas_fill/fill_04.html
// May 2023 - look at using a library instead of custom code: https://github.com/shaneosullivan/example-canvas-fill
function flood_fill(editor, the_canvas_context, x, y, color) {
pixel_stack = [{ x: x, y: y }]
pixels = the_canvas_context.getImageData(0, 0, editor.width, editor.height)

View File

@ -1,48 +1,56 @@
let activeTags = []
let modifiers = []
let customModifiersGroupElement = undefined
let customModifiersInitialContent
let customModifiersInitialContent = ""
let modifierPanelFreezed = false
let modifiersMainContainer = document.querySelector("#editor-modifiers")
let modifierDropdown = document.querySelector("#image-modifier-dropdown")
let editorModifiersContainer = document.querySelector("#editor-modifiers")
let editorModifierEntries = document.querySelector("#editor-modifiers-entries")
let editorModifierTagsList = document.querySelector("#editor-inputs-tags-list")
let editorTagsContainer = document.querySelector("#editor-inputs-tags-container")
let modifierCardSizeSlider = document.querySelector("#modifier-card-size-slider")
let previewImageField = document.querySelector("#preview-image")
let modifierSettingsBtn = document.querySelector("#modifier-settings-btn")
let modifierSettingsOverlay = document.querySelector("#modifier-settings-config")
let modifiersContainerSizeBtn = document.querySelector("#modifiers-container-size-btn")
let modifiersCloseBtn = document.querySelector("#modifiers-close-button")
let modifiersCollapsiblesBtn = document.querySelector("#modifiers-action-collapsibles-btn")
let modifierSettingsDialog = document.querySelector("#modifier-settings-config")
let customModifiersTextBox = document.querySelector("#custom-modifiers-input")
let customModifierEntriesToolbar = document.querySelector("#editor-modifiers-entries-toolbar")
let customModifierEntriesToolbar = document.querySelector("#editor-modifiers-subheader")
let modifierSettingsCloseBtn = document.querySelector("#modifier-settings-close-button")
const modifierThumbnailPath = "media/modifier-thumbnails"
const activeCardClass = "modifier-card-active"
const CUSTOM_MODIFIERS_KEY = "customModifiers"
function createModifierCard(name, previews, removeBy) {
const modifierCard = document.createElement("div")
let style = previewImageField.value
let styleIndex = style == "portrait" ? 0 : 1
let cardPreviewImageType = previewImageField.value
const modifierCard = document.createElement("div")
modifierCard.className = "modifier-card"
modifierCard.innerHTML = `
<div class="modifier-card-overlay"></div>
<div class="modifier-card-image-container">
<div class="modifier-card-image-overlay">+</div>
<p class="modifier-card-error-label"></p>
<p class="modifier-card-error-label">No Image</p>
<img onerror="this.remove()" alt="Modifier Image" class="modifier-card-image">
</div>
<div class="modifier-card-container">
<div class="modifier-card-label"><p></p></div>
<div class="modifier-card-label">
<span class="long-label hidden"></span>
<p class="regular-label"></p>
</div>
</div>`
const image = modifierCard.querySelector(".modifier-card-image")
const errorText = modifierCard.querySelector(".modifier-card-error-label")
const label = modifierCard.querySelector(".modifier-card-label")
errorText.innerText = "No Image"
const longLabel = modifierCard.querySelector(".modifier-card-label span.long-label")
const regularLabel = modifierCard.querySelector(".modifier-card-label p.regular-label")
if (typeof previews == "object") {
image.src = previews[styleIndex] // portrait
image.setAttribute("preview-type", style)
image.src = previews[cardPreviewImageType == "portrait" ? 0 : 1] // 0 index is portrait, 1 landscape
image.setAttribute("preview-type", cardPreviewImageType)
} else {
image.remove()
}
@ -50,24 +58,32 @@ function createModifierCard(name, previews, removeBy) {
const maxLabelLength = 30
const cardLabel = removeBy ? name.replace("by ", "") : name
if (cardLabel.length <= maxLabelLength) {
label.querySelector("p").innerText = cardLabel
} else {
const tooltipText = document.createElement("span")
tooltipText.className = "tooltip-text"
tooltipText.innerText = name
label.classList.add("tooltip")
label.appendChild(tooltipText)
label.querySelector("p").innerText = cardLabel.substring(0, maxLabelLength) + "..."
function getFormattedLabel(length) {
if (cardLabel?.length <= length) {
return cardLabel
} else {
return cardLabel.substring(0, length) + "..."
}
}
label.querySelector("p").dataset.fullName = name // preserve the full name
modifierCard.dataset.fullName = name // preserve the full name
regularLabel.dataset.fullName = name // preserve the full name, legacy support for older plugins
longLabel.innerText = getFormattedLabel(maxLabelLength * 2)
regularLabel.innerText = getFormattedLabel(maxLabelLength)
if (cardLabel.length > maxLabelLength) {
modifierCard.classList.add("support-long-label")
if (cardLabel.length > maxLabelLength * 2) {
modifierCard.title = `"${name}"`
}
}
return modifierCard
}
function createModifierGroup(modifierGroup, initiallyExpanded, removeBy) {
function createModifierGroup(modifierGroup, isInitiallyOpen, removeBy) {
const title = modifierGroup.category
const modifiers = modifierGroup.modifiers
@ -78,8 +94,8 @@ function createModifierGroup(modifierGroup, initiallyExpanded, removeBy) {
const modifiersEl = document.createElement("div")
modifiersEl.classList.add("collapsible-content", "editor-modifiers-leaf")
if (initiallyExpanded === true) {
titleEl.className += " active"
if (isInitiallyOpen === true) {
titleEl.classList.add("active")
}
modifiers.forEach((modObj) => {
@ -126,7 +142,7 @@ function createModifierGroup(modifierGroup, initiallyExpanded, removeBy) {
e.appendChild(titleEl)
e.appendChild(modifiersEl)
editorModifierEntries.insertBefore(e, customModifierEntriesToolbar.nextSibling)
editorModifierEntries.prepend(e)
return e
}
@ -149,7 +165,10 @@ async function loadModifiers() {
res.reverse()
res.forEach((modifierGroup, idx) => {
createModifierGroup(modifierGroup, idx === res.length - 1, modifierGroup === "Artist" ? true : false) // only remove "By " for artists
const isInitiallyOpen = false // idx === res.length - 1
const removeBy = modifierGroup === "Artist" ? true : false // only remove "By " for artists
createModifierGroup(modifierGroup, isInitiallyOpen, removeBy)
})
createCollapsibles(editorModifierEntries)
@ -169,7 +188,7 @@ function refreshModifiersState(newTags, inactiveTags) {
.querySelector("#editor-modifiers")
.querySelectorAll(".modifier-card")
.forEach((modifierCard) => {
const modifierName = modifierCard.querySelector(".modifier-card-label p").dataset.fullName // pick the full modifier name
const modifierName = modifierCard.dataset.fullName // pick the full modifier name
if (activeTags.map((x) => x.name).includes(modifierName)) {
modifierCard.classList.remove(activeCardClass)
modifierCard.querySelector(".modifier-card-image-overlay").innerText = "+"
@ -184,8 +203,9 @@ function refreshModifiersState(newTags, inactiveTags) {
.querySelector("#editor-modifiers")
.querySelectorAll(".modifier-card")
.forEach((modifierCard) => {
const modifierName = modifierCard.querySelector(".modifier-card-label p").dataset.fullName
const modifierName = modifierCard.dataset.fullName
const shortModifierName = modifierCard.querySelector(".modifier-card-label p").innerText
if (trimModifiers(tag) == trimModifiers(modifierName)) {
// add modifier to active array
if (!activeTags.map((x) => x.name).includes(tag)) {
@ -242,10 +262,10 @@ function refreshInactiveTags(inactiveTags) {
}
// update cards
let overlays = document.querySelector("#editor-inputs-tags-list").querySelectorAll(".modifier-card-overlay")
let overlays = editorModifierTagsList.querySelectorAll(".modifier-card-overlay")
overlays.forEach((i) => {
let modifierName = i.parentElement.getElementsByClassName("modifier-card-label")[0].getElementsByTagName("p")[0]
.dataset.fullName
let modifierName = i.parentElement.dataset.fullName
if (inactiveTags?.find((element) => trimModifiers(element) === modifierName) !== undefined) {
i.parentElement.classList.add("modifier-toggle-inactive")
}
@ -262,6 +282,12 @@ function refreshTagsList(inactiveTags) {
editorTagsContainer.style.display = "block"
}
if(activeTags.length > 15) {
editorModifierTagsList.style["overflow-y"] = "auto"
} else {
editorModifierTagsList.style["overflow-y"] = "unset"
}
activeTags.forEach((tag, index) => {
tag.element.querySelector(".modifier-card-image-overlay").innerText = "-"
tag.element.classList.add("modifier-card-tiny")
@ -285,48 +311,42 @@ function refreshTagsList(inactiveTags) {
let brk = document.createElement("br")
brk.style.clear = "both"
editorModifierTagsList.appendChild(brk)
refreshInactiveTags(inactiveTags)
document.dispatchEvent(new Event("refreshImageModifiers")) // notify plugins that the image tags have been refreshed
}
function toggleCardState(modifierName, makeActive) {
document
.querySelector("#editor-modifiers")
.querySelectorAll(".modifier-card")
.forEach((card) => {
const name = card.querySelector(".modifier-card-label").innerText
if (
trimModifiers(modifierName) == trimModifiers(name) ||
trimModifiers(modifierName) == "by " + trimModifiers(name)
) {
if (makeActive) {
card.classList.add(activeCardClass)
card.querySelector(".modifier-card-image-overlay").innerText = "-"
} else {
card.classList.remove(activeCardClass)
card.querySelector(".modifier-card-image-overlay").innerText = "+"
}
}
})
const cards = [...document.querySelectorAll("#editor-modifiers .modifier-card")]
.filter(cardElem => trimModifiers(cardElem.dataset.fullName) == trimModifiers(modifierName))
const cardExists = typeof cards == "object" && cards?.length > 0
if (cardExists) {
const card = cards[0]
if (makeActive) {
card.classList.add(activeCardClass)
card.querySelector(".modifier-card-image-overlay").innerText = "-"
} else {
card.classList.remove(activeCardClass)
card.querySelector(".modifier-card-image-overlay").innerText = "+"
}
}
}
function changePreviewImages(val) {
const previewImages = document.querySelectorAll(".modifier-card-image-container img")
let previewArr = []
modifiers.map((x) => x.modifiers).forEach((x) => previewArr.push(...x.map((m) => m.previews)))
previewArr = previewArr.map((x) => {
let obj = {}
x.forEach((preview) => {
const previewArr = modifiers.flatMap((x) => x.modifiers.map((m) => m.previews))
.map((x) => x.reduce((obj, preview) => {
obj[preview.name] = preview.path
})
return obj
})
return obj
}, {}))
previewImages.forEach((previewImage) => {
const currentPreviewType = previewImage.getAttribute("preview-type")
@ -343,7 +363,7 @@ function changePreviewImages(val) {
preview = previews.landscape
}
if (preview != null) {
if (preview) {
previewImage.src = `${modifierThumbnailPath}/${preview}`
previewImage.setAttribute("preview-type", val)
}
@ -369,34 +389,6 @@ function resizeModifierCards(val) {
})
}
modifierCardSizeSlider.onchange = () => resizeModifierCards(modifierCardSizeSlider.value)
previewImageField.onchange = () => changePreviewImages(previewImageField.value)
modifierSettingsBtn.addEventListener("click", function(e) {
modifierSettingsOverlay.classList.add("active")
customModifiersTextBox.setSelectionRange(0, 0)
customModifiersTextBox.focus()
customModifiersInitialContent = customModifiersTextBox.value // preserve the initial content
e.stopPropagation()
})
modifierSettingsOverlay.addEventListener("keydown", function(e) {
switch (e.key) {
case "Escape": // Escape to cancel
customModifiersTextBox.value = customModifiersInitialContent // undo the changes
modifierSettingsOverlay.classList.remove("active")
e.stopPropagation()
break
case "Enter":
if (e.ctrlKey) {
// Ctrl+Enter to confirm
modifierSettingsOverlay.classList.remove("active")
e.stopPropagation()
break
}
}
})
function saveCustomModifiers() {
localStorage.setItem(CUSTOM_MODIFIERS_KEY, customModifiersTextBox.value.trim())
@ -407,4 +399,156 @@ function loadCustomModifiers() {
PLUGINS["MODIFIERS_LOAD"].forEach((fn) => fn.loader.call())
}
function showModifierContainer() {
document.addEventListener("mousedown", checkIfClickedOutsideDropdownElem)
modifierDropdown.dataset.active = true
editorModifiersContainer.classList.add("active")
}
function hideModifierContainer() {
document.removeEventListener("click", checkIfClickedOutsideDropdownElem)
modifierDropdown.dataset.active = false
editorModifiersContainer.classList.remove("active")
}
function checkIfClickedOutsideDropdownElem(e) {
const clickedElement = e.target
const clickedInsideSpecificElems = [modifierDropdown, editorModifiersContainer, modifierSettingsDialog].some((div) =>
div && (div.contains(clickedElement) || div === clickedElement))
if (!clickedInsideSpecificElems && !modifierPanelFreezed) {
hideModifierContainer()
}
}
function collapseAllModifierCategory() {
collapseAll(".modifier-category .collapsible")
}
function expandAllModifierCategory() {
expandAll(".modifier-category .collapsible")
}
customModifiersTextBox.addEventListener("change", saveCustomModifiers)
modifierCardSizeSlider.onchange = () => resizeModifierCards(modifierCardSizeSlider.value)
previewImageField.onchange = () => changePreviewImages(previewImageField.value)
modifierSettingsDialog.addEventListener("keydown", function(e) {
switch (e.key) {
case "Escape": // Escape to cancel
customModifiersTextBox.value = customModifiersInitialContent // undo the changes
modifierSettingsDialog.close()
e.stopPropagation()
break
case "Enter":
if (e.ctrlKey) {
// Ctrl+Enter to confirm
modifierSettingsDialog.close()
e.stopPropagation()
break
}
}
})
modifierDropdown.addEventListener("click", e => {
const targetElem = e.target
const isDropdownActive = targetElem.dataset.active == "true" ? true : false
if (!isDropdownActive)
showModifierContainer()
else
hideModifierContainer()
})
let collapsiblesBtnState = false
modifiersCollapsiblesBtn.addEventListener("click", (e) => {
const btnElem = modifiersCollapsiblesBtn
const collapseText = "Collapse Categories"
const expandText = "Expand Categories"
const collapseIconClasses = ["fa-solid", "fa-square-minus"]
const expandIconClasses = ["fa-solid", "fa-square-plus"]
const iconElem = btnElem.querySelector(".modifiers-action-icon")
const textElem = btnElem.querySelector(".modifiers-action-text")
if (collapsiblesBtnState) {
collapseAllModifierCategory()
collapsiblesBtnState = false
collapseIconClasses.forEach((c) => iconElem.classList.remove(c))
expandIconClasses.forEach((c) => iconElem.classList.add(c))
textElem.innerText = expandText
} else {
expandAllModifierCategory()
collapsiblesBtnState = true
expandIconClasses.forEach((c) => iconElem.classList.remove(c))
collapseIconClasses.forEach((c) => iconElem.classList.add(c))
textElem.innerText = collapseText
}
})
let containerSizeBtnState = false
modifiersContainerSizeBtn.addEventListener("click", (e) => {
const btnElem = modifiersContainerSizeBtn
const maximizeIconClasses = ["fa-solid", "fa-expand"]
const revertIconClasses = ["fa-solid", "fa-compress"]
modifiersMainContainer.classList.toggle("modifiers-maximized")
if(containerSizeBtnState) {
revertIconClasses.forEach((c) => btnElem.classList.remove(c))
maximizeIconClasses.forEach((c) => btnElem.classList.add(c))
containerSizeBtnState = false
} else {
maximizeIconClasses.forEach((c) => btnElem.classList.remove(c))
revertIconClasses.forEach((c) => btnElem.classList.add(c))
containerSizeBtnState = true
}
})
modifierSettingsBtn.addEventListener("click", (e) => {
modifierSettingsDialog.showModal()
customModifiersTextBox.setSelectionRange(0, 0)
customModifiersTextBox.focus()
customModifiersInitialContent = customModifiersTextBox.value // preserve the initial content
e.stopPropagation()
})
modifiersCloseBtn.addEventListener("click", (e) => {
hideModifierContainer()
})
// prevents the modifier panel closing at the same time as the settings overlay
new MutationObserver(() => {
const isActive = modifierSettingsDialog.open
if (!isActive) {
modifierPanelFreezed = true
setTimeout(() => modifierPanelFreezed = false, 25)
}
}).observe(modifierSettingsDialog, { attributes: true })
modifierSettingsCloseBtn.addEventListener("click", (e) => {
modifierSettingsDialog.close()
})
modalDialogCloseOnBackdropClick(modifierSettingsDialog)
makeDialogDraggable(modifierSettingsDialog)

View File

@ -18,6 +18,11 @@ const taskConfigSetup = {
visible: ({ reqBody }) => reqBody?.clip_skip,
value: ({ reqBody }) => "yes",
},
tiling: {
label: "Tiling",
visible: ({ reqBody }) => reqBody?.tiling != "none",
value: ({ reqBody }) => reqBody?.tiling,
},
use_vae_model: {
label: "VAE",
visible: ({ reqBody }) => reqBody?.use_vae_model !== undefined && reqBody?.use_vae_model.trim() !== "",
@ -82,19 +87,22 @@ let promptStrengthField = document.querySelector("#prompt_strength")
let samplerField = document.querySelector("#sampler_name")
let samplerSelectionContainer = document.querySelector("#samplerSelection")
let useFaceCorrectionField = document.querySelector("#use_face_correction")
let gfpganModelField = new ModelDropdown(document.querySelector("#gfpgan_model"), "gfpgan")
let gfpganModelField = new ModelDropdown(document.querySelector("#gfpgan_model"), ["gfpgan", "codeformer"], "", false)
let useUpscalingField = document.querySelector("#use_upscale")
let upscaleModelField = document.querySelector("#upscale_model")
let upscaleAmountField = document.querySelector("#upscale_amount")
let latentUpscalerSettings = document.querySelector("#latent_upscaler_settings")
let latentUpscalerStepsSlider = document.querySelector("#latent_upscaler_steps_slider")
let latentUpscalerStepsField = document.querySelector("#latent_upscaler_steps")
let codeformerFidelitySlider = document.querySelector("#codeformer_fidelity_slider")
let codeformerFidelityField = document.querySelector("#codeformer_fidelity")
let stableDiffusionModelField = new ModelDropdown(document.querySelector("#stable_diffusion_model"), "stable-diffusion")
let clipSkipField = document.querySelector("#clip_skip")
let tilingField = document.querySelector("#tiling")
let vaeModelField = new ModelDropdown(document.querySelector("#vae_model"), "vae", "None")
let hypernetworkModelField = new ModelDropdown(document.querySelector("#hypernetwork_model"), "hypernetwork", "None")
let hypernetworkStrengthSlider = document.querySelector("#hypernetwork_strength_slider")
let hypernetworkStrengthField = document.querySelector("#hypernetwork_strength")
let loraModelField = new ModelDropdown(document.querySelector("#lora_model"), "lora", "None")
let loraAlphaSlider = document.querySelector("#lora_alpha_slider")
let loraAlphaField = document.querySelector("#lora_alpha")
let outputFormatField = document.querySelector("#output_format")
let outputLosslessField = document.querySelector("#output_lossless")
let outputLosslessContainer = document.querySelector("#output_lossless_container")
@ -105,6 +113,17 @@ let streamImageProgressField = document.querySelector("#stream_image_progress")
let thumbnailSizeField = document.querySelector("#thumbnail_size-input")
let autoscrollBtn = document.querySelector("#auto_scroll_btn")
let autoScroll = document.querySelector("#auto_scroll")
let embeddingsButton = document.querySelector("#embeddings-button")
let negativeEmbeddingsButton = document.querySelector("#negative-embeddings-button")
let embeddingsDialog = document.querySelector("#embeddings-dialog")
let embeddingsDialogCloseBtn = embeddingsDialog.querySelector("#embeddings-dialog-close-button")
let embeddingsSearchBox = document.querySelector("#embeddings-search-box")
let embeddingsList = document.querySelector("#embeddings-list")
let embeddingsModeField = document.querySelector("#embeddings-mode")
let positiveEmbeddingText = document.querySelector("#positive-embedding-text")
let negativeEmbeddingText = document.querySelector("#negative-embedding-text")
let embeddingsCollapsiblesBtn = document.querySelector("#embeddings-action-collapsibles-btn")
let makeImageBtn = document.querySelector("#makeImage")
let stopImageBtn = document.querySelector("#stopImage")
@ -118,15 +137,18 @@ let initImageClearBtn = document.querySelector(".init_image_clear")
let promptStrengthContainer = document.querySelector("#prompt_strength_container")
let initialText = document.querySelector("#initial-text")
let versionText = document.querySelector("#version")
let previewTools = document.querySelector("#preview-tools")
let clearAllPreviewsBtn = document.querySelector("#clear-all-previews")
let showDownloadPopupBtn = document.querySelector("#show-download-popup")
let saveAllImagesPopup = document.querySelector("#download-images-popup")
let showDownloadDialogBtn = document.querySelector("#show-download-popup")
let saveAllImagesDialog = document.querySelector("#download-images-dialog")
let saveAllImagesBtn = document.querySelector("#save-all-images")
let saveAllImagesCloseBtn = document.querySelector("#download-images-close-button")
let saveAllZipToggle = document.querySelector("#zip_toggle")
let saveAllTreeToggle = document.querySelector("#tree_toggle")
let saveAllJSONToggle = document.querySelector("#json_toggle")
let saveAllFoldersOption = document.querySelector("#download-add-folders")
let splashScreenPopup = document.querySelector("#splash-screen")
let maskSetting = document.querySelector("#enable_mask")
@ -139,6 +161,8 @@ let undoButton = document.querySelector("#undo")
let undoBuffer = []
const UNDO_LIMIT = 20
let loraModels = []
imagePreview.addEventListener("drop", function(ev) {
const data = ev.dataTransfer?.getData("text/plain")
if (!data) {
@ -239,7 +263,7 @@ function setServerStatus(event) {
break
}
if (SD.serverState.devices) {
document.dispatchEvent(new CustomEvent("system_info_update", { detail: SD.serverState.devices}))
document.dispatchEvent(new CustomEvent("system_info_update", { detail: SD.serverState.devices }))
}
}
@ -258,20 +282,13 @@ function shiftOrConfirm(e, prompt, fn) {
if (e.shiftKey || !confirmDangerousActionsField.checked) {
fn(e)
} else {
$.confirm({
theme: "modern",
title: prompt,
useBootstrap: false,
animateFromElement: false,
content:
'<small>Tip: To skip this dialog, use shift-click or disable the "Confirm dangerous actions" setting in the Settings tab.</small>',
buttons: {
yes: () => {
fn(e)
},
cancel: () => {},
},
})
confirm(
'<small>Tip: To skip this dialog, use shift-click or disable the "Confirm dangerous actions" setting in the Settings tab.</small>',
prompt,
() => {
fn(e)
}
)
}
}
@ -293,6 +310,7 @@ function logError(msg, res, outputMsg) {
logMsg(msg, "error", outputMsg)
console.log("request error", res)
console.trace()
setStatus("request", "error", "error")
}
@ -784,11 +802,6 @@ function getTaskUpdater(task, reqBody, outputContainer) {
}
msg += "</pre>"
logError(msg, event, outputMsg)
} else {
let msg = `Unexpected Read Error:<br/><pre>Error:${
this.exception
}<br/>EventInfo: ${JSON.stringify(event, undefined, 4)}</pre>`
logError(msg, event, outputMsg)
}
break
}
@ -885,17 +898,33 @@ function onTaskCompleted(task, reqBody, instance, outputContainer, stepUpdate) {
1. If you have set an initial image, please try reducing its dimension to ${MAX_INIT_IMAGE_DIMENSION}x${MAX_INIT_IMAGE_DIMENSION} or smaller.<br/>
2. Try picking a lower level in the '<em>GPU Memory Usage</em>' setting (in the '<em>Settings</em>' tab).<br/>
3. Try generating a smaller image.<br/>`
} else if (msg.toLowerCase().includes("DefaultCPUAllocator: not enough memory")) {
} else if (msg.includes("DefaultCPUAllocator: not enough memory")) {
msg += `<br/><br/>
Reason: Your computer is running out of system RAM!
<br/>
<br/><br/>
<b>Suggestions</b>:
<br/>
1. Try closing unnecessary programs and browser tabs.<br/>
2. If that doesn't help, please increase your computer's virtual memory by following these steps for
<a href="https://www.ibm.com/docs/en/opw/8.2.0?topic=tuning-optional-increasing-paging-file-size-windows-computers" target="_blank">Windows</a>, or
<a href="https://www.ibm.com/docs/en/opw/8.2.0?topic=tuning-optional-increasing-paging-file-size-windows-computers" target="_blank">Windows</a> or
<a href="https://linuxhint.com/increase-swap-space-linux/" target="_blank">Linux</a>.<br/>
3. Try restarting your computer.<br/>`
} else if (msg.includes("RuntimeError: output with shape [320, 320] doesn't match the broadcast shape")) {
msg += `<br/><br/>
<b>Reason</b>: You tried to use a LORA that was trained for a different Stable Diffusion model version!
<br/><br/>
<b>Suggestions</b>:
<br/>
Try to use a different model or a different LORA.`
} else if (msg.includes("Tensor on device cuda:0 is not on the expected device meta")) {
msg += `<br/><br/>
<b>Reason</b>: Due to some software issues, embeddings currently don't work with the "Low" memory profile.
<br/><br/>
<b>Suggestions</b>:
<br/>
1. Set the memory profile to "Balanced"<br/>
2. Remove the embeddings from the prompt and the negative prompt<br/>
3. Check whether the plugins you're using change the memory profile automatically.`
}
} else {
msg = `Unexpected Read Error:<br/><pre>StepUpdate: ${JSON.stringify(stepUpdate, undefined, 4)}</pre>`
@ -1231,6 +1260,7 @@ function getCurrentUserRequest() {
//render_device: undefined, // Set device affinity. Prefer this device, but wont activate.
use_stable_diffusion_model: stableDiffusionModelField.value,
clip_skip: clipSkipField.checked,
tiling: tilingField.value,
use_vae_model: vaeModelField.value,
stream_progress_updates: true,
stream_image_progress: numOutputsTotal > 50 ? false : streamImageProgressField.checked,
@ -1264,22 +1294,49 @@ function getCurrentUserRequest() {
}
if (useFaceCorrectionField.checked) {
newTask.reqBody.use_face_correction = gfpganModelField.value
if (gfpganModelField.value.includes("codeformer")) {
newTask.reqBody.codeformer_upscale_faces = document.querySelector("#codeformer_upscale_faces").checked
newTask.reqBody.codeformer_fidelity = 1 - parseFloat(codeformerFidelityField.value)
}
}
if (useUpscalingField.checked) {
newTask.reqBody.use_upscale = upscaleModelField.value
newTask.reqBody.upscale_amount = upscaleAmountField.value
if (upscaleModelField.value === "latent_upscaler") {
newTask.reqBody.upscale_amount = "2"
newTask.reqBody.latent_upscaler_steps = latentUpscalerStepsField.value
}
}
if (hypernetworkModelField.value) {
newTask.reqBody.use_hypernetwork_model = hypernetworkModelField.value
newTask.reqBody.hypernetwork_strength = parseFloat(hypernetworkStrengthField.value)
}
if (testDiffusers.checked && loraModelField.value) {
newTask.reqBody.use_lora_model = loraModelField.value
newTask.reqBody.lora_alpha = parseFloat(loraAlphaField.value)
if (testDiffusers.checked) {
let [modelNames, modelStrengths] = getModelInfo(loraModels)
if (modelNames.length > 0) {
modelNames = modelNames.length == 1 ? modelNames[0] : modelNames
modelStrengths = modelStrengths.length == 1 ? modelStrengths[0] : modelStrengths
newTask.reqBody.use_lora_model = modelNames
newTask.reqBody.lora_alpha = modelStrengths
}
}
return newTask
}
function getModelInfo(models) {
let modelInfo = models.map((e) => [e[0].value, e[1].value])
modelInfo = modelInfo.filter((e) => e[0].trim() !== "")
modelInfo = modelInfo.map((e) => [e[0], parseFloat(e[1])])
let modelNames = modelInfo.map((e) => e[0])
let modelStrengths = modelInfo.map((e) => e[1])
return [modelNames, modelStrengths]
}
function getPrompts(prompts) {
if (typeof prompts === "undefined") {
prompts = promptField.value
@ -1317,6 +1374,58 @@ function getPrompts(prompts) {
return promptsToMake
}
function getPromptsNumber(prompts) {
if (typeof prompts === "undefined") {
prompts = promptField.value
}
if (prompts.trim() === "" && activeTags.length === 0) {
return [""]
}
let promptsToMake = []
let numberOfPrompts = 0
if (prompts.trim() !== "") {
// this needs to stay sort of the same, as the prompts have to be passed through to the other functions
prompts = prompts.split("\n")
prompts = prompts.map((prompt) => prompt.trim())
prompts = prompts.filter((prompt) => prompt !== "")
// estimate number of prompts
let estimatedNumberOfPrompts = 0
prompts.forEach((prompt) => {
estimatedNumberOfPrompts +=
(prompt.match(/{[^}]*}/g) || [])
.map((e) => (e.match(/,/g) || []).length + 1)
.reduce((p, a) => p * a, 1) *
2 ** (prompt.match(/\|/g) || []).length
})
if (estimatedNumberOfPrompts >= 10000) {
return 10000
}
promptsToMake = applySetOperator(prompts) // switched those around as Set grows in a linear fashion and permute in 2^n, and one has to be computed for the other to be calculated
numberOfPrompts = applyPermuteOperatorNumber(promptsToMake)
}
const newTags = activeTags.filter((tag) => tag.inactive === undefined || tag.inactive === false)
if (newTags.length > 0) {
const promptTags = newTags.map((x) => x.name).join(", ")
if (numberOfPrompts > 0) {
// promptsToMake = promptsToMake.map((prompt) => `${prompt}, ${promptTags}`)
// nothing changes, as all prompts just get modified
} else {
// promptsToMake.push(promptTags)
numberOfPrompts = 1
}
}
// Why is this applied twice? It does not do anything here, as everything should have already been done earlier
// promptsToMake = applyPermuteOperator(promptsToMake)
// promptsToMake = applySetOperator(promptsToMake)
return numberOfPrompts
}
function applySetOperator(prompts) {
let promptsToMake = []
let braceExpander = new BraceExpander()
@ -1329,6 +1438,7 @@ function applySetOperator(prompts) {
}
function applyPermuteOperator(prompts) {
// prompts is array of input, trimmed, filtered and split by \n
let promptsToMake = []
prompts.forEach((prompt) => {
let promptMatrix = prompt.split("|")
@ -1347,6 +1457,27 @@ function applyPermuteOperator(prompts) {
return promptsToMake
}
// returns how many prompts would have to be made with the given prompts
function applyPermuteOperatorNumber(prompts) {
// prompts is array of input, trimmed, filtered and split by \n
let numberOfPrompts = 0
prompts.forEach((prompt) => {
let promptCounter = 1
let promptMatrix = prompt.split("|")
promptMatrix.shift()
promptMatrix = promptMatrix.map((p) => p.trim())
promptMatrix = promptMatrix.filter((p) => p !== "")
if (promptMatrix.length > 0) {
promptCounter *= permuteNumber(promptMatrix)
}
numberOfPrompts += promptCounter
})
return numberOfPrompts
}
function permutePrompts(promptBase, promptMatrix) {
let prompts = []
let permutations = permute(promptMatrix)
@ -1424,9 +1555,14 @@ clearAllPreviewsBtn.addEventListener("click", (e) => {
})
/* Download images popup */
showDownloadPopupBtn.addEventListener("click", (e) => {
saveAllImagesPopup.classList.add("active")
showDownloadDialogBtn.addEventListener("click", (e) => {
saveAllImagesDialog.showModal()
})
saveAllImagesCloseBtn.addEventListener("click", (e) => {
saveAllImagesDialog.close()
})
modalDialogCloseOnBackdropClick(saveAllImagesDialog)
makeDialogDraggable(saveAllImagesDialog)
saveAllZipToggle.addEventListener("change", (e) => {
if (saveAllZipToggle.checked) {
@ -1536,15 +1672,17 @@ heightField.addEventListener("change", onDimensionChange)
function renameMakeImageButton() {
let totalImages =
Math.max(parseInt(numOutputsTotalField.value), parseInt(numOutputsParallelField.value)) * getPrompts().length
Math.max(parseInt(numOutputsTotalField.value), parseInt(numOutputsParallelField.value)) * getPromptsNumber()
let imageLabel = "Image"
if (totalImages > 1) {
imageLabel = totalImages + " Images"
}
if (SD.activeTasks.size == 0) {
makeImageBtn.innerText = "Make " + imageLabel
if (totalImages >= 10000) makeImageBtn.innerText = "Make 10000+ images"
else makeImageBtn.innerText = "Make " + imageLabel
} else {
makeImageBtn.innerText = "Enqueue Next " + imageLabel
if (totalImages >= 10000) makeImageBtn.innerText = "Enqueue 10000+ images"
else makeImageBtn.innerText = "Enqueue Next " + imageLabel
}
}
numOutputsTotalField.addEventListener("change", renameMakeImageButton)
@ -1573,15 +1711,48 @@ metadataOutputFormatField.disabled = !saveToDiskField.checked
gfpganModelField.disabled = !useFaceCorrectionField.checked
useFaceCorrectionField.addEventListener("change", function(e) {
gfpganModelField.disabled = !this.checked
onFixFaceModelChange()
})
function onFixFaceModelChange() {
let codeformerSettings = document.querySelector("#codeformer_settings")
if (gfpganModelField.value === "codeformer" && !gfpganModelField.disabled) {
codeformerSettings.classList.remove("displayNone")
codeformerSettings.classList.add("expandedSettingRow")
} else {
codeformerSettings.classList.add("displayNone")
codeformerSettings.classList.remove("expandedSettingRow")
}
}
gfpganModelField.addEventListener("change", onFixFaceModelChange)
onFixFaceModelChange()
upscaleModelField.disabled = !useUpscalingField.checked
upscaleAmountField.disabled = !useUpscalingField.checked
useUpscalingField.addEventListener("change", function(e) {
upscaleModelField.disabled = !this.checked
upscaleAmountField.disabled = !this.checked
onUpscaleModelChange()
})
function onUpscaleModelChange() {
let upscale4x = document.querySelector("#upscale_amount_4x")
if (upscaleModelField.value === "latent_upscaler" && !upscaleModelField.disabled) {
upscale4x.disabled = true
upscaleAmountField.value = "2"
latentUpscalerSettings.classList.remove("displayNone")
latentUpscalerSettings.classList.add("expandedSettingRow")
} else {
upscale4x.disabled = false
latentUpscalerSettings.classList.add("displayNone")
latentUpscalerSettings.classList.remove("expandedSettingRow")
}
}
upscaleModelField.addEventListener("change", onUpscaleModelChange)
onUpscaleModelChange()
makeImageBtn.addEventListener("click", makeImage)
document.onkeydown = function(e) {
@ -1591,6 +1762,48 @@ document.onkeydown = function(e) {
}
}
/********************* CodeFormer Fidelity **************************/
function updateCodeformerFidelity() {
codeformerFidelityField.value = codeformerFidelitySlider.value / 10
codeformerFidelityField.dispatchEvent(new Event("change"))
}
function updateCodeformerFidelitySlider() {
if (codeformerFidelityField.value < 0) {
codeformerFidelityField.value = 0
} else if (codeformerFidelityField.value > 1) {
codeformerFidelityField.value = 1
}
codeformerFidelitySlider.value = codeformerFidelityField.value * 10
codeformerFidelitySlider.dispatchEvent(new Event("change"))
}
codeformerFidelitySlider.addEventListener("input", updateCodeformerFidelity)
codeformerFidelityField.addEventListener("input", updateCodeformerFidelitySlider)
updateCodeformerFidelity()
/********************* Latent Upscaler Steps **************************/
function updateLatentUpscalerSteps() {
latentUpscalerStepsField.value = latentUpscalerStepsSlider.value
latentUpscalerStepsField.dispatchEvent(new Event("change"))
}
function updateLatentUpscalerStepsSlider() {
if (latentUpscalerStepsField.value < 1) {
latentUpscalerStepsField.value = 1
} else if (latentUpscalerStepsField.value > 50) {
latentUpscalerStepsField.value = 50
}
latentUpscalerStepsSlider.value = latentUpscalerStepsField.value
latentUpscalerStepsSlider.dispatchEvent(new Event("change"))
}
latentUpscalerStepsSlider.addEventListener("input", updateLatentUpscalerSteps)
latentUpscalerStepsField.addEventListener("input", updateLatentUpscalerStepsSlider)
updateLatentUpscalerSteps()
/********************* Guidance **************************/
function updateGuidanceScale() {
guidanceScaleField.value = guidanceScaleSlider.value / 10
@ -1661,33 +1874,6 @@ function updateHypernetworkStrengthContainer() {
hypernetworkModelField.addEventListener("change", updateHypernetworkStrengthContainer)
updateHypernetworkStrengthContainer()
/********************* LoRA alpha **********************/
function updateLoraAlpha() {
loraAlphaField.value = loraAlphaSlider.value / 100
loraAlphaField.dispatchEvent(new Event("change"))
}
function updateLoraAlphaSlider() {
if (loraAlphaField.value < 0) {
loraAlphaField.value = 0
} else if (loraAlphaField.value > 1) {
loraAlphaField.value = 1
}
loraAlphaSlider.value = loraAlphaField.value * 100
loraAlphaSlider.dispatchEvent(new Event("change"))
}
loraAlphaSlider.addEventListener("input", updateLoraAlpha)
loraAlphaField.addEventListener("input", updateLoraAlphaSlider)
updateLoraAlpha()
function updateLoraAlphaContainer() {
document.querySelector("#lora_alpha_container").style.display = loraModelField.value === "" ? "none" : ""
}
loraModelField.addEventListener("change", updateLoraAlphaContainer)
updateLoraAlphaContainer()
/********************* JPEG/WEBP Quality **********************/
function updateOutputQuality() {
outputQualityField.value = 0 | outputQualitySlider.value
@ -1905,6 +2091,21 @@ function resumeClient() {
})
}
function splashScreen(force = false) {
const splashVersion = splashScreenPopup.dataset["version"]
const lastSplash = localStorage.getItem("lastSplashScreenVersion") || 0
if (testDiffusers.checked) {
if (force || lastSplash < splashVersion) {
splashScreenPopup.classList.add("active")
localStorage.setItem("lastSplashScreenVersion", splashVersion)
}
}
}
document.getElementById("logo_img").addEventListener("click", (e) => {
splashScreen(true)
})
promptField.addEventListener("input", debounce(renameMakeImageButton, 1000))
pauseBtn.addEventListener("click", function() {
@ -1922,6 +2123,181 @@ resumeBtn.addEventListener("click", function() {
document.body.classList.remove("wait-pause")
})
function tunnelUpdate(event) {
if ("cloudflare" in event) {
document.getElementById("cloudflare-off").classList.add("displayNone")
document.getElementById("cloudflare-on").classList.remove("displayNone")
cloudflareAddressField.value = event.cloudflare
document.getElementById("toggle-cloudflare-tunnel").innerHTML = "Stop"
} else {
document.getElementById("cloudflare-on").classList.add("displayNone")
document.getElementById("cloudflare-off").classList.remove("displayNone")
document.getElementById("toggle-cloudflare-tunnel").innerHTML = "Start"
}
}
document.getElementById("toggle-cloudflare-tunnel").addEventListener("click", async function() {
let command = "stop"
if (document.getElementById("toggle-cloudflare-tunnel").innerHTML == "Start") {
command = "start"
}
showToast(`Cloudflare tunnel ${command} initiated. Please wait.`)
let res = await fetch("/tunnel/cloudflare/" + command, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({}),
})
res = await res.json()
console.log(`Cloudflare tunnel ${command} result:`, res)
})
/* Embeddings */
function updateEmbeddingsList(filter = "") {
function html(model, prefix = "", filter = "") {
filter = filter.toLowerCase()
let toplevel = ""
let folders = ""
model?.forEach((m) => {
if (typeof m == "string") {
if (m.toLowerCase().search(filter) != -1) {
toplevel += `<button data-embedding="${m}">${m}</button> `
}
} else {
let subdir = html(m[1], prefix + m[0] + "/", filter)
if (subdir != "") {
folders += `<div class="embedding-category"><h4 class="collapsible">${prefix}${m[0]}</h4><div class="collapsible-content">` + subdir + '</div></div>'
}
}
})
return toplevel + folders
}
function onButtonClick(e) {
let text = e.target.dataset["embedding"]
const insertIntoNegative = e.shiftKey || positiveEmbeddingText.classList.contains("displayNone")
if (embeddingsModeField.value == "insert") {
if (insertIntoNegative) {
insertAtCursor(negativePromptField, text)
} else {
insertAtCursor(promptField, text)
}
} else {
let pad = ""
if (insertIntoNegative) {
if (!negativePromptField.value.endsWith(" ")) {
pad = " "
}
negativePromptField.value += pad + text
} else {
if (!promptField.value.endsWith(" ")) {
pad = " "
}
promptField.value += pad + text
}
}
}
// Remove after fixing https://github.com/huggingface/diffusers/issues/3922
let warning = ""
if (vramUsageLevelField.value == "low") {
warning = `
<div style="border-color: var(--accent-color); border-width: 4px; border-radius: 1em; border-style: solid; background: black; text-align: center; padding: 1em; margin: 1em; ">
<i class="fa fa-fire" style="color:#f7630c;"></i> Warning: Your GPU memory profile is set to "Low". Embeddings currently only work in "Balanced" mode!
</div>`
}
// END of remove block
embeddingsList.innerHTML = warning + html(modelsOptions.embeddings, "", filter)
embeddingsList.querySelectorAll("button").forEach((b) => {
b.addEventListener("click", onButtonClick)
})
createCollapsibles(embeddingsList)
if (filter != "") {
embeddingsExpandAll()
}
}
function showEmbeddingDialog() {
updateEmbeddingsList()
embeddingsSearchBox.value = ""
embeddingsDialog.showModal()
}
embeddingsButton.addEventListener("click", () => {
positiveEmbeddingText.classList.remove("displayNone")
negativeEmbeddingText.classList.add("displayNone")
showEmbeddingDialog()
})
negativeEmbeddingsButton.addEventListener("click", () => {
positiveEmbeddingText.classList.add("displayNone")
negativeEmbeddingText.classList.remove("displayNone")
showEmbeddingDialog()
})
embeddingsDialogCloseBtn.addEventListener("click", (e) => {
embeddingsDialog.close()
})
embeddingsSearchBox.addEventListener("input", (e) => {
updateEmbeddingsList(embeddingsSearchBox.value)
})
modalDialogCloseOnBackdropClick(embeddingsDialog)
makeDialogDraggable(embeddingsDialog)
const collapseText = "Collapse Categories"
const expandText = "Expand Categories"
const collapseIconClasses = ["fa-solid", "fa-square-minus"]
const expandIconClasses = ["fa-solid", "fa-square-plus"]
function embeddingsCollapseAll() {
const btnElem = embeddingsCollapsiblesBtn
const iconElem = btnElem.querySelector(".embeddings-action-icon")
const textElem = btnElem.querySelector(".embeddings-action-text")
collapseAll("#embeddings-list .collapsible")
collapsiblesBtnState = false
collapseIconClasses.forEach((c) => iconElem.classList.remove(c))
expandIconClasses.forEach((c) => iconElem.classList.add(c))
textElem.innerText = expandText
}
function embeddingsExpandAll() {
const btnElem = embeddingsCollapsiblesBtn
const iconElem = btnElem.querySelector(".embeddings-action-icon")
const textElem = btnElem.querySelector(".embeddings-action-text")
expandAll("#embeddings-list .collapsible")
collapsiblesBtnState = true
expandIconClasses.forEach((c) => iconElem.classList.remove(c))
collapseIconClasses.forEach((c) => iconElem.classList.add(c))
textElem.innerText = collapseText
}
embeddingsCollapsiblesBtn.addEventListener("click", (e) => {
if (collapsiblesBtnState) {
embeddingsCollapseAll()
} else {
embeddingsExpandAll()
}
})
if (testDiffusers.checked) {
document.getElementById("embeddings-container").classList.remove("displayNone")
}
/* Pause function */
document.querySelectorAll(".tab").forEach(linkTabContents)
@ -1944,3 +2320,73 @@ prettifyInputs(document)
// set the textbox as focused on start
promptField.focus()
promptField.selectionStart = promptField.value.length
// multi-models
let modelCount = 0
function addModelEntry(modelContainer, modelsList, modelType, defaultValue, strengthStep) {
let idx = modelCount++
let nameId = modelType + "_model_" + idx
let strengthId = modelType + "_alpha_" + idx
const modelElement = document.createElement("div")
modelElement.className = "model_entry"
modelElement.innerHTML = `
<input id="${nameId}" class="model_name" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
<input id="${strengthId}" class="model_strength" type="number" step="${strengthStep}" style="width: 50pt" value="${defaultValue}" pattern="^-?[0-9]*\.?[0-9]*$" onkeypress="preventNonNumericalInput(event)">
`
modelContainer.appendChild(modelElement)
let modelName = new ModelDropdown(modelElement.querySelector(".model_name"), modelType, "None")
let modelStrength = modelElement.querySelector(".model_strength")
let entry = [modelName, modelStrength, modelElement]
let removeBtn = document.createElement("button")
removeBtn.className = "remove_model_btn"
removeBtn.setAttribute("title", "Remove model")
removeBtn.innerHTML = '<i class="fa-solid fa-minus"></i>'
if (modelsList.length === 0) {
removeBtn.classList.add("displayNone")
}
removeBtn.addEventListener("click", function() {
let entryIdx = modelsList.indexOf(entry)
modelsList.splice(entryIdx, 1)
modelContainer.removeChild(modelElement)
})
modelElement.appendChild(removeBtn)
modelsList.push(entry)
return modelElement
}
function createLoraEntry() {
let container = document.querySelector("#lora_model_container .model_entries")
return addModelEntry(container, loraModels, "lora", 0.5, 0.02)
}
function createLoraEntries() {
let firstEntry = createLoraEntry()
let addLoraBtn = document.querySelector("#lora_model_container .add_model_entry")
addLoraBtn.addEventListener("click", () => {
createLoraEntry()
})
}
createLoraEntries()
// chrome-like spinners only on hover
// function showSpinnerOnlyOnHover(e) {
// e.addEventListener("mouseenter", () => {
// e.setAttribute("type", "number")
// })
// e.addEventListener("mouseleave", () => {
// e.removeAttribute("type")
// })
// e.removeAttribute("type")
// }
// document.querySelectorAll("input[type=number]").forEach(showSpinnerOnlyOnHover)

View File

@ -11,6 +11,12 @@ var ParameterType = {
custom: "custom",
}
/**
* Element shortcuts
*/
let parametersTable = document.querySelector("#system-settings-table")
let networkParametersTable = document.querySelector("#system-settings-network-table")
/**
* JSDoc style
* @typedef {object} Parameter
@ -186,17 +192,20 @@ var PARAMETERS = [
icon: "fa-network-wired",
default: true,
saveInAppConfig: true,
table: networkParametersTable,
},
{
id: "listen_port",
type: ParameterType.custom,
label: "Network port",
note: "Port that this server listens to. The '9000' part in 'http://localhost:9000'. Please restart the program after changing this.",
note:
"Port that this server listens to. The '9000' part in 'http://localhost:9000'. Please restart the program after changing this.",
icon: "fa-anchor",
render: (parameter) => {
return `<input id="${parameter.id}" name="${parameter.id}" size="6" value="9000" onkeypress="preventNonNumericalInput(event)">`
},
saveInAppConfig: true,
table: networkParametersTable,
},
{
id: "use_beta_channel",
@ -217,6 +226,21 @@ var PARAMETERS = [
default: false,
saveInAppConfig: true,
},
{
id: "cloudflare",
type: ParameterType.custom,
label: "Cloudflare tunnel",
note: `<span id="cloudflare-off">Create a VPN tunnel to share your Easy Diffusion instance with your friends. This will
generate a web server address on the public Internet for your Easy Diffusion instance. </span>
<div id="cloudflare-on" class="displayNone"><div>This Easy Diffusion server is available on the Internet using the
address:</div><div><input id="cloudflare-address" value="" readonly><button id="copy-cloudflare-address">Copy</button></div></div>
<b>Anyone knowing this address can access your server.</b> The address of your server will change each time
you share a session.<br>
Uses <a href="https://try.cloudflare.com/" target="_blank">Cloudflare services</a>.`,
icon: ["fa-brands", "fa-cloudflare"],
render: () => '<button id="toggle-cloudflare-tunnel" class="primaryButton">Start</button>',
table: networkParametersTable,
},
]
function getParameterSettingsEntry(id) {
@ -265,7 +289,6 @@ function getParameterElement(parameter) {
}
}
let parametersTable = document.querySelector("#system-settings .parameters-table")
/**
* fill in the system settings popup table
* @param {Array<Parameter> | undefined} parameters
@ -292,7 +315,10 @@ function initParameters(parameters) {
noteElements.push(noteElement)
}
const icon = parameter.icon ? [createElement("i", undefined, ["fa", parameter.icon])] : []
if (typeof parameter.icon == "string") {
parameter.icon = [parameter.icon]
}
const icon = parameter.icon ? [createElement("i", undefined, ["fa", ...parameter.icon])] : []
const label = typeof parameter.label === "function" ? parameter.label(parameter) : parameter.label
const labelElement = createElement("label", { for: parameter.id })
@ -312,7 +338,13 @@ function initParameters(parameters) {
elementWrapper,
]
)
parametersTable.appendChild(newrow)
let p = parametersTable
if (parameter.table) {
p = parameter.table
}
p.appendChild(newrow)
parameter.settingsEntry = newrow
})
}
@ -377,7 +409,7 @@ async function getAppConfig() {
useBetaChannelField.checked = true
document.querySelector("#updateBranchLabel").innerText = "(beta)"
} else {
getParameterSettingsEntry("test_diffusers").style.display = "none"
getParameterSettingsEntry("test_diffusers").classList.add("displayNone")
}
if (config.ui && config.ui.open_browser_on_start === false) {
uiOpenBrowserOnStartField.checked = false
@ -392,21 +424,33 @@ async function getAppConfig() {
const testDiffusersEnabled = config.test_diffusers && config.update_branch !== "main"
testDiffusers.checked = testDiffusersEnabled
if (config.config_on_startup) {
if (config.config_on_startup?.test_diffusers && config.update_branch !== "main") {
document.body.classList.add("diffusers-enabled-on-startup")
document.body.classList.remove("diffusers-disabled-on-startup")
} else {
document.body.classList.add("diffusers-disabled-on-startup")
document.body.classList.remove("diffusers-enabled-on-startup")
}
}
if (!testDiffusersEnabled) {
document.querySelector("#lora_model_container").style.display = "none"
document.querySelector("#lora_alpha_container").style.display = "none"
document.querySelector("#tiling_container").style.display = "none"
document.querySelectorAll("#sampler_name option.diffusers-only").forEach(option => {
document.querySelectorAll("#sampler_name option.diffusers-only").forEach((option) => {
option.style.display = "none"
})
} else {
document.querySelector("#lora_model_container").style.display = ""
document.querySelector("#lora_alpha_container").style.display = loraModelField.value ? "" : "none"
document.querySelector("#tiling_container").style.display = ""
document.querySelectorAll("#sampler_name option.k_diffusion-only").forEach(option => {
option.disabled = true
document.querySelectorAll("#sampler_name option.k_diffusion-only").forEach((option) => {
option.style.display = "none"
})
document.querySelector("#clip_skip_config").classList.remove("displayNone")
document.querySelector("#embeddings-button").classList.remove("displayNone")
document.querySelector("#negative-embeddings-button").classList.remove("displayNone")
}
console.log("get config status response", config)
@ -568,6 +612,16 @@ async function getSystemInfo() {
if (allDeviceIds.length === 0) {
useCPUField.checked = true
useCPUField.disabled = true // no compatible GPUs, so make the CPU mandatory
getParameterSettingsEntry("use_cpu").addEventListener("click", function() {
alert(
"Sorry, we could not find a compatible graphics card! Easy Diffusion supports graphics cards with minimum 2 GB of RAM. " +
"Only NVIDIA cards are supported on Windows. NVIDIA and AMD cards are supported on Linux.<br/><br/>" +
"If you have a compatible graphics card, please try updating to the latest drivers.<br/><br/>" +
"Only the CPU can be used for generating images, without a compatible graphics card.",
"No compatible graphics card found!"
)
})
}
autoPickGPUsField.checked = devices["config"] === "auto"
@ -586,7 +640,7 @@ async function getSystemInfo() {
$("#use_gpus").val(activeDeviceIds)
}
document.dispatchEvent(new CustomEvent("system_info_update", { detail: devices}))
document.dispatchEvent(new CustomEvent("system_info_update", { detail: devices }))
setHostInfo(res["hosts"])
let force = false
if (res["enforce_output_dir"] !== undefined) {
@ -620,7 +674,7 @@ saveSettingsBtn.addEventListener("click", function() {
update_branch: updateBranch,
}
Array.from(parametersTable.children).forEach((parameterRow) => {
document.querySelectorAll("#system-settings [data-setting-id]").forEach((parameterRow) => {
if (parameterRow.dataset.saveInAppConfig === "true") {
const parameterElement =
document.getElementById(parameterRow.dataset.settingId) ||
@ -654,8 +708,46 @@ saveSettingsBtn.addEventListener("click", function() {
})
const savePromise = changeAppConfig(updateAppConfigRequest)
showToast("Settings saved")
saveSettingsBtn.classList.add("active")
Promise.all([savePromise, asyncDelay(300)]).then(() => saveSettingsBtn.classList.remove("active"))
})
listenToNetworkField.addEventListener(
"change",
debounce(() => {
saveSettingsBtn.click()
}, 1000)
)
listenPortField.addEventListener(
"change",
debounce(() => {
saveSettingsBtn.click()
}, 1000)
)
let copyCloudflareAddressBtn = document.querySelector("#copy-cloudflare-address")
let cloudflareAddressField = document.getElementById("cloudflare-address")
navigator.permissions.query({ name: "clipboard-write" }).then(function(result) {
if (result.state === "granted") {
// you can read from the clipboard
copyCloudflareAddressBtn.addEventListener("click", (e) => {
navigator.clipboard.writeText(cloudflareAddressField.innerHTML)
showToast("Copied server address to clipboard")
})
} else {
copyCloudflareAddressBtn.classList.add("displayNone")
}
})
document.addEventListener("system_info_update", (e) => setDeviceInfo(e.detail))
useBetaChannelField.addEventListener('change', (e) => {
if (e.target.checked) {
getParameterSettingsEntry("test_diffusers").classList.remove('displayNone')
} else {
getParameterSettingsEntry("test_diffusers").classList.add('displayNone')
}
})

View File

@ -1,5 +1,8 @@
const PLUGIN_API_VERSION = "1.0"
const PLUGIN_CATALOG = 'https://raw.githubusercontent.com/easydiffusion/easydiffusion-plugins/main/plugins.json'
const PLUGIN_CATALOG_GITHUB = 'https://github.com/easydiffusion/easydiffusion-plugins/blob/main/plugins.json'
const PLUGINS = {
/**
* Register new buttons to show on each output image.
@ -78,3 +81,950 @@ async function loadUIPlugins() {
console.log("error fetching plugin paths", e)
}
}
/* PLUGIN MANAGER */
/* plugin tab */
// document.querySelector('.tab-container')?.insertAdjacentHTML('beforeend', `
// <span id="tab-plugin" class="tab" style="display: none">
// <span><i class="fa fa-puzzle-piece icon"></i> Plugins</span>
// </span>
// `)
// document.querySelector('#tab-content-wrapper')?.insertAdjacentHTML('beforeend', `
// <div id="tab-content-plugin" class="tab-content">
// <div id="plugin" class="tab-content-inner">
// Loading...
// </div>
// </div>
// `)
// const tabPlugin = document.querySelector('#tab-plugin')
// if (tabPlugin) {
// linkTabContents(tabPlugin)
// }
// const plugin = document.querySelector('#plugin')
// plugin.innerHTML = `
// <div id="plugin-manager" class="tab-content-inner">
// <i id="plugin-notification-button" class="fa-solid fa-message">
// <span class="plugin-notification-pill" id="notification-pill" style="display: none"></span>
// </i>
// <div id="plugin-notification-list" style="display: none">
// <h1>Notifications</h1>
// <div class="plugin-manager-intro">The latest plugin updates are listed below</div>
// <div class="notifications-table"></div>
// <div class="no-notification">No new notifications</div>
// </div>
// <div id="plugin-manager-section">
// <h1>Plugin Manager</h1>
// <div class="plugin-manager-intro">Changes take effect after reloading the page</div>
// <div class="plugins-table"></div>
// </div>
// </div>`
// const pluginsTable = document.querySelector("#plugin-manager-section .plugins-table")
// const pluginNotificationTable = document.querySelector("#plugin-notification-list .notifications-table")
// const pluginNoNotification = document.querySelector("#plugin-notification-list .no-notification")
// /* notification center */
// const pluginNotificationButton = document.getElementById("plugin-notification-button");
// const pluginNotificationList = document.getElementById("plugin-notification-list");
// const notificationPill = document.getElementById("notification-pill");
// const pluginManagerSection = document.getElementById("plugin-manager-section");
// let pluginNotifications;
// // Add event listener to show/hide the action center
// pluginNotificationButton.addEventListener("click", function () {
// // Hide the notification pill when the action center is opened
// notificationPill.style.display = "none"
// pluginNotifications.lastUpdated = Date.now()
// // save the notifications
// setStorageData('notifications', JSON.stringify(pluginNotifications))
// renderPluginNotifications()
// if (pluginNotificationList.style.display === "none") {
// pluginNotificationList.style.display = "block"
// pluginManagerSection.style.display = "none"
// } else {
// pluginNotificationList.style.display = "none"
// pluginManagerSection.style.display = "block"
// }
// })
// document.addEventListener("tabClick", (e) => {
// if (e.detail.name == 'plugin') {
// pluginNotificationList.style.display = "none"
// pluginManagerSection.style.display = "block"
// }
// })
// async function addPluginNotification(pluginNotifications, messageText, error) {
// const now = Date.now()
// pluginNotifications.entries.unshift({ date: now, text: messageText, error: error }); // add new entry to the beginning of the array
// if (pluginNotifications.entries.length > 50) {
// pluginNotifications.entries.length = 50 // limit array length to 50 entries
// }
// pluginNotifications.lastUpdated = now
// notificationPill.style.display = "block"
// // save the notifications
// await setStorageData('notifications', JSON.stringify(pluginNotifications))
// }
// function timeAgo(inputDate) {
// const now = new Date();
// const date = new Date(inputDate);
// const diffInSeconds = Math.floor((now - date) / 1000);
// const units = [
// { name: 'year', seconds: 31536000 },
// { name: 'month', seconds: 2592000 },
// { name: 'week', seconds: 604800 },
// { name: 'day', seconds: 86400 },
// { name: 'hour', seconds: 3600 },
// { name: 'minute', seconds: 60 },
// { name: 'second', seconds: 1 }
// ];
// for (const unit of units) {
// const unitValue = Math.floor(diffInSeconds / unit.seconds);
// if (unitValue > 0) {
// return `${unitValue} ${unit.name}${unitValue > 1 ? 's' : ''} ago`;
// }
// }
// return 'just now';
// }
// function convertSeconds(seconds) {
// const hours = Math.floor(seconds / 3600);
// const minutes = Math.floor((seconds % 3600) / 60);
// const remainingSeconds = seconds % 60;
// let timeParts = [];
// if (hours === 1) {
// timeParts.push(`${hours} hour`);
// } else if (hours > 1) {
// timeParts.push(`${hours} hours`);
// }
// if (minutes === 1) {
// timeParts.push(`${minutes} minute`);
// } else if (minutes > 1) {
// timeParts.push(`${minutes} minutes`);
// }
// if (remainingSeconds === 1) {
// timeParts.push(`${remainingSeconds} second`);
// } else if (remainingSeconds > 1) {
// timeParts.push(`${remainingSeconds} seconds`);
// }
// return timeParts.join(', and ');
// }
// function renderPluginNotifications() {
// pluginNotificationTable.innerHTML = ''
// if (pluginNotifications.entries?.length > 0) {
// pluginNoNotification.style.display = "none"
// pluginNotificationTable.style.display = "block"
// }
// else {
// pluginNoNotification.style.display = "block"
// pluginNotificationTable.style.display = "none"
// }
// for (let i = 0; i < pluginNotifications.entries?.length; i++) {
// const date = pluginNotifications.entries[i].date
// const text = pluginNotifications.entries[i].text
// const error = pluginNotifications.entries[i].error
// const newRow = document.createElement('div')
// newRow.innerHTML = `
// <div${error === true ? ' class="notification-error"' : ''}>${text}</div>
// <div><small>${timeAgo(date)}</small></div>
// `;
// pluginNotificationTable.appendChild(newRow)
// }
// }
// /* search box */
// function filterPlugins() {
// let search = pluginFilter.value.toLowerCase();
// let searchTerms = search.split(' ');
// let labels = pluginsTable.querySelectorAll("label.plugin-name");
// for (let i = 0; i < labels.length; i++) {
// let label = labels[i].innerText.toLowerCase();
// let match = true;
// for (let j = 0; j < searchTerms.length; j++) {
// let term = searchTerms[j].trim();
// if (term && label.indexOf(term) === -1) {
// match = false;
// break;
// }
// }
// if (match) {
// labels[i].closest('.plugin-container').style.display = "flex";
// } else {
// labels[i].closest('.plugin-container').style.display = "none";
// }
// }
// }
// // Call debounce function on filterImageModifierList function with 200ms wait time. Thanks JeLuf!
// const debouncedFilterPlugins = debounce(filterPlugins, 200);
// // add the searchbox
// pluginsTable.insertAdjacentHTML('beforebegin', `<input type="text" id="plugin-filter" placeholder="Search for..." autocomplete="off"/>`)
// const pluginFilter = document.getElementById("plugin-filter") // search box
// // Add the debounced function to the keyup event listener
// pluginFilter.addEventListener('keyup', debouncedFilterPlugins);
// // select the text on focus
// pluginFilter.addEventListener('focus', function (event) {
// pluginFilter.select()
// });
// // empty the searchbox on escape
// pluginFilter.addEventListener('keydown', function (event) {
// if (event.key === 'Escape') {
// pluginFilter.value = '';
// filterPlugins();
// }
// });
// // focus on the search box upon tab selection
// document.addEventListener("tabClick", (e) => {
// if (e.detail.name == 'plugin') {
// pluginFilter.focus()
// }
// })
// // refresh link
// pluginsTable.insertAdjacentHTML('afterend', `<p id="refresh-plugins"><small><a id="refresh-plugins-link">Refresh plugins</a></small></p>
// <p><small>(Plugin developers, add your plugins to <a href='${PLUGIN_CATALOG_GITHUB}' target='_blank'>plugins.json</a>)</small></p>`)
// const refreshPlugins = document.getElementById("refresh-plugins")
// refreshPlugins.addEventListener("click", async function (event) {
// event.preventDefault()
// await initPlugins(true)
// })
// function showPluginToast(message, duration = 5000, error = false, addNotification = true) {
// if (addNotification === true) {
// addPluginNotification(pluginNotifications, message, error)
// }
// try {
// showToast(message, duration, error)
// } catch (error) {
// console.error('Error while trying to show toast:', error);
// }
// }
// function matchPluginFileNames(fileName1, fileName2) {
// const regex = /^(.+?)(?:-\d+(\.\d+)*)?\.plugin\.js$/;
// const match1 = fileName1.match(regex);
// const match2 = fileName2.match(regex);
// if (match1 && match2 && match1[1] === match2[1]) {
// return true; // the two file names match
// } else {
// return false; // the two file names do not match
// }
// }
// function extractFilename(filepath) {
// // Normalize the path separators to forward slashes and make the file names lowercase
// const normalizedFilePath = filepath.replace(/\\/g, "/").toLowerCase();
// // Strip off the path from the file name
// const fileName = normalizedFilePath.substring(normalizedFilePath.lastIndexOf("/") + 1);
// return fileName
// }
// function checkFileNameInArray(paths, filePath) {
// // Strip off the path from the file name
// const fileName = extractFilename(filePath);
// // Check if the file name exists in the array of paths
// return paths.some(path => {
// // Strip off the path from the file name
// const baseName = extractFilename(path);
// // Check if the file names match and return the result as a boolean
// return matchPluginFileNames(fileName, baseName);
// });
// }
// function isGitHub(url) {
// return url.startsWith("https://raw.githubusercontent.com/") === true
// }
// /* fill in the plugins table */
// function getIncompatiblePlugins(pluginId) {
// const enabledPlugins = plugins.filter(plugin => plugin.enabled && plugin.id !== pluginId);
// const incompatiblePlugins = enabledPlugins.filter(plugin => plugin.compatIssueIds?.includes(pluginId));
// const pluginNames = incompatiblePlugins.map(plugin => plugin.name);
// if (pluginNames.length === 0) {
// return null;
// }
// const pluginNamesList = pluginNames.map(name => `<li>${name}</li>`).join('');
// return `<ul>${pluginNamesList}</ul>`;
// }
// async function initPluginTable(plugins) {
// pluginsTable.innerHTML = ''
// plugins.sort((a, b) => a.name.localeCompare(b.name, undefined, { sensitivity: 'base' }))
// plugins.forEach(plugin => {
// const name = plugin.name
// const author = plugin.author ? ', by ' + plugin.author : ''
// const version = plugin.version ? ' (version: ' + plugin.version + ')' : ''
// const warning = getIncompatiblePlugins(plugin.id) ? `<span class="plugin-warning${plugin.enabled ? '' : ' hide'}">This plugin might conflict with:${getIncompatiblePlugins(plugin.id)}</span>` : ''
// const note = plugin.description ? `<small>${plugin.description.replaceAll('\n', '<br>')}</small>` : `<small>No description</small>`;
// const icon = plugin.icon ? `<i class="fa ${plugin.icon}"></i>` : '<i class="fa fa-puzzle-piece"></i>';
// const newRow = document.createElement('div')
// const localPluginFound = checkFileNameInArray(localPlugins, plugin.url)
// newRow.innerHTML = `
// <div>${icon}</div>
// <div><label class="plugin-name">${name}${author}${version}</label>${warning}${note}<span class='plugin-source'>Source: <a href="${plugin.url}" target="_blank">${extractFilename(plugin.url)}</a><span></div>
// <div>
// ${localPluginFound ? "<span class='plugin-installed-locally'>Installed locally</span>" :
// (plugin.localInstallOnly ? '<span class="plugin-installed-locally">Download and<br />install manually</span>' :
// (isGitHub(plugin.url) ?
// '<input id="plugin-' + plugin.id + '" name="plugin-' + plugin.id + '" type="checkbox">' :
// '<button id="plugin-' + plugin.id + '-install" class="tertiaryButton"></button>'
// )
// )
// }
// </div>`;
// newRow.classList.add('plugin-container')
// //console.log(plugin.id, plugin.localInstallOnly)
// pluginsTable.appendChild(newRow)
// const pluginManualInstall = pluginsTable.querySelector('#plugin-' + plugin.id + '-install')
// updateManualInstallButtonCaption()
// // checkbox event handler
// const pluginToggle = pluginsTable.querySelector('#plugin-' + plugin.id)
// if (pluginToggle !== null) {
// pluginToggle.checked = plugin.enabled // set initial state of checkbox
// pluginToggle.addEventListener('change', async () => {
// const container = pluginToggle.closest(".plugin-container");
// const warningElement = container.querySelector(".plugin-warning");
// // if the plugin got enabled, download the plugin's code
// plugin.enabled = pluginToggle.checked
// if (plugin.enabled) {
// const pluginSource = await getDocument(plugin.url);
// if (pluginSource !== null) {
// // Store the current scroll position before navigating away
// const currentPosition = window.pageYOffset;
// initPluginTable(plugins)
// // When returning to the page, set the scroll position to the stored value
// window.scrollTo(0, currentPosition);
// warningElement?.classList.remove("hide");
// plugin.code = pluginSource
// loadPlugins([plugin])
// console.log(`Plugin ${plugin.name} installed`);
// showPluginToast("Plugin " + plugin.name + " installed");
// }
// else {
// plugin.enabled = false
// pluginToggle.checked = false
// console.error(`Couldn't download plugin ${plugin.name}`);
// showPluginToast("Failed to install " + plugin.name + " (Couldn't fetch " + extractFilename(plugin.url) + ")", 5000, true);
// }
// } else {
// warningElement?.classList.add("hide");
// // Store the current scroll position before navigating away
// const currentPosition = window.pageYOffset;
// initPluginTable(plugins)
// // When returning to the page, set the scroll position to the stored value
// window.scrollTo(0, currentPosition);
// console.log(`Plugin ${plugin.name} uninstalled`);
// showPluginToast("Plugin " + plugin.name + " uninstalled");
// }
// await setStorageData('plugins', JSON.stringify(plugins))
// })
// }
// // manual install event handler
// if (pluginManualInstall !== null) {
// pluginManualInstall.addEventListener('click', async () => {
// pluginDialogOpenDialog(inputOK, inputCancel)
// pluginDialogTextarea.value = plugin.code ? plugin.code : ''
// pluginDialogTextarea.select()
// pluginDialogTextarea.focus()
// })
// }
// // Dialog OK
// async function inputOK() {
// let pluginSource = pluginDialogTextarea.value
// // remove empty lines and trim existing lines
// plugin.code = pluginSource
// if (pluginSource.trim() !== '') {
// plugin.enabled = true
// console.log(`Plugin ${plugin.name} installed`);
// showPluginToast("Plugin " + plugin.name + " installed");
// }
// else {
// plugin.enabled = false
// console.log(`No code provided for plugin ${plugin.name}, disabling the plugin`);
// showPluginToast("No code provided for plugin " + plugin.name + ", disabling the plugin");
// }
// updateManualInstallButtonCaption()
// await setStorageData('plugins', JSON.stringify(plugins))
// }
// // Dialog Cancel
// async function inputCancel() {
// plugin.enabled = false
// console.log(`Installation of plugin ${plugin.name} cancelled`);
// showPluginToast("Cancelled installation of " + plugin.name);
// }
// // update button caption
// function updateManualInstallButtonCaption() {
// if (pluginManualInstall !== null) {
// pluginManualInstall.innerHTML = plugin.code === undefined || plugin.code.trim() === '' ? 'Install' : 'Edit'
// }
// }
// })
// prettifyInputs(pluginsTable)
// filterPlugins()
// }
// /* version management. Thanks Madrang! */
// const parseVersion = function (versionString, options = {}) {
// if (typeof versionString === "undefined") {
// throw new Error("versionString is undefined.");
// }
// if (typeof versionString !== "string") {
// throw new Error("versionString is not a string.");
// }
// const lexicographical = options && options.lexicographical;
// const zeroExtend = options && options.zeroExtend;
// let versionParts = versionString.split('.');
// function isValidPart(x) {
// const re = (lexicographical ? /^\d+[A-Za-z]*$/ : /^\d+$/);
// return re.test(x);
// }
// if (!versionParts.every(isValidPart)) {
// throw new Error("Version string is invalid.");
// }
// if (zeroExtend) {
// while (versionParts.length < 4) {
// versionParts.push("0");
// }
// }
// if (!lexicographical) {
// versionParts = versionParts.map(Number);
// }
// return versionParts;
// };
// const versionCompare = function (v1, v2, options = {}) {
// if (typeof v1 == "undefined") {
// throw new Error("vi is undefined.");
// }
// if (typeof v2 === "undefined") {
// throw new Error("v2 is undefined.");
// }
// let v1parts;
// if (typeof v1 === "string") {
// v1parts = parseVersion(v1, options);
// } else if (Array.isArray(v1)) {
// v1parts = [...v1];
// if (!v1parts.every(p => typeof p === "number" && p !== NaN)) {
// throw new Error("v1 part array does not only contains numbers.");
// }
// } else {
// throw new Error("v1 is of an unexpected type: " + typeof v1);
// }
// let v2parts;
// if (typeof v2 === "string") {
// v2parts = parseVersion(v2, options);
// } else if (Array.isArray(v2)) {
// v2parts = [...v2];
// if (!v2parts.every(p => typeof p === "number" && p !== NaN)) {
// throw new Error("v2 part array does not only contains numbers.");
// }
// } else {
// throw new Error("v2 is of an unexpected type: " + typeof v2);
// }
// while (v1parts.length < v2parts.length) {
// v1parts.push("0");
// }
// while (v2parts.length < v1parts.length) {
// v2parts.push("0");
// }
// for (let i = 0; i < v1parts.length; ++i) {
// if (v2parts.length == i) {
// return 1;
// }
// if (v1parts[i] == v2parts[i]) {
// continue;
// } else if (v1parts[i] > v2parts[i]) {
// return 1;
// } else {
// return -1;
// }
// }
// return 0;
// };
// function filterPluginsByMinEDVersion(plugins, EDVersion) {
// const filteredPlugins = plugins.filter(plugin => {
// if (plugin.minEDVersion) {
// return versionCompare(plugin.minEDVersion, EDVersion) <= 0;
// }
// return true;
// });
// return filteredPlugins;
// }
// function extractVersionNumber(elem) {
// const versionStr = elem.innerHTML;
// const regex = /v(\d+\.\d+\.\d+)/;
// const matches = regex.exec(versionStr);
// if (matches && matches.length > 1) {
// return matches[1];
// } else {
// return null;
// }
// }
// const EasyDiffusionVersion = extractVersionNumber(document.querySelector('#top-nav > #logo'))
// /* PLUGIN MANAGEMENT */
// let plugins
// let localPlugins
// let initPluginsInProgress = false
// async function initPlugins(refreshPlugins = false) {
// let pluginsLoaded
// if (initPluginsInProgress === true) {
// return
// }
// initPluginsInProgress = true
// const res = await fetch('/get/ui_plugins')
// if (!res.ok) {
// console.error(`Error HTTP${res.status} while loading plugins list. - ${res.statusText}`)
// }
// else {
// localPlugins = await res.json()
// }
// if (refreshPlugins === false) {
// // load the notifications
// pluginNotifications = await getStorageData('notifications')
// if (typeof pluginNotifications === "string") {
// try {
// pluginNotifications = JSON.parse(pluginNotifications)
// } catch (e) {
// console.error("Failed to parse pluginNotifications", e);
// pluginNotifications = {};
// pluginNotifications.entries = [];
// }
// }
// if (pluginNotifications !== undefined) {
// if (pluginNotifications.entries && pluginNotifications.entries.length > 0 && pluginNotifications.entries[0].date && pluginNotifications.lastUpdated <= pluginNotifications.entries[0].date) {
// notificationPill.style.display = "block";
// }
// } else {
// pluginNotifications = {};
// pluginNotifications.entries = [];
// }
// // try and load plugins from local cache
// plugins = await getStorageData('plugins')
// if (plugins !== undefined) {
// plugins = JSON.parse(plugins)
// // remove duplicate entries if any (should not happen)
// plugins = deduplicatePluginsById(plugins)
// // remove plugins that don't meet the min ED version requirement
// plugins = filterPluginsByMinEDVersion(plugins, EasyDiffusionVersion)
// // remove from plugins the entries that don't have mandatory fields (id, name, url)
// plugins = plugins.filter((plugin) => { return plugin.id !== '' && plugin.name !== '' && plugin.url !== ''; });
// // populate the table
// initPluginTable(plugins)
// await loadPlugins(plugins)
// pluginsLoaded = true
// }
// else {
// plugins = []
// pluginsLoaded = false
// }
// }
// // update plugins asynchronously (updated versions will be available next time the UI is loaded)
// if (refreshAllowed()) {
// let pluginCatalog = await getDocument(PLUGIN_CATALOG)
// if (pluginCatalog !== null) {
// let parseError = false;
// try {
// pluginCatalog = JSON.parse(pluginCatalog);
// console.log('Plugin catalog successfully downloaded');
// } catch (error) {
// console.error('Error parsing plugin catalog:', error);
// parseError = true;
// }
// if (!parseError) {
// await downloadPlugins(pluginCatalog, plugins, refreshPlugins)
// // update compatIssueIds
// updateCompatIssueIds()
// // remove plugins that don't meet the min ED version requirement
// plugins = filterPluginsByMinEDVersion(plugins, EasyDiffusionVersion)
// // remove from plugins the entries that don't have mandatory fields (id, name, url)
// plugins = plugins.filter((plugin) => { return plugin.id !== '' && plugin.name !== '' && plugin.url !== ''; });
// // remove from plugins the entries that no longer exist in the catalog
// plugins = plugins.filter((plugin) => { return pluginCatalog.some((p) => p.id === plugin.id) });
// if (pluginCatalog.length > plugins.length) {
// const newPlugins = pluginCatalog.filter((plugin) => {
// return !plugins.some((p) => p.id === plugin.id);
// });
// newPlugins.forEach((plugin, index) => {
// setTimeout(() => {
// showPluginToast(`New plugin "${plugin.name}" is available.`);
// }, (index + 1) * 1000);
// });
// }
// let pluginsJson;
// try {
// pluginsJson = JSON.stringify(plugins); // attempt to parse plugins to JSON
// } catch (error) {
// console.error('Error converting plugins to JSON:', error);
// }
// if (pluginsJson) { // only store the data if pluginsJson is not null or undefined
// await setStorageData('plugins', pluginsJson)
// }
// // refresh the display of the plugins table
// initPluginTable(plugins)
// if (pluginsLoaded && pluginsLoaded === false) {
// loadPlugins(plugins)
// }
// }
// }
// }
// else {
// if (refreshPlugins) {
// showPluginToast('Plugins have been refreshed recently, refresh will be available in ' + convertSeconds(getTimeUntilNextRefresh()), 5000, true, false)
// }
// }
// initPluginsInProgress = false
// }
// function updateMetaTagPlugins(plugin) {
// // Update the meta tag with the list of loaded plugins
// let metaTag = document.querySelector('meta[name="plugins"]');
// if (metaTag === null) {
// metaTag = document.createElement('meta');
// metaTag.name = 'plugins';
// document.head.appendChild(metaTag);
// }
// const pluginArray = [...(metaTag.content ? metaTag.content.split(',') : []), plugin.id];
// metaTag.content = pluginArray.join(',');
// }
// function updateCompatIssueIds() {
// // Loop through each plugin
// plugins.forEach(plugin => {
// // Check if the plugin has `compatIssueIds` property
// if (plugin.compatIssueIds !== undefined) {
// // Loop through each of the `compatIssueIds`
// plugin.compatIssueIds.forEach(issueId => {
// // Find the plugin with the corresponding `issueId`
// const issuePlugin = plugins.find(p => p.id === issueId);
// // If the corresponding plugin is found, initialize its `compatIssueIds` property with an empty array if it's undefined
// if (issuePlugin) {
// if (issuePlugin.compatIssueIds === undefined) {
// issuePlugin.compatIssueIds = [];
// }
// // If the current plugin's ID is not already in the `compatIssueIds` array, add it
// if (!issuePlugin.compatIssueIds.includes(plugin.id)) {
// issuePlugin.compatIssueIds.push(plugin.id);
// }
// }
// });
// } else {
// // If the plugin doesn't have `compatIssueIds` property, initialize it with an empty array
// plugin.compatIssueIds = [];
// }
// });
// }
// function deduplicatePluginsById(plugins) {
// const seenIds = new Set();
// const deduplicatedPlugins = [];
// for (const plugin of plugins) {
// if (!seenIds.has(plugin.id)) {
// seenIds.add(plugin.id);
// deduplicatedPlugins.push(plugin);
// } else {
// // favor dupes that have enabled == true
// const index = deduplicatedPlugins.findIndex(p => p.id === plugin.id);
// if (index >= 0) {
// if (plugin.enabled) {
// deduplicatedPlugins[index] = plugin;
// }
// }
// }
// }
// return deduplicatedPlugins;
// }
// async function loadPlugins(plugins) {
// for (let i = 0; i < plugins.length; i++) {
// const plugin = plugins[i];
// if (plugin.enabled === true && plugin.localInstallOnly !== true) {
// const localPluginFound = checkFileNameInArray(localPlugins, plugin.url);
// if (!localPluginFound) {
// try {
// // Indirect eval to work around sloppy plugin implementations
// const indirectEval = { eval };
// console.log("Loading plugin " + plugin.name);
// indirectEval.eval(plugin.code);
// console.log("Plugin " + plugin.name + " loaded");
// await updateMetaTagPlugins(plugin); // add plugin to the meta tag
// } catch (err) {
// showPluginToast("Error loading plugin " + plugin.name + " (" + err.message + ")", null, true);
// console.error("Error loading plugin " + plugin.name + ": " + err.message);
// }
// } else {
// console.log("Skipping plugin " + plugin.name + " (installed locally)");
// }
// }
// }
// }
// async function getFileHash(url) {
// const regex = /^https:\/\/raw\.githubusercontent\.com\/(?<owner>[^/]+)\/(?<repo>[^/]+)\/(?<branch>[^/]+)\/(?<filePath>.+)$/;
// const match = url.match(regex);
// if (!match) {
// console.error('Invalid GitHub repository URL.');
// return Promise.resolve(null);
// }
// const owner = match.groups.owner;
// const repo = match.groups.repo;
// const branch = match.groups.branch;
// const filePath = match.groups.filePath;
// const apiUrl = `https://api.github.com/repos/${owner}/${repo}/contents/${filePath}?ref=${branch}`;
// try {
// const response = await fetch(apiUrl);
// if (!response.ok) {
// throw new Error(`HTTP error! status: ${response.status}, url: ${apiUrl}`);
// }
// const data = await response.json();
// return data.sha;
// } catch (error) {
// console.error('Error fetching data from url:', apiUrl, 'Error:', error);
// return null;
// }
// }
// // only allow two refresh per hour
// function getTimeUntilNextRefresh() {
// const lastRuns = JSON.parse(localStorage.getItem('lastRuns') || '[]');
// const currentTime = new Date().getTime();
// const numRunsLast60Min = lastRuns.filter(run => currentTime - run <= 60 * 60 * 1000).length;
// if (numRunsLast60Min >= 2) {
// return 3600 - Math.round((currentTime - lastRuns[lastRuns.length - 1]) / 1000);
// }
// return 0;
// }
// function refreshAllowed() {
// const timeUntilNextRefresh = getTimeUntilNextRefresh();
// if (timeUntilNextRefresh > 0) {
// console.log(`Next refresh available in ${timeUntilNextRefresh} seconds`);
// return false;
// }
// const lastRuns = JSON.parse(localStorage.getItem('lastRuns') || '[]');
// const currentTime = new Date().getTime();
// lastRuns.push(currentTime);
// localStorage.setItem('lastRuns', JSON.stringify(lastRuns));
// return true;
// }
// async function downloadPlugins(pluginCatalog, plugins, refreshPlugins) {
// // download the plugins as needed
// for (const plugin of pluginCatalog) {
// //console.log(plugin.id, plugin.url)
// const existingPlugin = plugins.find(p => p.id === plugin.id);
// // get the file hash in the GitHub repo
// let sha
// if (isGitHub(plugin.url) && existingPlugin?.enabled === true) {
// sha = await getFileHash(plugin.url)
// }
// if (plugin.localInstallOnly !== true && isGitHub(plugin.url) && existingPlugin?.enabled === true && (refreshPlugins || (existingPlugin.sha !== undefined && existingPlugin.sha !== null && existingPlugin.sha !== sha) || existingPlugin?.code === undefined)) {
// const pluginSource = await getDocument(plugin.url);
// if (pluginSource !== null && pluginSource !== existingPlugin.code) {
// console.log(`Plugin ${plugin.name} updated`);
// showPluginToast("Plugin " + plugin.name + " updated", 5000);
// // Update the corresponding plugin
// const updatedPlugin = {
// ...existingPlugin,
// icon: plugin.icon ? plugin.icon : "fa-puzzle-piece",
// id: plugin.id,
// name: plugin.name,
// description: plugin.description,
// url: plugin.url,
// localInstallOnly: Boolean(plugin.localInstallOnly),
// version: plugin.version,
// code: pluginSource,
// author: plugin.author,
// sha: sha,
// compatIssueIds: plugin.compatIssueIds
// };
// // Replace the old plugin in the plugins array
// const pluginIndex = plugins.indexOf(existingPlugin);
// if (pluginIndex >= 0) {
// plugins.splice(pluginIndex, 1, updatedPlugin);
// } else {
// plugins.push(updatedPlugin);
// }
// }
// }
// else if (existingPlugin !== undefined) {
// // Update the corresponding plugin's metadata
// const updatedPlugin = {
// ...existingPlugin,
// icon: plugin.icon ? plugin.icon : "fa-puzzle-piece",
// id: plugin.id,
// name: plugin.name,
// description: plugin.description,
// url: plugin.url,
// localInstallOnly: Boolean(plugin.localInstallOnly),
// version: plugin.version,
// author: plugin.author,
// compatIssueIds: plugin.compatIssueIds
// };
// // Replace the old plugin in the plugins array
// const pluginIndex = plugins.indexOf(existingPlugin);
// plugins.splice(pluginIndex, 1, updatedPlugin);
// }
// else {
// plugins.push(plugin);
// }
// }
// }
// async function getDocument(url) {
// try {
// let response = await fetch(url === PLUGIN_CATALOG ? PLUGIN_CATALOG : url, { cache: "no-cache" });
// if (!response.ok) {
// throw new Error(`Response error: ${response.status} ${response.statusText}`);
// }
// let document = await response.text();
// return document;
// } catch (error) {
// showPluginToast("Couldn't fetch " + extractFilename(url) + " (" + error + ")", null, true);
// console.error(error);
// return null;
// }
// }
// /* MODAL DIALOG */
// const pluginDialogDialog = document.createElement("div");
// pluginDialogDialog.id = "pluginDialog-input-dialog";
// pluginDialogDialog.style.display = "none";
// pluginDialogDialog.innerHTML = `
// <div class="pluginDialog-dialog-overlay"></div>
// <div class="pluginDialog-dialog-box">
// <div class="pluginDialog-dialog-header">
// <h2>Paste the plugin's code here</h2>
// <button class="pluginDialog-dialog-close-button">&times;</button>
// </div>
// <div class="pluginDialog-dialog-content">
// <textarea id="pluginDialog-input-textarea" spellcheck="false" autocomplete="off"></textarea>
// </div>
// <div class="pluginDialog-dialog-buttons">
// <button id="pluginDialog-input-ok">OK</button>
// <button id="pluginDialog-input-cancel">Cancel</button>
// </div>
// </div>
// `;
// document.body.appendChild(pluginDialogDialog);
// const pluginDialogOverlay = document.querySelector(".pluginDialog-dialog-overlay");
// const pluginDialogOkButton = document.getElementById("pluginDialog-input-ok");
// const pluginDialogCancelButton = document.getElementById("pluginDialog-input-cancel");
// const pluginDialogCloseButton = document.querySelector(".pluginDialog-dialog-close-button");
// const pluginDialogTextarea = document.getElementById("pluginDialog-input-textarea");
// let callbackOK
// let callbackCancel
// function pluginDialogOpenDialog(inputOK, inputCancel) {
// pluginDialogDialog.style.display = "block";
// callbackOK = inputOK
// callbackCancel = inputCancel
// }
// function pluginDialogCloseDialog() {
// pluginDialogDialog.style.display = "none";
// }
// function pluginDialogHandleOkClick() {
// const userInput = pluginDialogTextarea.value;
// // Do something with the user input
// callbackOK()
// pluginDialogCloseDialog();
// }
// function pluginDialogHandleCancelClick() {
// callbackCancel()
// pluginDialogCloseDialog();
// }
// function pluginDialogHandleOverlayClick(event) {
// if (event.target === pluginDialogOverlay) {
// pluginDialogCloseDialog();
// }
// }
// function pluginDialogHandleKeyDown(event) {
// if ((event.key === "Enter" && event.ctrlKey) || event.key === "Escape") {
// event.preventDefault();
// if (event.key === "Enter" && event.ctrlKey) {
// pluginDialogHandleOkClick();
// } else {
// pluginDialogCloseDialog();
// }
// }
// }
// pluginDialogTextarea.addEventListener("keydown", pluginDialogHandleKeyDown);
// pluginDialogOkButton.addEventListener("click", pluginDialogHandleOkClick);
// pluginDialogCancelButton.addEventListener("click", pluginDialogHandleCancelClick);
// pluginDialogCloseButton.addEventListener("click", pluginDialogCloseDialog);
// pluginDialogOverlay.addEventListener("click", pluginDialogHandleOverlayClick);

View File

@ -38,6 +38,8 @@ class ModelDropdown {
noneEntry //= ''
modelFilterInitialized //= undefined
sorted //= true
/* MIMIC A REGULAR INPUT FIELD */
get parentElement() {
return this.modelFilter.parentElement
@ -83,21 +85,34 @@ class ModelDropdown {
/* SEARCHABLE INPUT */
constructor(input, modelKey, noneEntry = "") {
constructor(input, modelKey, noneEntry = "", sorted = true) {
this.modelFilter = input
this.noneEntry = noneEntry
this.modelKey = modelKey
this.sorted = sorted
if (modelsOptions !== undefined) {
// reuse models from cache (only useful for plugins, which are loaded after models)
this.inputModels = modelsOptions[this.modelKey]
this.inputModels = []
let modelKeys = Array.isArray(this.modelKey) ? this.modelKey : [this.modelKey]
for (let i = 0; i < modelKeys.length; i++) {
let key = modelKeys[i]
let k = Array.isArray(modelsOptions[key]) ? modelsOptions[key] : [modelsOptions[key]]
this.inputModels.push(...k)
}
this.populateModels()
}
document.addEventListener(
"refreshModels",
this.bind(function(e) {
// reload the models
this.inputModels = modelsOptions[this.modelKey]
this.inputModels = []
let modelKeys = Array.isArray(this.modelKey) ? this.modelKey : [this.modelKey]
for (let i = 0; i < modelKeys.length; i++) {
let key = modelKeys[i]
let k = Array.isArray(modelsOptions[key]) ? modelsOptions[key] : [modelsOptions[key]]
this.inputModels.push(...k)
}
this.populateModels()
}, this)
)
@ -554,11 +569,15 @@ class ModelDropdown {
})
const childFolderNames = Array.from(foldersMap.keys())
this.sortStringArray(childFolderNames)
if (this.sorted) {
this.sortStringArray(childFolderNames)
}
const folderElements = childFolderNames.map((name) => foldersMap.get(name))
const modelNames = Array.from(modelsMap.keys())
this.sortStringArray(modelNames)
if (this.sorted) {
this.sortStringArray(modelNames)
}
const modelElements = modelNames.map((name) => modelsMap.get(name))
if (modelElements.length && folderName) {
@ -608,9 +627,9 @@ class ModelDropdown {
}
/* (RE)LOAD THE MODELS */
async function getModels() {
async function getModels(scanForMalicious = true) {
try {
modelsCache = await SD.getModels()
modelsCache = await SD.getModels(scanForMalicious)
modelsOptions = modelsCache["options"]
if ("scan-error" in modelsCache) {
// let previewPane = document.getElementById('tab-content-wrapper')
@ -648,4 +667,4 @@ async function getModels() {
}
// reload models button
document.querySelector("#reload-models").addEventListener("click", getModels)
document.querySelector("#reload-models").addEventListener("click", () => getModels())

View File

@ -129,6 +129,31 @@ function tryLoadOldCollapsibles() {
return null
}
function collapseAll(selector) {
const collapsibleElems = document.querySelectorAll(selector); // needs to have ";"
[...collapsibleElems].forEach((elem) => {
const isActive = elem.classList.contains("active")
if(isActive) {
elem?.click()
}
})
}
function expandAll(selector) {
const collapsibleElems = document.querySelectorAll(selector); // needs to have ";"
[...collapsibleElems].forEach((elem) => {
const isActive = elem.classList.contains("active")
if (!isActive) {
elem?.click()
}
})
}
function permute(arr) {
let permutations = []
let n = arr.length
@ -153,6 +178,10 @@ function permute(arr) {
return permutations
}
function permuteNumber(arr) {
return Math.pow(2, arr.length)
}
// https://stackoverflow.com/a/8212878
function millisecondsToStr(milliseconds) {
function numberEnding(number) {
@ -402,12 +431,12 @@ function debounce(func, wait, immediate) {
function preventNonNumericalInput(e) {
e = e || window.event
let charCode = typeof e.which == "undefined" ? e.keyCode : e.which
let charStr = String.fromCharCode(charCode)
let re = e.target.getAttribute("pattern") || "^[0-9]+$"
re = new RegExp(re)
const charCode = typeof e.which == "undefined" ? e.keyCode : e.which
const charStr = String.fromCharCode(charCode)
const newInputValue = `${e.target.value}${charStr}`
const re = new RegExp(e.target.getAttribute("pattern") || "^[0-9]+$")
if (!charStr.match(re)) {
if (!re.test(charStr) && !re.test(newInputValue)) {
e.preventDefault()
}
}
@ -841,59 +870,290 @@ function createTab(request) {
})
}
/* TOAST NOTIFICATIONS */
function showToast(message, duration = 5000, error = false) {
const toast = document.createElement("div");
toast.classList.add("toast-notification");
const toast = document.createElement("div")
toast.classList.add("toast-notification")
if (error === true) {
toast.classList.add("toast-notification-error");
toast.classList.add("toast-notification-error")
}
toast.innerHTML = message;
document.body.appendChild(toast);
toast.innerHTML = message
document.body.appendChild(toast)
// Set the position of the toast on the screen
const toastCount = document.querySelectorAll(".toast-notification").length;
const toastHeight = toast.offsetHeight;
const toastCount = document.querySelectorAll(".toast-notification").length
const toastHeight = toast.offsetHeight
const previousToastsHeight = Array.from(document.querySelectorAll(".toast-notification"))
.slice(0, -1) // exclude current toast
.reduce((totalHeight, toast) => totalHeight + toast.offsetHeight + 10, 0); // add 10 pixels for spacing
toast.style.bottom = `${10 + previousToastsHeight}px`;
toast.style.right = "10px";
.reduce((totalHeight, toast) => totalHeight + toast.offsetHeight + 10, 0) // add 10 pixels for spacing
toast.style.bottom = `${10 + previousToastsHeight}px`
toast.style.right = "10px"
// Delay the removal of the toast until animation has completed
const removeToast = () => {
toast.classList.add("hide");
toast.classList.add("hide")
const removeTimeoutId = setTimeout(() => {
toast.remove();
toast.remove()
// Adjust the position of remaining toasts
const remainingToasts = document.querySelectorAll(".toast-notification");
const removedToastBottom = toast.getBoundingClientRect().bottom;
const remainingToasts = document.querySelectorAll(".toast-notification")
const removedToastBottom = toast.getBoundingClientRect().bottom
remainingToasts.forEach((toast) => {
if (toast.getBoundingClientRect().bottom < removedToastBottom) {
toast.classList.add("slide-down");
toast.classList.add("slide-down")
}
});
})
// Wait for the slide-down animation to complete
setTimeout(() => {
// Remove the slide-down class after the animation has completed
const slidingToasts = document.querySelectorAll(".slide-down");
const slidingToasts = document.querySelectorAll(".slide-down")
slidingToasts.forEach((toast) => {
toast.classList.remove("slide-down");
});
toast.classList.remove("slide-down")
})
// Adjust the position of remaining toasts again, in case there are multiple toasts being removed at once
const remainingToastsDown = document.querySelectorAll(".toast-notification");
let heightSoFar = 0;
const remainingToastsDown = document.querySelectorAll(".toast-notification")
let heightSoFar = 0
remainingToastsDown.forEach((toast) => {
toast.style.bottom = `${10 + heightSoFar}px`;
heightSoFar += toast.offsetHeight + 10; // add 10 pixels for spacing
});
}, 0); // The duration of the slide-down animation (in milliseconds)
}, 500);
};
toast.style.bottom = `${10 + heightSoFar}px`
heightSoFar += toast.offsetHeight + 10 // add 10 pixels for spacing
})
}, 0) // The duration of the slide-down animation (in milliseconds)
}, 500)
}
// Remove the toast after specified duration
setTimeout(removeToast, duration);
setTimeout(removeToast, duration)
}
function alert(msg, title) {
title = title || ""
$.alert({
theme: "modern",
title: title,
useBootstrap: false,
animateFromElement: false,
content: msg,
})
}
function confirm(msg, title, fn) {
title = title || ""
$.confirm({
theme: "modern",
title: title,
useBootstrap: false,
animateFromElement: false,
content: msg,
buttons: {
yes: fn,
cancel: () => {},
},
})
}
/* STORAGE MANAGEMENT */
// Request persistent storage
async function requestPersistentStorage() {
if (navigator.storage && navigator.storage.persist) {
const isPersisted = await navigator.storage.persist();
console.log(`Persisted storage granted: ${isPersisted}`);
}
}
requestPersistentStorage()
// Open a database
async function openDB() {
return new Promise((resolve, reject) => {
let request = indexedDB.open("EasyDiffusionSettingsDatabase", 1);
request.addEventListener("upgradeneeded", function () {
let db = request.result;
db.createObjectStore("EasyDiffusionSettings", { keyPath: "id" });
});
request.addEventListener("success", function () {
resolve(request.result);
});
request.addEventListener("error", function () {
reject(request.error);
});
});
}
// Function to write data to the object store
async function setStorageData(key, value) {
return openDB().then(db => {
let tx = db.transaction("EasyDiffusionSettings", "readwrite");
let store = tx.objectStore("EasyDiffusionSettings");
let data = { id: key, value: value };
return new Promise((resolve, reject) => {
let request = store.put(data);
request.addEventListener("success", function () {
resolve(request.result);
});
request.addEventListener("error", function () {
reject(request.error);
});
});
});
}
// Function to retrieve data from the object store
async function getStorageData(key) {
return openDB().then(db => {
let tx = db.transaction("EasyDiffusionSettings", "readonly");
let store = tx.objectStore("EasyDiffusionSettings");
return new Promise((resolve, reject) => {
let request = store.get(key);
request.addEventListener("success", function () {
if (request.result) {
resolve(request.result.value);
} else {
// entry not found
resolve();
}
});
request.addEventListener("error", function () {
reject(request.error);
});
});
});
}
function insertAtCursor(field, text) {
if (field.selectionStart || field.selectionStart == "0") {
var startPos = field.selectionStart
var endPos = field.selectionEnd
var before = field.value.substring(0, startPos)
var after = field.value.substring(endPos, field.value.length)
if (!before.endsWith(" ")) { before += " " }
if (!after.startsWith(" ")) { after = " "+after }
field.value = before + text + after
} else {
field.value += text
}
}
// indexedDB debug functions
async function getAllKeys() {
return openDB().then(db => {
let tx = db.transaction("EasyDiffusionSettings", "readonly");
let store = tx.objectStore("EasyDiffusionSettings");
let keys = [];
return new Promise((resolve, reject) => {
store.openCursor().onsuccess = function (event) {
let cursor = event.target.result;
if (cursor) {
keys.push(cursor.key);
cursor.continue();
} else {
resolve(keys);
}
};
});
});
}
async function logAllStorageKeys() {
try {
let keys = await getAllKeys();
console.log("All keys:", keys);
for (const k of keys) {
console.log(k, await getStorageData(k))
}
} catch (error) {
console.error("Error retrieving keys:", error);
}
}
// USE WITH CARE - THIS MAY DELETE ALL ENTRIES
async function deleteKeys(keyToDelete) {
let confirmationMessage = keyToDelete
? `This will delete the template with key "${keyToDelete}". Continue?`
: "This will delete ALL templates. Continue?";
if (confirm(confirmationMessage)) {
return openDB().then(db => {
let tx = db.transaction("EasyDiffusionSettings", "readwrite");
let store = tx.objectStore("EasyDiffusionSettings");
return new Promise((resolve, reject) => {
store.openCursor().onsuccess = function (event) {
let cursor = event.target.result;
if (cursor) {
if (!keyToDelete || cursor.key === keyToDelete) {
cursor.delete();
}
cursor.continue();
} else {
// refresh the dropdown and resolve
resolve();
}
};
});
});
}
}
function modalDialogCloseOnBackdropClick(dialog) {
dialog.addEventListener('mousedown', function (event) {
// Firefox creates an event with clientX|Y = 0|0 when choosing an <option>.
// Test whether the element interacted with is a child of the dialog, but not the
// dialog itself (the backdrop would be a part of the dialog)
if (dialog.contains(event.target) && dialog != event.target) {
return
}
var rect = dialog.getBoundingClientRect()
var isInDialog=(rect.top <= event.clientY && event.clientY <= rect.top + rect.height
&& rect.left <= event.clientX && event.clientX <= rect.left + rect.width)
if (!isInDialog) {
dialog.close()
}
})
}
function makeDialogDraggable(element) {
element.querySelector(".dialog-header").addEventListener('mousedown', (function() {
let deltaX=0
let deltaY=0
let dragStartX=0
let dragStartY=0
let oldTop=0
let oldLeft=0
function dlgDragStart(e) {
e = e || window.event;
const d = e.target.closest("dialog")
e.preventDefault();
dragStartX = e.clientX;
dragStartY = e.clientY;
oldTop = parseInt(d.style.top)
oldLeft = parseInt(d.style.left)
if (isNaN(oldTop)) { oldTop=0 }
if (isNaN(oldLeft)) { oldLeft=0 }
document.addEventListener('mouseup', dlgDragClose);
document.addEventListener('mousemove', dlgDrag);
}
function dlgDragClose(e) {
document.removeEventListener('mouseup', dlgDragClose);
document.removeEventListener('mousemove', dlgDrag);
}
function dlgDrag(e) {
e = e || window.event;
const d = e.target.closest("dialog")
e.preventDefault();
deltaX = dragStartX - e.clientX;
deltaY = dragStartY - e.clientY;
d.style.left = `${oldLeft-2*deltaX}px`
d.style.top = `${oldTop-2*deltaY}px`
}
return dlgDragStart
})() )
}

File diff suppressed because it is too large Load Diff

View File

@ -403,16 +403,19 @@
// Batch main loop
for (let i = 0; i < iterations; i++) {
let alpha = (start + i * step) / 100
switch (document.querySelector("#merge-interpolation").value) {
case "SmoothStep":
alpha = smoothstep(alpha)
break
case "SmootherStep":
alpha = smootherstep(alpha)
break
case "SmoothestStep":
alpha = smootheststep(alpha)
break
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)}...`)
@ -420,7 +423,8 @@
request["out_path"] += "-" + alpha.toFixed(5) + "." + document.querySelector("#merge-format").value
addLogMessage(`&nbsp;&nbsp;filename: ${request["out_path"]}`)
request["ratio"] = alpha
// 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" },

View File

@ -4,7 +4,7 @@
PLUGINS.SELFTEST["release-notes"] = function() {
it("should be able to fetch CHANGES.md", async function() {
let releaseNotes = await fetch(
`https://raw.githubusercontent.com/cmdr2/stable-diffusion-ui/main/CHANGES.md`
`https://raw.githubusercontent.com/easydiffusion/easydiffusion/main/CHANGES.md`
)
expect(releaseNotes.status).toBe(200)
})
@ -36,7 +36,7 @@
const updateBranch = appConfig.update_branch || "main"
let releaseNotes = await fetch(
`https://raw.githubusercontent.com/cmdr2/stable-diffusion-ui/${updateBranch}/CHANGES.md`
`https://raw.githubusercontent.com/easydiffusion/easydiffusion/${updateBranch}/CHANGES.md`
)
if (!releaseNotes.ok) {
console.error("[release-notes] Failed to get CHANGES.md.")

View File

@ -0,0 +1,317 @@
;(function(){
"use strict";
const PAPERSIZE = [
{id: "a3p", width: 297, height: 420, unit: "mm"},
{id: "a3l", width: 420, height: 297, unit: "mm"},
{id: "a4p", width: 210, height: 297, unit: "mm"},
{id: "a4l", width: 297, height: 210, unit: "mm"},
{id: "ll", width: 279, height: 216, unit: "mm"},
{id: "lp", width: 216, height: 279, unit: "mm"},
{id: "hd", width: 1920, height: 1080, unit: "pixels"},
{id: "4k", width: 3840, height: 2160, unit: "pixels"},
]
// ---- Register plugin
PLUGINS['IMAGE_INFO_BUTTONS'].push({
html: '<i class="fa-solid fa-table-cells-large"></i> Download tiled image',
on_click: onDownloadTiledImage,
filter: (req, img) => req.tiling != "none",
})
var thisImage
function onDownloadTiledImage(req, img) {
document.getElementById("download-tiled-image-dialog").showModal()
thisImage = new Image()
thisImage.src = img.src
thisImage.dataset["prompt"] = img.dataset["prompt"]
}
// ---- Add HTML
document.getElementById('container').lastElementChild.insertAdjacentHTML("afterend",
`<dialog id="download-tiled-image-dialog">
<div class="dialog-header">
<div class="dialog-header-left">
<h4>Download tiled image</h4>
<span>Generate a larger image from this tile</span>
</div>
<div id="download-header-right">
<i id="downnload-tiled-close-button" class="fa-solid fa-xmark fa-lg"></i>
</div>
</div>
<div class="download-tiled-image dtim-container">
<div class="download-tiled-image-top">
<div class="tab-container">
<span id="tab-image-tiles" class="tab active">
<span>Number of tiles</small></span>
</span>
<span id="tab-image-size" class="tab">
<span>Image dimensions</span>
</span>
</div>
<div>
<div id="tab-content-image-tiles" class="tab-content active">
<div class="tab-content-inner">
<label for="dtim1-width">Width:</label> <input id="dtim1-width" min="1" max="99" type="number" value="2">
<label for="dtim1-height">Height:</label> <input id="dtim1-height" min="1" max="99" type="number" value="2">
</div>
</div>
<div id="tab-content-image-size" class="tab-content">
<div class="tab-content-inner">
<div class="method-2-options">
<label for="dtim2-width">Width:</label> <input id="dtim2-width" size="3" value="1920">
<label for="dtim2-height">Height:</label> <input id="dtim2-height" size="3" value="1080">
<select id="dtim2-unit">
<option>pixels</option>
<option>mm</option>
<option>inches</option>
</select>
</div>
<div class="method-2-dpi">
<label for="dtim2-dpi">DPI:</label> <input id="dtim2-dpi" size="3" value="72">
</div>
<div class="method-2-paper">
<i>Some standard sizes:</i><br>
<button id="dtim2-a3p">A3 portrait</button><button id="dtim2-a3l">A3 landscape</button><br>
<button id="dtim2-a4p">A4 portrait</button><button id="dtim2-a4l">A4 landscape</button><br>
<button id="dtim2-lp">Letter portrait</button><button id="dtim2-ll">Letter landscape</button><br>
<button id="dtim2-hd">Full HD</button><button id="dtim2-4k">4K</button>
</div>
</div>
</div>
</div>
</div>
<div class="download-tiled-image-placement">
<div class="tab-container">
<span id="tab-image-placement" class="tab active">
<span>Tile placement</span>
</span>
</div>
<div>
<div id="tab-content-image-placement" class="tab-content active">
<div class="tab-content-inner">
<img id="dtim-1tl" class="active" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA3BAMAAACiFTSCAAAAMFBMVEUCAgKIhobRz89vMJ7s6uo9PDx4d3ewra0bHR1dXV19NrLa2Nj+/f29u7uWlJQuLi7ws27qAAAACXBIWXMAAAsTAAALEwEAmpwYAAABlUlEQVQ4y7VUMU7DQBCckpYCJEpS0ByhcecuUZQUtvIHGku0vICSDtHkA9eltCylOEBKFInCRworXToK3kDJ7jpn2SYmgGESeWyPRuudvTugHTyC72momKDGMMJDLIhmgK+nWmuPXxtlxkhjExszRKqU6uRuTW7TYTwh6HTpR25+JLcngBJ5jL5wIecqu9nFbid3t27N7vhrtypqV2SfP4zc5pfu/Msb3P6U4fru1eXpVg7tcmnDZ1gb0s1ceAEcSPI3uM2B9xLf7Z3YLlfJ/WCppF1QbbqxeW0brlztjXzprBhJrW8nu4HWGlt/xz1qcrervfmT2ma3WxpTjfK5ZUioNg+VsUL+tiXuI8YJLrd8KHyENyaqPWC8QGiwwlJ4LtyvNtb9vFKrqZXXeebkrEiN3ZUNXHJnO3aJkxt2aH2gDRNTLdyzJvee1CZXUTSJrhA55itlfszUdqDrxCQmGIEu9KfFFCRJYnpIgyB4JJlPWM6cY6MjN+UW5MjdM7FKavF/pFbfRD9zv8rjBa6FT5EJn0HoA8lOiD4+8B3mAAAAAElFTkSuQmCC" />
<img id="dtim-1tr" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA3BAMAAACiFTSCAAAAMFBMVEUCAgKIhobRz89vMJ7s6uo9PDx4d3ewra0bHR1dXV19NrLa2Nj+/f29u7uWlJQuLi7ws27qAAAACXBIWXMAAAsTAAALEwEAmpwYAAABoUlEQVQ4y61UsU7CUBQ9o6uGmJgwNSQOLS7dOndrGfwEDWnC4tQNB8duxoUfYGN86fZgIWy+iVUnwwYf4Oi9lxa0tFSpB9IDXM6775773gUaYWjbtoO+IrI1VsIKnjt2CYCllJqir7Wt7SlWWmn+m+t53sQbU5hAamtJrxRr/mppUnuZOgszOlgJK7gCUS93YVbzKqx2q9U2q71Mbf1Qbxc/qqadu7y509W7nX8Pt/K6JwwKO+HCGLRNKPy4oA9mkYUnwGeSJM9IBDknOJN+PNV2rEy9XyXLvaGcktuY0FBux9AP5rVYd96SofCsWFje0NJwUd2rUse/UTfLPTspd83iFFZZYY4xbKoRsKlmaypjjoaICA+4ZYrO8SJ8mfEV0PF9P0Tb94U3wj7eheaHJ3VZLKxbcs4P6uartz/nMYlKbFnzYtWe5ze0wtSjDd1Ph7iReheucS0aRYM78pwoiiDPUc6Dpg19S9N0ipYOgiClw5TqgN6I6aGD7S2RkcsbppnKbLPnPHt7VZOpxvN/cq1cHf9BbeFeqIsL4Wt8CN/gC1XPfwv6U6jJAAAAAElFTkSuQmCC" /><br>
<img id="dtim-1bl" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA3BAMAAACiFTSCAAAAMFBMVEUCAgKIhobRz89vMJ7s6uo9PDx4d3ewra0bHR1dXV19NrLa2Nj+/f29u7uWlJQuLi7ws27qAAAACXBIWXMAAAsTAAALEwEAmpwYAAABjElEQVQ4y7WUsU7DMBCG/5GVoUiMMLC4ZcmWrVXVDq7yDiyRuvIEjGyIpS/graMVKYMBqVUkhoYOUTc2Bp6BEd+5qdI2SasGLpE/KZc/d76LD/i6JrvFPfMKGfMGDOCTGUMwA/SYA8yL7iEM8w2yzH1AHderh9D1alGuXmmtBaVGchFgQe8J69bOHZnIyCHsYu8AUkZRZLpYSClf0dAm4zCchGOEOWkNW7ggAO0+2QcY/SUS5ozZ+6uqNVHHR9Q8q1Bnm9+B1B17HdGxbDe1zn7sA1V7DskucbfmObOFb0LThrZTsjlGzHcw0iXcU6woQxFv9i3rah5UdSxvSa/+EMn6hp6iroy9+s/YL2mSjlxRE1fUkX2wZNqiPjrDTwmfDnbsjNeH0q9Y9ZRN2diJjeliJ+ksj+2v3W5j3d2N+R5b4T/fcjuvqppMvqfsdbqaxF7VCc3Vho9eUd0pZi6q1cpThemwdYB9NVVK2cy1NsLYmaqNNmZgZ6sQa7VPmWuavQG9ZkkjV+u42QH8BWe+iD71TSARAAAAAElFTkSuQmCC" />
<img id="dtim-1br" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA3BAMAAACiFTSCAAAAMFBMVEUCAgKIhobRz89vMJ7s6uo9PDx4d3ewra0bHR1dXV19NrLa2Nj+/f29u7uWlJQuLi7ws27qAAAACXBIWXMAAAsTAAALEwEAmpwYAAABkklEQVQ4y7VULU/DUBQ9EgtZSEimliWIt2Lmnq5rJ/gJkKXJDGquCGQdwewPzE2+PPeGWeaomgVF6tgPmOTe2zWkox8LC6dLT/ZuTs9957UXPQbuhTxcCF/jU/gGYBpgLH/7yIQNYuHXctniS9hhWlU+Wh03qVX1wwt1+eGKyoZXl8iYFbdmlFIj4N1au0THBUFgLTLrAvphSjcXUPk0RLNocodbpiiC3GcFT4C+7/shur4vvBX28SG0+o/UTHNqrZnXe3uVrW3oKtScuVeUvZYTK3lvyq21pBYRHihzxjlehC/3fHXqgQ5SArapAI9C63w1XR3GUuw75neuN6otV++78SOyza9Dv/lAj1Yf5T061XsQrjnUdSpMoYZ5qLSQvgG7JEmekQgOOWk9sV2l6kxqT4V3Nw1zb7IMyVsvBIcb6+w3lpfn1V+Jw1Awr5tMOq/XqzVdf1Mr9tZ7701JzZ+ia1ab352z6mc6cGO52hiapWPnlFM0U51ximbqUGu90KSOabTyyCWi5UyYO5/n6pPwDYr8fwvXgN7jAAAAAElFTkSuQmCC" /> <br>
<img id="dtim-1center" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA3BAMAAACiFTSCAAAAMFBMVEUBAQGPjY3Rz89DQ0O0sbHz8vJZJoFwbm6+vLxBHV10MqY6ODifnZ1XV1cdHR3c2trZIbFLAAAACXBIWXMAAAsTAAALEwEAmpwYAAACCElEQVQ4y7VVPWvjQBCVnZXt5JRT1LsQwwnS7YHrgLg6hTBsva4MSeUurX5CqqtTuXCVn6CAf0DgimvvJ4iFredmd2VZcqTYIWSap2V4+/HezMgDSAdgIw0cFhVeMQAPIAuUWfF44jAdOix8k8YsmCNXyEuGynzkQ4u68BE8LbKJsJGFDkvfYe6Lufe5ePi7unywUePY4Suhl4iMCaGlFOWQQGiRhw5Tc3b9MIiZe1Deehhkg3nXu5MirGW5NmnmkNjX9EFs1VKN7djgNg+bovae3a15cpg+ZIfquGP97J2h0viJ5cT6SoZaX+lspYyoX2doFBXjlyiaRtHV+XL5++5u+TiITExXQRR5XGeBQIkoyouNjadQSqm1Tn2pmg8bbe5NelFb0nQMKL25XxO7tsSoxmu/q80XbdXK/eZrs/2iR/OR4a53m1eO8ayPfWDJqHU2VuwywNbVnt6czflbttucVGOkmUbdUI2WSG0g0ZvepuNbiu22IM1NPAZ2uV2x7csnDf3FywFdhQPmttYUT6kkubv5D4+bWlOoFNWa5BRJHiJNDzTDQzUd21fqoaHdPaaO1/kp/d1mwwkdunfsIx2K7Q6lapmDIrVihqAsG41qiZ0tbq7ZFhw6jKsWtHPtz+z128zGT4c3z2cVXs5ujjn2773k9472j5vtf/pkYp2TKe/7E00A/gO7G7pwJRGqtAAAAABJRU5ErkJggg==" />
<img id="dtim-4center" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA3BAMAAACiFTSCAAAAMFBMVEUBAQGbmppqLZZ8fHzRz8+LPMZ0MqXs6upTUVE+G1q5ublubm6iRedQInH9/Pze3NzAiv2WAAAACXBIWXMAAAsTAAALEwEAmpwYAAABuUlEQVQ4y6VVvU7CUBSmCEVQao0vQDrcWWcWhiYkDsICc3OS3pmhSbfiI7C6MfgAJo4sPoCDcSdhMGFDBhI24zn3tBjh2DTy3eEj9+P0/Pa05BtMrZQbzG7KJaZFIyLqrS82hqfOnszXnUquLFv3dvLOeiP57uT69teFfHcP5CKJ+QdyN0YsF5Ul8WpUI06SjmM4Ks0Mrk+Zn86Y70+YS8fha0VY2K8GL1XmwDHXnxj54y1GXgbwwNOBrT2lPNWiyFHIEitrhYdkDaB1ay/vsjY6yiiCJJMVykq0pkt+OPoQH44gGX8IskqtFYjWgODQQAwt8y1aAygPdN8GCkHt5LSoaTH75ylnRT0ON5cEtz4nvL81Dc8nlrm+wmEax9t4YQ/0MNRhn1iHYcuJt+PxOMoib5p8uGpySzAfUxbQKqcsSov9VmlRqSPyOHBR6Q9Sx9haKci3lvsNPGtyv8Hogc3c+nkFl3iwasNBOBz0q8yBk8RJvMRXsE3HrT8YTDK2Zs942kc29I6npbZi5ilZjZg/DpaHL++WqNDiypfzt+LfO3VTaO39c6dmsp9nPZJ9Z18i19r8+hJ9A3EAErhB3eXkAAAAAElFTkSuQmCC" /> <br>
</div>
</div>
</div>
</div>
<div class="dtim-ok">
<button class="primaryButton" id="dti-ok">Download</button>
</div>
<div class="dtim-newtab">
<button class="primaryButton" id="dti-newtab">Open in new tab</button>
</div>
<div class="dtim-cancel">
<button class="primaryButton" id="dti-cancel">Cancel</button>
</div>
</div>
</dialog>`)
let downloadTiledImageDialog = document.getElementById("download-tiled-image-dialog")
let dtim1_width = document.getElementById("dtim1-width")
let dtim1_height = document.getElementById("dtim1-height")
let dtim2_width = document.getElementById("dtim2-width")
let dtim2_height = document.getElementById("dtim2-height")
let dtim2_unit = document.getElementById("dtim2-unit")
let dtim2_dpi = document.getElementById("dtim2-dpi")
let tabTiledTilesOptions = document.getElementById("tab-image-tiles")
let tabTiledSizeOptions = document.getElementById("tab-image-size")
linkTabContents(tabTiledTilesOptions)
linkTabContents(tabTiledSizeOptions)
prettifyInputs(downloadTiledImageDialog)
// ---- Predefined image dimensions
PAPERSIZE.forEach( function(p) {
document.getElementById("dtim2-" + p.id).addEventListener("click", (e) => {
dtim2_unit.value = p.unit
dtim2_width.value = p.width
dtim2_height.value = p.height
})
})
// ---- Close popup
document.getElementById("dti-cancel").addEventListener("click", (e) => downloadTiledImageDialog.close())
document.getElementById("downnload-tiled-close-button").addEventListener("click", (e) => downloadTiledImageDialog.close())
modalDialogCloseOnBackdropClick(downloadTiledImageDialog)
makeDialogDraggable(downloadTiledImageDialog)
// ---- Stylesheet
const styleSheet = document.createElement("style")
styleSheet.textContent = `
button[disabled] {
opacity: 0.5;
}
.method-2-dpi {
margin-top: 1em;
margin-bottom: 1em;
}
.method-2-paper button {
width: 10em;
padding: 4px;
margin: 4px;
}
.download-tiled-image .tab-content {
background: var(--background-color1);
border-radius: 3pt;
}
.dtim-container { display: grid;
grid-template-columns: auto auto;
grid-template-rows: auto auto;
gap: 1em 0px;
grid-auto-flow: row;
grid-template-areas:
"dtim-tab dtim-tab dtim-plc"
"dtim-ok dtim-newtab dtim-cancel";
}
.download-tiled-image-top {
justify-self: center;
grid-area: dtim-tab;
}
.download-tiled-image-placement {
justify-self: center;
grid-area: dtim-plc;
margin-left: 1em;
}
.dtim-ok {
justify-self: center;
align-self: start;
grid-area: dtim-ok;
}
.dtim-newtab {
justify-self: center;
align-self: start;
grid-area: dtim-newtab;
}
.dtim-cancel {
justify-self: center;
align-self: start;
grid-area: dtim-cancel;
}
#tab-content-image-placement img {
margin: 4px;
opacity: 0.3;
border: solid 2px var(--background-color1);
}
#tab-content-image-placement img:hover {
margin: 4px;
opacity: 1;
border: solid 2px var(--accent-color);
filter: brightness(2);
}
#tab-content-image-placement img.active {
margin: 4px;
opacity: 1;
border: solid 2px var(--background-color1);
}
`
document.head.appendChild(styleSheet)
// ---- Placement widget
function updatePlacementWidget(event) {
document.querySelector("#tab-content-image-placement img.active").classList.remove("active")
event.target.classList.add("active")
}
document.querySelectorAll("#tab-content-image-placement img").forEach(
(i) => i.addEventListener("click", updatePlacementWidget)
)
function getPlacement() {
return document.querySelector("#tab-content-image-placement img.active").id.substr(5)
}
// ---- Make the image
function downloadTiledImage(image, width, height, offsetX=0, offsetY=0, new_tab=false) {
const canvas = document.createElement('canvas')
canvas.width = width
canvas.height = height
const context = canvas.getContext('2d')
const w = image.width
const h = image.height
for (var x = offsetX; x < width; x += w) {
for (var y = offsetY; y < height; y += h) {
context.drawImage(image, x, y, w, h)
}
}
if (new_tab) {
var newTab = window.open("")
newTab.document.write(`<html><head><title>${width}×${height}, "${image.dataset["prompt"]}"</title></head><body><img src="${canvas.toDataURL()}"></body></html>`)
} else {
const link = document.createElement('a')
link.href = canvas.toDataURL()
link.download = image.dataset["prompt"].replace(/[^a-zA-Z0-9]+/g, "-").substr(0,22)+crypto.randomUUID()+".png"
link.click()
}
}
function onDownloadTiledImageClick(e, newtab=false) {
var width, height, offsetX, offsetY
if (isTabActive(tabTiledTilesOptions)) {
width = thisImage.width * dtim1_width.value
height = thisImage.height * dtim1_height.value
} else {
if ( dtim2_unit.value == "pixels" ) {
width = dtim2_width.value
height= dtim2_height.value
} else if ( dtim2_unit.value == "mm" ) {
width = Math.floor( dtim2_width.value * dtim2_dpi.value / 25.4 )
height = Math.floor( dtim2_height.value * dtim2_dpi.value / 25.4 )
} else { // inch
width = Math.floor( dtim2_width.value * dtim2_dpi.value )
height = Math.floor( dtim2_height.value * dtim2_dpi.value )
}
}
var placement = getPlacement()
if (placement == "1tl") {
offsetX = 0
offsetY = 0
} else if (placement == "1tr") {
offsetX = width - thisImage.width * Math.ceil( width / thisImage.width )
offsetY = 0
} else if (placement == "1bl") {
offsetX = 0
offsetY = height - thisImage.height * Math.ceil( height / thisImage.height )
} else if (placement == "1br") {
offsetX = width - thisImage.width * Math.ceil( width / thisImage.width )
offsetY = height - thisImage.height * Math.ceil( height / thisImage.height )
} else if (placement == "4center") {
offsetX = width/2 - thisImage.width * Math.ceil( width/2 / thisImage.width )
offsetY = height/2 - thisImage.height * Math.ceil( height/2 / thisImage.height )
} else if (placement == "1center") {
offsetX = width/2 - thisImage.width/2 - thisImage.width * Math.ceil( (width/2 - thisImage.width/2) / thisImage.width )
offsetY = height/2 - thisImage.height/2 - thisImage.height * Math.ceil( (height/2 - thisImage.height/2) / thisImage.height )
}
downloadTiledImage(thisImage, width, height, offsetX, offsetY, newtab)
downloadTiledImageDialog.close()
}
document.getElementById("dti-ok").addEventListener("click", onDownloadTiledImageClick)
document.getElementById("dti-newtab").addEventListener("click", (e) => onDownloadTiledImageClick(e,true))
})()