mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat: Add Refiner Pass to SDXL Outpainting
Also fix Scale Before Processing
This commit is contained in:
parent
0af8a0e84b
commit
8277bfab5e
@ -40,7 +40,6 @@ import {
|
|||||||
POSITIVE_CONDITIONING,
|
POSITIVE_CONDITIONING,
|
||||||
RANDOM_INT,
|
RANDOM_INT,
|
||||||
RANGE_OF_SIZE,
|
RANGE_OF_SIZE,
|
||||||
SEAM_MASK_RESIZE_UP,
|
|
||||||
} from './constants';
|
} from './constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -168,15 +167,6 @@ export const buildCanvasOutpaintGraph = (
|
|||||||
denoising_start: 1 - strength,
|
denoising_start: 1 - strength,
|
||||||
denoising_end: 1,
|
denoising_end: 1,
|
||||||
},
|
},
|
||||||
// [MASK_EDGE]: {
|
|
||||||
// type: 'mask_edge',
|
|
||||||
// id: MASK_EDGE,
|
|
||||||
// is_intermediate: true,
|
|
||||||
// edge_size: seamSize,
|
|
||||||
// edge_blur: seamBlur,
|
|
||||||
// low_threshold: seamLowThreshold,
|
|
||||||
// high_threshold: seamHighThreshold,
|
|
||||||
// },
|
|
||||||
[OUTPAINT_REFINE_DENOISE_LATENTS]: {
|
[OUTPAINT_REFINE_DENOISE_LATENTS]: {
|
||||||
type: 'denoise_latents',
|
type: 'denoise_latents',
|
||||||
id: OUTPAINT_REFINE_DENOISE_LATENTS,
|
id: OUTPAINT_REFINE_DENOISE_LATENTS,
|
||||||
@ -361,7 +351,6 @@ export const buildCanvasOutpaintGraph = (
|
|||||||
field: 'unet',
|
field: 'unet',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
source: {
|
source: {
|
||||||
node_id: POSITIVE_CONDITIONING,
|
node_id: POSITIVE_CONDITIONING,
|
||||||
@ -446,13 +435,6 @@ export const buildCanvasOutpaintGraph = (
|
|||||||
width: scaledWidth,
|
width: scaledWidth,
|
||||||
height: scaledHeight,
|
height: scaledHeight,
|
||||||
};
|
};
|
||||||
graph.nodes[SEAM_MASK_RESIZE_UP] = {
|
|
||||||
type: 'img_resize',
|
|
||||||
id: SEAM_MASK_RESIZE_UP,
|
|
||||||
is_intermediate: true,
|
|
||||||
width: scaledWidth,
|
|
||||||
height: scaledHeight,
|
|
||||||
};
|
|
||||||
graph.nodes[INPAINT_IMAGE_RESIZE_DOWN] = {
|
graph.nodes[INPAINT_IMAGE_RESIZE_DOWN] = {
|
||||||
type: 'img_resize',
|
type: 'img_resize',
|
||||||
id: INPAINT_IMAGE_RESIZE_DOWN,
|
id: INPAINT_IMAGE_RESIZE_DOWN,
|
||||||
|
@ -19,7 +19,6 @@ import { addVAEToGraph } from './addVAEToGraph';
|
|||||||
import { addWatermarkerToGraph } from './addWatermarkerToGraph';
|
import { addWatermarkerToGraph } from './addWatermarkerToGraph';
|
||||||
import {
|
import {
|
||||||
CANVAS_OUTPUT,
|
CANVAS_OUTPUT,
|
||||||
COLOR_CORRECT,
|
|
||||||
INPAINT_IMAGE,
|
INPAINT_IMAGE,
|
||||||
INPAINT_IMAGE_RESIZE_DOWN,
|
INPAINT_IMAGE_RESIZE_DOWN,
|
||||||
INPAINT_IMAGE_RESIZE_UP,
|
INPAINT_IMAGE_RESIZE_UP,
|
||||||
@ -29,20 +28,18 @@ import {
|
|||||||
LATENTS_TO_IMAGE,
|
LATENTS_TO_IMAGE,
|
||||||
MASK_BLUR,
|
MASK_BLUR,
|
||||||
MASK_COMBINE,
|
MASK_COMBINE,
|
||||||
MASK_EDGE,
|
|
||||||
MASK_FROM_ALPHA,
|
MASK_FROM_ALPHA,
|
||||||
MASK_RESIZE_DOWN,
|
MASK_RESIZE_DOWN,
|
||||||
MASK_RESIZE_UP,
|
MASK_RESIZE_UP,
|
||||||
NEGATIVE_CONDITIONING,
|
NEGATIVE_CONDITIONING,
|
||||||
NOISE,
|
NOISE,
|
||||||
|
OUTPAINT_REFINE_DENOISE_LATENTS,
|
||||||
POSITIVE_CONDITIONING,
|
POSITIVE_CONDITIONING,
|
||||||
RANDOM_INT,
|
RANDOM_INT,
|
||||||
RANGE_OF_SIZE,
|
RANGE_OF_SIZE,
|
||||||
SDXL_CANVAS_OUTPAINT_GRAPH,
|
SDXL_CANVAS_OUTPAINT_GRAPH,
|
||||||
SDXL_DENOISE_LATENTS,
|
SDXL_DENOISE_LATENTS,
|
||||||
SDXL_MODEL_LOADER,
|
SDXL_MODEL_LOADER,
|
||||||
SEAM_FIX_DENOISE_LATENTS,
|
|
||||||
SEAM_MASK_RESIZE_UP,
|
|
||||||
} from './constants';
|
} from './constants';
|
||||||
import { craftSDXLStylePrompt } from './helpers/craftSDXLStylePrompt';
|
import { craftSDXLStylePrompt } from './helpers/craftSDXLStylePrompt';
|
||||||
|
|
||||||
@ -70,12 +67,8 @@ export const buildCanvasSDXLOutpaintGraph = (
|
|||||||
shouldUseCpuNoise,
|
shouldUseCpuNoise,
|
||||||
maskBlur,
|
maskBlur,
|
||||||
maskBlurMethod,
|
maskBlurMethod,
|
||||||
seamSize,
|
refineSteps,
|
||||||
seamBlur,
|
refineStrength,
|
||||||
seamSteps,
|
|
||||||
seamStrength,
|
|
||||||
seamLowThreshold,
|
|
||||||
seamHighThreshold,
|
|
||||||
tileSize,
|
tileSize,
|
||||||
infillMethod,
|
infillMethod,
|
||||||
} = state.generation;
|
} = state.generation;
|
||||||
@ -179,23 +172,14 @@ export const buildCanvasSDXLOutpaintGraph = (
|
|||||||
: 1 - strength,
|
: 1 - strength,
|
||||||
denoising_end: shouldUseSDXLRefiner ? refinerStart : 1,
|
denoising_end: shouldUseSDXLRefiner ? refinerStart : 1,
|
||||||
},
|
},
|
||||||
[MASK_EDGE]: {
|
[OUTPAINT_REFINE_DENOISE_LATENTS]: {
|
||||||
type: 'mask_edge',
|
|
||||||
id: MASK_EDGE,
|
|
||||||
is_intermediate: true,
|
|
||||||
edge_size: seamSize,
|
|
||||||
edge_blur: seamBlur,
|
|
||||||
low_threshold: seamLowThreshold,
|
|
||||||
high_threshold: seamHighThreshold,
|
|
||||||
},
|
|
||||||
[SEAM_FIX_DENOISE_LATENTS]: {
|
|
||||||
type: 'denoise_latents',
|
type: 'denoise_latents',
|
||||||
id: SEAM_FIX_DENOISE_LATENTS,
|
id: OUTPAINT_REFINE_DENOISE_LATENTS,
|
||||||
is_intermediate: true,
|
is_intermediate: true,
|
||||||
steps: seamSteps,
|
steps: refineSteps,
|
||||||
cfg_scale: cfg_scale,
|
cfg_scale: cfg_scale,
|
||||||
scheduler: scheduler,
|
scheduler: scheduler,
|
||||||
denoising_start: 1 - seamStrength,
|
denoising_start: 1 - refineStrength,
|
||||||
denoising_end: 1,
|
denoising_end: 1,
|
||||||
},
|
},
|
||||||
[LATENTS_TO_IMAGE]: {
|
[LATENTS_TO_IMAGE]: {
|
||||||
@ -204,13 +188,8 @@ export const buildCanvasSDXLOutpaintGraph = (
|
|||||||
is_intermediate: true,
|
is_intermediate: true,
|
||||||
fp32: vaePrecision === 'fp32' ? true : false,
|
fp32: vaePrecision === 'fp32' ? true : false,
|
||||||
},
|
},
|
||||||
[COLOR_CORRECT]: {
|
|
||||||
type: 'color_correct',
|
|
||||||
id: COLOR_CORRECT,
|
|
||||||
is_intermediate: true,
|
|
||||||
},
|
|
||||||
[CANVAS_OUTPUT]: {
|
[CANVAS_OUTPUT]: {
|
||||||
type: 'img_paste',
|
type: 'color_correct',
|
||||||
id: CANVAS_OUTPUT,
|
id: CANVAS_OUTPUT,
|
||||||
is_intermediate: !shouldAutoSave,
|
is_intermediate: !shouldAutoSave,
|
||||||
},
|
},
|
||||||
@ -375,14 +354,14 @@ export const buildCanvasSDXLOutpaintGraph = (
|
|||||||
field: 'seed',
|
field: 'seed',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// Seam Paint
|
// Image To Image Clean Up
|
||||||
{
|
{
|
||||||
source: {
|
source: {
|
||||||
node_id: SDXL_MODEL_LOADER,
|
node_id: SDXL_MODEL_LOADER,
|
||||||
field: 'unet',
|
field: 'unet',
|
||||||
},
|
},
|
||||||
destination: {
|
destination: {
|
||||||
node_id: SEAM_FIX_DENOISE_LATENTS,
|
node_id: OUTPAINT_REFINE_DENOISE_LATENTS,
|
||||||
field: 'unet',
|
field: 'unet',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -392,7 +371,7 @@ export const buildCanvasSDXLOutpaintGraph = (
|
|||||||
field: 'conditioning',
|
field: 'conditioning',
|
||||||
},
|
},
|
||||||
destination: {
|
destination: {
|
||||||
node_id: SEAM_FIX_DENOISE_LATENTS,
|
node_id: OUTPAINT_REFINE_DENOISE_LATENTS,
|
||||||
field: 'positive_conditioning',
|
field: 'positive_conditioning',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -402,7 +381,7 @@ export const buildCanvasSDXLOutpaintGraph = (
|
|||||||
field: 'conditioning',
|
field: 'conditioning',
|
||||||
},
|
},
|
||||||
destination: {
|
destination: {
|
||||||
node_id: SEAM_FIX_DENOISE_LATENTS,
|
node_id: OUTPAINT_REFINE_DENOISE_LATENTS,
|
||||||
field: 'negative_conditioning',
|
field: 'negative_conditioning',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -412,7 +391,7 @@ export const buildCanvasSDXLOutpaintGraph = (
|
|||||||
field: 'noise',
|
field: 'noise',
|
||||||
},
|
},
|
||||||
destination: {
|
destination: {
|
||||||
node_id: SEAM_FIX_DENOISE_LATENTS,
|
node_id: OUTPAINT_REFINE_DENOISE_LATENTS,
|
||||||
field: 'noise',
|
field: 'noise',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -422,14 +401,14 @@ export const buildCanvasSDXLOutpaintGraph = (
|
|||||||
field: 'latents',
|
field: 'latents',
|
||||||
},
|
},
|
||||||
destination: {
|
destination: {
|
||||||
node_id: SEAM_FIX_DENOISE_LATENTS,
|
node_id: OUTPAINT_REFINE_DENOISE_LATENTS,
|
||||||
field: 'latents',
|
field: 'latents',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// Decode inpainted latents to image
|
// Decode inpainted latents to image
|
||||||
{
|
{
|
||||||
source: {
|
source: {
|
||||||
node_id: SEAM_FIX_DENOISE_LATENTS,
|
node_id: OUTPAINT_REFINE_DENOISE_LATENTS,
|
||||||
field: 'latents',
|
field: 'latents',
|
||||||
},
|
},
|
||||||
destination: {
|
destination: {
|
||||||
@ -471,13 +450,6 @@ export const buildCanvasSDXLOutpaintGraph = (
|
|||||||
width: scaledWidth,
|
width: scaledWidth,
|
||||||
height: scaledHeight,
|
height: scaledHeight,
|
||||||
};
|
};
|
||||||
graph.nodes[SEAM_MASK_RESIZE_UP] = {
|
|
||||||
type: 'img_resize',
|
|
||||||
id: SEAM_MASK_RESIZE_UP,
|
|
||||||
is_intermediate: true,
|
|
||||||
width: scaledWidth,
|
|
||||||
height: scaledHeight,
|
|
||||||
};
|
|
||||||
graph.nodes[INPAINT_IMAGE_RESIZE_DOWN] = {
|
graph.nodes[INPAINT_IMAGE_RESIZE_DOWN] = {
|
||||||
type: 'img_resize',
|
type: 'img_resize',
|
||||||
id: INPAINT_IMAGE_RESIZE_DOWN,
|
id: INPAINT_IMAGE_RESIZE_DOWN,
|
||||||
@ -540,37 +512,6 @@ export const buildCanvasSDXLOutpaintGraph = (
|
|||||||
field: 'image',
|
field: 'image',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// Seam Paint Mask
|
|
||||||
{
|
|
||||||
source: {
|
|
||||||
node_id: MASK_FROM_ALPHA,
|
|
||||||
field: 'image',
|
|
||||||
},
|
|
||||||
destination: {
|
|
||||||
node_id: MASK_EDGE,
|
|
||||||
field: 'image',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
source: {
|
|
||||||
node_id: MASK_EDGE,
|
|
||||||
field: 'image',
|
|
||||||
},
|
|
||||||
destination: {
|
|
||||||
node_id: SEAM_MASK_RESIZE_UP,
|
|
||||||
field: 'image',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
source: {
|
|
||||||
node_id: SEAM_MASK_RESIZE_UP,
|
|
||||||
field: 'image',
|
|
||||||
},
|
|
||||||
destination: {
|
|
||||||
node_id: SEAM_FIX_DENOISE_LATENTS,
|
|
||||||
field: 'mask',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// Resize Results Down
|
// Resize Results Down
|
||||||
{
|
{
|
||||||
source: {
|
source: {
|
||||||
@ -609,7 +550,7 @@ export const buildCanvasSDXLOutpaintGraph = (
|
|||||||
field: 'image',
|
field: 'image',
|
||||||
},
|
},
|
||||||
destination: {
|
destination: {
|
||||||
node_id: COLOR_CORRECT,
|
node_id: CANVAS_OUTPUT,
|
||||||
field: 'reference',
|
field: 'reference',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -618,37 +559,6 @@ export const buildCanvasSDXLOutpaintGraph = (
|
|||||||
node_id: INPAINT_IMAGE_RESIZE_DOWN,
|
node_id: INPAINT_IMAGE_RESIZE_DOWN,
|
||||||
field: 'image',
|
field: 'image',
|
||||||
},
|
},
|
||||||
destination: {
|
|
||||||
node_id: COLOR_CORRECT,
|
|
||||||
field: 'image',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
source: {
|
|
||||||
node_id: MASK_RESIZE_DOWN,
|
|
||||||
field: 'image',
|
|
||||||
},
|
|
||||||
destination: {
|
|
||||||
node_id: COLOR_CORRECT,
|
|
||||||
field: 'mask',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// Paste Everything Back
|
|
||||||
{
|
|
||||||
source: {
|
|
||||||
node_id: INPAINT_INFILL_RESIZE_DOWN,
|
|
||||||
field: 'image',
|
|
||||||
},
|
|
||||||
destination: {
|
|
||||||
node_id: CANVAS_OUTPUT,
|
|
||||||
field: 'base_image',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
source: {
|
|
||||||
node_id: COLOR_CORRECT,
|
|
||||||
field: 'image',
|
|
||||||
},
|
|
||||||
destination: {
|
destination: {
|
||||||
node_id: CANVAS_OUTPUT,
|
node_id: CANVAS_OUTPUT,
|
||||||
field: 'image',
|
field: 'image',
|
||||||
@ -698,27 +608,6 @@ export const buildCanvasSDXLOutpaintGraph = (
|
|||||||
field: 'image',
|
field: 'image',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// Seam Paint Mask
|
|
||||||
{
|
|
||||||
source: {
|
|
||||||
node_id: MASK_FROM_ALPHA,
|
|
||||||
field: 'image',
|
|
||||||
},
|
|
||||||
destination: {
|
|
||||||
node_id: MASK_EDGE,
|
|
||||||
field: 'image',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
source: {
|
|
||||||
node_id: MASK_EDGE,
|
|
||||||
field: 'image',
|
|
||||||
},
|
|
||||||
destination: {
|
|
||||||
node_id: SEAM_FIX_DENOISE_LATENTS,
|
|
||||||
field: 'mask',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// Color Correct The Inpainted Result
|
// Color Correct The Inpainted Result
|
||||||
{
|
{
|
||||||
source: {
|
source: {
|
||||||
@ -726,7 +615,7 @@ export const buildCanvasSDXLOutpaintGraph = (
|
|||||||
field: 'image',
|
field: 'image',
|
||||||
},
|
},
|
||||||
destination: {
|
destination: {
|
||||||
node_id: COLOR_CORRECT,
|
node_id: CANVAS_OUTPUT,
|
||||||
field: 'reference',
|
field: 'reference',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -735,37 +624,6 @@ export const buildCanvasSDXLOutpaintGraph = (
|
|||||||
node_id: LATENTS_TO_IMAGE,
|
node_id: LATENTS_TO_IMAGE,
|
||||||
field: 'image',
|
field: 'image',
|
||||||
},
|
},
|
||||||
destination: {
|
|
||||||
node_id: COLOR_CORRECT,
|
|
||||||
field: 'image',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
source: {
|
|
||||||
node_id: MASK_BLUR,
|
|
||||||
field: 'image',
|
|
||||||
},
|
|
||||||
destination: {
|
|
||||||
node_id: COLOR_CORRECT,
|
|
||||||
field: 'mask',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// Paste Everything Back
|
|
||||||
{
|
|
||||||
source: {
|
|
||||||
node_id: INPAINT_INFILL,
|
|
||||||
field: 'image',
|
|
||||||
},
|
|
||||||
destination: {
|
|
||||||
node_id: CANVAS_OUTPUT,
|
|
||||||
field: 'base_image',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
source: {
|
|
||||||
node_id: COLOR_CORRECT,
|
|
||||||
field: 'image',
|
|
||||||
},
|
|
||||||
destination: {
|
destination: {
|
||||||
node_id: CANVAS_OUTPUT,
|
node_id: CANVAS_OUTPUT,
|
||||||
field: 'image',
|
field: 'image',
|
||||||
@ -806,7 +664,7 @@ export const buildCanvasSDXLOutpaintGraph = (
|
|||||||
|
|
||||||
// Add Refiner if enabled
|
// Add Refiner if enabled
|
||||||
if (shouldUseSDXLRefiner) {
|
if (shouldUseSDXLRefiner) {
|
||||||
addSDXLRefinerToGraph(state, graph, SEAM_FIX_DENOISE_LATENTS);
|
addSDXLRefinerToGraph(state, graph, OUTPAINT_REFINE_DENOISE_LATENTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// optionally add custom VAE
|
// optionally add custom VAE
|
||||||
|
@ -25,14 +25,12 @@ 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 SEAM_FIX_DENOISE_LATENTS = 'seam_fix_denoise_latents';
|
|
||||||
export const OUTPAINT_REFINE_DENOISE_LATENTS =
|
export const OUTPAINT_REFINE_DENOISE_LATENTS =
|
||||||
'outpaint_refine_denoise_latents';
|
'outpaint_refine_denoise_latents';
|
||||||
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';
|
||||||
export const MASK_COMBINE = 'mask_combine';
|
export const MASK_COMBINE = 'mask_combine';
|
||||||
export const SEAM_MASK_RESIZE_UP = 'seam_mask_resize_up';
|
|
||||||
export const MASK_RESIZE_UP = 'mask_resize_up';
|
export const MASK_RESIZE_UP = 'mask_resize_up';
|
||||||
export const MASK_RESIZE_DOWN = 'mask_resize_down';
|
export const MASK_RESIZE_DOWN = 'mask_resize_down';
|
||||||
export const COLOR_CORRECT = 'color_correct';
|
export const COLOR_CORRECT = 'color_correct';
|
||||||
|
Loading…
Reference in New Issue
Block a user