feat: Make SDXL work across the board + Custom VAE Support

Also a major cleanup pass to the SDXL graphs to ensure there's no ID overlap
This commit is contained in:
blessedcoolant 2023-08-13 01:45:03 +12:00
parent 55d27f71a3
commit 500cd552bc
9 changed files with 132 additions and 139 deletions

View File

@ -2,12 +2,12 @@ import { RootState } from 'app/store/store';
import { MetadataAccumulatorInvocation } from 'services/api/types';
import { NonNullableGraph } from '../../types/types';
import {
DENOISE_LATENTS,
IMAGE_TO_LATENTS,
LATENTS_TO_IMAGE,
METADATA_ACCUMULATOR,
SDXL_LATENTS_TO_LATENTS,
SDXL_DENOISE_LATENTS,
SDXL_MODEL_LOADER,
SDXL_REFINER_DENOISE_LATENTS,
SDXL_REFINER_MODEL_LOADER,
SDXL_REFINER_NEGATIVE_CONDITIONING,
SDXL_REFINER_POSITIVE_CONDITIONING,
@ -61,7 +61,7 @@ export const addSDXLRefinerToGraph = (
// connect the VAE back to the i2l, which we just removed in the filter
// but only if we are doing l2l
if (baseNodeId === SDXL_LATENTS_TO_LATENTS) {
if (baseNodeId === SDXL_DENOISE_LATENTS) {
graph.edges.push({
source: {
node_id: SDXL_MODEL_LOADER,
@ -91,9 +91,9 @@ export const addSDXLRefinerToGraph = (
style: `${negativePrompt} ${negativeStylePrompt}`,
aesthetic_score: refinerAestheticScore,
};
graph.nodes[DENOISE_LATENTS] = {
graph.nodes[SDXL_REFINER_DENOISE_LATENTS] = {
type: 'denoise_latents',
id: DENOISE_LATENTS,
id: SDXL_REFINER_DENOISE_LATENTS,
cfg_scale: refinerCFGScale,
steps: refinerSteps / (1 - Math.min(refinerStart, 0.99)),
scheduler: refinerScheduler,
@ -108,7 +108,7 @@ export const addSDXLRefinerToGraph = (
field: 'unet',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_REFINER_DENOISE_LATENTS,
field: 'unet',
},
},
@ -148,7 +148,7 @@ export const addSDXLRefinerToGraph = (
field: 'conditioning',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_REFINER_DENOISE_LATENTS,
field: 'positive_conditioning',
},
},
@ -158,7 +158,7 @@ export const addSDXLRefinerToGraph = (
field: 'conditioning',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_REFINER_DENOISE_LATENTS,
field: 'negative_conditioning',
},
},
@ -168,13 +168,13 @@ export const addSDXLRefinerToGraph = (
field: 'latents',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_REFINER_DENOISE_LATENTS,
field: 'latents',
},
},
{
source: {
node_id: DENOISE_LATENTS,
node_id: SDXL_REFINER_DENOISE_LATENTS,
field: 'latents',
},
destination: {

View File

@ -14,6 +14,12 @@ import {
MAIN_MODEL_LOADER,
METADATA_ACCUMULATOR,
ONNX_MODEL_LOADER,
SDXL_CANVAS_IMAGE_TO_IMAGE_GRAPH,
SDXL_CANVAS_INPAINT_GRAPH,
SDXL_CANVAS_OUTPAINT_GRAPH,
SDXL_CANVAS_TEXT_TO_IMAGE_GRAPH,
SDXL_IMAGE_TO_IMAGE_GRAPH,
SDXL_TEXT_TO_IMAGE_GRAPH,
TEXT_TO_IMAGE_GRAPH,
VAE_LOADER,
} from './constants';
@ -40,7 +46,12 @@ export const addVAEToGraph = (
}
const isOnnxModel = modelLoaderNodeId == ONNX_MODEL_LOADER;
if (graph.id === TEXT_TO_IMAGE_GRAPH || graph.id === IMAGE_TO_IMAGE_GRAPH) {
if (
graph.id === TEXT_TO_IMAGE_GRAPH ||
graph.id === IMAGE_TO_IMAGE_GRAPH ||
graph.id === SDXL_TEXT_TO_IMAGE_GRAPH ||
graph.id === SDXL_IMAGE_TO_IMAGE_GRAPH
) {
graph.edges.push({
source: {
node_id: isAutoVae ? modelLoaderNodeId : VAE_LOADER,
@ -55,7 +66,9 @@ export const addVAEToGraph = (
if (
graph.id === CANVAS_TEXT_TO_IMAGE_GRAPH ||
graph.id === CANVAS_IMAGE_TO_IMAGE_GRAPH
graph.id === CANVAS_IMAGE_TO_IMAGE_GRAPH ||
graph.id === SDXL_CANVAS_TEXT_TO_IMAGE_GRAPH ||
graph.id == SDXL_CANVAS_IMAGE_TO_IMAGE_GRAPH
) {
graph.edges.push({
source: {
@ -71,7 +84,9 @@ export const addVAEToGraph = (
if (
graph.id === IMAGE_TO_IMAGE_GRAPH ||
graph.id === CANVAS_IMAGE_TO_IMAGE_GRAPH
graph.id === SDXL_IMAGE_TO_IMAGE_GRAPH ||
graph.id === CANVAS_IMAGE_TO_IMAGE_GRAPH ||
graph.id === SDXL_CANVAS_IMAGE_TO_IMAGE_GRAPH
) {
graph.edges.push({
source: {
@ -85,7 +100,12 @@ export const addVAEToGraph = (
});
}
if (graph.id === CANVAS_INPAINT_GRAPH || graph.id == CANVAS_OUTPAINT_GRAPH) {
if (
graph.id === CANVAS_INPAINT_GRAPH ||
graph.id === CANVAS_OUTPAINT_GRAPH ||
graph.id === SDXL_CANVAS_INPAINT_GRAPH ||
graph.id === SDXL_CANVAS_OUTPAINT_GRAPH
) {
graph.edges.push(
{
source: {

View File

@ -15,15 +15,15 @@ import { addSDXLRefinerToGraph } from './addSDXLRefinerToGraph';
import { addVAEToGraph } from './addVAEToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import {
CANVAS_IMAGE_TO_IMAGE_GRAPH,
CANVAS_OUTPUT,
DENOISE_LATENTS,
IMAGE_TO_LATENTS,
METADATA_ACCUMULATOR,
NEGATIVE_CONDITIONING,
NOISE,
POSITIVE_CONDITIONING,
RESIZE,
SDXL_CANVAS_IMAGE_TO_IMAGE_GRAPH,
SDXL_DENOISE_LATENTS,
SDXL_MODEL_LOADER,
} from './constants';
@ -81,7 +81,7 @@ export const buildCanvasSDXLImageToImageGraph = (
// copy-pasted graph from node editor, filled in with state values & friendly node ids
const graph: NonNullableGraph = {
id: CANVAS_IMAGE_TO_IMAGE_GRAPH,
id: SDXL_CANVAS_IMAGE_TO_IMAGE_GRAPH,
nodes: {
[SDXL_MODEL_LOADER]: {
type: 'sdxl_model_loader',
@ -119,9 +119,9 @@ export const buildCanvasSDXLImageToImageGraph = (
// image_name: initialImage.image_name,
// },
},
[DENOISE_LATENTS]: {
[SDXL_DENOISE_LATENTS]: {
type: 'denoise_latents',
id: DENOISE_LATENTS,
id: SDXL_DENOISE_LATENTS,
is_intermediate: true,
cfg_scale,
scheduler,
@ -145,7 +145,7 @@ export const buildCanvasSDXLImageToImageGraph = (
field: 'unet',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'unet',
},
},
@ -196,7 +196,7 @@ export const buildCanvasSDXLImageToImageGraph = (
field: 'conditioning',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'positive_conditioning',
},
},
@ -206,7 +206,7 @@ export const buildCanvasSDXLImageToImageGraph = (
field: 'conditioning',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'negative_conditioning',
},
},
@ -216,7 +216,7 @@ export const buildCanvasSDXLImageToImageGraph = (
field: 'noise',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'noise',
},
},
@ -226,14 +226,14 @@ export const buildCanvasSDXLImageToImageGraph = (
field: 'latents',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'latents',
},
},
// Decode denoised latents to an image
{
source: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'latents',
},
destination: {
@ -241,17 +241,6 @@ export const buildCanvasSDXLImageToImageGraph = (
field: 'latents',
},
},
// Canvas Output
{
source: {
node_id: CANVAS_OUTPUT,
field: 'image',
},
destination: {
node_id: CANVAS_OUTPUT,
field: 'image',
},
},
],
};
@ -356,11 +345,11 @@ export const buildCanvasSDXLImageToImageGraph = (
});
// add LoRA support
addLoRAsToGraph(state, graph, DENOISE_LATENTS);
addLoRAsToGraph(state, graph, SDXL_DENOISE_LATENTS);
// Add Refiner if enabled
if (shouldUseSDXLRefiner) {
addSDXLRefinerToGraph(state, graph, DENOISE_LATENTS);
addSDXLRefinerToGraph(state, graph, SDXL_DENOISE_LATENTS);
}
// optionally add custom VAE
@ -370,7 +359,7 @@ export const buildCanvasSDXLImageToImageGraph = (
addDynamicPromptsToGraph(state, graph);
// add controlnet, mutating `graph`
addControlNetToLinearGraph(state, graph, DENOISE_LATENTS);
addControlNetToLinearGraph(state, graph, SDXL_DENOISE_LATENTS);
// NSFW & watermark - must be last thing added to graph
if (state.system.shouldUseNSFWChecker) {

View File

@ -13,10 +13,8 @@ import { addSDXLRefinerToGraph } from './addSDXLRefinerToGraph';
import { addVAEToGraph } from './addVAEToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import {
CANVAS_INPAINT_GRAPH,
CANVAS_OUTPUT,
COLOR_CORRECT,
INPAINT,
INPAINT_IMAGE,
ITERATE,
LATENTS_TO_IMAGE,
@ -26,6 +24,8 @@ import {
POSITIVE_CONDITIONING,
RANDOM_INT,
RANGE_OF_SIZE,
SDXL_CANVAS_INPAINT_GRAPH,
SDXL_DENOISE_LATENTS,
SDXL_MODEL_LOADER,
} from './constants';
@ -85,7 +85,7 @@ export const buildCanvasSDXLInpaintGraph = (
: shouldUseCpuNoise;
const graph: NonNullableGraph = {
id: CANVAS_INPAINT_GRAPH,
id: SDXL_CANVAS_INPAINT_GRAPH,
nodes: {
[SDXL_MODEL_LOADER]: {
type: 'sdxl_model_loader',
@ -131,9 +131,9 @@ export const buildCanvasSDXLInpaintGraph = (
use_cpu,
is_intermediate: true,
},
[INPAINT]: {
[SDXL_DENOISE_LATENTS]: {
type: 'denoise_latents',
id: INPAINT,
id: SDXL_DENOISE_LATENTS,
is_intermediate: true,
steps: steps,
cfg_scale: cfg_scale,
@ -182,7 +182,7 @@ export const buildCanvasSDXLInpaintGraph = (
field: 'unet',
},
destination: {
node_id: INPAINT,
node_id: SDXL_DENOISE_LATENTS,
field: 'unet',
},
},
@ -233,7 +233,7 @@ export const buildCanvasSDXLInpaintGraph = (
field: 'conditioning',
},
destination: {
node_id: INPAINT,
node_id: SDXL_DENOISE_LATENTS,
field: 'positive_conditioning',
},
},
@ -243,7 +243,7 @@ export const buildCanvasSDXLInpaintGraph = (
field: 'conditioning',
},
destination: {
node_id: INPAINT,
node_id: SDXL_DENOISE_LATENTS,
field: 'negative_conditioning',
},
},
@ -253,7 +253,7 @@ export const buildCanvasSDXLInpaintGraph = (
field: 'noise',
},
destination: {
node_id: INPAINT,
node_id: SDXL_DENOISE_LATENTS,
field: 'noise',
},
},
@ -263,7 +263,7 @@ export const buildCanvasSDXLInpaintGraph = (
field: 'latents',
},
destination: {
node_id: INPAINT,
node_id: SDXL_DENOISE_LATENTS,
field: 'latents',
},
},
@ -273,7 +273,7 @@ export const buildCanvasSDXLInpaintGraph = (
field: 'image',
},
destination: {
node_id: INPAINT,
node_id: SDXL_DENOISE_LATENTS,
field: 'mask',
},
},
@ -301,7 +301,7 @@ export const buildCanvasSDXLInpaintGraph = (
// Decode inpainted latents to image
{
source: {
node_id: INPAINT,
node_id: SDXL_DENOISE_LATENTS,
field: 'latents',
},
destination: {
@ -356,10 +356,10 @@ export const buildCanvasSDXLInpaintGraph = (
// Add Refiner if enabled
if (shouldUseSDXLRefiner) {
addSDXLRefinerToGraph(state, graph, INPAINT);
addSDXLRefinerToGraph(state, graph, SDXL_DENOISE_LATENTS);
}
// Add VAE
// optionally add custom VAE
addVAEToGraph(state, graph, SDXL_MODEL_LOADER);
// handle seed
@ -383,10 +383,10 @@ export const buildCanvasSDXLInpaintGraph = (
}
// add LoRA support
addSDXLLoRAsToGraph(state, graph, INPAINT, SDXL_MODEL_LOADER);
addSDXLLoRAsToGraph(state, graph, SDXL_DENOISE_LATENTS, SDXL_MODEL_LOADER);
// add controlnet, mutating `graph`
addControlNetToLinearGraph(state, graph, INPAINT);
addControlNetToLinearGraph(state, graph, SDXL_DENOISE_LATENTS);
// NSFW & watermark - must be last thing added to graph
if (state.system.shouldUseNSFWChecker) {

View File

@ -15,10 +15,8 @@ import { addSDXLRefinerToGraph } from './addSDXLRefinerToGraph';
import { addVAEToGraph } from './addVAEToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import {
CANVAS_OUTPAINT_GRAPH,
CANVAS_OUTPUT,
COLOR_CORRECT,
INPAINT,
INPAINT_IMAGE,
INPAINT_INFILL,
ITERATE,
@ -31,6 +29,8 @@ import {
POSITIVE_CONDITIONING,
RANDOM_INT,
RANGE_OF_SIZE,
SDXL_CANVAS_OUTPAINT_GRAPH,
SDXL_DENOISE_LATENTS,
SDXL_MODEL_LOADER,
} from './constants';
@ -109,7 +109,7 @@ export const buildCanvasSDXLOutpaintGraph = (
}
const graph: NonNullableGraph = {
id: CANVAS_OUTPAINT_GRAPH,
id: SDXL_CANVAS_OUTPAINT_GRAPH,
nodes: {
[SDXL_MODEL_LOADER]: {
type: 'sdxl_model_loader',
@ -166,9 +166,9 @@ export const buildCanvasSDXLOutpaintGraph = (
use_cpu,
is_intermediate: true,
},
[INPAINT]: {
[SDXL_DENOISE_LATENTS]: {
type: 'denoise_latents',
id: INPAINT,
id: SDXL_DENOISE_LATENTS,
is_intermediate: true,
steps: steps,
cfg_scale: cfg_scale,
@ -215,7 +215,7 @@ export const buildCanvasSDXLOutpaintGraph = (
field: 'unet',
},
destination: {
node_id: INPAINT,
node_id: SDXL_DENOISE_LATENTS,
field: 'unet',
},
},
@ -298,7 +298,7 @@ export const buildCanvasSDXLOutpaintGraph = (
field: 'conditioning',
},
destination: {
node_id: INPAINT,
node_id: SDXL_DENOISE_LATENTS,
field: 'positive_conditioning',
},
},
@ -308,7 +308,7 @@ export const buildCanvasSDXLOutpaintGraph = (
field: 'conditioning',
},
destination: {
node_id: INPAINT,
node_id: SDXL_DENOISE_LATENTS,
field: 'negative_conditioning',
},
},
@ -318,7 +318,7 @@ export const buildCanvasSDXLOutpaintGraph = (
field: 'noise',
},
destination: {
node_id: INPAINT,
node_id: SDXL_DENOISE_LATENTS,
field: 'noise',
},
},
@ -328,7 +328,7 @@ export const buildCanvasSDXLOutpaintGraph = (
field: 'latents',
},
destination: {
node_id: INPAINT,
node_id: SDXL_DENOISE_LATENTS,
field: 'latents',
},
},
@ -338,7 +338,7 @@ export const buildCanvasSDXLOutpaintGraph = (
field: 'image',
},
destination: {
node_id: INPAINT,
node_id: SDXL_DENOISE_LATENTS,
field: 'mask',
},
},
@ -366,7 +366,7 @@ export const buildCanvasSDXLOutpaintGraph = (
// Decode inpainted latents to image
{
source: {
node_id: INPAINT,
node_id: SDXL_DENOISE_LATENTS,
field: 'latents',
},
destination: {
@ -441,10 +441,10 @@ export const buildCanvasSDXLOutpaintGraph = (
// Add Refiner if enabled
if (shouldUseSDXLRefiner) {
addSDXLRefinerToGraph(state, graph, INPAINT);
addSDXLRefinerToGraph(state, graph, SDXL_DENOISE_LATENTS);
}
// Add VAE
// optionally add custom VAE
addVAEToGraph(state, graph, SDXL_MODEL_LOADER);
// handle seed
@ -468,10 +468,10 @@ export const buildCanvasSDXLOutpaintGraph = (
}
// add LoRA support
addSDXLLoRAsToGraph(state, graph, INPAINT, SDXL_MODEL_LOADER);
addSDXLLoRAsToGraph(state, graph, SDXL_DENOISE_LATENTS, SDXL_MODEL_LOADER);
// add controlnet, mutating `graph`
addControlNetToLinearGraph(state, graph, INPAINT);
addControlNetToLinearGraph(state, graph, SDXL_DENOISE_LATENTS);
// NSFW & watermark - must be last thing added to graph
if (state.system.shouldUseNSFWChecker) {

View File

@ -15,13 +15,13 @@ import { addVAEToGraph } from './addVAEToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import {
CANVAS_OUTPUT,
CANVAS_TEXT_TO_IMAGE_GRAPH,
DENOISE_LATENTS,
METADATA_ACCUMULATOR,
NEGATIVE_CONDITIONING,
NOISE,
ONNX_MODEL_LOADER,
POSITIVE_CONDITIONING,
SDXL_CANVAS_TEXT_TO_IMAGE_GRAPH,
SDXL_DENOISE_LATENTS,
SDXL_MODEL_LOADER,
} from './constants';
@ -80,7 +80,7 @@ export const buildCanvasSDXLTextToImageGraph = (
isUsingOnnxModel
? {
type: 't2l_onnx',
id: DENOISE_LATENTS,
id: SDXL_DENOISE_LATENTS,
is_intermediate: true,
cfg_scale,
scheduler,
@ -88,7 +88,7 @@ export const buildCanvasSDXLTextToImageGraph = (
}
: {
type: 'denoise_latents',
id: DENOISE_LATENTS,
id: SDXL_DENOISE_LATENTS,
is_intermediate: true,
cfg_scale,
scheduler,
@ -108,7 +108,7 @@ export const buildCanvasSDXLTextToImageGraph = (
// copy-pasted graph from node editor, filled in with state values & friendly node ids
// TODO: Actually create the graph correctly for ONNX
const graph: NonNullableGraph = {
id: CANVAS_TEXT_TO_IMAGE_GRAPH,
id: SDXL_CANVAS_TEXT_TO_IMAGE_GRAPH,
nodes: {
[modelLoaderNodeId]: {
type: modelLoaderNodeType,
@ -157,7 +157,7 @@ export const buildCanvasSDXLTextToImageGraph = (
field: 'unet',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'unet',
},
},
@ -208,7 +208,7 @@ export const buildCanvasSDXLTextToImageGraph = (
field: 'conditioning',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'positive_conditioning',
},
},
@ -218,7 +218,7 @@ export const buildCanvasSDXLTextToImageGraph = (
field: 'conditioning',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'negative_conditioning',
},
},
@ -228,14 +228,14 @@ export const buildCanvasSDXLTextToImageGraph = (
field: 'noise',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'noise',
},
},
// Decode Denoised Latents To Image
{
source: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'latents',
},
destination: {
@ -280,11 +280,11 @@ export const buildCanvasSDXLTextToImageGraph = (
// Add Refiner if enabled
if (shouldUseSDXLRefiner) {
addSDXLRefinerToGraph(state, graph, DENOISE_LATENTS);
addSDXLRefinerToGraph(state, graph, SDXL_DENOISE_LATENTS);
}
// add LoRA support
addSDXLLoRAsToGraph(state, graph, DENOISE_LATENTS, modelLoaderNodeId);
addSDXLLoRAsToGraph(state, graph, SDXL_DENOISE_LATENTS, modelLoaderNodeId);
// optionally add custom VAE
addVAEToGraph(state, graph, modelLoaderNodeId);
@ -293,7 +293,7 @@ export const buildCanvasSDXLTextToImageGraph = (
addDynamicPromptsToGraph(state, graph);
// add controlnet, mutating `graph`
addControlNetToLinearGraph(state, graph, DENOISE_LATENTS);
addControlNetToLinearGraph(state, graph, SDXL_DENOISE_LATENTS);
// NSFW & watermark - must be last thing added to graph
if (state.system.shouldUseNSFWChecker) {

View File

@ -10,9 +10,9 @@ import { addDynamicPromptsToGraph } from './addDynamicPromptsToGraph';
import { addNSFWCheckerToGraph } from './addNSFWCheckerToGraph';
import { addSDXLLoRAsToGraph } from './addSDXLLoRAstoGraph';
import { addSDXLRefinerToGraph } from './addSDXLRefinerToGraph';
import { addVAEToGraph } from './addVAEToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import {
DENOISE_LATENTS,
IMAGE_TO_LATENTS,
LATENTS_TO_IMAGE,
METADATA_ACCUMULATOR,
@ -20,6 +20,7 @@ import {
NOISE,
POSITIVE_CONDITIONING,
RESIZE,
SDXL_DENOISE_LATENTS,
SDXL_IMAGE_TO_IMAGE_GRAPH,
SDXL_MODEL_LOADER,
} from './constants';
@ -115,9 +116,9 @@ export const buildLinearSDXLImageToImageGraph = (
id: LATENTS_TO_IMAGE,
fp32: vaePrecision === 'fp32' ? true : false,
},
[DENOISE_LATENTS]: {
[SDXL_DENOISE_LATENTS]: {
type: 'denoise_latents',
id: DENOISE_LATENTS,
id: SDXL_DENOISE_LATENTS,
cfg_scale,
scheduler,
steps,
@ -144,30 +145,10 @@ export const buildLinearSDXLImageToImageGraph = (
field: 'unet',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'unet',
},
},
{
source: {
node_id: SDXL_MODEL_LOADER,
field: 'vae',
},
destination: {
node_id: LATENTS_TO_IMAGE,
field: 'vae',
},
},
{
source: {
node_id: SDXL_MODEL_LOADER,
field: 'vae',
},
destination: {
node_id: IMAGE_TO_LATENTS,
field: 'vae',
},
},
{
source: {
node_id: SDXL_MODEL_LOADER,
@ -215,7 +196,7 @@ export const buildLinearSDXLImageToImageGraph = (
field: 'conditioning',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'positive_conditioning',
},
},
@ -225,7 +206,7 @@ export const buildLinearSDXLImageToImageGraph = (
field: 'conditioning',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'negative_conditioning',
},
},
@ -235,7 +216,7 @@ export const buildLinearSDXLImageToImageGraph = (
field: 'noise',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'noise',
},
},
@ -245,14 +226,14 @@ export const buildLinearSDXLImageToImageGraph = (
field: 'latents',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'latents',
},
},
// Decode Denoised Latents To Image
{
source: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'latents',
},
destination: {
@ -368,13 +349,16 @@ export const buildLinearSDXLImageToImageGraph = (
},
});
addSDXLLoRAsToGraph(state, graph, DENOISE_LATENTS, SDXL_MODEL_LOADER);
addSDXLLoRAsToGraph(state, graph, SDXL_DENOISE_LATENTS, SDXL_MODEL_LOADER);
// Add Refiner if enabled
if (shouldUseSDXLRefiner) {
addSDXLRefinerToGraph(state, graph, DENOISE_LATENTS);
addSDXLRefinerToGraph(state, graph, SDXL_DENOISE_LATENTS);
}
// optionally add custom VAE
addVAEToGraph(state, graph, SDXL_MODEL_LOADER);
// add dynamic prompts - also sets up core iteration and seed
addDynamicPromptsToGraph(state, graph);

View File

@ -6,14 +6,15 @@ import { addDynamicPromptsToGraph } from './addDynamicPromptsToGraph';
import { addNSFWCheckerToGraph } from './addNSFWCheckerToGraph';
import { addSDXLLoRAsToGraph } from './addSDXLLoRAstoGraph';
import { addSDXLRefinerToGraph } from './addSDXLRefinerToGraph';
import { addVAEToGraph } from './addVAEToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import {
DENOISE_LATENTS,
LATENTS_TO_IMAGE,
METADATA_ACCUMULATOR,
NEGATIVE_CONDITIONING,
NOISE,
POSITIVE_CONDITIONING,
SDXL_DENOISE_LATENTS,
SDXL_MODEL_LOADER,
SDXL_TEXT_TO_IMAGE_GRAPH,
} from './constants';
@ -95,9 +96,9 @@ export const buildLinearSDXLTextToImageGraph = (
height,
use_cpu,
},
[DENOISE_LATENTS]: {
[SDXL_DENOISE_LATENTS]: {
type: 'denoise_latents',
id: DENOISE_LATENTS,
id: SDXL_DENOISE_LATENTS,
cfg_scale,
scheduler,
steps,
@ -118,20 +119,10 @@ export const buildLinearSDXLTextToImageGraph = (
field: 'unet',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'unet',
},
},
{
source: {
node_id: SDXL_MODEL_LOADER,
field: 'vae',
},
destination: {
node_id: LATENTS_TO_IMAGE,
field: 'vae',
},
},
{
source: {
node_id: SDXL_MODEL_LOADER,
@ -179,7 +170,7 @@ export const buildLinearSDXLTextToImageGraph = (
field: 'conditioning',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'positive_conditioning',
},
},
@ -189,7 +180,7 @@ export const buildLinearSDXLTextToImageGraph = (
field: 'conditioning',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'negative_conditioning',
},
},
@ -199,14 +190,14 @@ export const buildLinearSDXLTextToImageGraph = (
field: 'noise',
},
destination: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'noise',
},
},
// Decode Denoised Latents To Image
{
source: {
node_id: DENOISE_LATENTS,
node_id: SDXL_DENOISE_LATENTS,
field: 'latents',
},
destination: {
@ -251,13 +242,17 @@ export const buildLinearSDXLTextToImageGraph = (
},
});
addSDXLLoRAsToGraph(state, graph, DENOISE_LATENTS, SDXL_MODEL_LOADER);
// Add Refiner if enabled
if (shouldUseSDXLRefiner) {
addSDXLRefinerToGraph(state, graph, DENOISE_LATENTS);
addSDXLRefinerToGraph(state, graph, SDXL_DENOISE_LATENTS);
}
// optionally add custom VAE
addVAEToGraph(state, graph, SDXL_MODEL_LOADER);
// add LoRA support
addSDXLLoRAsToGraph(state, graph, SDXL_DENOISE_LATENTS, SDXL_MODEL_LOADER);
// add dynamic prompts - also sets up core iteration and seed
addDynamicPromptsToGraph(state, graph);

View File

@ -38,14 +38,13 @@ export const REALESRGAN = 'esrgan';
export const DIVIDE = 'divide';
export const SCALE = 'scale_image';
export const SDXL_MODEL_LOADER = 'sdxl_model_loader';
export const SDXL_TEXT_TO_LATENTS = 't2l_sdxl';
export const SDXL_LATENTS_TO_LATENTS = 'l2l_sdxl';
export const SDXL_DENOISE_LATENTS = 'sdxl_denoise_latents';
export const SDXL_REFINER_MODEL_LOADER = 'sdxl_refiner_model_loader';
export const SDXL_REFINER_POSITIVE_CONDITIONING =
'sdxl_refiner_positive_conditioning';
export const SDXL_REFINER_NEGATIVE_CONDITIONING =
'sdxl_refiner_negative_conditioning';
export const SDXL_REFINER_LATENTS_TO_LATENTS = 'l2l_sdxl_refiner';
export const SDXL_REFINER_DENOISE_LATENTS = 'sdxl_refiner_denoise_latents';
// friendly graph ids
export const TEXT_TO_IMAGE_GRAPH = 'text_to_image_graph';
@ -56,3 +55,9 @@ export const CANVAS_INPAINT_GRAPH = 'canvas_inpaint_graph';
export const CANVAS_OUTPAINT_GRAPH = 'canvas_outpaint_graph';
export const SDXL_TEXT_TO_IMAGE_GRAPH = 'sdxl_text_to_image_graph';
export const SDXL_IMAGE_TO_IMAGE_GRAPH = 'sxdl_image_to_image_graph';
export const SDXL_CANVAS_TEXT_TO_IMAGE_GRAPH =
'sdxl_canvas_text_to_image_graph';
export const SDXL_CANVAS_IMAGE_TO_IMAGE_GRAPH =
'sdxl_canvas_image_to_image_graph';
export const SDXL_CANVAS_INPAINT_GRAPH = 'sdxl_canvas_inpaint_graph';
export const SDXL_CANVAS_OUTPAINT_GRAPH = 'sdxl_canvas_outpaint_graph';