From 9d9fc1683a71adf1ff87d85e3be4c30d213b0923 Mon Sep 17 00:00:00 2001 From: JeLuF Date: Fri, 13 Jan 2023 22:05:25 +0100 Subject: [PATCH 1/2] Fix number on the "Make X images" button With this change, the number of prompt variants is taken into account when computing the number of images that will be generated. X = getPrompts().length * numOutputsTotalField.value --- ui/media/js/main.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/media/js/main.js b/ui/media/js/main.js index e515787b..d83a8c9d 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -1138,7 +1138,7 @@ widthField.addEventListener('change', onDimensionChange) heightField.addEventListener('change', onDimensionChange) function renameMakeImageButton() { - let totalImages = Math.max(parseInt(numOutputsTotalField.value), parseInt(numOutputsParallelField.value)) + let totalImages = Math.max(parseInt(numOutputsTotalField.value), parseInt(numOutputsParallelField.value)) * getPrompts().length let imageLabel = 'Image' if (totalImages > 1) { imageLabel = totalImages + ' Images' @@ -1483,6 +1483,9 @@ function resumeClient() { }) } +promptField.addEventListener("input", debounce( renameMakeImageButton, 1000) ) + + pauseBtn.addEventListener("click", function () { pauseClient = true pauseBtn.style.display="none" From b99d9db8f9653bfd8a3d695c67519e0ef1d1c55e Mon Sep 17 00:00:00 2001 From: JeLuF Date: Sun, 5 Feb 2023 17:09:56 +0100 Subject: [PATCH 2/2] Create exactly 'total' images even if 'in parallel' is no factor of 'total' --- ui/media/js/main.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/media/js/main.js b/ui/media/js/main.js index d83a8c9d..c6660a57 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -702,12 +702,18 @@ async function onTaskStart(task) { if (task.batchCount > 1) { // Each output render batch needs it's own task reqBody instance to avoid altering the other runs after they are completed. newTaskReqBody = Object.assign({}, task.reqBody) + if (task.batchesDone == task.batchCount-1) { + // Last batch of the task + // If the number of parallel jobs is no factor of the total number of images, the last batch must create less than "parallel jobs count" images + // E.g. with numOutputsTotal = 6 and num_outputs = 5, the last batch shall only generate 1 image. + newTaskReqBody.num_outputs = task.numOutputsTotal - task.reqBody.num_outputs * (task.batchCount-1) + } } const startSeed = task.seed || newTaskReqBody.seed const genSeeds = Boolean(typeof newTaskReqBody.seed !== 'number' || (newTaskReqBody.seed === task.seed && task.numOutputsTotal > 1)) if (genSeeds) { - newTaskReqBody.seed = parseInt(startSeed) + (task.batchesDone * newTaskReqBody.num_outputs) + newTaskReqBody.seed = parseInt(startSeed) + (task.batchesDone * task.reqBody.num_outputs) } // Update the seed *before* starting the processing so it's retained if user stops the task