Fix invoke UI graphs for onnx

This commit is contained in:
Brandon Rising 2023-07-18 23:16:51 -04:00
parent 9e65470ada
commit 8699fd7050
5 changed files with 28 additions and 36 deletions

View File

@ -60,10 +60,8 @@ export const buildCanvasImageToImageGraph = (
? shouldUseCpuNoise ? shouldUseCpuNoise
: initialGenerationState.shouldUseCpuNoise; : initialGenerationState.shouldUseCpuNoise;
console.log(model); const onnx_model_type = model.model_type.includes('onnx');
const model_loader = model.model_name.includes('onnx') const model_loader = onnx_model_type ? ONNX_MODEL_LOADER : MAIN_MODEL_LOADER;
? ONNX_MODEL_LOADER
: MAIN_MODEL_LOADER;
/** /**
* The easiest way to build linear graphs is to do it in the node editor, then copy and paste the * The easiest way to build linear graphs is to do it in the node editor, then copy and paste the
@ -80,12 +78,12 @@ export const buildCanvasImageToImageGraph = (
id: IMAGE_TO_IMAGE_GRAPH, id: IMAGE_TO_IMAGE_GRAPH,
nodes: { nodes: {
[POSITIVE_CONDITIONING]: { [POSITIVE_CONDITIONING]: {
type: 'compel', type: onnx_model_type ? 'prompt_onnx' : 'compel',
id: POSITIVE_CONDITIONING, id: POSITIVE_CONDITIONING,
prompt: positivePrompt, prompt: positivePrompt,
}, },
[NEGATIVE_CONDITIONING]: { [NEGATIVE_CONDITIONING]: {
type: 'compel', type: onnx_model_type ? 'prompt_onnx' : 'compel',
id: NEGATIVE_CONDITIONING, id: NEGATIVE_CONDITIONING,
prompt: negativePrompt, prompt: negativePrompt,
}, },
@ -105,11 +103,11 @@ export const buildCanvasImageToImageGraph = (
skipped_layers: clipSkip, skipped_layers: clipSkip,
}, },
[LATENTS_TO_IMAGE]: { [LATENTS_TO_IMAGE]: {
type: 'l2i', type: onnx_model_type ? 'l2i_onnx' : 'l2i',
id: LATENTS_TO_IMAGE, id: LATENTS_TO_IMAGE,
}, },
[LATENTS_TO_LATENTS]: { [LATENTS_TO_LATENTS]: {
type: 'l2l', type: onnx_model_type ? 'l2l_onnx' : 'l2l',
id: LATENTS_TO_LATENTS, id: LATENTS_TO_LATENTS,
cfg_scale, cfg_scale,
scheduler, scheduler,
@ -117,7 +115,7 @@ export const buildCanvasImageToImageGraph = (
strength, strength,
}, },
[IMAGE_TO_LATENTS]: { [IMAGE_TO_LATENTS]: {
type: 'i2l', type: onnx_model_type ? 'i2l_onnx' : 'i2l',
id: IMAGE_TO_LATENTS, id: IMAGE_TO_LATENTS,
// must be set manually later, bc `fit` parameter may require a resize node inserted // must be set manually later, bc `fit` parameter may require a resize node inserted
// image: { // image: {
@ -320,10 +318,10 @@ export const buildCanvasImageToImageGraph = (
}); });
// add LoRA support // add LoRA support
addLoRAsToGraph(state, graph, LATENTS_TO_LATENTS); addLoRAsToGraph(state, graph, LATENTS_TO_LATENTS, model_loader);
// optionally add custom VAE // optionally add custom VAE
addVAEToGraph(state, graph); addVAEToGraph(state, graph, model_loader);
// add dynamic prompts - also sets up core iteration and seed // add dynamic prompts - also sets up core iteration and seed
addDynamicPromptsToGraph(state, graph); addDynamicPromptsToGraph(state, graph);

View File

@ -64,8 +64,7 @@ export const buildCanvasInpaintGraph = (
// We may need to set the inpaint width and height to scale the image // We may need to set the inpaint width and height to scale the image
const { scaledBoundingBoxDimensions, boundingBoxScaleMethod } = state.canvas; const { scaledBoundingBoxDimensions, boundingBoxScaleMethod } = state.canvas;
console.log(model); const model_loader = model.model_type.includes('onnx')
const model_loader = model.model_name.includes('onnx')
? ONNX_MODEL_LOADER ? ONNX_MODEL_LOADER
: MAIN_MODEL_LOADER; : MAIN_MODEL_LOADER;

View File

@ -50,10 +50,8 @@ export const buildCanvasTextToImageGraph = (
const use_cpu = shouldUseNoiseSettings const use_cpu = shouldUseNoiseSettings
? shouldUseCpuNoise ? shouldUseCpuNoise
: initialGenerationState.shouldUseCpuNoise; : initialGenerationState.shouldUseCpuNoise;
console.log(model); const onnx_model_type = model.model_type.includes('onnx');
const model_loader = model.model_name.includes('onnx') const model_loader = onnx_model_type ? ONNX_MODEL_LOADER : MAIN_MODEL_LOADER;
? ONNX_MODEL_LOADER
: MAIN_MODEL_LOADER;
/** /**
* The easiest way to build linear graphs is to do it in the node editor, then copy and paste the * The easiest way to build linear graphs is to do it in the node editor, then copy and paste the
* full graph here as a template. Then use the parameters from app state and set friendlier node * full graph here as a template. Then use the parameters from app state and set friendlier node
@ -69,12 +67,12 @@ export const buildCanvasTextToImageGraph = (
id: TEXT_TO_IMAGE_GRAPH, id: TEXT_TO_IMAGE_GRAPH,
nodes: { nodes: {
[POSITIVE_CONDITIONING]: { [POSITIVE_CONDITIONING]: {
type: 'compel', type: onnx_model_type ? 'prompt_onnx' : 'compel',
id: POSITIVE_CONDITIONING, id: POSITIVE_CONDITIONING,
prompt: positivePrompt, prompt: positivePrompt,
}, },
[NEGATIVE_CONDITIONING]: { [NEGATIVE_CONDITIONING]: {
type: 'compel', type: onnx_model_type ? 'prompt_onnx' : 'compel',
id: NEGATIVE_CONDITIONING, id: NEGATIVE_CONDITIONING,
prompt: negativePrompt, prompt: negativePrompt,
}, },
@ -86,7 +84,7 @@ export const buildCanvasTextToImageGraph = (
use_cpu, use_cpu,
}, },
[TEXT_TO_LATENTS]: { [TEXT_TO_LATENTS]: {
type: 't2l', type: onnx_model_type ? 't2l_onnx' : 't2l',
id: TEXT_TO_LATENTS, id: TEXT_TO_LATENTS,
cfg_scale, cfg_scale,
scheduler, scheduler,
@ -103,7 +101,7 @@ export const buildCanvasTextToImageGraph = (
skipped_layers: clipSkip, skipped_layers: clipSkip,
}, },
[LATENTS_TO_IMAGE]: { [LATENTS_TO_IMAGE]: {
type: 'l2i', type: onnx_model_type ? 'l2i_onnx' : 'l2i',
id: LATENTS_TO_IMAGE, id: LATENTS_TO_IMAGE,
}, },
}, },
@ -224,10 +222,10 @@ export const buildCanvasTextToImageGraph = (
}); });
// add LoRA support // add LoRA support
addLoRAsToGraph(state, graph, TEXT_TO_LATENTS); addLoRAsToGraph(state, graph, TEXT_TO_LATENTS, model_loader);
// optionally add custom VAE // optionally add custom VAE
addVAEToGraph(state, graph); addVAEToGraph(state, graph, model_loader);
// add dynamic prompts - also sets up core iteration and seed // add dynamic prompts - also sets up core iteration and seed
addDynamicPromptsToGraph(state, graph); addDynamicPromptsToGraph(state, graph);

View File

@ -83,10 +83,8 @@ export const buildLinearImageToImageGraph = (
? shouldUseCpuNoise ? shouldUseCpuNoise
: initialGenerationState.shouldUseCpuNoise; : initialGenerationState.shouldUseCpuNoise;
console.log(model); const onnx_model_type = model.model_type.includes('onnx');
const model_loader = model.model_name.includes('onnx') const model_loader = onnx_model_type ? ONNX_MODEL_LOADER : MAIN_MODEL_LOADER;
? ONNX_MODEL_LOADER
: MAIN_MODEL_LOADER;
// copy-pasted graph from node editor, filled in with state values & friendly node ids // copy-pasted graph from node editor, filled in with state values & friendly node ids
// TODO: Actually create the graph correctly for ONNX // TODO: Actually create the graph correctly for ONNX
@ -104,12 +102,12 @@ export const buildLinearImageToImageGraph = (
skipped_layers: clipSkip, skipped_layers: clipSkip,
}, },
[POSITIVE_CONDITIONING]: { [POSITIVE_CONDITIONING]: {
type: 'compel', type: onnx_model_type ? 'prompt_onnx' : 'compel',
id: POSITIVE_CONDITIONING, id: POSITIVE_CONDITIONING,
prompt: positivePrompt, prompt: positivePrompt,
}, },
[NEGATIVE_CONDITIONING]: { [NEGATIVE_CONDITIONING]: {
type: 'compel', type: onnx_model_type ? 'prompt_onnx' : 'compel',
id: NEGATIVE_CONDITIONING, id: NEGATIVE_CONDITIONING,
prompt: negativePrompt, prompt: negativePrompt,
}, },
@ -119,11 +117,11 @@ export const buildLinearImageToImageGraph = (
use_cpu, use_cpu,
}, },
[LATENTS_TO_IMAGE]: { [LATENTS_TO_IMAGE]: {
type: 'l2i', type: onnx_model_type ? 'l2i_onnx' : 'l2i',
id: LATENTS_TO_IMAGE, id: LATENTS_TO_IMAGE,
}, },
[LATENTS_TO_LATENTS]: { [LATENTS_TO_LATENTS]: {
type: 'l2l', type: onnx_model_type ? 'l2l_onnx' : 'l2l',
id: LATENTS_TO_LATENTS, id: LATENTS_TO_LATENTS,
cfg_scale, cfg_scale,
scheduler, scheduler,
@ -131,7 +129,7 @@ export const buildLinearImageToImageGraph = (
strength, strength,
}, },
[IMAGE_TO_LATENTS]: { [IMAGE_TO_LATENTS]: {
type: 'i2l', type: onnx_model_type ? 'i2l_onnx' : 'i2l',
id: IMAGE_TO_LATENTS, id: IMAGE_TO_LATENTS,
// must be set manually later, bc `fit` parameter may require a resize node inserted // must be set manually later, bc `fit` parameter may require a resize node inserted
// image: { // image: {
@ -373,10 +371,10 @@ export const buildLinearImageToImageGraph = (
}); });
// add LoRA support // add LoRA support
addLoRAsToGraph(state, graph, LATENTS_TO_LATENTS); addLoRAsToGraph(state, graph, LATENTS_TO_LATENTS, model_loader);
// optionally add custom VAE // optionally add custom VAE
addVAEToGraph(state, graph); addVAEToGraph(state, graph, model_loader);
// add dynamic prompts - also sets up core iteration and seed // add dynamic prompts - also sets up core iteration and seed
addDynamicPromptsToGraph(state, graph); addDynamicPromptsToGraph(state, graph);

View File

@ -49,8 +49,7 @@ export const buildLinearTextToImageGraph = (
throw new Error('No model found in state'); throw new Error('No model found in state');
} }
console.log(model); const onnx_model_type = model.model_type.includes('onnx');
const onnx_model_type = model.model_name.includes('onnx');
const model_loader = onnx_model_type ? ONNX_MODEL_LOADER : MAIN_MODEL_LOADER; const model_loader = onnx_model_type ? ONNX_MODEL_LOADER : MAIN_MODEL_LOADER;
/** /**
* The easiest way to build linear graphs is to do it in the node editor, then copy and paste the * The easiest way to build linear graphs is to do it in the node editor, then copy and paste the