feat: Add Seamless to Inpaint & Outpaint

This commit is contained in:
blessedcoolant 2023-08-29 05:11:22 +12:00
parent 87bb4d8f6e
commit 50a266e064
4 changed files with 90 additions and 28 deletions

View File

@ -13,6 +13,7 @@ import {
import { addControlNetToLinearGraph } from './addControlNetToLinearGraph'; import { addControlNetToLinearGraph } from './addControlNetToLinearGraph';
import { addLoRAsToGraph } from './addLoRAsToGraph'; import { addLoRAsToGraph } from './addLoRAsToGraph';
import { addNSFWCheckerToGraph } from './addNSFWCheckerToGraph'; import { addNSFWCheckerToGraph } from './addNSFWCheckerToGraph';
import { addSeamlessToLinearGraph } from './addSeamlessToLinearGraph';
import { addVAEToGraph } from './addVAEToGraph'; import { addVAEToGraph } from './addVAEToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph'; import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import { import {
@ -38,6 +39,7 @@ import {
POSITIVE_CONDITIONING, POSITIVE_CONDITIONING,
RANDOM_INT, RANDOM_INT,
RANGE_OF_SIZE, RANGE_OF_SIZE,
SEAMLESS,
} from './constants'; } from './constants';
/** /**
@ -68,6 +70,8 @@ export const buildCanvasInpaintGraph = (
canvasCoherenceSteps, canvasCoherenceSteps,
canvasCoherenceStrength, canvasCoherenceStrength,
clipSkip, clipSkip,
seamlessXAxis,
seamlessYAxis,
} = state.generation; } = state.generation;
if (!model) { if (!model) {
@ -85,6 +89,8 @@ export const buildCanvasInpaintGraph = (
shouldAutoSave, shouldAutoSave,
} = state.canvas; } = state.canvas;
let modelLoaderNodeId = MAIN_MODEL_LOADER;
const use_cpu = shouldUseNoiseSettings const use_cpu = shouldUseNoiseSettings
? shouldUseCpuNoise ? shouldUseCpuNoise
: shouldUseCpuNoise; : shouldUseCpuNoise;
@ -92,9 +98,9 @@ export const buildCanvasInpaintGraph = (
const graph: NonNullableGraph = { const graph: NonNullableGraph = {
id: CANVAS_INPAINT_GRAPH, id: CANVAS_INPAINT_GRAPH,
nodes: { nodes: {
[MAIN_MODEL_LOADER]: { [modelLoaderNodeId]: {
type: 'main_model_loader', type: 'main_model_loader',
id: MAIN_MODEL_LOADER, id: modelLoaderNodeId,
is_intermediate: true, is_intermediate: true,
model, model,
}, },
@ -204,7 +210,7 @@ export const buildCanvasInpaintGraph = (
// Connect Model Loader to CLIP Skip and UNet // Connect Model Loader to CLIP Skip and UNet
{ {
source: { source: {
node_id: MAIN_MODEL_LOADER, node_id: modelLoaderNodeId,
field: 'unet', field: 'unet',
}, },
destination: { destination: {
@ -214,7 +220,7 @@ export const buildCanvasInpaintGraph = (
}, },
{ {
source: { source: {
node_id: MAIN_MODEL_LOADER, node_id: modelLoaderNodeId,
field: 'clip', field: 'clip',
}, },
destination: { destination: {
@ -349,7 +355,7 @@ export const buildCanvasInpaintGraph = (
}, },
{ {
source: { source: {
node_id: MAIN_MODEL_LOADER, node_id: modelLoaderNodeId,
field: 'unet', field: 'unet',
}, },
destination: { destination: {
@ -595,11 +601,17 @@ export const buildCanvasInpaintGraph = (
(graph.nodes[RANGE_OF_SIZE] as RangeOfSizeInvocation).start = seed; (graph.nodes[RANGE_OF_SIZE] as RangeOfSizeInvocation).start = seed;
} }
// Add Seamless To Graph
if (seamlessXAxis || seamlessYAxis) {
addSeamlessToLinearGraph(state, graph, modelLoaderNodeId);
modelLoaderNodeId = SEAMLESS;
}
// Add VAE // Add VAE
addVAEToGraph(state, graph, MAIN_MODEL_LOADER); addVAEToGraph(state, graph, modelLoaderNodeId);
// add LoRA support // add LoRA support
addLoRAsToGraph(state, graph, DENOISE_LATENTS, MAIN_MODEL_LOADER); addLoRAsToGraph(state, graph, DENOISE_LATENTS, modelLoaderNodeId);
// add controlnet, mutating `graph` // add controlnet, mutating `graph`
addControlNetToLinearGraph(state, graph, DENOISE_LATENTS); addControlNetToLinearGraph(state, graph, DENOISE_LATENTS);

View File

@ -14,6 +14,7 @@ import {
import { addControlNetToLinearGraph } from './addControlNetToLinearGraph'; import { addControlNetToLinearGraph } from './addControlNetToLinearGraph';
import { addLoRAsToGraph } from './addLoRAsToGraph'; import { addLoRAsToGraph } from './addLoRAsToGraph';
import { addNSFWCheckerToGraph } from './addNSFWCheckerToGraph'; import { addNSFWCheckerToGraph } from './addNSFWCheckerToGraph';
import { addSeamlessToLinearGraph } from './addSeamlessToLinearGraph';
import { addVAEToGraph } from './addVAEToGraph'; import { addVAEToGraph } from './addVAEToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph'; import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import { import {
@ -43,6 +44,7 @@ import {
POSITIVE_CONDITIONING, POSITIVE_CONDITIONING,
RANDOM_INT, RANDOM_INT,
RANGE_OF_SIZE, RANGE_OF_SIZE,
SEAMLESS,
} from './constants'; } from './constants';
/** /**
@ -75,6 +77,8 @@ export const buildCanvasOutpaintGraph = (
tileSize, tileSize,
infillMethod, infillMethod,
clipSkip, clipSkip,
seamlessXAxis,
seamlessYAxis,
} = state.generation; } = state.generation;
if (!model) { if (!model) {
@ -92,6 +96,8 @@ export const buildCanvasOutpaintGraph = (
shouldAutoSave, shouldAutoSave,
} = state.canvas; } = state.canvas;
let modelLoaderNodeId = MAIN_MODEL_LOADER;
const use_cpu = shouldUseNoiseSettings const use_cpu = shouldUseNoiseSettings
? shouldUseCpuNoise ? shouldUseCpuNoise
: shouldUseCpuNoise; : shouldUseCpuNoise;
@ -99,9 +105,9 @@ export const buildCanvasOutpaintGraph = (
const graph: NonNullableGraph = { const graph: NonNullableGraph = {
id: CANVAS_OUTPAINT_GRAPH, id: CANVAS_OUTPAINT_GRAPH,
nodes: { nodes: {
[MAIN_MODEL_LOADER]: { [modelLoaderNodeId]: {
type: 'main_model_loader', type: 'main_model_loader',
id: MAIN_MODEL_LOADER, id: modelLoaderNodeId,
is_intermediate: true, is_intermediate: true,
model, model,
}, },
@ -222,7 +228,7 @@ export const buildCanvasOutpaintGraph = (
// Connect Model Loader To UNet & Clip Skip // Connect Model Loader To UNet & Clip Skip
{ {
source: { source: {
node_id: MAIN_MODEL_LOADER, node_id: modelLoaderNodeId,
field: 'unet', field: 'unet',
}, },
destination: { destination: {
@ -232,7 +238,7 @@ export const buildCanvasOutpaintGraph = (
}, },
{ {
source: { source: {
node_id: MAIN_MODEL_LOADER, node_id: modelLoaderNodeId,
field: 'clip', field: 'clip',
}, },
destination: { destination: {
@ -389,7 +395,7 @@ export const buildCanvasOutpaintGraph = (
}, },
{ {
source: { source: {
node_id: MAIN_MODEL_LOADER, node_id: modelLoaderNodeId,
field: 'unet', field: 'unet',
}, },
destination: { destination: {
@ -732,11 +738,17 @@ export const buildCanvasOutpaintGraph = (
(graph.nodes[RANGE_OF_SIZE] as RangeOfSizeInvocation).start = seed; (graph.nodes[RANGE_OF_SIZE] as RangeOfSizeInvocation).start = seed;
} }
// Add Seamless To Graph
if (seamlessXAxis || seamlessYAxis) {
addSeamlessToLinearGraph(state, graph, modelLoaderNodeId);
modelLoaderNodeId = SEAMLESS;
}
// Add VAE // Add VAE
addVAEToGraph(state, graph, MAIN_MODEL_LOADER); addVAEToGraph(state, graph, modelLoaderNodeId);
// add LoRA support // add LoRA support
addLoRAsToGraph(state, graph, DENOISE_LATENTS, MAIN_MODEL_LOADER); addLoRAsToGraph(state, graph, DENOISE_LATENTS, modelLoaderNodeId);
// add controlnet, mutating `graph` // add controlnet, mutating `graph`
addControlNetToLinearGraph(state, graph, DENOISE_LATENTS); addControlNetToLinearGraph(state, graph, DENOISE_LATENTS);

View File

@ -14,6 +14,7 @@ import { addControlNetToLinearGraph } from './addControlNetToLinearGraph';
import { addNSFWCheckerToGraph } from './addNSFWCheckerToGraph'; import { addNSFWCheckerToGraph } from './addNSFWCheckerToGraph';
import { addSDXLLoRAsToGraph } from './addSDXLLoRAstoGraph'; import { addSDXLLoRAsToGraph } from './addSDXLLoRAstoGraph';
import { addSDXLRefinerToGraph } from './addSDXLRefinerToGraph'; import { addSDXLRefinerToGraph } from './addSDXLRefinerToGraph';
import { addSeamlessToLinearGraph } from './addSeamlessToLinearGraph';
import { addVAEToGraph } from './addVAEToGraph'; import { addVAEToGraph } from './addVAEToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph'; import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import { import {
@ -35,9 +36,11 @@ import {
POSITIVE_CONDITIONING, POSITIVE_CONDITIONING,
RANDOM_INT, RANDOM_INT,
RANGE_OF_SIZE, RANGE_OF_SIZE,
REFINER_SEAMLESS,
SDXL_CANVAS_INPAINT_GRAPH, SDXL_CANVAS_INPAINT_GRAPH,
SDXL_DENOISE_LATENTS, SDXL_DENOISE_LATENTS,
SDXL_MODEL_LOADER, SDXL_MODEL_LOADER,
SEAMLESS,
} from './constants'; } from './constants';
import { craftSDXLStylePrompt } from './helpers/craftSDXLStylePrompt'; import { craftSDXLStylePrompt } from './helpers/craftSDXLStylePrompt';
@ -67,6 +70,8 @@ export const buildCanvasSDXLInpaintGraph = (
maskBlurMethod, maskBlurMethod,
canvasCoherenceSteps, canvasCoherenceSteps,
canvasCoherenceStrength, canvasCoherenceStrength,
seamlessXAxis,
seamlessYAxis,
} = state.generation; } = state.generation;
const { const {
@ -91,6 +96,8 @@ export const buildCanvasSDXLInpaintGraph = (
shouldAutoSave, shouldAutoSave,
} = state.canvas; } = state.canvas;
let modelLoaderNodeId = SDXL_MODEL_LOADER;
const use_cpu = shouldUseNoiseSettings const use_cpu = shouldUseNoiseSettings
? shouldUseCpuNoise ? shouldUseCpuNoise
: shouldUseCpuNoise; : shouldUseCpuNoise;
@ -102,9 +109,9 @@ export const buildCanvasSDXLInpaintGraph = (
const graph: NonNullableGraph = { const graph: NonNullableGraph = {
id: SDXL_CANVAS_INPAINT_GRAPH, id: SDXL_CANVAS_INPAINT_GRAPH,
nodes: { nodes: {
[SDXL_MODEL_LOADER]: { [modelLoaderNodeId]: {
type: 'sdxl_model_loader', type: 'sdxl_model_loader',
id: SDXL_MODEL_LOADER, id: modelLoaderNodeId,
model, model,
}, },
[POSITIVE_CONDITIONING]: { [POSITIVE_CONDITIONING]: {
@ -209,7 +216,7 @@ export const buildCanvasSDXLInpaintGraph = (
// Connect Model Loader to UNet and CLIP // Connect Model Loader to UNet and CLIP
{ {
source: { source: {
node_id: SDXL_MODEL_LOADER, node_id: modelLoaderNodeId,
field: 'unet', field: 'unet',
}, },
destination: { destination: {
@ -219,7 +226,7 @@ export const buildCanvasSDXLInpaintGraph = (
}, },
{ {
source: { source: {
node_id: SDXL_MODEL_LOADER, node_id: modelLoaderNodeId,
field: 'clip', field: 'clip',
}, },
destination: { destination: {
@ -229,7 +236,7 @@ export const buildCanvasSDXLInpaintGraph = (
}, },
{ {
source: { source: {
node_id: SDXL_MODEL_LOADER, node_id: modelLoaderNodeId,
field: 'clip2', field: 'clip2',
}, },
destination: { destination: {
@ -239,7 +246,7 @@ export const buildCanvasSDXLInpaintGraph = (
}, },
{ {
source: { source: {
node_id: SDXL_MODEL_LOADER, node_id: modelLoaderNodeId,
field: 'clip', field: 'clip',
}, },
destination: { destination: {
@ -249,7 +256,7 @@ export const buildCanvasSDXLInpaintGraph = (
}, },
{ {
source: { source: {
node_id: SDXL_MODEL_LOADER, node_id: modelLoaderNodeId,
field: 'clip2', field: 'clip2',
}, },
destination: { destination: {
@ -363,7 +370,7 @@ export const buildCanvasSDXLInpaintGraph = (
}, },
{ {
source: { source: {
node_id: SDXL_MODEL_LOADER, node_id: modelLoaderNodeId,
field: 'unet', field: 'unet',
}, },
destination: { destination: {
@ -609,16 +616,28 @@ export const buildCanvasSDXLInpaintGraph = (
(graph.nodes[RANGE_OF_SIZE] as RangeOfSizeInvocation).start = seed; (graph.nodes[RANGE_OF_SIZE] as RangeOfSizeInvocation).start = seed;
} }
// Add Seamless To Graph
if (seamlessXAxis || seamlessYAxis) {
addSeamlessToLinearGraph(state, graph, modelLoaderNodeId);
modelLoaderNodeId = SEAMLESS;
}
// Add Refiner if enabled // Add Refiner if enabled
if (shouldUseSDXLRefiner) { if (shouldUseSDXLRefiner) {
addSDXLRefinerToGraph(state, graph, CANVAS_COHERENCE_DENOISE_LATENTS); addSDXLRefinerToGraph(
state,
graph,
CANVAS_COHERENCE_DENOISE_LATENTS,
modelLoaderNodeId
);
modelLoaderNodeId = REFINER_SEAMLESS;
} }
// optionally add custom VAE // optionally add custom VAE
addVAEToGraph(state, graph, SDXL_MODEL_LOADER); addVAEToGraph(state, graph, modelLoaderNodeId);
// add LoRA support // add LoRA support
addSDXLLoRAsToGraph(state, graph, SDXL_DENOISE_LATENTS, SDXL_MODEL_LOADER); addSDXLLoRAsToGraph(state, graph, SDXL_DENOISE_LATENTS, modelLoaderNodeId);
// add controlnet, mutating `graph` // add controlnet, mutating `graph`
addControlNetToLinearGraph(state, graph, SDXL_DENOISE_LATENTS); addControlNetToLinearGraph(state, graph, SDXL_DENOISE_LATENTS);

View File

@ -15,6 +15,7 @@ import { addControlNetToLinearGraph } from './addControlNetToLinearGraph';
import { addNSFWCheckerToGraph } from './addNSFWCheckerToGraph'; import { addNSFWCheckerToGraph } from './addNSFWCheckerToGraph';
import { addSDXLLoRAsToGraph } from './addSDXLLoRAstoGraph'; import { addSDXLLoRAsToGraph } from './addSDXLLoRAstoGraph';
import { addSDXLRefinerToGraph } from './addSDXLRefinerToGraph'; import { addSDXLRefinerToGraph } from './addSDXLRefinerToGraph';
import { addSeamlessToLinearGraph } from './addSeamlessToLinearGraph';
import { addVAEToGraph } from './addVAEToGraph'; import { addVAEToGraph } from './addVAEToGraph';
import { addWatermarkerToGraph } from './addWatermarkerToGraph'; import { addWatermarkerToGraph } from './addWatermarkerToGraph';
import { import {
@ -40,9 +41,11 @@ import {
POSITIVE_CONDITIONING, POSITIVE_CONDITIONING,
RANDOM_INT, RANDOM_INT,
RANGE_OF_SIZE, RANGE_OF_SIZE,
REFINER_SEAMLESS,
SDXL_CANVAS_OUTPAINT_GRAPH, SDXL_CANVAS_OUTPAINT_GRAPH,
SDXL_DENOISE_LATENTS, SDXL_DENOISE_LATENTS,
SDXL_MODEL_LOADER, SDXL_MODEL_LOADER,
SEAMLESS,
} from './constants'; } from './constants';
import { craftSDXLStylePrompt } from './helpers/craftSDXLStylePrompt'; import { craftSDXLStylePrompt } from './helpers/craftSDXLStylePrompt';
@ -74,6 +77,8 @@ export const buildCanvasSDXLOutpaintGraph = (
canvasCoherenceStrength, canvasCoherenceStrength,
tileSize, tileSize,
infillMethod, infillMethod,
seamlessXAxis,
seamlessYAxis,
} = state.generation; } = state.generation;
const { const {
@ -98,6 +103,8 @@ export const buildCanvasSDXLOutpaintGraph = (
shouldAutoSave, shouldAutoSave,
} = state.canvas; } = state.canvas;
let modelLoaderNodeId = SDXL_MODEL_LOADER;
const use_cpu = shouldUseNoiseSettings const use_cpu = shouldUseNoiseSettings
? shouldUseCpuNoise ? shouldUseCpuNoise
: shouldUseCpuNoise; : shouldUseCpuNoise;
@ -747,16 +754,28 @@ export const buildCanvasSDXLOutpaintGraph = (
(graph.nodes[RANGE_OF_SIZE] as RangeOfSizeInvocation).start = seed; (graph.nodes[RANGE_OF_SIZE] as RangeOfSizeInvocation).start = seed;
} }
// Add Seamless To Graph
if (seamlessXAxis || seamlessYAxis) {
addSeamlessToLinearGraph(state, graph, modelLoaderNodeId);
modelLoaderNodeId = SEAMLESS;
}
// Add Refiner if enabled // Add Refiner if enabled
if (shouldUseSDXLRefiner) { if (shouldUseSDXLRefiner) {
addSDXLRefinerToGraph(state, graph, CANVAS_COHERENCE_DENOISE_LATENTS); addSDXLRefinerToGraph(
state,
graph,
CANVAS_COHERENCE_DENOISE_LATENTS,
modelLoaderNodeId
);
modelLoaderNodeId = REFINER_SEAMLESS;
} }
// optionally add custom VAE // optionally add custom VAE
addVAEToGraph(state, graph, SDXL_MODEL_LOADER); addVAEToGraph(state, graph, modelLoaderNodeId);
// add LoRA support // add LoRA support
addSDXLLoRAsToGraph(state, graph, SDXL_DENOISE_LATENTS, SDXL_MODEL_LOADER); addSDXLLoRAsToGraph(state, graph, SDXL_DENOISE_LATENTS, modelLoaderNodeId);
// add controlnet, mutating `graph` // add controlnet, mutating `graph`
addControlNetToLinearGraph(state, graph, SDXL_DENOISE_LATENTS); addControlNetToLinearGraph(state, graph, SDXL_DENOISE_LATENTS);