fix(ui): use seed + 1 for inpaint/outpaint second pass

This commit is contained in:
psychedelicious 2023-08-24 11:59:24 +10:00 committed by Kent Keirsey
parent 2ba52b8921
commit 2f11936db0
5 changed files with 198 additions and 56 deletions

View File

@ -18,6 +18,8 @@ import {
CANVAS_INPAINT_GRAPH, CANVAS_INPAINT_GRAPH,
CANVAS_OUTPUT, CANVAS_OUTPUT,
CANVAS_REFINE_DENOISE_LATENTS, CANVAS_REFINE_DENOISE_LATENTS,
CANVAS_REFINE_NOISE,
CANVAS_REFINE_NOISE_INCREMENT,
CLIP_SKIP, CLIP_SKIP,
DENOISE_LATENTS, DENOISE_LATENTS,
INPAINT_IMAGE, INPAINT_IMAGE,
@ -141,6 +143,18 @@ export const buildCanvasInpaintGraph = (
denoising_start: 1 - strength, denoising_start: 1 - strength,
denoising_end: 1, denoising_end: 1,
}, },
[CANVAS_REFINE_NOISE]: {
type: 'noise',
id: NOISE,
use_cpu,
is_intermediate: true,
},
[CANVAS_REFINE_NOISE_INCREMENT]: {
type: 'add',
id: CANVAS_REFINE_NOISE_INCREMENT,
b: 1,
is_intermediate: true,
},
[CANVAS_REFINE_DENOISE_LATENTS]: { [CANVAS_REFINE_DENOISE_LATENTS]: {
type: 'denoise_latents', type: 'denoise_latents',
id: DENOISE_LATENTS, id: DENOISE_LATENTS,
@ -294,6 +308,26 @@ export const buildCanvasInpaintGraph = (
}, },
}, },
// Canvas Refine // Canvas Refine
{
source: {
node_id: ITERATE,
field: 'item',
},
destination: {
node_id: CANVAS_REFINE_NOISE_INCREMENT,
field: 'a',
},
},
{
source: {
node_id: CANVAS_REFINE_NOISE_INCREMENT,
field: 'value',
},
destination: {
node_id: CANVAS_REFINE_NOISE,
field: 'seed',
},
},
{ {
source: { source: {
node_id: MAIN_MODEL_LOADER, node_id: MAIN_MODEL_LOADER,
@ -326,7 +360,7 @@ export const buildCanvasInpaintGraph = (
}, },
{ {
source: { source: {
node_id: NOISE, node_id: CANVAS_REFINE_NOISE,
field: 'noise', field: 'noise',
}, },
destination: { destination: {
@ -395,11 +429,10 @@ export const buildCanvasInpaintGraph = (
height: height, height: height,
}; };
graph.nodes[NOISE] = { (graph.nodes[NOISE] as NoiseInvocation).width = scaledWidth;
...(graph.nodes[NOISE] as NoiseInvocation), (graph.nodes[NOISE] as NoiseInvocation).height = scaledHeight;
width: scaledWidth, (graph.nodes[CANVAS_REFINE_NOISE] as NoiseInvocation).width = scaledWidth;
height: scaledHeight, (graph.nodes[CANVAS_REFINE_NOISE] as NoiseInvocation).height = scaledHeight;
};
// Connect Nodes // Connect Nodes
graph.edges.push( graph.edges.push(
@ -468,11 +501,11 @@ export const buildCanvasInpaintGraph = (
); );
} else { } else {
// Add Images To Nodes // Add Images To Nodes
graph.nodes[NOISE] = { (graph.nodes[NOISE] as NoiseInvocation).width = width;
...(graph.nodes[NOISE] as NoiseInvocation), (graph.nodes[NOISE] as NoiseInvocation).height = height;
width: width, (graph.nodes[CANVAS_REFINE_NOISE] as NoiseInvocation).width = width;
height: height, (graph.nodes[CANVAS_REFINE_NOISE] as NoiseInvocation).height = height;
};
graph.nodes[INPAINT_IMAGE] = { graph.nodes[INPAINT_IMAGE] = {
...(graph.nodes[INPAINT_IMAGE] as ImageToLatentsInvocation), ...(graph.nodes[INPAINT_IMAGE] as ImageToLatentsInvocation),
image: canvasInitImage, image: canvasInitImage,

View File

@ -20,6 +20,8 @@ import {
CANVAS_OUTPAINT_GRAPH, CANVAS_OUTPAINT_GRAPH,
CANVAS_OUTPUT, CANVAS_OUTPUT,
CANVAS_REFINE_DENOISE_LATENTS, CANVAS_REFINE_DENOISE_LATENTS,
CANVAS_REFINE_NOISE,
CANVAS_REFINE_NOISE_INCREMENT,
CLIP_SKIP, CLIP_SKIP,
DENOISE_LATENTS, DENOISE_LATENTS,
INPAINT_IMAGE, INPAINT_IMAGE,
@ -139,12 +141,6 @@ export const buildCanvasOutpaintGraph = (
radius: maskBlur, radius: maskBlur,
blur_type: maskBlurMethod, blur_type: maskBlurMethod,
}, },
[INPAINT_INFILL]: {
type: 'infill_tile',
id: INPAINT_INFILL,
is_intermediate: true,
tile_size: tileSize,
},
[INPAINT_IMAGE]: { [INPAINT_IMAGE]: {
type: 'i2l', type: 'i2l',
id: INPAINT_IMAGE, id: INPAINT_IMAGE,
@ -167,6 +163,18 @@ export const buildCanvasOutpaintGraph = (
denoising_start: 1 - strength, denoising_start: 1 - strength,
denoising_end: 1, denoising_end: 1,
}, },
[CANVAS_REFINE_NOISE]: {
type: 'noise',
id: NOISE,
use_cpu,
is_intermediate: true,
},
[CANVAS_REFINE_NOISE_INCREMENT]: {
type: 'add',
id: CANVAS_REFINE_NOISE_INCREMENT,
b: 1,
is_intermediate: true,
},
[CANVAS_REFINE_DENOISE_LATENTS]: { [CANVAS_REFINE_DENOISE_LATENTS]: {
type: 'denoise_latents', type: 'denoise_latents',
id: CANVAS_REFINE_DENOISE_LATENTS, id: CANVAS_REFINE_DENOISE_LATENTS,
@ -341,6 +349,26 @@ export const buildCanvasOutpaintGraph = (
}, },
}, },
// Canvas Refine // Canvas Refine
{
source: {
node_id: ITERATE,
field: 'item',
},
destination: {
node_id: CANVAS_REFINE_NOISE_INCREMENT,
field: 'a',
},
},
{
source: {
node_id: CANVAS_REFINE_NOISE_INCREMENT,
field: 'value',
},
destination: {
node_id: CANVAS_REFINE_NOISE,
field: 'seed',
},
},
{ {
source: { source: {
node_id: MAIN_MODEL_LOADER, node_id: MAIN_MODEL_LOADER,
@ -373,7 +401,7 @@ export const buildCanvasOutpaintGraph = (
}, },
{ {
source: { source: {
node_id: NOISE, node_id: CANVAS_REFINE_NOISE,
field: 'noise', field: 'noise',
}, },
destination: { destination: {
@ -422,6 +450,15 @@ export const buildCanvasOutpaintGraph = (
}; };
} }
if (infillMethod === 'tile') {
graph.nodes[INPAINT_INFILL] = {
type: 'infill_tile',
id: INPAINT_INFILL,
is_intermediate: true,
tile_size: tileSize,
};
}
// Handle Scale Before Processing // Handle Scale Before Processing
if (['auto', 'manual'].includes(boundingBoxScaleMethod)) { if (['auto', 'manual'].includes(boundingBoxScaleMethod)) {
const scaledWidth: number = scaledBoundingBoxDimensions.width; const scaledWidth: number = scaledBoundingBoxDimensions.width;
@ -465,11 +502,10 @@ export const buildCanvasOutpaintGraph = (
height: height, height: height,
}; };
graph.nodes[NOISE] = { (graph.nodes[NOISE] as NoiseInvocation).width = scaledWidth;
...(graph.nodes[NOISE] as NoiseInvocation), (graph.nodes[NOISE] as NoiseInvocation).height = scaledHeight;
width: scaledWidth, (graph.nodes[CANVAS_REFINE_NOISE] as NoiseInvocation).width = scaledWidth;
height: scaledHeight, (graph.nodes[CANVAS_REFINE_NOISE] as NoiseInvocation).height = scaledHeight;
};
// Connect Nodes // Connect Nodes
graph.edges.push( graph.edges.push(
@ -576,11 +612,12 @@ export const buildCanvasOutpaintGraph = (
| InfillPatchMatchInvocation), | InfillPatchMatchInvocation),
image: canvasInitImage, image: canvasInitImage,
}; };
graph.nodes[NOISE] = {
...(graph.nodes[NOISE] as NoiseInvocation), (graph.nodes[NOISE] as NoiseInvocation).width = width;
width: width, (graph.nodes[NOISE] as NoiseInvocation).height = height;
height: height, (graph.nodes[CANVAS_REFINE_NOISE] as NoiseInvocation).width = width;
}; (graph.nodes[CANVAS_REFINE_NOISE] as NoiseInvocation).height = height;
graph.nodes[INPAINT_IMAGE] = { graph.nodes[INPAINT_IMAGE] = {
...(graph.nodes[INPAINT_IMAGE] as ImageToLatentsInvocation), ...(graph.nodes[INPAINT_IMAGE] as ImageToLatentsInvocation),
image: canvasInitImage, image: canvasInitImage,

View File

@ -18,6 +18,8 @@ import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import { import {
CANVAS_OUTPUT, CANVAS_OUTPUT,
CANVAS_REFINE_DENOISE_LATENTS, CANVAS_REFINE_DENOISE_LATENTS,
CANVAS_REFINE_NOISE,
CANVAS_REFINE_NOISE_INCREMENT,
INPAINT_IMAGE, INPAINT_IMAGE,
INPAINT_IMAGE_RESIZE_DOWN, INPAINT_IMAGE_RESIZE_DOWN,
INPAINT_IMAGE_RESIZE_UP, INPAINT_IMAGE_RESIZE_UP,
@ -146,6 +148,18 @@ export const buildCanvasSDXLInpaintGraph = (
: 1 - strength, : 1 - strength,
denoising_end: shouldUseSDXLRefiner ? refinerStart : 1, denoising_end: shouldUseSDXLRefiner ? refinerStart : 1,
}, },
[CANVAS_REFINE_NOISE]: {
type: 'noise',
id: NOISE,
use_cpu,
is_intermediate: true,
},
[CANVAS_REFINE_NOISE_INCREMENT]: {
type: 'add',
id: CANVAS_REFINE_NOISE_INCREMENT,
b: 1,
is_intermediate: true,
},
[CANVAS_REFINE_DENOISE_LATENTS]: { [CANVAS_REFINE_DENOISE_LATENTS]: {
type: 'denoise_latents', type: 'denoise_latents',
id: SDXL_DENOISE_LATENTS, id: SDXL_DENOISE_LATENTS,
@ -308,6 +322,26 @@ export const buildCanvasSDXLInpaintGraph = (
}, },
}, },
// Canvas Refine // Canvas Refine
{
source: {
node_id: ITERATE,
field: 'item',
},
destination: {
node_id: CANVAS_REFINE_NOISE_INCREMENT,
field: 'a',
},
},
{
source: {
node_id: CANVAS_REFINE_NOISE_INCREMENT,
field: 'value',
},
destination: {
node_id: CANVAS_REFINE_NOISE,
field: 'seed',
},
},
{ {
source: { source: {
node_id: SDXL_MODEL_LOADER, node_id: SDXL_MODEL_LOADER,
@ -340,7 +374,7 @@ export const buildCanvasSDXLInpaintGraph = (
}, },
{ {
source: { source: {
node_id: NOISE, node_id: CANVAS_REFINE_NOISE,
field: 'noise', field: 'noise',
}, },
destination: { destination: {
@ -409,11 +443,10 @@ export const buildCanvasSDXLInpaintGraph = (
height: height, height: height,
}; };
graph.nodes[NOISE] = { (graph.nodes[NOISE] as NoiseInvocation).width = scaledWidth;
...(graph.nodes[NOISE] as NoiseInvocation), (graph.nodes[NOISE] as NoiseInvocation).height = scaledHeight;
width: scaledWidth, (graph.nodes[CANVAS_REFINE_NOISE] as NoiseInvocation).width = scaledWidth;
height: scaledHeight, (graph.nodes[CANVAS_REFINE_NOISE] as NoiseInvocation).height = scaledHeight;
};
// Connect Nodes // Connect Nodes
graph.edges.push( graph.edges.push(
@ -482,11 +515,11 @@ export const buildCanvasSDXLInpaintGraph = (
); );
} else { } else {
// Add Images To Nodes // Add Images To Nodes
graph.nodes[NOISE] = { (graph.nodes[NOISE] as NoiseInvocation).width = width;
...(graph.nodes[NOISE] as NoiseInvocation), (graph.nodes[NOISE] as NoiseInvocation).height = height;
width: width, (graph.nodes[CANVAS_REFINE_NOISE] as NoiseInvocation).width = width;
height: height, (graph.nodes[CANVAS_REFINE_NOISE] as NoiseInvocation).height = height;
};
graph.nodes[INPAINT_IMAGE] = { graph.nodes[INPAINT_IMAGE] = {
...(graph.nodes[INPAINT_IMAGE] as ImageToLatentsInvocation), ...(graph.nodes[INPAINT_IMAGE] as ImageToLatentsInvocation),
image: canvasInitImage, image: canvasInitImage,

View File

@ -20,6 +20,8 @@ import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import { import {
CANVAS_OUTPUT, CANVAS_OUTPUT,
CANVAS_REFINE_DENOISE_LATENTS, CANVAS_REFINE_DENOISE_LATENTS,
CANVAS_REFINE_NOISE,
CANVAS_REFINE_NOISE_INCREMENT,
INPAINT_IMAGE, INPAINT_IMAGE,
INPAINT_IMAGE_RESIZE_DOWN, INPAINT_IMAGE_RESIZE_DOWN,
INPAINT_IMAGE_RESIZE_UP, INPAINT_IMAGE_RESIZE_UP,
@ -142,12 +144,6 @@ export const buildCanvasSDXLOutpaintGraph = (
radius: maskBlur, radius: maskBlur,
blur_type: maskBlurMethod, blur_type: maskBlurMethod,
}, },
[INPAINT_INFILL]: {
type: 'infill_tile',
id: INPAINT_INFILL,
is_intermediate: true,
tile_size: tileSize,
},
[INPAINT_IMAGE]: { [INPAINT_IMAGE]: {
type: 'i2l', type: 'i2l',
id: INPAINT_IMAGE, id: INPAINT_IMAGE,
@ -172,6 +168,18 @@ export const buildCanvasSDXLOutpaintGraph = (
: 1 - strength, : 1 - strength,
denoising_end: shouldUseSDXLRefiner ? refinerStart : 1, denoising_end: shouldUseSDXLRefiner ? refinerStart : 1,
}, },
[CANVAS_REFINE_NOISE]: {
type: 'noise',
id: NOISE,
use_cpu,
is_intermediate: true,
},
[CANVAS_REFINE_NOISE_INCREMENT]: {
type: 'add',
id: CANVAS_REFINE_NOISE_INCREMENT,
b: 1,
is_intermediate: true,
},
[CANVAS_REFINE_DENOISE_LATENTS]: { [CANVAS_REFINE_DENOISE_LATENTS]: {
type: 'denoise_latents', type: 'denoise_latents',
id: CANVAS_REFINE_DENOISE_LATENTS, id: CANVAS_REFINE_DENOISE_LATENTS,
@ -355,6 +363,26 @@ export const buildCanvasSDXLOutpaintGraph = (
}, },
}, },
// Canvas Refine // Canvas Refine
{
source: {
node_id: ITERATE,
field: 'item',
},
destination: {
node_id: CANVAS_REFINE_NOISE_INCREMENT,
field: 'a',
},
},
{
source: {
node_id: CANVAS_REFINE_NOISE_INCREMENT,
field: 'value',
},
destination: {
node_id: CANVAS_REFINE_NOISE,
field: 'seed',
},
},
{ {
source: { source: {
node_id: SDXL_MODEL_LOADER, node_id: SDXL_MODEL_LOADER,
@ -387,7 +415,7 @@ export const buildCanvasSDXLOutpaintGraph = (
}, },
{ {
source: { source: {
node_id: NOISE, node_id: CANVAS_REFINE_NOISE,
field: 'noise', field: 'noise',
}, },
destination: { destination: {
@ -437,6 +465,15 @@ export const buildCanvasSDXLOutpaintGraph = (
}; };
} }
if (infillMethod === 'tile') {
graph.nodes[INPAINT_INFILL] = {
type: 'infill_tile',
id: INPAINT_INFILL,
is_intermediate: true,
tile_size: tileSize,
};
}
// Handle Scale Before Processing // Handle Scale Before Processing
if (['auto', 'manual'].includes(boundingBoxScaleMethod)) { if (['auto', 'manual'].includes(boundingBoxScaleMethod)) {
const scaledWidth: number = scaledBoundingBoxDimensions.width; const scaledWidth: number = scaledBoundingBoxDimensions.width;
@ -480,11 +517,10 @@ export const buildCanvasSDXLOutpaintGraph = (
height: height, height: height,
}; };
graph.nodes[NOISE] = { (graph.nodes[NOISE] as NoiseInvocation).width = scaledWidth;
...(graph.nodes[NOISE] as NoiseInvocation), (graph.nodes[NOISE] as NoiseInvocation).height = scaledHeight;
width: scaledWidth, (graph.nodes[CANVAS_REFINE_NOISE] as NoiseInvocation).width = scaledWidth;
height: scaledHeight, (graph.nodes[CANVAS_REFINE_NOISE] as NoiseInvocation).height = scaledHeight;
};
// Connect Nodes // Connect Nodes
graph.edges.push( graph.edges.push(
@ -591,11 +627,12 @@ export const buildCanvasSDXLOutpaintGraph = (
| InfillPatchMatchInvocation), | InfillPatchMatchInvocation),
image: canvasInitImage, image: canvasInitImage,
}; };
graph.nodes[NOISE] = {
...(graph.nodes[NOISE] as NoiseInvocation), (graph.nodes[NOISE] as NoiseInvocation).width = width;
width: width, (graph.nodes[NOISE] as NoiseInvocation).height = height;
height: height, (graph.nodes[CANVAS_REFINE_NOISE] as NoiseInvocation).width = width;
}; (graph.nodes[CANVAS_REFINE_NOISE] as NoiseInvocation).height = height;
graph.nodes[INPAINT_IMAGE] = { graph.nodes[INPAINT_IMAGE] = {
...(graph.nodes[INPAINT_IMAGE] as ImageToLatentsInvocation), ...(graph.nodes[INPAINT_IMAGE] as ImageToLatentsInvocation),
image: canvasInitImage, image: canvasInitImage,

View File

@ -26,6 +26,8 @@ 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 CANVAS_REFINE_DENOISE_LATENTS = 'canvas_refine_denoise_latents'; export const CANVAS_REFINE_DENOISE_LATENTS = 'canvas_refine_denoise_latents';
export const CANVAS_REFINE_NOISE = 'canvas_refine_noise';
export const CANVAS_REFINE_NOISE_INCREMENT = 'canvas_refine_noise_increment';
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';