experimental: Pass Mask To Coherence Pass

This commit is contained in:
blessedcoolant 2023-09-01 11:20:45 +12:00
parent 6f162c5dec
commit 7a295cbfd5
8 changed files with 313 additions and 53 deletions

View File

@ -10,7 +10,8 @@ import {
CANVAS_OUTPUT, CANVAS_OUTPUT,
INPAINT_IMAGE_RESIZE_UP, INPAINT_IMAGE_RESIZE_UP,
LATENTS_TO_IMAGE, LATENTS_TO_IMAGE,
MASK_BLUR, MASK_COMBINE,
MASK_RESIZE_UP,
METADATA_ACCUMULATOR, METADATA_ACCUMULATOR,
SDXL_CANVAS_IMAGE_TO_IMAGE_GRAPH, SDXL_CANVAS_IMAGE_TO_IMAGE_GRAPH,
SDXL_CANVAS_INPAINT_GRAPH, SDXL_CANVAS_INPAINT_GRAPH,
@ -257,7 +258,7 @@ export const addSDXLRefinerToGraph = (
graph.edges.push( graph.edges.push(
{ {
source: { source: {
node_id: MASK_BLUR, node_id: isUsingScaledDimensions ? MASK_RESIZE_UP : MASK_COMBINE,
field: 'image', field: 'image',
}, },
destination: { destination: {

View File

@ -2,6 +2,7 @@ import { RootState } from 'app/store/store';
import { NonNullableGraph } from 'features/nodes/types/types'; import { NonNullableGraph } from 'features/nodes/types/types';
import { MetadataAccumulatorInvocation } from 'services/api/types'; import { MetadataAccumulatorInvocation } from 'services/api/types';
import { import {
CANVAS_COHERENCE_INPAINT_CREATE_MASK,
CANVAS_IMAGE_TO_IMAGE_GRAPH, CANVAS_IMAGE_TO_IMAGE_GRAPH,
CANVAS_INPAINT_GRAPH, CANVAS_INPAINT_GRAPH,
CANVAS_OUTPAINT_GRAPH, CANVAS_OUTPAINT_GRAPH,
@ -135,6 +136,16 @@ export const addVAEToGraph = (
field: 'vae', field: 'vae',
}, },
}, },
{
source: {
node_id: isAutoVae ? modelLoaderNodeId : VAE_LOADER,
field: isAutoVae && isOnnxModel ? 'vae_decoder' : 'vae',
},
destination: {
node_id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
field: 'vae',
},
},
{ {
source: { source: {
node_id: isAutoVae ? modelLoaderNodeId : VAE_LOADER, node_id: isAutoVae ? modelLoaderNodeId : VAE_LOADER,

View File

@ -6,6 +6,7 @@ import {
ImageBlurInvocation, ImageBlurInvocation,
ImageDTO, ImageDTO,
ImageToLatentsInvocation, ImageToLatentsInvocation,
MaskEdgeInvocation,
NoiseInvocation, NoiseInvocation,
RandomIntInvocation, RandomIntInvocation,
RangeOfSizeInvocation, RangeOfSizeInvocation,
@ -18,6 +19,8 @@ import { addVAEToGraph } from './addVAEToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph'; import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import { import {
CANVAS_COHERENCE_DENOISE_LATENTS, CANVAS_COHERENCE_DENOISE_LATENTS,
CANVAS_COHERENCE_INPAINT_CREATE_MASK,
CANVAS_COHERENCE_MASK_EDGE,
CANVAS_COHERENCE_NOISE, CANVAS_COHERENCE_NOISE,
CANVAS_COHERENCE_NOISE_INCREMENT, CANVAS_COHERENCE_NOISE_INCREMENT,
CANVAS_INPAINT_GRAPH, CANVAS_INPAINT_GRAPH,
@ -89,6 +92,10 @@ export const buildCanvasInpaintGraph = (
shouldAutoSave, shouldAutoSave,
} = state.canvas; } = state.canvas;
const isUsingScaledDimensions = ['auto', 'manual'].includes(
boundingBoxScaleMethod
);
let modelLoaderNodeId = MAIN_MODEL_LOADER; let modelLoaderNodeId = MAIN_MODEL_LOADER;
const use_cpu = shouldUseNoiseSettings const use_cpu = shouldUseNoiseSettings
@ -135,18 +142,18 @@ export const buildCanvasInpaintGraph = (
is_intermediate: true, is_intermediate: true,
fp32: vaePrecision === 'fp32' ? true : false, fp32: vaePrecision === 'fp32' ? true : false,
}, },
[INPAINT_CREATE_MASK]: {
type: 'create_denoise_mask',
id: INPAINT_CREATE_MASK,
is_intermediate: true,
fp32: vaePrecision === 'fp32' ? true : false,
},
[NOISE]: { [NOISE]: {
type: 'noise', type: 'noise',
id: NOISE, id: NOISE,
use_cpu, use_cpu,
is_intermediate: true, is_intermediate: true,
}, },
[INPAINT_CREATE_MASK]: {
type: 'create_denoise_mask',
id: INPAINT_CREATE_MASK,
is_intermediate: true,
fp32: vaePrecision === 'fp32' ? true : false,
},
[DENOISE_LATENTS]: { [DENOISE_LATENTS]: {
type: 'denoise_latents', type: 'denoise_latents',
id: DENOISE_LATENTS, id: DENOISE_LATENTS,
@ -169,9 +176,24 @@ export const buildCanvasInpaintGraph = (
b: 1, b: 1,
is_intermediate: true, is_intermediate: true,
}, },
[CANVAS_COHERENCE_MASK_EDGE]: {
type: 'mask_edge',
id: CANVAS_COHERENCE_MASK_EDGE,
is_intermediate: true,
edge_blur: maskBlur,
edge_size: maskBlur * 2,
low_threshold: 100,
high_threshold: 200,
},
[CANVAS_COHERENCE_INPAINT_CREATE_MASK]: {
type: 'create_denoise_mask',
id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
is_intermediate: true,
fp32: vaePrecision === 'fp32' ? true : false,
},
[CANVAS_COHERENCE_DENOISE_LATENTS]: { [CANVAS_COHERENCE_DENOISE_LATENTS]: {
type: 'denoise_latents', type: 'denoise_latents',
id: DENOISE_LATENTS, id: CANVAS_COHERENCE_DENOISE_LATENTS,
is_intermediate: true, is_intermediate: true,
steps: canvasCoherenceSteps, steps: canvasCoherenceSteps,
cfg_scale: cfg_scale, cfg_scale: cfg_scale,
@ -311,6 +333,27 @@ export const buildCanvasInpaintGraph = (
field: 'denoise_mask', field: 'denoise_mask',
}, },
}, },
// Create Coherence Mask
{
source: {
node_id: CANVAS_COHERENCE_MASK_EDGE,
field: 'image',
},
destination: {
node_id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
field: 'mask',
},
},
{
source: {
node_id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
field: 'denoise_mask',
},
destination: {
node_id: CANVAS_COHERENCE_DENOISE_LATENTS,
field: 'denoise_mask',
},
},
// Iterate // Iterate
{ {
source: { source: {
@ -418,7 +461,7 @@ export const buildCanvasInpaintGraph = (
}; };
// Handle Scale Before Processing // Handle Scale Before Processing
if (['auto', 'manual'].includes(boundingBoxScaleMethod)) { if (isUsingScaledDimensions) {
const scaledWidth: number = scaledBoundingBoxDimensions.width; const scaledWidth: number = scaledBoundingBoxDimensions.width;
const scaledHeight: number = scaledBoundingBoxDimensions.height; const scaledHeight: number = scaledBoundingBoxDimensions.height;
@ -494,6 +537,26 @@ export const buildCanvasInpaintGraph = (
field: 'image', field: 'image',
}, },
}, },
{
source: {
node_id: INPAINT_IMAGE_RESIZE_UP,
field: 'image',
},
destination: {
node_id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
field: 'image',
},
},
{
source: {
node_id: MASK_RESIZE_UP,
field: 'image',
},
destination: {
node_id: CANVAS_COHERENCE_MASK_EDGE,
field: 'image',
},
},
// Color Correct The Inpainted Result // Color Correct The Inpainted Result
{ {
source: { source: {
@ -555,6 +618,16 @@ export const buildCanvasInpaintGraph = (
...(graph.nodes[INPAINT_CREATE_MASK] as CreateDenoiseMaskInvocation), ...(graph.nodes[INPAINT_CREATE_MASK] as CreateDenoiseMaskInvocation),
image: canvasInitImage, image: canvasInitImage,
}; };
graph.nodes[CANVAS_COHERENCE_INPAINT_CREATE_MASK] = {
...(graph.nodes[
CANVAS_COHERENCE_INPAINT_CREATE_MASK
] as CreateDenoiseMaskInvocation),
image: canvasInitImage,
};
graph.nodes[CANVAS_COHERENCE_MASK_EDGE] = {
...(graph.nodes[CANVAS_COHERENCE_MASK_EDGE] as MaskEdgeInvocation),
image: canvasMaskImage,
};
graph.edges.push( graph.edges.push(
// Color Correct The Inpainted Result // Color Correct The Inpainted Result

View File

@ -2,7 +2,6 @@ import { logger } from 'app/logging/logger';
import { RootState } from 'app/store/store'; import { RootState } from 'app/store/store';
import { NonNullableGraph } from 'features/nodes/types/types'; import { NonNullableGraph } from 'features/nodes/types/types';
import { import {
ImageBlurInvocation,
ImageDTO, ImageDTO,
ImageToLatentsInvocation, ImageToLatentsInvocation,
InfillPatchMatchInvocation, InfillPatchMatchInvocation,
@ -19,6 +18,8 @@ import { addVAEToGraph } from './addVAEToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph'; import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import { import {
CANVAS_COHERENCE_DENOISE_LATENTS, CANVAS_COHERENCE_DENOISE_LATENTS,
CANVAS_COHERENCE_INPAINT_CREATE_MASK,
CANVAS_COHERENCE_MASK_EDGE,
CANVAS_COHERENCE_NOISE, CANVAS_COHERENCE_NOISE,
CANVAS_COHERENCE_NOISE_INCREMENT, CANVAS_COHERENCE_NOISE_INCREMENT,
CANVAS_OUTPAINT_GRAPH, CANVAS_OUTPAINT_GRAPH,
@ -34,7 +35,6 @@ import {
ITERATE, ITERATE,
LATENTS_TO_IMAGE, LATENTS_TO_IMAGE,
MAIN_MODEL_LOADER, MAIN_MODEL_LOADER,
MASK_BLUR,
MASK_COMBINE, MASK_COMBINE,
MASK_FROM_ALPHA, MASK_FROM_ALPHA,
MASK_RESIZE_DOWN, MASK_RESIZE_DOWN,
@ -71,7 +71,6 @@ export const buildCanvasOutpaintGraph = (
shouldUseNoiseSettings, shouldUseNoiseSettings,
shouldUseCpuNoise, shouldUseCpuNoise,
maskBlur, maskBlur,
maskBlurMethod,
canvasCoherenceSteps, canvasCoherenceSteps,
canvasCoherenceStrength, canvasCoherenceStrength,
tileSize, tileSize,
@ -96,6 +95,10 @@ export const buildCanvasOutpaintGraph = (
shouldAutoSave, shouldAutoSave,
} = state.canvas; } = state.canvas;
const isUsingScaledDimensions = ['auto', 'manual'].includes(
boundingBoxScaleMethod
);
let modelLoaderNodeId = MAIN_MODEL_LOADER; let modelLoaderNodeId = MAIN_MODEL_LOADER;
const use_cpu = shouldUseNoiseSettings const use_cpu = shouldUseNoiseSettings
@ -141,13 +144,6 @@ export const buildCanvasOutpaintGraph = (
is_intermediate: true, is_intermediate: true,
mask2: canvasMaskImage, mask2: canvasMaskImage,
}, },
[MASK_BLUR]: {
type: 'img_blur',
id: MASK_BLUR,
is_intermediate: true,
radius: maskBlur,
blur_type: maskBlurMethod,
},
[INPAINT_IMAGE]: { [INPAINT_IMAGE]: {
type: 'i2l', type: 'i2l',
id: INPAINT_IMAGE, id: INPAINT_IMAGE,
@ -188,6 +184,21 @@ export const buildCanvasOutpaintGraph = (
b: 1, b: 1,
is_intermediate: true, is_intermediate: true,
}, },
[CANVAS_COHERENCE_MASK_EDGE]: {
type: 'mask_edge',
id: CANVAS_COHERENCE_MASK_EDGE,
is_intermediate: true,
edge_blur: maskBlur,
edge_size: maskBlur * 2,
low_threshold: 100,
high_threshold: 200,
},
[CANVAS_COHERENCE_INPAINT_CREATE_MASK]: {
type: 'create_denoise_mask',
id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
is_intermediate: true,
fp32: vaePrecision === 'fp32' ? true : false,
},
[CANVAS_COHERENCE_DENOISE_LATENTS]: { [CANVAS_COHERENCE_DENOISE_LATENTS]: {
type: 'denoise_latents', type: 'denoise_latents',
id: CANVAS_COHERENCE_DENOISE_LATENTS, id: CANVAS_COHERENCE_DENOISE_LATENTS,
@ -333,7 +344,7 @@ export const buildCanvasOutpaintGraph = (
// Create Inpaint Mask // Create Inpaint Mask
{ {
source: { source: {
node_id: MASK_BLUR, node_id: isUsingScaledDimensions ? MASK_RESIZE_UP : MASK_COMBINE,
field: 'image', field: 'image',
}, },
destination: { destination: {
@ -351,6 +362,27 @@ export const buildCanvasOutpaintGraph = (
field: 'denoise_mask', field: 'denoise_mask',
}, },
}, },
// Create Coherence Mask
{
source: {
node_id: CANVAS_COHERENCE_MASK_EDGE,
field: 'image',
},
destination: {
node_id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
field: 'mask',
},
},
{
source: {
node_id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
field: 'denoise_mask',
},
destination: {
node_id: CANVAS_COHERENCE_DENOISE_LATENTS,
field: 'denoise_mask',
},
},
// Iterate // Iterate
{ {
source: { source: {
@ -484,7 +516,7 @@ export const buildCanvasOutpaintGraph = (
} }
// Handle Scale Before Processing // Handle Scale Before Processing
if (['auto', 'manual'].includes(boundingBoxScaleMethod)) { if (isUsingScaledDimensions) {
const scaledWidth: number = scaledBoundingBoxDimensions.width; const scaledWidth: number = scaledBoundingBoxDimensions.width;
const scaledHeight: number = scaledBoundingBoxDimensions.height; const scaledHeight: number = scaledBoundingBoxDimensions.height;
@ -556,6 +588,16 @@ export const buildCanvasOutpaintGraph = (
field: 'image', field: 'image',
}, },
}, },
{
source: {
node_id: INPAINT_INFILL,
field: 'image',
},
destination: {
node_id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
field: 'image',
},
},
// Take combined mask and resize and then blur // Take combined mask and resize and then blur
{ {
source: { source: {
@ -573,7 +615,7 @@ export const buildCanvasOutpaintGraph = (
field: 'image', field: 'image',
}, },
destination: { destination: {
node_id: MASK_BLUR, node_id: CANVAS_COHERENCE_MASK_EDGE,
field: 'image', field: 'image',
}, },
}, },
@ -658,19 +700,26 @@ export const buildCanvasOutpaintGraph = (
...(graph.nodes[INPAINT_IMAGE] as ImageToLatentsInvocation), ...(graph.nodes[INPAINT_IMAGE] as ImageToLatentsInvocation),
image: canvasInitImage, image: canvasInitImage,
}; };
graph.nodes[MASK_BLUR] = {
...(graph.nodes[MASK_BLUR] as ImageBlurInvocation),
};
graph.edges.push( graph.edges.push(
// Take combined mask and plug it to blur // Take combined mask and plug it to blur
{
source: {
node_id: INPAINT_INFILL,
field: 'image',
},
destination: {
node_id: INPAINT_CREATE_MASK,
field: 'image',
},
},
{ {
source: { source: {
node_id: MASK_COMBINE, node_id: MASK_COMBINE,
field: 'image', field: 'image',
}, },
destination: { destination: {
node_id: MASK_BLUR, node_id: CANVAS_COHERENCE_MASK_EDGE,
field: 'image', field: 'image',
}, },
}, },
@ -680,7 +729,7 @@ export const buildCanvasOutpaintGraph = (
field: 'image', field: 'image',
}, },
destination: { destination: {
node_id: INPAINT_CREATE_MASK, node_id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
field: 'image', field: 'image',
}, },
}, },
@ -707,7 +756,7 @@ export const buildCanvasOutpaintGraph = (
}, },
{ {
source: { source: {
node_id: MASK_BLUR, node_id: MASK_COMBINE,
field: 'image', field: 'image',
}, },
destination: { destination: {

View File

@ -6,6 +6,7 @@ import {
ImageBlurInvocation, ImageBlurInvocation,
ImageDTO, ImageDTO,
ImageToLatentsInvocation, ImageToLatentsInvocation,
MaskEdgeInvocation,
NoiseInvocation, NoiseInvocation,
RandomIntInvocation, RandomIntInvocation,
RangeOfSizeInvocation, RangeOfSizeInvocation,
@ -19,6 +20,8 @@ import { addVAEToGraph } from './addVAEToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph'; import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import { import {
CANVAS_COHERENCE_DENOISE_LATENTS, CANVAS_COHERENCE_DENOISE_LATENTS,
CANVAS_COHERENCE_INPAINT_CREATE_MASK,
CANVAS_COHERENCE_MASK_EDGE,
CANVAS_COHERENCE_NOISE, CANVAS_COHERENCE_NOISE,
CANVAS_COHERENCE_NOISE_INCREMENT, CANVAS_COHERENCE_NOISE_INCREMENT,
CANVAS_OUTPUT, CANVAS_OUTPUT,
@ -96,6 +99,10 @@ export const buildCanvasSDXLInpaintGraph = (
shouldAutoSave, shouldAutoSave,
} = state.canvas; } = state.canvas;
const isUsingScaledDimensions = ['auto', 'manual'].includes(
boundingBoxScaleMethod
);
let modelLoaderNodeId = SDXL_MODEL_LOADER; let modelLoaderNodeId = SDXL_MODEL_LOADER;
const use_cpu = shouldUseNoiseSettings const use_cpu = shouldUseNoiseSettings
@ -175,9 +182,24 @@ export const buildCanvasSDXLInpaintGraph = (
b: 1, b: 1,
is_intermediate: true, is_intermediate: true,
}, },
[CANVAS_COHERENCE_MASK_EDGE]: {
type: 'mask_edge',
id: CANVAS_COHERENCE_MASK_EDGE,
is_intermediate: true,
edge_blur: maskBlur,
edge_size: maskBlur * 2,
low_threshold: 100,
high_threshold: 200,
},
[CANVAS_COHERENCE_INPAINT_CREATE_MASK]: {
type: 'create_denoise_mask',
id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
is_intermediate: true,
fp32: vaePrecision === 'fp32' ? true : false,
},
[CANVAS_COHERENCE_DENOISE_LATENTS]: { [CANVAS_COHERENCE_DENOISE_LATENTS]: {
type: 'denoise_latents', type: 'denoise_latents',
id: SDXL_DENOISE_LATENTS, id: CANVAS_COHERENCE_DENOISE_LATENTS,
is_intermediate: true, is_intermediate: true,
steps: canvasCoherenceSteps, steps: canvasCoherenceSteps,
cfg_scale: cfg_scale, cfg_scale: cfg_scale,
@ -326,6 +348,27 @@ export const buildCanvasSDXLInpaintGraph = (
field: 'denoise_mask', field: 'denoise_mask',
}, },
}, },
// Create Coherence Mask
{
source: {
node_id: CANVAS_COHERENCE_MASK_EDGE,
field: 'image',
},
destination: {
node_id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
field: 'mask',
},
},
{
source: {
node_id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
field: 'denoise_mask',
},
destination: {
node_id: CANVAS_COHERENCE_DENOISE_LATENTS,
field: 'denoise_mask',
},
},
// Iterate // Iterate
{ {
source: { source: {
@ -433,7 +476,7 @@ export const buildCanvasSDXLInpaintGraph = (
}; };
// Handle Scale Before Processing // Handle Scale Before Processing
if (['auto', 'manual'].includes(boundingBoxScaleMethod)) { if (isUsingScaledDimensions) {
const scaledWidth: number = scaledBoundingBoxDimensions.width; const scaledWidth: number = scaledBoundingBoxDimensions.width;
const scaledHeight: number = scaledBoundingBoxDimensions.height; const scaledHeight: number = scaledBoundingBoxDimensions.height;
@ -509,6 +552,26 @@ export const buildCanvasSDXLInpaintGraph = (
field: 'image', field: 'image',
}, },
}, },
{
source: {
node_id: INPAINT_IMAGE_RESIZE_UP,
field: 'image',
},
destination: {
node_id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
field: 'image',
},
},
{
source: {
node_id: MASK_RESIZE_UP,
field: 'image',
},
destination: {
node_id: CANVAS_COHERENCE_MASK_EDGE,
field: 'image',
},
},
// Color Correct The Inpainted Result // Color Correct The Inpainted Result
{ {
source: { source: {
@ -570,6 +633,16 @@ export const buildCanvasSDXLInpaintGraph = (
...(graph.nodes[INPAINT_CREATE_MASK] as CreateDenoiseMaskInvocation), ...(graph.nodes[INPAINT_CREATE_MASK] as CreateDenoiseMaskInvocation),
image: canvasInitImage, image: canvasInitImage,
}; };
graph.nodes[CANVAS_COHERENCE_INPAINT_CREATE_MASK] = {
...(graph.nodes[
CANVAS_COHERENCE_INPAINT_CREATE_MASK
] as CreateDenoiseMaskInvocation),
image: canvasInitImage,
};
graph.nodes[CANVAS_COHERENCE_MASK_EDGE] = {
...(graph.nodes[CANVAS_COHERENCE_MASK_EDGE] as MaskEdgeInvocation),
image: canvasMaskImage,
};
graph.edges.push( graph.edges.push(
// Color Correct The Inpainted Result // Color Correct The Inpainted Result

View File

@ -2,7 +2,6 @@ import { logger } from 'app/logging/logger';
import { RootState } from 'app/store/store'; import { RootState } from 'app/store/store';
import { NonNullableGraph } from 'features/nodes/types/types'; import { NonNullableGraph } from 'features/nodes/types/types';
import { import {
ImageBlurInvocation,
ImageDTO, ImageDTO,
ImageToLatentsInvocation, ImageToLatentsInvocation,
InfillPatchMatchInvocation, InfillPatchMatchInvocation,
@ -20,6 +19,8 @@ import { addVAEToGraph } from './addVAEToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph'; import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import { import {
CANVAS_COHERENCE_DENOISE_LATENTS, CANVAS_COHERENCE_DENOISE_LATENTS,
CANVAS_COHERENCE_INPAINT_CREATE_MASK,
CANVAS_COHERENCE_MASK_EDGE,
CANVAS_COHERENCE_NOISE, CANVAS_COHERENCE_NOISE,
CANVAS_COHERENCE_NOISE_INCREMENT, CANVAS_COHERENCE_NOISE_INCREMENT,
CANVAS_OUTPUT, CANVAS_OUTPUT,
@ -31,7 +32,6 @@ import {
INPAINT_INFILL_RESIZE_DOWN, INPAINT_INFILL_RESIZE_DOWN,
ITERATE, ITERATE,
LATENTS_TO_IMAGE, LATENTS_TO_IMAGE,
MASK_BLUR,
MASK_COMBINE, MASK_COMBINE,
MASK_FROM_ALPHA, MASK_FROM_ALPHA,
MASK_RESIZE_DOWN, MASK_RESIZE_DOWN,
@ -72,7 +72,6 @@ export const buildCanvasSDXLOutpaintGraph = (
shouldUseNoiseSettings, shouldUseNoiseSettings,
shouldUseCpuNoise, shouldUseCpuNoise,
maskBlur, maskBlur,
maskBlurMethod,
canvasCoherenceSteps, canvasCoherenceSteps,
canvasCoherenceStrength, canvasCoherenceStrength,
tileSize, tileSize,
@ -103,6 +102,10 @@ export const buildCanvasSDXLOutpaintGraph = (
shouldAutoSave, shouldAutoSave,
} = state.canvas; } = state.canvas;
const isUsingScaledDimensions = ['auto', 'manual'].includes(
boundingBoxScaleMethod
);
let modelLoaderNodeId = SDXL_MODEL_LOADER; let modelLoaderNodeId = SDXL_MODEL_LOADER;
const use_cpu = shouldUseNoiseSettings const use_cpu = shouldUseNoiseSettings
@ -145,13 +148,6 @@ export const buildCanvasSDXLOutpaintGraph = (
is_intermediate: true, is_intermediate: true,
mask2: canvasMaskImage, mask2: canvasMaskImage,
}, },
[MASK_BLUR]: {
type: 'img_blur',
id: MASK_BLUR,
is_intermediate: true,
radius: maskBlur,
blur_type: maskBlurMethod,
},
[INPAINT_IMAGE]: { [INPAINT_IMAGE]: {
type: 'i2l', type: 'i2l',
id: INPAINT_IMAGE, id: INPAINT_IMAGE,
@ -194,6 +190,21 @@ export const buildCanvasSDXLOutpaintGraph = (
b: 1, b: 1,
is_intermediate: true, is_intermediate: true,
}, },
[CANVAS_COHERENCE_MASK_EDGE]: {
type: 'mask_edge',
id: CANVAS_COHERENCE_MASK_EDGE,
is_intermediate: true,
edge_blur: maskBlur,
edge_size: maskBlur * 2,
low_threshold: 100,
high_threshold: 200,
},
[CANVAS_COHERENCE_INPAINT_CREATE_MASK]: {
type: 'create_denoise_mask',
id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
is_intermediate: true,
fp32: vaePrecision === 'fp32' ? true : false,
},
[CANVAS_COHERENCE_DENOISE_LATENTS]: { [CANVAS_COHERENCE_DENOISE_LATENTS]: {
type: 'denoise_latents', type: 'denoise_latents',
id: CANVAS_COHERENCE_DENOISE_LATENTS, id: CANVAS_COHERENCE_DENOISE_LATENTS,
@ -348,7 +359,7 @@ export const buildCanvasSDXLOutpaintGraph = (
// Create Inpaint Mask // Create Inpaint Mask
{ {
source: { source: {
node_id: MASK_BLUR, node_id: isUsingScaledDimensions ? MASK_RESIZE_UP : MASK_COMBINE,
field: 'image', field: 'image',
}, },
destination: { destination: {
@ -366,6 +377,27 @@ export const buildCanvasSDXLOutpaintGraph = (
field: 'denoise_mask', field: 'denoise_mask',
}, },
}, },
// Create Coherence Mask
{
source: {
node_id: CANVAS_COHERENCE_MASK_EDGE,
field: 'image',
},
destination: {
node_id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
field: 'mask',
},
},
{
source: {
node_id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
field: 'denoise_mask',
},
destination: {
node_id: CANVAS_COHERENCE_DENOISE_LATENTS,
field: 'denoise_mask',
},
},
// Iterate // Iterate
{ {
source: { source: {
@ -410,7 +442,7 @@ export const buildCanvasSDXLOutpaintGraph = (
}, },
{ {
source: { source: {
node_id: SDXL_MODEL_LOADER, node_id: modelLoaderNodeId,
field: 'unet', field: 'unet',
}, },
destination: { destination: {
@ -473,7 +505,6 @@ export const buildCanvasSDXLOutpaintGraph = (
}; };
// Add Infill Nodes // Add Infill Nodes
if (infillMethod === 'patchmatch') { if (infillMethod === 'patchmatch') {
graph.nodes[INPAINT_INFILL] = { graph.nodes[INPAINT_INFILL] = {
type: 'infill_patchmatch', type: 'infill_patchmatch',
@ -500,7 +531,7 @@ export const buildCanvasSDXLOutpaintGraph = (
} }
// Handle Scale Before Processing // Handle Scale Before Processing
if (['auto', 'manual'].includes(boundingBoxScaleMethod)) { if (isUsingScaledDimensions) {
const scaledWidth: number = scaledBoundingBoxDimensions.width; const scaledWidth: number = scaledBoundingBoxDimensions.width;
const scaledHeight: number = scaledBoundingBoxDimensions.height; const scaledHeight: number = scaledBoundingBoxDimensions.height;
@ -572,6 +603,16 @@ export const buildCanvasSDXLOutpaintGraph = (
field: 'image', field: 'image',
}, },
}, },
{
source: {
node_id: INPAINT_INFILL,
field: 'image',
},
destination: {
node_id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
field: 'image',
},
},
// Take combined mask and resize and then blur // Take combined mask and resize and then blur
{ {
source: { source: {
@ -589,7 +630,7 @@ export const buildCanvasSDXLOutpaintGraph = (
field: 'image', field: 'image',
}, },
destination: { destination: {
node_id: MASK_BLUR, node_id: CANVAS_COHERENCE_MASK_EDGE,
field: 'image', field: 'image',
}, },
}, },
@ -674,19 +715,26 @@ export const buildCanvasSDXLOutpaintGraph = (
...(graph.nodes[INPAINT_IMAGE] as ImageToLatentsInvocation), ...(graph.nodes[INPAINT_IMAGE] as ImageToLatentsInvocation),
image: canvasInitImage, image: canvasInitImage,
}; };
graph.nodes[MASK_BLUR] = {
...(graph.nodes[MASK_BLUR] as ImageBlurInvocation),
};
graph.edges.push( graph.edges.push(
// Take combined mask and plug it to blur // Take combined mask and plug it to blur
{
source: {
node_id: INPAINT_INFILL,
field: 'image',
},
destination: {
node_id: INPAINT_CREATE_MASK,
field: 'image',
},
},
{ {
source: { source: {
node_id: MASK_COMBINE, node_id: MASK_COMBINE,
field: 'image', field: 'image',
}, },
destination: { destination: {
node_id: MASK_BLUR, node_id: CANVAS_COHERENCE_MASK_EDGE,
field: 'image', field: 'image',
}, },
}, },
@ -696,7 +744,7 @@ export const buildCanvasSDXLOutpaintGraph = (
field: 'image', field: 'image',
}, },
destination: { destination: {
node_id: INPAINT_CREATE_MASK, node_id: CANVAS_COHERENCE_INPAINT_CREATE_MASK,
field: 'image', field: 'image',
}, },
}, },
@ -723,7 +771,7 @@ export const buildCanvasSDXLOutpaintGraph = (
}, },
{ {
source: { source: {
node_id: MASK_BLUR, node_id: MASK_COMBINE,
field: 'image', field: 'image',
}, },
destination: { destination: {
@ -734,7 +782,7 @@ export const buildCanvasSDXLOutpaintGraph = (
); );
} }
// Handle seed // Handle Seed
if (shouldRandomizeSeed) { if (shouldRandomizeSeed) {
// Random int node to generate the starting seed // Random int node to generate the starting seed
const randomIntNode: RandomIntInvocation = { const randomIntNode: RandomIntInvocation = {

View File

@ -27,11 +27,15 @@ export const INPAINT_INFILL = 'inpaint_infill';
export const INPAINT_INFILL_RESIZE_DOWN = 'inpaint_infill_resize_down'; export const INPAINT_INFILL_RESIZE_DOWN = 'inpaint_infill_resize_down';
export const INPAINT_FINAL_IMAGE = 'inpaint_final_image'; export const INPAINT_FINAL_IMAGE = 'inpaint_final_image';
export const INPAINT_CREATE_MASK = 'inpaint_create_mask'; export const INPAINT_CREATE_MASK = 'inpaint_create_mask';
export const INPAINT_MASK = 'inpaint_mask';
export const CANVAS_COHERENCE_DENOISE_LATENTS = export const CANVAS_COHERENCE_DENOISE_LATENTS =
'canvas_coherence_denoise_latents'; 'canvas_coherence_denoise_latents';
export const CANVAS_COHERENCE_NOISE = 'canvas_coherence_noise'; export const CANVAS_COHERENCE_NOISE = 'canvas_coherence_noise';
export const CANVAS_COHERENCE_NOISE_INCREMENT = export const CANVAS_COHERENCE_NOISE_INCREMENT =
'canvas_coherence_noise_increment'; 'canvas_coherence_noise_increment';
export const CANVAS_COHERENCE_MASK_EDGE = 'canvas_coherence_mask_edge';
export const CANVAS_COHERENCE_INPAINT_CREATE_MASK =
'canvas_coherence_inpaint_create_mask';
export const MASK_FROM_ALPHA = 'tomask'; export const MASK_FROM_ALPHA = 'tomask';
export const MASK_EDGE = 'mask_edge'; export const MASK_EDGE = 'mask_edge';
export const MASK_BLUR = 'mask_blur'; export const MASK_BLUR = 'mask_blur';

View File

@ -112,6 +112,7 @@ export type ImageScaleInvocation = s['ImageScaleInvocation'];
export type InfillPatchMatchInvocation = s['InfillPatchMatchInvocation']; export type InfillPatchMatchInvocation = s['InfillPatchMatchInvocation'];
export type InfillTileInvocation = s['InfillTileInvocation']; export type InfillTileInvocation = s['InfillTileInvocation'];
export type CreateDenoiseMaskInvocation = s['CreateDenoiseMaskInvocation']; export type CreateDenoiseMaskInvocation = s['CreateDenoiseMaskInvocation'];
export type MaskEdgeInvocation = s['MaskEdgeInvocation'];
export type RandomIntInvocation = s['RandomIntInvocation']; export type RandomIntInvocation = s['RandomIntInvocation'];
export type CompelInvocation = s['CompelInvocation']; export type CompelInvocation = s['CompelInvocation'];
export type DynamicPromptInvocation = s['DynamicPromptInvocation']; export type DynamicPromptInvocation = s['DynamicPromptInvocation'];