Keep the Klein Concept LoRA on xAIGen only.
AIGen hides the sliders, ignores snofs strengths, and strips the SNOFS node so that file cannot be queued from the public studio. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
type ImageV2Mode,
|
||||
type ImageV2Task
|
||||
} from '~/utils/imageV2'
|
||||
import { isXaigenStudio } from '~/utils/videoModels'
|
||||
import { getStill, rememberInputStill, stillPath } from '~/server/utils/library'
|
||||
import { existsSync, readFileSync } from 'node:fs'
|
||||
|
||||
@@ -215,8 +216,9 @@ export default defineEventHandler(async (event) => {
|
||||
fields.consistency_clip,
|
||||
mode === 'generate' || engine === 'krea' ? 0 : IMAGE_V2_CONSISTENCY_CLIP
|
||||
)
|
||||
const generateSnofsFallback = engine === 'krea' ? 0 : IMAGE_V2_SNOFS_MODEL
|
||||
const generateSnofsClipFallback = engine === 'krea' ? 0 : IMAGE_V2_SNOFS_CLIP
|
||||
const conceptAllowed = isXaigenStudio()
|
||||
const generateSnofsFallback = !conceptAllowed || engine === 'krea' ? 0 : IMAGE_V2_SNOFS_MODEL
|
||||
const generateSnofsClipFallback = !conceptAllowed || engine === 'krea' ? 0 : IMAGE_V2_SNOFS_CLIP
|
||||
|
||||
const still = imageA
|
||||
? await rememberInputStill({
|
||||
@@ -287,8 +289,8 @@ export default defineEventHandler(async (event) => {
|
||||
v2Mode,
|
||||
v2Task,
|
||||
engine,
|
||||
snofsModel: clampImageV2Strength(fields.snofs_model, generateSnofsFallback),
|
||||
snofsClip: clampImageV2Strength(fields.snofs_clip, generateSnofsClipFallback),
|
||||
snofsModel: conceptAllowed ? clampImageV2Strength(fields.snofs_model, generateSnofsFallback) : 0,
|
||||
snofsClip: conceptAllowed ? clampImageV2Strength(fields.snofs_clip, generateSnofsClipFallback) : 0,
|
||||
consistencyModel: generateConsistencyModel,
|
||||
consistencyClip: generateConsistencyClip,
|
||||
maskStillId: savedMask?.id,
|
||||
|
||||
@@ -124,8 +124,8 @@ function sanitizeImageV2Settings(raw: unknown): ImageV2PresetSettings {
|
||||
engine,
|
||||
task: mode === 'compose' ? parseImageV2Task(rec.task, 'scene') : mode === 'refine' ? 'refine' : mode === 'generate' ? 't2i' : 'scene',
|
||||
negative: String(rec.negative || '').slice(0, 2000),
|
||||
snofsModel: clampImageV2Strength(rec.snofsModel ?? rec.snofs_model, IMAGE_V2_SNOFS_MODEL),
|
||||
snofsClip: clampImageV2Strength(rec.snofsClip ?? rec.snofs_clip, IMAGE_V2_SNOFS_CLIP),
|
||||
snofsModel: isXaigenStudio() ? clampImageV2Strength(rec.snofsModel ?? rec.snofs_model, IMAGE_V2_SNOFS_MODEL) : 0,
|
||||
snofsClip: isXaigenStudio() ? clampImageV2Strength(rec.snofsClip ?? rec.snofs_clip, IMAGE_V2_SNOFS_CLIP) : 0,
|
||||
consistencyModel: clampImageV2Strength(rec.consistencyModel ?? rec.consistency_model, mode === 'generate' ? 0 : IMAGE_V2_CONSISTENCY_MODEL),
|
||||
consistencyClip: clampImageV2Strength(rec.consistencyClip ?? rec.consistency_clip, mode === 'generate' ? 0 : IMAGE_V2_CONSISTENCY_CLIP),
|
||||
steps: engine === 'krea' ? clampImageSteps(rec.steps, IMAGE_V2_KREA_STEPS) : turbo ? 8 : clampImageSteps(rec.steps, IMAGE_V2_STEPS_DEFAULT),
|
||||
@@ -165,12 +165,15 @@ function normalizeStoredPreset(raw: unknown): GenerationPreset | null {
|
||||
|
||||
function publicPreset(preset: GenerationPreset): GenerationPreset {
|
||||
const xaigen = isXaigenStudio()
|
||||
const settings = preset.kind === 'video'
|
||||
? { ...preset.settings, workflow: coerceVideoWorkflow((preset.settings as VideoPresetSettings).workflow) }
|
||||
: preset.kind === 'imagev2' && !xaigen
|
||||
? { ...preset.settings, snofsModel: 0, snofsClip: 0 }
|
||||
: preset.settings
|
||||
return {
|
||||
...preset,
|
||||
loraStack: filterLoraStackForStudio(preset.loraStack, xaigen),
|
||||
settings: preset.kind === 'video'
|
||||
? { ...preset.settings, workflow: coerceVideoWorkflow((preset.settings as VideoPresetSettings).workflow) }
|
||||
: preset.settings
|
||||
settings
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import { imageComfyFetch } from '~/server/utils/imageComfy'
|
||||
import { cachedComfyLoraNames } from '~/server/utils/loras'
|
||||
import { resolveComfyLoraName, loraIdentityKey } from '~/utils/loras'
|
||||
import { clampImageCfg, clampImageScaleMegapixels, clampImageSteps } from '~/utils/generationPresets'
|
||||
import { isXaigenStudio } from '~/utils/videoModels'
|
||||
import {
|
||||
IMAGE_V2_CONSISTENCY_CLIP,
|
||||
IMAGE_V2_CONSISTENCY_LORA,
|
||||
@@ -51,6 +52,8 @@ const NOISE = '15'
|
||||
const SCHEDULER = '17'
|
||||
const CFG = '18'
|
||||
const SAVE = '21'
|
||||
const UNET = '4'
|
||||
const CLIP = '5'
|
||||
const SNOFS = '7'
|
||||
const CONSISTENCY = '8'
|
||||
|
||||
@@ -138,6 +141,16 @@ function bypassLoraNode(graph: WorkflowGraph, id: string, modelFrom: string, cli
|
||||
}
|
||||
}
|
||||
|
||||
function bypassLoraToBaseLoaders(graph: WorkflowGraph, id: string) {
|
||||
delete graph[id]
|
||||
for (const node of Object.values(graph)) {
|
||||
for (const [key, value] of Object.entries(node.inputs)) {
|
||||
if (!Array.isArray(value) || value[0] !== id) continue
|
||||
node.inputs[key] = value[1] === 1 ? [CLIP, 0] : [UNET, 0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function modelBasename(name: string) {
|
||||
return String(name || '').replace(/\\/g, '/').split('/').pop() || ''
|
||||
}
|
||||
@@ -367,7 +380,7 @@ function buildKreaGenerateWorkflow(params: ImageV2BuildParams) {
|
||||
const size = clampImageV2Size(params.width, params.height)
|
||||
const steps = clampImageSteps(params.steps, IMAGE_V2_KREA_STEPS)
|
||||
const cfg = clampImageCfg(params.cfg, IMAGE_V2_KREA_CFG)
|
||||
const conceptName = String(params.kreaConceptLora || '').trim()
|
||||
const conceptName = isXaigenStudio() ? String(params.kreaConceptLora || '').trim() : ''
|
||||
const snofsModel = conceptName ? clampImageV2Strength(params.snofsModel, 0) : 0
|
||||
const snofsClip = conceptName ? clampImageV2Strength(params.snofsClip, 0) : 0
|
||||
const workflowFile = IMAGE_V2_KREA_GENERATE_WORKFLOW
|
||||
@@ -434,8 +447,9 @@ export function buildImageV2Workflow(params: ImageV2BuildParams) {
|
||||
) as WorkflowGraph
|
||||
const prompt = composeImageV2Prompt(params.mode, params.task, params.prompt)
|
||||
const negative = String(params.negative || '')
|
||||
const snofsModel = clampImageV2Strength(params.snofsModel, IMAGE_V2_SNOFS_MODEL)
|
||||
const snofsClip = clampImageV2Strength(params.snofsClip, IMAGE_V2_SNOFS_CLIP)
|
||||
const conceptAllowed = isXaigenStudio()
|
||||
const snofsModel = conceptAllowed ? clampImageV2Strength(params.snofsModel, IMAGE_V2_SNOFS_MODEL) : 0
|
||||
const snofsClip = conceptAllowed ? clampImageV2Strength(params.snofsClip, IMAGE_V2_SNOFS_CLIP) : 0
|
||||
const consistencyModel = clampImageV2Strength(
|
||||
params.consistencyModel,
|
||||
generate ? 0 : IMAGE_V2_CONSISTENCY_MODEL
|
||||
@@ -470,11 +484,16 @@ export function buildImageV2Workflow(params: ImageV2BuildParams) {
|
||||
setInput(graph, SAVE, 'filename_prefix', params.filenamePrefix || (generate ? 'aigen-v2-generate' : 'aigen-v2'))
|
||||
if (!generate) patchScaleMegapixels(graph, params.megapixels ?? 1)
|
||||
|
||||
setInput(graph, SNOFS, 'lora_name', resolveRequiredLora(IMAGE_V2_SNOFS_LORA, 'SNOFS'))
|
||||
setInput(graph, SNOFS, 'strength_model', snofsModel)
|
||||
setInput(graph, SNOFS, 'strength_clip', snofsClip)
|
||||
if (conceptAllowed) {
|
||||
setInput(graph, SNOFS, 'lora_name', resolveRequiredLora(IMAGE_V2_SNOFS_LORA, 'SNOFS'))
|
||||
setInput(graph, SNOFS, 'strength_model', snofsModel)
|
||||
setInput(graph, SNOFS, 'strength_clip', snofsClip)
|
||||
} else {
|
||||
bypassLoraToBaseLoaders(graph, SNOFS)
|
||||
}
|
||||
if (generate && consistencyModel <= 0 && consistencyClip <= 0) {
|
||||
bypassLoraNode(graph, CONSISTENCY, SNOFS, SNOFS)
|
||||
if (graph[SNOFS]) bypassLoraNode(graph, CONSISTENCY, SNOFS, SNOFS)
|
||||
else bypassLoraToBaseLoaders(graph, CONSISTENCY)
|
||||
} else {
|
||||
setInput(graph, CONSISTENCY, 'lora_name', resolveRequiredLora(IMAGE_V2_CONSISTENCY_LORA, 'Consistency'))
|
||||
setInput(graph, CONSISTENCY, 'strength_model', consistencyModel)
|
||||
|
||||
@@ -4,7 +4,7 @@ import { getJob, listJobs, emitJob, type Job } from '~/server/utils/jobs'
|
||||
import { listPendingJobs, patchPendingJob, readPendingJob, deletePendingJob } from '~/server/utils/pending'
|
||||
import { getShotQueue } from '~/server/utils/shotQueue'
|
||||
import { fetchLiveQueue } from '~/server/utils/comfy'
|
||||
import { isLtxWorkflow, isTextToVideo, LTX_DISABLED_MESSAGE, ltxWorkflowEnabled, parseVideoWorkflow, type VideoWorkflowId } from '~/utils/videoModels'
|
||||
import { isLtxWorkflow, isTextToVideo, isXaigenStudio, LTX_DISABLED_MESSAGE, ltxWorkflowEnabled, parseVideoWorkflow, type VideoWorkflowId } from '~/utils/videoModels'
|
||||
import { persistLoraFields } from '~/server/utils/loras'
|
||||
import { resolveLoraStack } from '~/utils/loras'
|
||||
import { allowIdentityRefs } from '~/utils/globalLocks'
|
||||
@@ -764,8 +764,8 @@ async function startStudioEditJob(item: StudioJob) {
|
||||
steps: payload.steps,
|
||||
seed: live.library?.seed || payload.seed,
|
||||
cfg: payload.cfg,
|
||||
snofsModel: payload.snofsModel ?? 0.65,
|
||||
snofsClip: payload.snofsClip ?? 0.35,
|
||||
snofsModel: payload.snofsModel ?? (isXaigenStudio() ? 0.65 : 0),
|
||||
snofsClip: payload.snofsClip ?? (isXaigenStudio() ? 0.35 : 0),
|
||||
consistencyModel: payload.consistencyModel ?? (mode === 'generate' ? 0 : 0.7),
|
||||
consistencyClip: payload.consistencyClip ?? (mode === 'generate' ? 0 : 0.7),
|
||||
megapixels: payload.scaleMegapixels ?? 1,
|
||||
|
||||
Reference in New Issue
Block a user