feat: Setup UnifiedCanvas to work with new InpaintMaskField

This commit is contained in:
blessedcoolant 2023-08-27 03:50:29 +12:00
parent af3e316cee
commit 226721ce51
7 changed files with 161 additions and 6 deletions

View File

@ -9,6 +9,7 @@ import {
CANVAS_TEXT_TO_IMAGE_GRAPH, CANVAS_TEXT_TO_IMAGE_GRAPH,
IMAGE_TO_IMAGE_GRAPH, IMAGE_TO_IMAGE_GRAPH,
IMAGE_TO_LATENTS, IMAGE_TO_LATENTS,
INPAINT_CREATE_MASK,
INPAINT_IMAGE, INPAINT_IMAGE,
LATENTS_TO_IMAGE, LATENTS_TO_IMAGE,
MAIN_MODEL_LOADER, MAIN_MODEL_LOADER,
@ -117,6 +118,16 @@ export const addVAEToGraph = (
field: 'vae', field: 'vae',
}, },
}, },
{
source: {
node_id: isAutoVae ? modelLoaderNodeId : VAE_LOADER,
field: isAutoVae && isOnnxModel ? 'vae_decoder' : 'vae',
},
destination: {
node_id: INPAINT_CREATE_MASK,
field: 'vae',
},
},
{ {
source: { source: {
node_id: isAutoVae ? modelLoaderNodeId : VAE_LOADER, node_id: isAutoVae ? modelLoaderNodeId : VAE_LOADER,

View File

@ -2,6 +2,7 @@ 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 {
CreateInpaintMaskInvocation,
ImageBlurInvocation, ImageBlurInvocation,
ImageDTO, ImageDTO,
ImageToLatentsInvocation, ImageToLatentsInvocation,
@ -15,13 +16,14 @@ import { addNSFWCheckerToGraph } from './addNSFWCheckerToGraph';
import { addVAEToGraph } from './addVAEToGraph'; import { addVAEToGraph } from './addVAEToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph'; import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import { import {
CANVAS_INPAINT_GRAPH,
CANVAS_OUTPUT,
CANVAS_COHERENCE_DENOISE_LATENTS, CANVAS_COHERENCE_DENOISE_LATENTS,
CANVAS_COHERENCE_NOISE, CANVAS_COHERENCE_NOISE,
CANVAS_COHERENCE_NOISE_INCREMENT, CANVAS_COHERENCE_NOISE_INCREMENT,
CANVAS_INPAINT_GRAPH,
CANVAS_OUTPUT,
CLIP_SKIP, CLIP_SKIP,
DENOISE_LATENTS, DENOISE_LATENTS,
INPAINT_CREATE_MASK,
INPAINT_IMAGE, INPAINT_IMAGE,
INPAINT_IMAGE_RESIZE_DOWN, INPAINT_IMAGE_RESIZE_DOWN,
INPAINT_IMAGE_RESIZE_UP, INPAINT_IMAGE_RESIZE_UP,
@ -127,6 +129,12 @@ export const buildCanvasInpaintGraph = (
is_intermediate: true, is_intermediate: true,
fp32: vaePrecision === 'fp32' ? true : false, fp32: vaePrecision === 'fp32' ? true : false,
}, },
[INPAINT_CREATE_MASK]: {
type: 'create_inpaint_mask',
id: INPAINT_CREATE_MASK,
is_intermediate: true,
fp32: vaePrecision === 'fp32' ? true : false,
},
[NOISE]: { [NOISE]: {
type: 'noise', type: 'noise',
id: NOISE, id: NOISE,
@ -276,11 +284,22 @@ export const buildCanvasInpaintGraph = (
field: 'latents', field: 'latents',
}, },
}, },
// Create Inpaint Mask
{ {
source: { source: {
node_id: MASK_BLUR, node_id: MASK_BLUR,
field: 'image', field: 'image',
}, },
destination: {
node_id: INPAINT_CREATE_MASK,
field: 'mask',
},
},
{
source: {
node_id: INPAINT_CREATE_MASK,
field: 'inpaint_mask',
},
destination: { destination: {
node_id: DENOISE_LATENTS, node_id: DENOISE_LATENTS,
field: 'mask', field: 'mask',
@ -459,6 +478,16 @@ export const buildCanvasInpaintGraph = (
field: 'image', field: 'image',
}, },
}, },
{
source: {
node_id: INPAINT_IMAGE_RESIZE_UP,
field: 'image',
},
destination: {
node_id: INPAINT_CREATE_MASK,
field: 'image',
},
},
// Color Correct The Inpainted Result // Color Correct The Inpainted Result
{ {
source: { source: {
@ -516,6 +545,10 @@ export const buildCanvasInpaintGraph = (
...(graph.nodes[MASK_BLUR] as ImageBlurInvocation), ...(graph.nodes[MASK_BLUR] as ImageBlurInvocation),
image: canvasMaskImage, image: canvasMaskImage,
}; };
graph.nodes[INPAINT_CREATE_MASK] = {
...(graph.nodes[INPAINT_CREATE_MASK] as CreateInpaintMaskInvocation),
image: canvasInitImage,
};
graph.edges.push( graph.edges.push(
// Color Correct The Inpainted Result // Color Correct The Inpainted Result

View File

@ -17,13 +17,14 @@ import { addNSFWCheckerToGraph } from './addNSFWCheckerToGraph';
import { addVAEToGraph } from './addVAEToGraph'; import { addVAEToGraph } from './addVAEToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph'; import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import { import {
CANVAS_OUTPAINT_GRAPH,
CANVAS_OUTPUT,
CANVAS_COHERENCE_DENOISE_LATENTS, CANVAS_COHERENCE_DENOISE_LATENTS,
CANVAS_COHERENCE_NOISE, CANVAS_COHERENCE_NOISE,
CANVAS_COHERENCE_NOISE_INCREMENT, CANVAS_COHERENCE_NOISE_INCREMENT,
CANVAS_OUTPAINT_GRAPH,
CANVAS_OUTPUT,
CLIP_SKIP, CLIP_SKIP,
DENOISE_LATENTS, DENOISE_LATENTS,
INPAINT_CREATE_MASK,
INPAINT_IMAGE, INPAINT_IMAGE,
INPAINT_IMAGE_RESIZE_DOWN, INPAINT_IMAGE_RESIZE_DOWN,
INPAINT_IMAGE_RESIZE_UP, INPAINT_IMAGE_RESIZE_UP,
@ -153,6 +154,12 @@ export const buildCanvasOutpaintGraph = (
use_cpu, use_cpu,
is_intermediate: true, is_intermediate: true,
}, },
[INPAINT_CREATE_MASK]: {
type: 'create_inpaint_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,
@ -317,11 +324,22 @@ export const buildCanvasOutpaintGraph = (
field: 'latents', field: 'latents',
}, },
}, },
// Create Inpaint Mask
{ {
source: { source: {
node_id: MASK_BLUR, node_id: MASK_BLUR,
field: 'image', field: 'image',
}, },
destination: {
node_id: INPAINT_CREATE_MASK,
field: 'mask',
},
},
{
source: {
node_id: INPAINT_CREATE_MASK,
field: 'inpaint_mask',
},
destination: { destination: {
node_id: DENOISE_LATENTS, node_id: DENOISE_LATENTS,
field: 'mask', field: 'mask',
@ -522,6 +540,16 @@ export const buildCanvasOutpaintGraph = (
field: 'image', field: 'image',
}, },
}, },
{
source: {
node_id: INPAINT_INFILL,
field: 'image',
},
destination: {
node_id: INPAINT_CREATE_MASK,
field: 'image',
},
},
// Take combined mask and resize and then blur // Take combined mask and resize and then blur
{ {
source: { source: {
@ -640,6 +668,16 @@ export const buildCanvasOutpaintGraph = (
field: 'image', field: 'image',
}, },
}, },
{
source: {
node_id: INPAINT_INFILL,
field: 'image',
},
destination: {
node_id: INPAINT_CREATE_MASK,
field: 'image',
},
},
// Color Correct The Inpainted Result // Color Correct The Inpainted Result
{ {
source: { source: {

View File

@ -2,6 +2,7 @@ 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 {
CreateInpaintMaskInvocation,
ImageBlurInvocation, ImageBlurInvocation,
ImageDTO, ImageDTO,
ImageToLatentsInvocation, ImageToLatentsInvocation,
@ -16,10 +17,11 @@ import { addSDXLRefinerToGraph } from './addSDXLRefinerToGraph';
import { addVAEToGraph } from './addVAEToGraph'; import { addVAEToGraph } from './addVAEToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph'; import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import { import {
CANVAS_OUTPUT,
CANVAS_COHERENCE_DENOISE_LATENTS, CANVAS_COHERENCE_DENOISE_LATENTS,
CANVAS_COHERENCE_NOISE, CANVAS_COHERENCE_NOISE,
CANVAS_COHERENCE_NOISE_INCREMENT, CANVAS_COHERENCE_NOISE_INCREMENT,
CANVAS_OUTPUT,
INPAINT_CREATE_MASK,
INPAINT_IMAGE, INPAINT_IMAGE,
INPAINT_IMAGE_RESIZE_DOWN, INPAINT_IMAGE_RESIZE_DOWN,
INPAINT_IMAGE_RESIZE_UP, INPAINT_IMAGE_RESIZE_UP,
@ -136,6 +138,12 @@ export const buildCanvasSDXLInpaintGraph = (
use_cpu, use_cpu,
is_intermediate: true, is_intermediate: true,
}, },
[INPAINT_CREATE_MASK]: {
type: 'create_inpaint_mask',
id: INPAINT_CREATE_MASK,
is_intermediate: true,
fp32: vaePrecision === 'fp32' ? true : false,
},
[SDXL_DENOISE_LATENTS]: { [SDXL_DENOISE_LATENTS]: {
type: 'denoise_latents', type: 'denoise_latents',
id: SDXL_DENOISE_LATENTS, id: SDXL_DENOISE_LATENTS,
@ -290,11 +298,22 @@ export const buildCanvasSDXLInpaintGraph = (
field: 'latents', field: 'latents',
}, },
}, },
// Create Inpaint Mask
{ {
source: { source: {
node_id: MASK_BLUR, node_id: MASK_BLUR,
field: 'image', field: 'image',
}, },
destination: {
node_id: INPAINT_CREATE_MASK,
field: 'mask',
},
},
{
source: {
node_id: INPAINT_CREATE_MASK,
field: 'inpaint_mask',
},
destination: { destination: {
node_id: SDXL_DENOISE_LATENTS, node_id: SDXL_DENOISE_LATENTS,
field: 'mask', field: 'mask',
@ -473,6 +492,16 @@ export const buildCanvasSDXLInpaintGraph = (
field: 'image', field: 'image',
}, },
}, },
{
source: {
node_id: INPAINT_IMAGE_RESIZE_UP,
field: 'image',
},
destination: {
node_id: INPAINT_CREATE_MASK,
field: 'image',
},
},
// Color Correct The Inpainted Result // Color Correct The Inpainted Result
{ {
source: { source: {
@ -530,6 +559,10 @@ export const buildCanvasSDXLInpaintGraph = (
...(graph.nodes[MASK_BLUR] as ImageBlurInvocation), ...(graph.nodes[MASK_BLUR] as ImageBlurInvocation),
image: canvasMaskImage, image: canvasMaskImage,
}; };
graph.nodes[INPAINT_CREATE_MASK] = {
...(graph.nodes[INPAINT_CREATE_MASK] as CreateInpaintMaskInvocation),
image: canvasInitImage,
};
graph.edges.push( graph.edges.push(
// Color Correct The Inpainted Result // Color Correct The Inpainted Result

View File

@ -18,10 +18,11 @@ import { addSDXLRefinerToGraph } from './addSDXLRefinerToGraph';
import { addVAEToGraph } from './addVAEToGraph'; import { addVAEToGraph } from './addVAEToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph'; import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import { import {
CANVAS_OUTPUT,
CANVAS_COHERENCE_DENOISE_LATENTS, CANVAS_COHERENCE_DENOISE_LATENTS,
CANVAS_COHERENCE_NOISE, CANVAS_COHERENCE_NOISE,
CANVAS_COHERENCE_NOISE_INCREMENT, CANVAS_COHERENCE_NOISE_INCREMENT,
CANVAS_OUTPUT,
INPAINT_CREATE_MASK,
INPAINT_IMAGE, INPAINT_IMAGE,
INPAINT_IMAGE_RESIZE_DOWN, INPAINT_IMAGE_RESIZE_DOWN,
INPAINT_IMAGE_RESIZE_UP, INPAINT_IMAGE_RESIZE_UP,
@ -156,6 +157,12 @@ export const buildCanvasSDXLOutpaintGraph = (
use_cpu, use_cpu,
is_intermediate: true, is_intermediate: true,
}, },
[INPAINT_CREATE_MASK]: {
type: 'create_inpaint_mask',
id: INPAINT_CREATE_MASK,
is_intermediate: true,
fp32: vaePrecision === 'fp32' ? true : false,
},
[SDXL_DENOISE_LATENTS]: { [SDXL_DENOISE_LATENTS]: {
type: 'denoise_latents', type: 'denoise_latents',
id: SDXL_DENOISE_LATENTS, id: SDXL_DENOISE_LATENTS,
@ -331,11 +338,22 @@ export const buildCanvasSDXLOutpaintGraph = (
field: 'latents', field: 'latents',
}, },
}, },
// Create Inpaint Mask
{ {
source: { source: {
node_id: MASK_BLUR, node_id: MASK_BLUR,
field: 'image', field: 'image',
}, },
destination: {
node_id: INPAINT_CREATE_MASK,
field: 'mask',
},
},
{
source: {
node_id: INPAINT_CREATE_MASK,
field: 'inpaint_mask',
},
destination: { destination: {
node_id: SDXL_DENOISE_LATENTS, node_id: SDXL_DENOISE_LATENTS,
field: 'mask', field: 'mask',
@ -537,6 +555,16 @@ export const buildCanvasSDXLOutpaintGraph = (
field: 'image', field: 'image',
}, },
}, },
{
source: {
node_id: INPAINT_INFILL,
field: 'image',
},
destination: {
node_id: INPAINT_CREATE_MASK,
field: 'image',
},
},
// Take combined mask and resize and then blur // Take combined mask and resize and then blur
{ {
source: { source: {
@ -655,6 +683,16 @@ export const buildCanvasSDXLOutpaintGraph = (
field: 'image', field: 'image',
}, },
}, },
{
source: {
node_id: INPAINT_INFILL,
field: 'image',
},
destination: {
node_id: INPAINT_CREATE_MASK,
field: 'image',
},
},
// Color Correct The Inpainted Result // Color Correct The Inpainted Result
{ {
source: { source: {

View File

@ -25,6 +25,7 @@ export const INPAINT_IMAGE_RESIZE_DOWN = 'inpaint_image_resize_down';
export const INPAINT_INFILL = 'inpaint_infill'; 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 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';

View File

@ -111,6 +111,7 @@ export type ImageBlurInvocation = s['ImageBlurInvocation'];
export type ImageScaleInvocation = s['ImageScaleInvocation']; 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 CreateInpaintMaskInvocation = s['CreateInpaintMaskInvocation'];
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'];