Add per-image iteration settings and steps/CFG sweeps
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { normalizeImageIterations } from '~/utils/imageIterations'
|
||||
import { assertImageV2LoraStack, parsePostedLoraStack } from '~/server/utils/loras'
|
||||
import { persistLoraFields, normalizeLoraStack } from '~/utils/loras'
|
||||
import { listStudioJobs, patchStudioJob, type StudioJobPayload } from '~/server/utils/studioQueue'
|
||||
|
||||
@@ -32,6 +34,7 @@ export default defineEventHandler(async (event) => {
|
||||
const body = await readBody<Record<string, unknown>>(event).catch(() => ({}))
|
||||
|
||||
const job = await patchStudioJob(owner, id, (row) => {
|
||||
if (!EDITABLE.has(row.status)) throw createError({ statusCode: 409, statusMessage: 'That job has started generating.' })
|
||||
const payload = row.payload
|
||||
if (body.name != null) {
|
||||
const name = text(body.name, 80).trim()
|
||||
@@ -75,9 +78,16 @@ export default defineEventHandler(async (event) => {
|
||||
payload.loraStack = fields.loraStack
|
||||
}
|
||||
if (Array.isArray(body.passes) && row.kind === 'edit') {
|
||||
payload.passes = body.passes.map((item) => ({
|
||||
prompt: text((item as { prompt?: unknown })?.prompt)
|
||||
}))
|
||||
try {
|
||||
payload.passes = normalizeImageIterations(body.passes)
|
||||
if (payload.imagePipeline === 'v2') {
|
||||
for (const pass of payload.passes) {
|
||||
if (pass.loraStack !== undefined) pass.loraStack = assertImageV2LoraStack(parsePostedLoraStack(pass.loraStack, 'image'), payload.engine || 'flux')
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
throw createError({ statusCode: 400, statusMessage: error instanceof Error ? error.message : String(error) })
|
||||
}
|
||||
row.shotCount = 1 + payload.passes.length
|
||||
}
|
||||
if (Array.isArray(body.extensions) && row.kind !== 'edit') {
|
||||
|
||||
Reference in New Issue
Block a user