diff --git a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasInpaintGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasInpaintGraph.ts index 817e8d5176..968e32efe9 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasInpaintGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/buildCanvasInpaintGraph.ts @@ -3,6 +3,8 @@ import { RootState } from 'app/store/store'; import { NonNullableGraph } from 'features/nodes/types/types'; import { ImageDTO, + InfillPatchmatchInvocation, + InfillTileInvocation, RandomIntInvocation, RangeOfSizeInvocation, } from 'services/api/types'; @@ -18,6 +20,7 @@ import { INPAINT_FINAL_IMAGE, INPAINT_GRAPH, INPAINT_IMAGE, + INPAINT_INFILL, ITERATE, LATENTS_TO_IMAGE, MAIN_MODEL_LOADER, @@ -60,6 +63,8 @@ export const buildCanvasInpaintGraph = ( clipSkip, } = state.generation; + const { generationMode } = state.canvas; + if (!model) { log.error('No model found in state'); throw new Error('No model found in state'); @@ -79,6 +84,23 @@ export const buildCanvasInpaintGraph = ( ? shouldUseCpuNoise : shouldUseCpuNoise; + let infillNode: InfillTileInvocation | InfillPatchmatchInvocation = { + type: 'infill_tile', + id: INPAINT_INFILL, + is_intermediate: true, + image: canvasInitImage, + tile_size: tileSize, + }; + + if (infillMethod === 'patchmatch') { + infillNode = { + type: 'infill_patchmatch', + id: INPAINT_INFILL, + is_intermediate: true, + image: canvasInitImage, + }; + } + const graph: NonNullableGraph = { id: INPAINT_GRAPH, nodes: { @@ -92,11 +114,11 @@ export const buildCanvasInpaintGraph = ( denoising_start: 1 - strength, denoising_end: 1, }, + [infillNode.id]: infillNode, [INPAINT_IMAGE]: { type: 'i2l', id: INPAINT_IMAGE, is_intermediate: true, - image: canvasInitImage, fp32: vaePrecision === 'fp32' ? true : false, }, [NOISE]: { @@ -244,6 +266,16 @@ export const buildCanvasInpaintGraph = ( field: 'noise', }, }, + { + source: { + node_id: INPAINT_INFILL, + field: 'image', + }, + destination: { + node_id: INPAINT_IMAGE, + field: 'image', + }, + }, { source: { node_id: INPAINT_IMAGE, diff --git a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/constants.ts b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/constants.ts index 6a66093da0..b75dfbf4c6 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graphBuilders/constants.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graphBuilders/constants.ts @@ -20,7 +20,7 @@ export const RESIZE = 'resize_image'; export const INPAINT = 'inpaint'; export const INPAINT_SEAM_FIX = 'inpaint_seam_fix'; export const INPAINT_IMAGE = 'inpaint_image'; -export const INFILL_TILE = 'infill_tile'; +export const INPAINT_INFILL = 'inpaint_infill'; export const INPAINT_FINAL_IMAGE = 'inpaint_final_image'; export const MASK_FROM_ALPHA = 'tomask'; export const MASK_EDGE = 'mask_edge'; diff --git a/invokeai/frontend/web/src/services/api/types.ts b/invokeai/frontend/web/src/services/api/types.ts index 7c8f0908b0..471c995f4d 100644 --- a/invokeai/frontend/web/src/services/api/types.ts +++ b/invokeai/frontend/web/src/services/api/types.ts @@ -172,6 +172,12 @@ export type ESRGANInvocation = TypeReq< export type DivideInvocation = TypeReq< components['schemas']['DivideInvocation'] >; +export type InfillTileInvocation = TypeReq< + components['schemas']['InfillTileInvocation'] +>; +export type InfillPatchmatchInvocation = TypeReq< + components['schemas']['InfillPatchMatchInvocation'] +>; export type ImageNSFWBlurInvocation = TypeReq< components['schemas']['ImageNSFWBlurInvocation'] >;