mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-06-13 21:36:43 +02:00
Create exactly 'total' images even if 'in parallel' is no factor of 'total'
This commit is contained in:
parent
9d9fc1683a
commit
b99d9db8f9
@ -702,12 +702,18 @@ async function onTaskStart(task) {
|
|||||||
if (task.batchCount > 1) {
|
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.
|
// 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)
|
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 startSeed = task.seed || newTaskReqBody.seed
|
||||||
const genSeeds = Boolean(typeof newTaskReqBody.seed !== 'number' || (newTaskReqBody.seed === task.seed && task.numOutputsTotal > 1))
|
const genSeeds = Boolean(typeof newTaskReqBody.seed !== 'number' || (newTaskReqBody.seed === task.seed && task.numOutputsTotal > 1))
|
||||||
if (genSeeds) {
|
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
|
// Update the seed *before* starting the processing so it's retained if user stops the task
|
||||||
|
Loading…
x
Reference in New Issue
Block a user