fix: Metadata Not Being Saved

This commit is contained in:
blessedcoolant 2023-07-27 07:09:51 +12:00
parent 3376968cbb
commit 7053347559
7 changed files with 136 additions and 24 deletions

View File

@ -335,5 +335,21 @@ export const buildCanvasImageToImageGraph = (
addWatermarkerToGraph(state, graph); 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; return graph;
}; };

View File

@ -8,20 +8,21 @@ import {
RangeOfSizeInvocation, RangeOfSizeInvocation,
} from 'services/api/types'; } from 'services/api/types';
import { addLoRAsToGraph } from './addLoRAsToGraph'; import { addLoRAsToGraph } from './addLoRAsToGraph';
import { addNSFWCheckerToGraph } from './addNSFWCheckerToGraph';
import { addVAEToGraph } from './addVAEToGraph'; import { addVAEToGraph } from './addVAEToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import { import {
CLIP_SKIP, CLIP_SKIP,
INPAINT, INPAINT,
INPAINT_GRAPH, INPAINT_GRAPH,
ITERATE, ITERATE,
MAIN_MODEL_LOADER, MAIN_MODEL_LOADER,
METADATA_ACCUMULATOR,
NEGATIVE_CONDITIONING, NEGATIVE_CONDITIONING,
POSITIVE_CONDITIONING, POSITIVE_CONDITIONING,
RANDOM_INT, RANDOM_INT,
RANGE_OF_SIZE, RANGE_OF_SIZE,
} from './constants'; } from './constants';
import { addNSFWCheckerToGraph } from './addNSFWCheckerToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph';
/** /**
* Builds the Canvas tab's Inpaint graph. * Builds the Canvas tab's Inpaint graph.
@ -251,6 +252,27 @@ export const buildCanvasInpaintGraph = (
(graph.nodes[RANGE_OF_SIZE] as RangeOfSizeInvocation).start = seed; (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 // NSFW & watermark - must be last thing added to graph
if (state.system.shouldUseNSFWChecker) { if (state.system.shouldUseNSFWChecker) {
// must add before watermarker! // must add before watermarker!
@ -262,5 +284,21 @@ export const buildCanvasInpaintGraph = (
addWatermarkerToGraph(state, graph, INPAINT); 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; return graph;
}; };

View File

@ -240,5 +240,21 @@ export const buildCanvasTextToImageGraph = (
addWatermarkerToGraph(state, graph); 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; return graph;
}; };

View File

@ -345,5 +345,21 @@ export const buildLinearImageToImageGraph = (
addWatermarkerToGraph(state, graph); 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; return graph;
}; };

View File

@ -353,17 +353,6 @@ export const buildLinearSDXLImageToImageGraph = (
negative_style_prompt: negativeStylePrompt, 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 // Add Refiner if enabled
if (shouldUseSDXLRefiner) { if (shouldUseSDXLRefiner) {
addSDXLRefinerToGraph(state, graph, SDXL_LATENTS_TO_LATENTS); addSDXLRefinerToGraph(state, graph, SDXL_LATENTS_TO_LATENTS);
@ -383,5 +372,21 @@ export const buildLinearSDXLImageToImageGraph = (
addWatermarkerToGraph(state, graph); 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; return graph;
}; };

View File

@ -235,17 +235,6 @@ export const buildLinearSDXLTextToImageGraph = (
negative_style_prompt: negativeStylePrompt, 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 // Add Refiner if enabled
if (shouldUseSDXLRefiner) { if (shouldUseSDXLRefiner) {
addSDXLRefinerToGraph(state, graph, SDXL_TEXT_TO_LATENTS); addSDXLRefinerToGraph(state, graph, SDXL_TEXT_TO_LATENTS);
@ -265,5 +254,21 @@ export const buildLinearSDXLTextToImageGraph = (
addWatermarkerToGraph(state, graph); 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; return graph;
}; };

View File

@ -229,5 +229,21 @@ export const buildLinearTextToImageGraph = (
addWatermarkerToGraph(state, graph); 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; return graph;
}; };