From c56a2adbcb1d8581fcb8df501ee65d35561f44f7 Mon Sep 17 00:00:00 2001 From: patriceac <48073125+patriceac@users.noreply.github.com> Date: Tue, 22 Nov 2022 19:04:20 -0800 Subject: [PATCH 01/29] Custom modifiers as a plugin --- ui/index.html | 2 +- ui/media/js/image-modifiers.js | 26 +------------------ ui/media/js/plugins.js | 3 ++- ui/plugins/ui/custom-modifiers.plugin.js | 33 ++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 27 deletions(-) create mode 100644 ui/plugins/ui/custom-modifiers.plugin.js diff --git a/ui/index.html b/ui/index.html index 3e85b254..a6daaa5a 100644 --- a/ui/index.html +++ b/ui/index.html @@ -346,8 +346,8 @@ async function init() { await getModels() await getDiskPath() await getAppConfig() - await loadModifiers() await loadUIPlugins() + await loadModifiers() await getDevices() setInterval(healthCheck, HEALTH_PING_INTERVAL * 1000) diff --git a/ui/media/js/image-modifiers.js b/ui/media/js/image-modifiers.js index 24347fc4..2bca80a8 100644 --- a/ui/media/js/image-modifiers.js +++ b/ui/media/js/image-modifiers.js @@ -310,31 +310,7 @@ function saveCustomModifiers() { } function loadCustomModifiers() { - let customModifiers = localStorage.getItem(CUSTOM_MODIFIERS_KEY, '') - customModifiersTextBox.value = customModifiers - - if (customModifiersGroupElement !== undefined) { - customModifiersGroupElement.remove() - } - - if (customModifiers && customModifiers.trim() !== '') { - customModifiers = customModifiers.split('\n') - customModifiers = customModifiers.filter(m => m.trim() !== '') - customModifiers = customModifiers.map(function(m) { - return { - "modifier": m - } - }) - - let customGroup = { - 'category': 'Custom Modifiers', - 'modifiers': customModifiers - } - - customModifiersGroupElement = createModifierGroup(customGroup, true) - - createCollapsibles(customModifiersGroupElement) - } + PLUGINS['MODIFIERS_LOAD'].forEach(fn=>fn.loader.call()) } customModifiersTextBox.addEventListener('change', saveCustomModifiers) diff --git a/ui/media/js/plugins.js b/ui/media/js/plugins.js index 6471e8cb..c370aa03 100644 --- a/ui/media/js/plugins.js +++ b/ui/media/js/plugins.js @@ -24,7 +24,8 @@ const PLUGINS = { * } * }) */ - IMAGE_INFO_BUTTONS: [] + IMAGE_INFO_BUTTONS: [], + MODIFIERS_LOAD: [] } async function loadUIPlugins() { diff --git a/ui/plugins/ui/custom-modifiers.plugin.js b/ui/plugins/ui/custom-modifiers.plugin.js new file mode 100644 index 00000000..632f8c4a --- /dev/null +++ b/ui/plugins/ui/custom-modifiers.plugin.js @@ -0,0 +1,33 @@ +(function() { + PLUGINS['MODIFIERS_LOAD'] = [] + + PLUGINS['MODIFIERS_LOAD'].push({ + loader: function() { + let customModifiers = localStorage.getItem(CUSTOM_MODIFIERS_KEY, '') + customModifiersTextBox.value = customModifiers + + if (customModifiersGroupElement !== undefined) { + customModifiersGroupElement.remove() + } + + if (customModifiers && customModifiers.trim() !== '') { + customModifiers = customModifiers.split('\n') + customModifiers = customModifiers.filter(m => m.trim() !== '') + customModifiers = customModifiers.map(function(m) { + return { + "modifier": m + } + }) + + let customGroup = { + 'category': 'Custom Modifiers', + 'modifiers': customModifiers + } + + customModifiersGroupElement = createModifierGroup(customGroup, true) + + createCollapsibles(customModifiersGroupElement) + } + } + }) +})() \ No newline at end of file From ba30a63407579b3bb9e672a3d971b86e27846c27 Mon Sep 17 00:00:00 2001 From: patriceac <48073125+patriceac@users.noreply.github.com> Date: Tue, 22 Nov 2022 23:07:44 -0800 Subject: [PATCH 02/29] Update custom-modifiers.plugin.js Add a carriage return at the end --- ui/plugins/ui/custom-modifiers.plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/plugins/ui/custom-modifiers.plugin.js b/ui/plugins/ui/custom-modifiers.plugin.js index 632f8c4a..8404ee9f 100644 --- a/ui/plugins/ui/custom-modifiers.plugin.js +++ b/ui/plugins/ui/custom-modifiers.plugin.js @@ -30,4 +30,4 @@ } } }) -})() \ No newline at end of file +})() From e5c11ea21413bb82c3d2071d8459562df81f6d45 Mon Sep 17 00:00:00 2001 From: patriceac <48073125+patriceac@users.noreply.github.com> Date: Wed, 23 Nov 2022 03:00:19 -0800 Subject: [PATCH 03/29] Update custom-modifiers.plugin.js Removing the redundant initialization of the array. --- ui/plugins/ui/custom-modifiers.plugin.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/ui/plugins/ui/custom-modifiers.plugin.js b/ui/plugins/ui/custom-modifiers.plugin.js index 8404ee9f..68599c63 100644 --- a/ui/plugins/ui/custom-modifiers.plugin.js +++ b/ui/plugins/ui/custom-modifiers.plugin.js @@ -1,6 +1,4 @@ (function() { - PLUGINS['MODIFIERS_LOAD'] = [] - PLUGINS['MODIFIERS_LOAD'].push({ loader: function() { let customModifiers = localStorage.getItem(CUSTOM_MODIFIERS_KEY, '') From 2d8401473d1b075ece673e43ab9d60b800c08f4b Mon Sep 17 00:00:00 2001 From: patriceac <48073125+patriceac@users.noreply.github.com> Date: Sat, 26 Nov 2022 16:57:54 -0800 Subject: [PATCH 04/29] Revert "Update custom-modifiers.plugin.js" This reverts commit e5c11ea21413bb82c3d2071d8459562df81f6d45. --- ui/plugins/ui/custom-modifiers.plugin.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/plugins/ui/custom-modifiers.plugin.js b/ui/plugins/ui/custom-modifiers.plugin.js index 68599c63..8404ee9f 100644 --- a/ui/plugins/ui/custom-modifiers.plugin.js +++ b/ui/plugins/ui/custom-modifiers.plugin.js @@ -1,4 +1,6 @@ (function() { + PLUGINS['MODIFIERS_LOAD'] = [] + PLUGINS['MODIFIERS_LOAD'].push({ loader: function() { let customModifiers = localStorage.getItem(CUSTOM_MODIFIERS_KEY, '') From 0dc970562a255150d726bcaab7ce3a70bb3af3d3 Mon Sep 17 00:00:00 2001 From: patriceac <48073125+patriceac@users.noreply.github.com> Date: Sat, 26 Nov 2022 18:27:04 -0800 Subject: [PATCH 05/29] Reverting this unnecessary change --- ui/plugins/ui/custom-modifiers.plugin.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/ui/plugins/ui/custom-modifiers.plugin.js b/ui/plugins/ui/custom-modifiers.plugin.js index 8404ee9f..68599c63 100644 --- a/ui/plugins/ui/custom-modifiers.plugin.js +++ b/ui/plugins/ui/custom-modifiers.plugin.js @@ -1,6 +1,4 @@ (function() { - PLUGINS['MODIFIERS_LOAD'] = [] - PLUGINS['MODIFIERS_LOAD'].push({ loader: function() { let customModifiers = localStorage.getItem(CUSTOM_MODIFIERS_KEY, '') From 69f14edd8080cdb0fc84979dcc443d981266520d Mon Sep 17 00:00:00 2001 From: patriceac <48073125+patriceac@users.noreply.github.com> Date: Mon, 28 Nov 2022 01:19:31 -0800 Subject: [PATCH 06/29] Tweak the seed behavior Update the seed *before* starting the processing, so interrupting the processing retains the seed being used for the batch being currently processed. The idea behind that is that if I like the gen I'm currently seeing and want to build on top of it, I can create a new task with the same seed without having to wait for the current task to complete. --- ui/media/js/main.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ui/media/js/main.js b/ui/media/js/main.js index 2811a50c..fe4caacb 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -695,6 +695,12 @@ async function checkTasks() { const genSeeds = Boolean(typeof task.reqBody.seed !== 'number' || (task.reqBody.seed === task.seed && task.numOutputsTotal > 1)) const startSeed = task.reqBody.seed || task.seed + + // Update the seed *before* starting the processing so it's retained if user stops the task + if (randomSeedField.checked) { + seedField.value = task.seed + } + for (let i = 0; i < task.batchCount; i++) { let newTask = task if (task.batchCount > 1) { @@ -741,10 +747,6 @@ async function checkTasks() { } } - if (randomSeedField.checked) { - seedField.value = task.seed - } - currentTask = null if (typeof requestIdleCallback === 'function') { @@ -1201,7 +1203,7 @@ async function getModels() { function checkRandomSeed() { if (randomSeedField.checked) { seedField.disabled = true - seedField.value = "0" + //seedField.value = "0" // This causes the seed to be lost if the user changes their mind after toggling the checkbox } else { seedField.disabled = false } From a69d4c279efbef06b185a92af4352c5547d452cc Mon Sep 17 00:00:00 2001 From: patriceac <48073125+patriceac@users.noreply.github.com> Date: Tue, 29 Nov 2022 19:04:42 -0800 Subject: [PATCH 07/29] Make seed field behavior deterministic Copying the image settings while 'Random' is enabled would cause the seed to be randomized. This was misleading as what I see wasn't what I would get. --- ui/index.html | 2 +- ui/media/js/dnd.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/index.html b/ui/index.html index edbccf97..7a5cf737 100644 --- a/ui/index.html +++ b/ui/index.html @@ -104,7 +104,7 @@