possible fix: Seamless not working with Custom VAE's

This commit is contained in:
blessedcoolant 2024-02-14 23:01:49 +05:30 committed by Kent Keirsey
parent 17d5f7bebd
commit ff9bd040cc
4 changed files with 32 additions and 18 deletions

View File

@ -23,6 +23,7 @@ import {
NOISE, NOISE,
NOISE_HRF, NOISE_HRF,
RESIZE_HRF, RESIZE_HRF,
SEAMLESS,
VAE_LOADER, VAE_LOADER,
} from './constants'; } from './constants';
import { setMetadataReceivingNode, upsertMetadata } from './metadata'; import { setMetadataReceivingNode, upsertMetadata } from './metadata';
@ -30,7 +31,6 @@ import { setMetadataReceivingNode, upsertMetadata } from './metadata';
// Copy certain connections from previous DENOISE_LATENTS to new DENOISE_LATENTS_HRF. // Copy certain connections from previous DENOISE_LATENTS to new DENOISE_LATENTS_HRF.
function copyConnectionsToDenoiseLatentsHrf(graph: NonNullableGraph): void { function copyConnectionsToDenoiseLatentsHrf(graph: NonNullableGraph): void {
const destinationFields = [ const destinationFields = [
'vae',
'control', 'control',
'ip_adapter', 'ip_adapter',
'metadata', 'metadata',
@ -107,9 +107,10 @@ export const addHrfToGraph = (state: RootState, graph: NonNullableGraph): void =
} }
const log = logger('txt2img'); const log = logger('txt2img');
const { vae } = state.generation; const { vae, seamlessXAxis, seamlessYAxis } = state.generation;
const { hrfStrength, hrfEnabled, hrfMethod } = state.hrf; const { hrfStrength, hrfEnabled, hrfMethod } = state.hrf;
const isAutoVae = !vae; const isAutoVae = !vae;
const isSeamlessEnabled = seamlessXAxis || seamlessYAxis;
const width = state.generation.width; const width = state.generation.width;
const height = state.generation.height; const height = state.generation.height;
const optimalDimension = selectOptimalDimension(state); const optimalDimension = selectOptimalDimension(state);
@ -158,7 +159,7 @@ export const addHrfToGraph = (state: RootState, graph: NonNullableGraph): void =
}, },
{ {
source: { source: {
node_id: isAutoVae ? MAIN_MODEL_LOADER : VAE_LOADER, node_id: isAutoVae ? MAIN_MODEL_LOADER : isSeamlessEnabled ? SEAMLESS : VAE_LOADER,
field: 'vae', field: 'vae',
}, },
destination: { destination: {
@ -259,7 +260,7 @@ export const addHrfToGraph = (state: RootState, graph: NonNullableGraph): void =
graph.edges.push( graph.edges.push(
{ {
source: { source: {
node_id: isAutoVae ? MAIN_MODEL_LOADER : VAE_LOADER, node_id: isAutoVae ? MAIN_MODEL_LOADER : isSeamlessEnabled ? SEAMLESS : VAE_LOADER,
field: 'vae', field: 'vae',
}, },
destination: { destination: {
@ -322,7 +323,7 @@ export const addHrfToGraph = (state: RootState, graph: NonNullableGraph): void =
graph.edges.push( graph.edges.push(
{ {
source: { source: {
node_id: isAutoVae ? MAIN_MODEL_LOADER : VAE_LOADER, node_id: isAutoVae ? MAIN_MODEL_LOADER : isSeamlessEnabled ? SEAMLESS : VAE_LOADER,
field: 'vae', field: 'vae',
}, },
destination: { destination: {

View File

@ -14,6 +14,7 @@ import {
SDXL_IMAGE_TO_IMAGE_GRAPH, SDXL_IMAGE_TO_IMAGE_GRAPH,
SDXL_TEXT_TO_IMAGE_GRAPH, SDXL_TEXT_TO_IMAGE_GRAPH,
SEAMLESS, SEAMLESS,
VAE_LOADER,
} from './constants'; } from './constants';
import { upsertMetadata } from './metadata'; import { upsertMetadata } from './metadata';
@ -23,7 +24,8 @@ export const addSeamlessToLinearGraph = (
modelLoaderNodeId: string modelLoaderNodeId: string
): void => { ): void => {
// Remove Existing UNet Connections // Remove Existing UNet Connections
const { seamlessXAxis, seamlessYAxis } = state.generation; const { seamlessXAxis, seamlessYAxis, vae } = state.generation;
const isAutoVae = !vae;
graph.nodes[SEAMLESS] = { graph.nodes[SEAMLESS] = {
id: SEAMLESS, id: SEAMLESS,
@ -32,6 +34,15 @@ export const addSeamlessToLinearGraph = (
seamless_y: seamlessYAxis, seamless_y: seamlessYAxis,
} as SeamlessModeInvocation; } as SeamlessModeInvocation;
if (!isAutoVae) {
graph.nodes[VAE_LOADER] = {
type: 'vae_loader',
id: VAE_LOADER,
is_intermediate: true,
vae_model: vae,
};
}
if (seamlessXAxis) { if (seamlessXAxis) {
upsertMetadata(graph, { upsertMetadata(graph, {
seamless_x: seamlessXAxis, seamless_x: seamlessXAxis,
@ -75,7 +86,7 @@ export const addSeamlessToLinearGraph = (
}, },
{ {
source: { source: {
node_id: modelLoaderNodeId, node_id: isAutoVae ? modelLoaderNodeId : VAE_LOADER,
field: 'vae', field: 'vae',
}, },
destination: { destination: {

View File

@ -21,6 +21,7 @@ import {
SDXL_IMAGE_TO_IMAGE_GRAPH, SDXL_IMAGE_TO_IMAGE_GRAPH,
SDXL_REFINER_INPAINT_CREATE_MASK, SDXL_REFINER_INPAINT_CREATE_MASK,
SDXL_TEXT_TO_IMAGE_GRAPH, SDXL_TEXT_TO_IMAGE_GRAPH,
SEAMLESS,
TEXT_TO_IMAGE_GRAPH, TEXT_TO_IMAGE_GRAPH,
VAE_LOADER, VAE_LOADER,
} from './constants'; } from './constants';
@ -31,15 +32,16 @@ export const addVAEToGraph = (
graph: NonNullableGraph, graph: NonNullableGraph,
modelLoaderNodeId: string = MAIN_MODEL_LOADER modelLoaderNodeId: string = MAIN_MODEL_LOADER
): void => { ): void => {
const { vae, canvasCoherenceMode } = state.generation; const { vae, canvasCoherenceMode, seamlessXAxis, seamlessYAxis } = state.generation;
const { boundingBoxScaleMethod } = state.canvas; const { boundingBoxScaleMethod } = state.canvas;
const { refinerModel } = state.sdxl; const { refinerModel } = state.sdxl;
const isUsingScaledDimensions = ['auto', 'manual'].includes(boundingBoxScaleMethod); const isUsingScaledDimensions = ['auto', 'manual'].includes(boundingBoxScaleMethod);
const isAutoVae = !vae; const isAutoVae = !vae;
const isSeamlessEnabled = seamlessXAxis || seamlessYAxis;
if (!isAutoVae) { if (!isAutoVae && !isSeamlessEnabled) {
graph.nodes[VAE_LOADER] = { graph.nodes[VAE_LOADER] = {
type: 'vae_loader', type: 'vae_loader',
id: VAE_LOADER, id: VAE_LOADER,
@ -56,7 +58,7 @@ export const addVAEToGraph = (
) { ) {
graph.edges.push({ graph.edges.push({
source: { source: {
node_id: isAutoVae ? modelLoaderNodeId : VAE_LOADER, node_id: isAutoVae ? modelLoaderNodeId : isSeamlessEnabled ? SEAMLESS : VAE_LOADER,
field: 'vae', field: 'vae',
}, },
destination: { destination: {
@ -74,7 +76,7 @@ export const addVAEToGraph = (
) { ) {
graph.edges.push({ graph.edges.push({
source: { source: {
node_id: isAutoVae ? modelLoaderNodeId : VAE_LOADER, node_id: isAutoVae ? modelLoaderNodeId : isSeamlessEnabled ? SEAMLESS : VAE_LOADER,
field: 'vae', field: 'vae',
}, },
destination: { destination: {
@ -92,7 +94,7 @@ export const addVAEToGraph = (
) { ) {
graph.edges.push({ graph.edges.push({
source: { source: {
node_id: isAutoVae ? modelLoaderNodeId : VAE_LOADER, node_id: isAutoVae ? modelLoaderNodeId : isSeamlessEnabled ? SEAMLESS : VAE_LOADER,
field: 'vae', field: 'vae',
}, },
destination: { destination: {
@ -111,7 +113,7 @@ export const addVAEToGraph = (
graph.edges.push( graph.edges.push(
{ {
source: { source: {
node_id: isAutoVae ? modelLoaderNodeId : VAE_LOADER, node_id: isAutoVae ? modelLoaderNodeId : isSeamlessEnabled ? SEAMLESS : VAE_LOADER,
field: 'vae', field: 'vae',
}, },
destination: { destination: {
@ -121,7 +123,7 @@ export const addVAEToGraph = (
}, },
{ {
source: { source: {
node_id: isAutoVae ? modelLoaderNodeId : VAE_LOADER, node_id: isAutoVae ? modelLoaderNodeId : isSeamlessEnabled ? SEAMLESS : VAE_LOADER,
field: 'vae', field: 'vae',
}, },
destination: { destination: {
@ -131,7 +133,7 @@ export const addVAEToGraph = (
}, },
{ {
source: { source: {
node_id: isAutoVae ? modelLoaderNodeId : VAE_LOADER, node_id: isAutoVae ? modelLoaderNodeId : isSeamlessEnabled ? SEAMLESS : VAE_LOADER,
field: 'vae', field: 'vae',
}, },
destination: { destination: {
@ -145,7 +147,7 @@ export const addVAEToGraph = (
if (canvasCoherenceMode !== 'unmasked') { if (canvasCoherenceMode !== 'unmasked') {
graph.edges.push({ graph.edges.push({
source: { source: {
node_id: isAutoVae ? modelLoaderNodeId : VAE_LOADER, node_id: isAutoVae ? modelLoaderNodeId : isSeamlessEnabled ? SEAMLESS : VAE_LOADER,
field: 'vae', field: 'vae',
}, },
destination: { destination: {
@ -160,7 +162,7 @@ export const addVAEToGraph = (
if (graph.id === SDXL_CANVAS_INPAINT_GRAPH || graph.id === SDXL_CANVAS_OUTPAINT_GRAPH) { if (graph.id === SDXL_CANVAS_INPAINT_GRAPH || graph.id === SDXL_CANVAS_OUTPAINT_GRAPH) {
graph.edges.push({ graph.edges.push({
source: { source: {
node_id: isAutoVae ? modelLoaderNodeId : VAE_LOADER, node_id: isAutoVae ? modelLoaderNodeId : isSeamlessEnabled ? SEAMLESS : VAE_LOADER,
field: 'vae', field: 'vae',
}, },
destination: { destination: {