From 890a3ce32a777aa2fb942ed801168fd5a1923d44 Mon Sep 17 00:00:00 2001 From: Mary Hipp Date: Fri, 19 Jul 2024 16:19:11 -0400 Subject: [PATCH] add limited metadata --- .../graph/buildMultidiffusionUpscaleGraph.ts | 44 ++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/invokeai/frontend/web/src/features/nodes/util/graph/buildMultidiffusionUpscaleGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graph/buildMultidiffusionUpscaleGraph.ts index 8236cd26fb..400d083450 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graph/buildMultidiffusionUpscaleGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graph/buildMultidiffusionUpscaleGraph.ts @@ -22,6 +22,8 @@ import { import { addLoRAs } from './generation/addLoRAs'; import { addSDXLLoRas } from './generation/addSDXLLoRAs'; import { getBoardField, getSDXLStylePrompts } from './graphBuilderUtils'; +import { fetchModelConfigWithTypeGuard } from '../../../metadata/util/modelFetchingHelpers'; +import { isNonRefinerMainModelConfig } from '../../../../services/api/types'; export const UPSCALE_SCALE = 2; @@ -36,6 +38,9 @@ export const buildMultidiffusionUpscsaleGraph = async (state: RootState): Promis assert(upscaleInitialImage, 'No initial image found in state'); assert(tileControlnetModel, 'Tile controlnet is required'); + const outputWidth = ((upscaleInitialImage.width * UPSCALE_SCALE) / 8) * 8 + const outputHeight = ((upscaleInitialImage.height * UPSCALE_SCALE) / 8) * 8 + const g = new Graph(); const unsharpMaskNode1 = g.addNode({ @@ -64,11 +69,12 @@ export const buildMultidiffusionUpscsaleGraph = async (state: RootState): Promis g.addEdge(upscaleNode, 'image', unsharpMaskNode2, 'image'); + const resizeNode = g.addNode({ id: RESIZE, type: 'img_resize', - width: ((upscaleInitialImage.width * UPSCALE_SCALE) / 8) * 8, - height: ((upscaleInitialImage.height * UPSCALE_SCALE) / 8) * 8, + width: outputWidth, + height: outputHeight, resample_mode: 'lanczos', }); @@ -144,6 +150,23 @@ export const buildMultidiffusionUpscsaleGraph = async (state: RootState): Promis g.addEdge(modelNode, 'clip2', negCondNode, 'clip2'); g.addEdge(modelNode, 'unet', tiledMultidiffusionNode, 'unet'); addSDXLLoRas(state, g, tiledMultidiffusionNode, modelNode, null, posCondNode, negCondNode); + + const modelConfig = await fetchModelConfigWithTypeGuard(model.key, isNonRefinerMainModelConfig); + + g.upsertMetadata({ + cfg_scale, + height: outputHeight, + width: outputWidth, + positive_prompt: positivePrompt, + negative_prompt: negativePrompt, + positive_style_prompt: positiveStylePrompt, + negative_style_prompt: negativeStylePrompt, + model: Graph.getModelMetadataField(modelConfig), + seed, + steps, + scheduler, + vae: vae ?? undefined, + }); } else { posCondNode = g.addNode({ type: 'compel', @@ -170,8 +193,25 @@ export const buildMultidiffusionUpscsaleGraph = async (state: RootState): Promis g.addEdge(clipSkipNode, 'clip', negCondNode, 'clip'); g.addEdge(modelNode, 'unet', tiledMultidiffusionNode, 'unet'); addLoRAs(state, g, tiledMultidiffusionNode, modelNode, null, clipSkipNode, posCondNode, negCondNode); + + const modelConfig = await fetchModelConfigWithTypeGuard(model.key, isNonRefinerMainModelConfig); + + g.upsertMetadata({ + cfg_scale, + height: outputHeight, + width: outputWidth, + positive_prompt: positivePrompt, + negative_prompt: negativePrompt, + model: Graph.getModelMetadataField(modelConfig), + seed, + steps, + scheduler, + vae: vae ?? undefined, + }); } + g.setMetadataReceivingNode(l2iNode); + let vaeNode; if (vae) { vaeNode = g.addNode({