From 7053347559263c6bb209332cc240b2110847b666 Mon Sep 17 00:00:00 2001 From: blessedcoolant <54517381+blessedcoolant@users.noreply.github.com> Date: Thu, 27 Jul 2023 07:09:51 +1200 Subject: [PATCH 1/3] fix: Metadata Not Being Saved --- .../buildCanvasImageToImageGraph.ts | 16 +++++++ .../graphBuilders/buildCanvasInpaintGraph.ts | 42 ++++++++++++++++++- .../buildCanvasTextToImageGraph.ts | 16 +++++++ .../buildLinearImageToImageGraph.ts | 16 +++++++ .../buildLinearSDXLImageToImageGraph.ts | 27 +++++++----- .../buildLinearSDXLTextToImageGraph.ts | 27 +++++++----- .../buildLinearTextToImageGraph.ts | 16 +++++++ 7 files changed, 136 insertions(+), 24 deletions(-) diff --git a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasImageToImageGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasImageToImageGraph.ts index 81e99e0dd0..2981c090d8 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasImageToImageGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasImageToImageGraph.ts @@ -335,5 +335,21 @@ export const buildCanvasImageToImageGraph = ( addWatermarkerToGraph(state, graph); } + if ( + !state.system.shouldUseNSFWChecker && + !state.system.shouldUseWatermarker + ) { + graph.edges.push({ + source: { + node_id: METADATA_ACCUMULATOR, + field: 'metadata', + }, + destination: { + node_id: LATENTS_TO_IMAGE, + field: 'metadata', + }, + }); + } + return graph; }; diff --git a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasInpaintGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasInpaintGraph.ts index 4154c1b5eb..8462b32e63 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasInpaintGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasInpaintGraph.ts @@ -8,20 +8,21 @@ import { RangeOfSizeInvocation, } from 'services/api/types'; import { addLoRAsToGraph } from './addLoRAsToGraph'; +import { addNSFWCheckerToGraph } from './addNSFWCheckerToGraph'; import { addVAEToGraph } from './addVAEToGraph'; +import { addWatermarkerToGraph } from './addWatermarkerToGraph'; import { CLIP_SKIP, INPAINT, INPAINT_GRAPH, ITERATE, MAIN_MODEL_LOADER, + METADATA_ACCUMULATOR, NEGATIVE_CONDITIONING, POSITIVE_CONDITIONING, RANDOM_INT, RANGE_OF_SIZE, } from './constants'; -import { addNSFWCheckerToGraph } from './addNSFWCheckerToGraph'; -import { addWatermarkerToGraph } from './addWatermarkerToGraph'; /** * Builds the Canvas tab's Inpaint graph. @@ -251,6 +252,27 @@ export const buildCanvasInpaintGraph = ( (graph.nodes[RANGE_OF_SIZE] as RangeOfSizeInvocation).start = seed; } + // add metadata accumulator, which is only mostly populated - some fields are added later + graph.nodes[METADATA_ACCUMULATOR] = { + id: METADATA_ACCUMULATOR, + type: 'metadata_accumulator', + generation_mode: 'txt2img', + cfg_scale, + height, + width, + positive_prompt: '', // set in addDynamicPromptsToGraph + negative_prompt: negativePrompt, + model, + seed: 0, // set in addDynamicPromptsToGraph + steps, + rand_device: 'cpu', + scheduler, + vae: undefined, // option; set in addVAEToGraph + controlnets: [], // populated in addControlNetToLinearGraph + loras: [], // populated in addLoRAsToGraph + clip_skip: clipSkip, + }; + // NSFW & watermark - must be last thing added to graph if (state.system.shouldUseNSFWChecker) { // must add before watermarker! @@ -262,5 +284,21 @@ export const buildCanvasInpaintGraph = ( addWatermarkerToGraph(state, graph, INPAINT); } + if ( + !state.system.shouldUseNSFWChecker && + !state.system.shouldUseWatermarker + ) { + graph.edges.push({ + source: { + node_id: METADATA_ACCUMULATOR, + field: 'metadata', + }, + destination: { + node_id: INPAINT, + field: 'metadata', + }, + }); + } + return graph; }; diff --git a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasTextToImageGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasTextToImageGraph.ts index 597a643367..55e11e4f37 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasTextToImageGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasTextToImageGraph.ts @@ -240,5 +240,21 @@ export const buildCanvasTextToImageGraph = ( addWatermarkerToGraph(state, graph); } + if ( + !state.system.shouldUseNSFWChecker && + !state.system.shouldUseWatermarker + ) { + graph.edges.push({ + source: { + node_id: METADATA_ACCUMULATOR, + field: 'metadata', + }, + destination: { + node_id: LATENTS_TO_IMAGE, + field: 'metadata', + }, + }); + } + return graph; }; diff --git a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearImageToImageGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearImageToImageGraph.ts index d78e2e1356..e726a02a5c 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearImageToImageGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearImageToImageGraph.ts @@ -345,5 +345,21 @@ export const buildLinearImageToImageGraph = ( addWatermarkerToGraph(state, graph); } + if ( + !state.system.shouldUseNSFWChecker && + !state.system.shouldUseWatermarker + ) { + graph.edges.push({ + source: { + node_id: METADATA_ACCUMULATOR, + field: 'metadata', + }, + destination: { + node_id: LATENTS_TO_IMAGE, + field: 'metadata', + }, + }); + } + return graph; }; diff --git a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearSDXLImageToImageGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearSDXLImageToImageGraph.ts index a260dbc467..3697b96bea 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearSDXLImageToImageGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearSDXLImageToImageGraph.ts @@ -353,17 +353,6 @@ export const buildLinearSDXLImageToImageGraph = ( negative_style_prompt: negativeStylePrompt, }; - graph.edges.push({ - source: { - node_id: METADATA_ACCUMULATOR, - field: 'metadata', - }, - destination: { - node_id: LATENTS_TO_IMAGE, - field: 'metadata', - }, - }); - // Add Refiner if enabled if (shouldUseSDXLRefiner) { addSDXLRefinerToGraph(state, graph, SDXL_LATENTS_TO_LATENTS); @@ -383,5 +372,21 @@ export const buildLinearSDXLImageToImageGraph = ( addWatermarkerToGraph(state, graph); } + if ( + !state.system.shouldUseNSFWChecker && + !state.system.shouldUseWatermarker + ) { + graph.edges.push({ + source: { + node_id: METADATA_ACCUMULATOR, + field: 'metadata', + }, + destination: { + node_id: LATENTS_TO_IMAGE, + field: 'metadata', + }, + }); + } + return graph; }; diff --git a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearSDXLTextToImageGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearSDXLTextToImageGraph.ts index c10e7831d3..1669de5341 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearSDXLTextToImageGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearSDXLTextToImageGraph.ts @@ -235,17 +235,6 @@ export const buildLinearSDXLTextToImageGraph = ( negative_style_prompt: negativeStylePrompt, }; - graph.edges.push({ - source: { - node_id: METADATA_ACCUMULATOR, - field: 'metadata', - }, - destination: { - node_id: LATENTS_TO_IMAGE, - field: 'metadata', - }, - }); - // Add Refiner if enabled if (shouldUseSDXLRefiner) { addSDXLRefinerToGraph(state, graph, SDXL_TEXT_TO_LATENTS); @@ -265,5 +254,21 @@ export const buildLinearSDXLTextToImageGraph = ( addWatermarkerToGraph(state, graph); } + if ( + !state.system.shouldUseNSFWChecker && + !state.system.shouldUseWatermarker + ) { + graph.edges.push({ + source: { + node_id: METADATA_ACCUMULATOR, + field: 'metadata', + }, + destination: { + node_id: LATENTS_TO_IMAGE, + field: 'metadata', + }, + }); + } + return graph; }; diff --git a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearTextToImageGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearTextToImageGraph.ts index 94f35feba0..08aa355d4d 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearTextToImageGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearTextToImageGraph.ts @@ -229,5 +229,21 @@ export const buildLinearTextToImageGraph = ( addWatermarkerToGraph(state, graph); } + if ( + !state.system.shouldUseNSFWChecker && + !state.system.shouldUseWatermarker + ) { + graph.edges.push({ + source: { + node_id: METADATA_ACCUMULATOR, + field: 'metadata', + }, + destination: { + node_id: LATENTS_TO_IMAGE, + field: 'metadata', + }, + }); + } + return graph; }; From 049e6664126b4aa9ddef563e103810b73766522c Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Thu, 27 Jul 2023 09:43:45 +1000 Subject: [PATCH 2/3] fix(ui): revise metadata edges in linear graphs - always add metadata to l2i nodes - no metadata handling for inpaint, removed --- .../buildCanvasImageToImageGraph.ts | 27 ++++++-------- .../graphBuilders/buildCanvasInpaintGraph.ts | 37 ------------------- .../buildCanvasTextToImageGraph.ts | 27 ++++++-------- .../buildLinearImageToImageGraph.ts | 27 ++++++-------- .../buildLinearSDXLImageToImageGraph.ts | 27 ++++++-------- .../buildLinearSDXLTextToImageGraph.ts | 27 ++++++-------- .../buildLinearTextToImageGraph.ts | 27 ++++++-------- 7 files changed, 66 insertions(+), 133 deletions(-) diff --git a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasImageToImageGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasImageToImageGraph.ts index 2981c090d8..42f768c107 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasImageToImageGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasImageToImageGraph.ts @@ -312,6 +312,17 @@ export const buildCanvasImageToImageGraph = ( init_image: initialImage.image_name, }; + graph.edges.push({ + source: { + node_id: METADATA_ACCUMULATOR, + field: 'metadata', + }, + destination: { + node_id: LATENTS_TO_IMAGE, + field: 'metadata', + }, + }); + // add LoRA support addLoRAsToGraph(state, graph, LATENTS_TO_LATENTS); @@ -335,21 +346,5 @@ export const buildCanvasImageToImageGraph = ( addWatermarkerToGraph(state, graph); } - if ( - !state.system.shouldUseNSFWChecker && - !state.system.shouldUseWatermarker - ) { - graph.edges.push({ - source: { - node_id: METADATA_ACCUMULATOR, - field: 'metadata', - }, - destination: { - node_id: LATENTS_TO_IMAGE, - field: 'metadata', - }, - }); - } - return graph; }; diff --git a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasInpaintGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasInpaintGraph.ts index 8462b32e63..c47a169634 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasInpaintGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasInpaintGraph.ts @@ -252,27 +252,6 @@ export const buildCanvasInpaintGraph = ( (graph.nodes[RANGE_OF_SIZE] as RangeOfSizeInvocation).start = seed; } - // add metadata accumulator, which is only mostly populated - some fields are added later - graph.nodes[METADATA_ACCUMULATOR] = { - id: METADATA_ACCUMULATOR, - type: 'metadata_accumulator', - generation_mode: 'txt2img', - cfg_scale, - height, - width, - positive_prompt: '', // set in addDynamicPromptsToGraph - negative_prompt: negativePrompt, - model, - seed: 0, // set in addDynamicPromptsToGraph - steps, - rand_device: 'cpu', - scheduler, - vae: undefined, // option; set in addVAEToGraph - controlnets: [], // populated in addControlNetToLinearGraph - loras: [], // populated in addLoRAsToGraph - clip_skip: clipSkip, - }; - // NSFW & watermark - must be last thing added to graph if (state.system.shouldUseNSFWChecker) { // must add before watermarker! @@ -284,21 +263,5 @@ export const buildCanvasInpaintGraph = ( addWatermarkerToGraph(state, graph, INPAINT); } - if ( - !state.system.shouldUseNSFWChecker && - !state.system.shouldUseWatermarker - ) { - graph.edges.push({ - source: { - node_id: METADATA_ACCUMULATOR, - field: 'metadata', - }, - destination: { - node_id: INPAINT, - field: 'metadata', - }, - }); - } - return graph; }; diff --git a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasTextToImageGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasTextToImageGraph.ts index 55e11e4f37..13b27392ba 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasTextToImageGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasTextToImageGraph.ts @@ -217,6 +217,17 @@ export const buildCanvasTextToImageGraph = ( clip_skip: clipSkip, }; + graph.edges.push({ + source: { + node_id: METADATA_ACCUMULATOR, + field: 'metadata', + }, + destination: { + node_id: LATENTS_TO_IMAGE, + field: 'metadata', + }, + }); + // add LoRA support addLoRAsToGraph(state, graph, TEXT_TO_LATENTS); @@ -240,21 +251,5 @@ export const buildCanvasTextToImageGraph = ( addWatermarkerToGraph(state, graph); } - if ( - !state.system.shouldUseNSFWChecker && - !state.system.shouldUseWatermarker - ) { - graph.edges.push({ - source: { - node_id: METADATA_ACCUMULATOR, - field: 'metadata', - }, - destination: { - node_id: LATENTS_TO_IMAGE, - field: 'metadata', - }, - }); - } - return graph; }; diff --git a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearImageToImageGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearImageToImageGraph.ts index e726a02a5c..f264edc6be 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearImageToImageGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearImageToImageGraph.ts @@ -322,6 +322,17 @@ export const buildLinearImageToImageGraph = ( init_image: initialImage.imageName, }; + graph.edges.push({ + source: { + node_id: METADATA_ACCUMULATOR, + field: 'metadata', + }, + destination: { + node_id: LATENTS_TO_IMAGE, + field: 'metadata', + }, + }); + // add LoRA support addLoRAsToGraph(state, graph, LATENTS_TO_LATENTS); @@ -345,21 +356,5 @@ export const buildLinearImageToImageGraph = ( addWatermarkerToGraph(state, graph); } - if ( - !state.system.shouldUseNSFWChecker && - !state.system.shouldUseWatermarker - ) { - graph.edges.push({ - source: { - node_id: METADATA_ACCUMULATOR, - field: 'metadata', - }, - destination: { - node_id: LATENTS_TO_IMAGE, - field: 'metadata', - }, - }); - } - return graph; }; diff --git a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearSDXLImageToImageGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearSDXLImageToImageGraph.ts index 3697b96bea..a260dbc467 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearSDXLImageToImageGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearSDXLImageToImageGraph.ts @@ -353,6 +353,17 @@ export const buildLinearSDXLImageToImageGraph = ( negative_style_prompt: negativeStylePrompt, }; + graph.edges.push({ + source: { + node_id: METADATA_ACCUMULATOR, + field: 'metadata', + }, + destination: { + node_id: LATENTS_TO_IMAGE, + field: 'metadata', + }, + }); + // Add Refiner if enabled if (shouldUseSDXLRefiner) { addSDXLRefinerToGraph(state, graph, SDXL_LATENTS_TO_LATENTS); @@ -372,21 +383,5 @@ export const buildLinearSDXLImageToImageGraph = ( addWatermarkerToGraph(state, graph); } - if ( - !state.system.shouldUseNSFWChecker && - !state.system.shouldUseWatermarker - ) { - graph.edges.push({ - source: { - node_id: METADATA_ACCUMULATOR, - field: 'metadata', - }, - destination: { - node_id: LATENTS_TO_IMAGE, - field: 'metadata', - }, - }); - } - return graph; }; diff --git a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearSDXLTextToImageGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearSDXLTextToImageGraph.ts index 1669de5341..c10e7831d3 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearSDXLTextToImageGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearSDXLTextToImageGraph.ts @@ -235,6 +235,17 @@ export const buildLinearSDXLTextToImageGraph = ( negative_style_prompt: negativeStylePrompt, }; + graph.edges.push({ + source: { + node_id: METADATA_ACCUMULATOR, + field: 'metadata', + }, + destination: { + node_id: LATENTS_TO_IMAGE, + field: 'metadata', + }, + }); + // Add Refiner if enabled if (shouldUseSDXLRefiner) { addSDXLRefinerToGraph(state, graph, SDXL_TEXT_TO_LATENTS); @@ -254,21 +265,5 @@ export const buildLinearSDXLTextToImageGraph = ( addWatermarkerToGraph(state, graph); } - if ( - !state.system.shouldUseNSFWChecker && - !state.system.shouldUseWatermarker - ) { - graph.edges.push({ - source: { - node_id: METADATA_ACCUMULATOR, - field: 'metadata', - }, - destination: { - node_id: LATENTS_TO_IMAGE, - field: 'metadata', - }, - }); - } - return graph; }; diff --git a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearTextToImageGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearTextToImageGraph.ts index 08aa355d4d..3766ac1ee3 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearTextToImageGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildLinearTextToImageGraph.ts @@ -206,6 +206,17 @@ export const buildLinearTextToImageGraph = ( clip_skip: clipSkip, }; + graph.edges.push({ + source: { + node_id: METADATA_ACCUMULATOR, + field: 'metadata', + }, + destination: { + node_id: LATENTS_TO_IMAGE, + field: 'metadata', + }, + }); + // add LoRA support addLoRAsToGraph(state, graph, TEXT_TO_LATENTS); @@ -229,21 +240,5 @@ export const buildLinearTextToImageGraph = ( addWatermarkerToGraph(state, graph); } - if ( - !state.system.shouldUseNSFWChecker && - !state.system.shouldUseWatermarker - ) { - graph.edges.push({ - source: { - node_id: METADATA_ACCUMULATOR, - field: 'metadata', - }, - destination: { - node_id: LATENTS_TO_IMAGE, - field: 'metadata', - }, - }); - } - return graph; }; From 4bfbdb0d97c94ca3e9d412584ff713ade8468c91 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Thu, 27 Jul 2023 11:58:59 +1000 Subject: [PATCH 3/3] chore(ui): lint --- .../features/nodes/util/graphBuilders/buildCanvasInpaintGraph.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasInpaintGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasInpaintGraph.ts index c47a169634..3cec76757f 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasInpaintGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasInpaintGraph.ts @@ -17,7 +17,6 @@ import { INPAINT_GRAPH, ITERATE, MAIN_MODEL_LOADER, - METADATA_ACCUMULATOR, NEGATIVE_CONDITIONING, POSITIVE_CONDITIONING, RANDOM_INT,