feat(ui): migrate linear workflows to latents

This commit is contained in:
psychedelicious 2023-05-24 17:19:13 +10:00 committed by Kent Keirsey
parent d2c223de8f
commit c7c0836721
23 changed files with 550 additions and 111 deletions

View File

@ -10,7 +10,7 @@ export const readinessSelector = createSelector(
[generationSelector, systemSelector, activeTabNameSelector], [generationSelector, systemSelector, activeTabNameSelector],
(generation, system, activeTabName) => { (generation, system, activeTabName) => {
const { const {
prompt, positivePrompt: prompt,
shouldGenerateVariations, shouldGenerateVariations,
seedWeights, seedWeights,
initialImage, initialImage,

View File

@ -20,7 +20,7 @@ import {
setImg2imgStrength, setImg2imgStrength,
setNegativePrompt, setNegativePrompt,
setPerlin, setPerlin,
setPrompt, setPositivePrompt,
setScheduler, setScheduler,
setSeamless, setSeamless,
setSeed, setSeed,
@ -199,7 +199,7 @@ const ImageMetadataViewer = memo(({ image }: ImageMetadataViewerProps) => {
? metadata.positive_conditioning ? metadata.positive_conditioning
: promptToString(metadata.positive_conditioning) : promptToString(metadata.positive_conditioning)
} }
onClick={() => setPrompt(metadata.positive_conditioning!)} onClick={() => setPositivePrompt(metadata.positive_conditioning!)}
/> />
)} )}
{metadata.negative_conditioning && ( {metadata.negative_conditioning && (

View File

@ -1,7 +1,10 @@
import { OpenAPIV3 } from 'openapi-types'; import { OpenAPIV3 } from 'openapi-types';
import { RgbaColor } from 'react-colorful'; import { RgbaColor } from 'react-colorful';
import { ImageDTO } from 'services/api'; import { Graph, ImageDTO } from 'services/api';
import { AnyInvocationType } from 'services/events/types'; import { AnyInvocationType } from 'services/events/types';
import { O } from 'ts-toolbelt';
export type NonNullableGraph = O.Required<Graph, 'nodes' | 'edges'>;
export type InvocationValue = { export type InvocationValue = {
id: string; id: string;

View File

@ -1,35 +1,132 @@
import { v4 as uuidv4 } from 'uuid';
import { RootState } from 'app/store/store'; import { RootState } from 'app/store/store';
import { Graph } from 'services/api'; import {
import { buildImg2ImgNode } from '../nodeBuilders/buildImageToImageNode'; CompelInvocation,
import { buildRangeNode } from '../nodeBuilders/buildRangeNode'; Graph,
import { buildIterateNode } from '../nodeBuilders/buildIterateNode'; ImageToLatentsInvocation,
import { buildEdges } from '../edgeBuilders/buildEdges'; LatentsToImageInvocation,
LatentsToLatentsInvocation,
} from 'services/api';
import { NonNullableGraph } from 'features/nodes/types/types';
import { addNoiseNodes } from '../nodeBuilders/addNoiseNodes';
import { log } from 'app/logging/useLogger';
const moduleLog = log.child({ namespace: 'buildImageToImageGraph' });
const POSITIVE_CONDITIONING = 'positive_conditioning';
const NEGATIVE_CONDITIONING = 'negative_conditioning';
const IMAGE_TO_LATENTS = 'image_to_latents';
const LATENTS_TO_LATENTS = 'latents_to_latents';
const LATENTS_TO_IMAGE = 'latents_to_image';
/** /**
* Builds the Linear workflow graph. * Builds the Image to Image tab graph.
*/ */
export const buildImageToImageGraph = (state: RootState): Graph => { export const buildImageToImageGraph = (state: RootState): Graph => {
const baseNode = buildImg2ImgNode(state); const {
positivePrompt,
negativePrompt,
model,
cfgScale: cfg_scale,
scheduler,
steps,
initialImage,
img2imgStrength: strength,
} = state.generation;
// We always range and iterate nodes, no matter the iteration count if (!initialImage) {
// This is required to provide the correct seeds to the backend engine moduleLog.error('No initial image found in state');
const rangeNode = buildRangeNode(state); throw new Error('No initial image found in state');
const iterateNode = buildIterateNode(); }
// Build the edges for the nodes selected. let graph: NonNullableGraph = {
const edges = buildEdges(baseNode, rangeNode, iterateNode); nodes: {},
edges: [],
// Assemble!
const graph = {
nodes: {
[rangeNode.id]: rangeNode,
[iterateNode.id]: iterateNode,
[baseNode.id]: baseNode,
},
edges,
}; };
// TODO: hires fix requires latent space upscaling; we don't have nodes for this yet // Create the conditioning, t2l and l2i nodes
const positiveConditioningNode: CompelInvocation = {
id: POSITIVE_CONDITIONING,
type: 'compel',
prompt: positivePrompt,
model,
};
const negativeConditioningNode: CompelInvocation = {
id: NEGATIVE_CONDITIONING,
type: 'compel',
prompt: negativePrompt,
model,
};
const imageToLatentsNode: ImageToLatentsInvocation = {
id: IMAGE_TO_LATENTS,
type: 'i2l',
model,
image: {
image_name: initialImage?.image_name,
image_type: initialImage?.image_type,
},
};
const latentsToLatentsNode: LatentsToLatentsInvocation = {
id: LATENTS_TO_LATENTS,
type: 'l2l',
cfg_scale,
model,
scheduler,
steps,
strength,
};
const latentsToImageNode: LatentsToImageInvocation = {
id: LATENTS_TO_IMAGE,
type: 'l2i',
model,
};
// Add to the graph
graph.nodes[POSITIVE_CONDITIONING] = positiveConditioningNode;
graph.nodes[NEGATIVE_CONDITIONING] = negativeConditioningNode;
graph.nodes[IMAGE_TO_LATENTS] = imageToLatentsNode;
graph.nodes[LATENTS_TO_LATENTS] = latentsToLatentsNode;
graph.nodes[LATENTS_TO_IMAGE] = latentsToImageNode;
// Connect them
graph.edges.push({
source: { node_id: POSITIVE_CONDITIONING, field: 'conditioning' },
destination: {
node_id: LATENTS_TO_LATENTS,
field: 'positive_conditioning',
},
});
graph.edges.push({
source: { node_id: NEGATIVE_CONDITIONING, field: 'conditioning' },
destination: {
node_id: LATENTS_TO_LATENTS,
field: 'negative_conditioning',
},
});
graph.edges.push({
source: { node_id: IMAGE_TO_LATENTS, field: 'latents' },
destination: {
node_id: LATENTS_TO_LATENTS,
field: 'latents',
},
});
graph.edges.push({
source: { node_id: LATENTS_TO_LATENTS, field: 'latents' },
destination: {
node_id: LATENTS_TO_IMAGE,
field: 'latents',
},
});
// Create and add the noise nodes
graph = addNoiseNodes(graph, latentsToLatentsNode.id, state);
return graph; return graph;
}; };

View File

@ -1,35 +1,99 @@
import { RootState } from 'app/store/store'; import { RootState } from 'app/store/store';
import { Graph } from 'services/api'; import {
import { buildTxt2ImgNode } from '../nodeBuilders/buildTextToImageNode'; CompelInvocation,
import { buildRangeNode } from '../nodeBuilders/buildRangeNode'; Graph,
import { buildIterateNode } from '../nodeBuilders/buildIterateNode'; LatentsToImageInvocation,
import { buildEdges } from '../edgeBuilders/buildEdges'; TextToLatentsInvocation,
} from 'services/api';
import { NonNullableGraph } from 'features/nodes/types/types';
import { addNoiseNodes } from '../nodeBuilders/addNoiseNodes';
const POSITIVE_CONDITIONING = 'positive_conditioning';
const NEGATIVE_CONDITIONING = 'negative_conditioning';
const TEXT_TO_LATENTS = 'text_to_latents';
const LATENTS_TO_IMAGE = 'latnets_to_image';
/** /**
* Builds the Linear workflow graph. * Builds the Text to Image tab graph.
*/ */
export const buildTextToImageGraph = (state: RootState): Graph => { export const buildTextToImageGraph = (state: RootState): Graph => {
const baseNode = buildTxt2ImgNode(state); const {
positivePrompt,
negativePrompt,
model,
cfgScale: cfg_scale,
scheduler,
steps,
} = state.generation;
// We always range and iterate nodes, no matter the iteration count let graph: NonNullableGraph = {
// This is required to provide the correct seeds to the backend engine nodes: {},
const rangeNode = buildRangeNode(state); edges: [],
const iterateNode = buildIterateNode();
// Build the edges for the nodes selected.
const edges = buildEdges(baseNode, rangeNode, iterateNode);
// Assemble!
const graph = {
nodes: {
[rangeNode.id]: rangeNode,
[iterateNode.id]: iterateNode,
[baseNode.id]: baseNode,
},
edges,
}; };
// TODO: hires fix requires latent space upscaling; we don't have nodes for this yet // Create the conditioning, t2l and l2i nodes
const positiveConditioningNode: CompelInvocation = {
id: POSITIVE_CONDITIONING,
type: 'compel',
prompt: positivePrompt,
model,
};
const negativeConditioningNode: CompelInvocation = {
id: NEGATIVE_CONDITIONING,
type: 'compel',
prompt: negativePrompt,
model,
};
const textToLatentsNode: TextToLatentsInvocation = {
id: TEXT_TO_LATENTS,
type: 't2l',
cfg_scale,
model,
scheduler,
steps,
};
const latentsToImageNode: LatentsToImageInvocation = {
id: LATENTS_TO_IMAGE,
type: 'l2i',
model,
};
// Add to the graph
graph.nodes[POSITIVE_CONDITIONING] = positiveConditioningNode;
graph.nodes[NEGATIVE_CONDITIONING] = negativeConditioningNode;
graph.nodes[TEXT_TO_LATENTS] = textToLatentsNode;
graph.nodes[LATENTS_TO_IMAGE] = latentsToImageNode;
// Connect them
graph.edges.push({
source: { node_id: POSITIVE_CONDITIONING, field: 'conditioning' },
destination: {
node_id: TEXT_TO_LATENTS,
field: 'positive_conditioning',
},
});
graph.edges.push({
source: { node_id: NEGATIVE_CONDITIONING, field: 'conditioning' },
destination: {
node_id: TEXT_TO_LATENTS,
field: 'negative_conditioning',
},
});
graph.edges.push({
source: { node_id: TEXT_TO_LATENTS, field: 'latents' },
destination: {
node_id: LATENTS_TO_IMAGE,
field: 'latents',
},
});
// Create and add the noise nodes
graph = addNoiseNodes(graph, TEXT_TO_LATENTS, state);
console.log(graph);
return graph; return graph;
}; };

View File

@ -0,0 +1,208 @@
import { RootState } from 'app/store/store';
import {
IterateInvocation,
NoiseInvocation,
RandomIntInvocation,
RangeOfSizeInvocation,
} from 'services/api';
import { NonNullableGraph } from 'features/nodes/types/types';
import { cloneDeep } from 'lodash-es';
const NOISE = 'noise';
const RANDOM_INT = 'rand_int';
const RANGE_OF_SIZE = 'range_of_size';
const ITERATE = 'iterate';
/**
* Adds the appropriate noise nodes to a linear UI t2l or l2l graph.
*
* @param graph The graph to add the noise nodes to.
* @param baseNodeId The id of the base node to connect the noise nodes to.
* @param state The app state..
*/
export const addNoiseNodes = (
graph: NonNullableGraph,
baseNodeId: string,
state: RootState
): NonNullableGraph => {
const graphClone = cloneDeep(graph);
// Create and add the noise nodes
const { width, height, seed, iterations, shouldRandomizeSeed } =
state.generation;
// Single iteration, explicit seed
if (!shouldRandomizeSeed && iterations === 1) {
const noiseNode: NoiseInvocation = {
id: NOISE,
type: 'noise',
seed: seed,
width,
height,
};
graphClone.nodes[NOISE] = noiseNode;
// Connect them
graphClone.edges.push({
source: { node_id: NOISE, field: 'noise' },
destination: {
node_id: baseNodeId,
field: 'noise',
},
});
}
// Single iteration, random seed
if (shouldRandomizeSeed && iterations === 1) {
// TODO: This assumes the `high` value is the max seed value
const randomIntNode: RandomIntInvocation = {
id: RANDOM_INT,
type: 'rand_int',
};
const noiseNode: NoiseInvocation = {
id: NOISE,
type: 'noise',
width,
height,
};
graphClone.nodes[RANDOM_INT] = randomIntNode;
graphClone.nodes[NOISE] = noiseNode;
graphClone.edges.push({
source: { node_id: RANDOM_INT, field: 'a' },
destination: {
node_id: NOISE,
field: 'seed',
},
});
graphClone.edges.push({
source: { node_id: NOISE, field: 'noise' },
destination: {
node_id: baseNodeId,
field: 'noise',
},
});
}
// Multiple iterations, explicit seed
if (!shouldRandomizeSeed && iterations > 1) {
const rangeOfSizeNode: RangeOfSizeInvocation = {
id: RANGE_OF_SIZE,
type: 'range_of_size',
start: seed,
size: iterations,
};
const iterateNode: IterateInvocation = {
id: ITERATE,
type: 'iterate',
};
const noiseNode: NoiseInvocation = {
id: NOISE,
type: 'noise',
width,
height,
};
graphClone.nodes[RANGE_OF_SIZE] = rangeOfSizeNode;
graphClone.nodes[ITERATE] = iterateNode;
graphClone.nodes[NOISE] = noiseNode;
graphClone.edges.push({
source: { node_id: RANGE_OF_SIZE, field: 'collection' },
destination: {
node_id: ITERATE,
field: 'collection',
},
});
graphClone.edges.push({
source: {
node_id: ITERATE,
field: 'item',
},
destination: {
node_id: NOISE,
field: 'seed',
},
});
graphClone.edges.push({
source: { node_id: NOISE, field: 'noise' },
destination: {
node_id: baseNodeId,
field: 'noise',
},
});
}
// Multiple iterations, random seed
if (shouldRandomizeSeed && iterations > 1) {
// TODO: This assumes the `high` value is the max seed value
const randomIntNode: RandomIntInvocation = {
id: RANDOM_INT,
type: 'rand_int',
};
const rangeOfSizeNode: RangeOfSizeInvocation = {
id: RANGE_OF_SIZE,
type: 'range_of_size',
size: iterations,
};
const iterateNode: IterateInvocation = {
id: ITERATE,
type: 'iterate',
};
const noiseNode: NoiseInvocation = {
id: NOISE,
type: 'noise',
width,
height,
};
graphClone.nodes[RANDOM_INT] = randomIntNode;
graphClone.nodes[RANGE_OF_SIZE] = rangeOfSizeNode;
graphClone.nodes[ITERATE] = iterateNode;
graphClone.nodes[NOISE] = noiseNode;
graphClone.edges.push({
source: { node_id: RANDOM_INT, field: 'a' },
destination: { node_id: RANGE_OF_SIZE, field: 'start' },
});
graphClone.edges.push({
source: { node_id: RANGE_OF_SIZE, field: 'collection' },
destination: {
node_id: ITERATE,
field: 'collection',
},
});
graphClone.edges.push({
source: {
node_id: ITERATE,
field: 'item',
},
destination: {
node_id: NOISE,
field: 'seed',
},
});
graphClone.edges.push({
source: { node_id: NOISE, field: 'noise' },
destination: {
node_id: baseNodeId,
field: 'noise',
},
});
}
return graphClone;
};

View File

@ -0,0 +1,26 @@
import { v4 as uuidv4 } from 'uuid';
import { RootState } from 'app/store/store';
import { CompelInvocation } from 'services/api';
import { O } from 'ts-toolbelt';
export const buildCompelNode = (
prompt: string,
state: RootState,
overrides: O.Partial<CompelInvocation, 'deep'> = {}
): CompelInvocation => {
const nodeId = uuidv4();
const { generation } = state;
const { model } = generation;
const compelNode: CompelInvocation = {
id: nodeId,
type: 'compel',
prompt,
model,
};
Object.assign(compelNode, overrides);
return compelNode;
};

View File

@ -18,8 +18,8 @@ export const buildImg2ImgNode = (
const activeTabName = activeTabNameSelector(state); const activeTabName = activeTabNameSelector(state);
const { const {
prompt, positivePrompt: prompt,
negativePrompt, negativePrompt: negativePrompt,
seed, seed,
steps, steps,
width, width,

View File

@ -13,8 +13,8 @@ export const buildInpaintNode = (
const activeTabName = activeTabNameSelector(state); const activeTabName = activeTabNameSelector(state);
const { const {
prompt, positivePrompt: prompt,
negativePrompt, negativePrompt: negativePrompt,
seed, seed,
steps, steps,
width, width,

View File

@ -11,8 +11,8 @@ export const buildTxt2ImgNode = (
const { generation } = state; const { generation } = state;
const { const {
prompt, positivePrompt: prompt,
negativePrompt, negativePrompt: negativePrompt,
seed, seed,
steps, steps,
width, width,

View File

@ -8,7 +8,7 @@ import { readinessSelector } from 'app/selectors/readinessSelector';
import { import {
GenerationState, GenerationState,
clampSymmetrySteps, clampSymmetrySteps,
setPrompt, setPositivePrompt,
} from 'features/parameters/store/generationSlice'; } from 'features/parameters/store/generationSlice';
import { activeTabNameSelector } from 'features/ui/store/uiSelectors'; import { activeTabNameSelector } from 'features/ui/store/uiSelectors';
@ -22,7 +22,7 @@ const promptInputSelector = createSelector(
[(state: RootState) => state.generation, activeTabNameSelector], [(state: RootState) => state.generation, activeTabNameSelector],
(parameters: GenerationState, activeTabName) => { (parameters: GenerationState, activeTabName) => {
return { return {
prompt: parameters.prompt, prompt: parameters.positivePrompt,
activeTabName, activeTabName,
}; };
}, },
@ -46,7 +46,7 @@ const ParamPositiveConditioning = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const handleChangePrompt = (e: ChangeEvent<HTMLTextAreaElement>) => { const handleChangePrompt = (e: ChangeEvent<HTMLTextAreaElement>) => {
dispatch(setPrompt(e.target.value)); dispatch(setPositivePrompt(e.target.value));
}; };
useHotkeys( useHotkeys(

View File

@ -57,7 +57,7 @@ const InitialImagePreview = () => {
const name = e.dataTransfer.getData('invokeai/imageName'); const name = e.dataTransfer.getData('invokeai/imageName');
const type = e.dataTransfer.getData('invokeai/imageType') as ImageType; const type = e.dataTransfer.getData('invokeai/imageType') as ImageType;
dispatch(initialImageSelected({ name, type })); dispatch(initialImageSelected({ image_name: name, image_type: type }));
}, },
[dispatch] [dispatch]
); );
@ -73,10 +73,10 @@ const InitialImagePreview = () => {
}} }}
onDrop={handleDrop} onDrop={handleDrop}
> >
{initialImage?.url && ( {initialImage?.image_url && (
<> <>
<Image <Image
src={getUrl(initialImage?.url)} src={getUrl(initialImage?.image_url)}
fallbackStrategy="beforeLoadOrError" fallbackStrategy="beforeLoadOrError"
fallback={<ImageFallbackSpinner />} fallback={<ImageFallbackSpinner />}
onError={handleError} onError={handleError}
@ -92,7 +92,7 @@ const InitialImagePreview = () => {
<ImageMetadataOverlay image={initialImage} /> <ImageMetadataOverlay image={initialImage} />
</> </>
)} )}
{!initialImage?.url && ( {!initialImage?.image_url && (
<Icon <Icon
as={FaImage} as={FaImage}
sx={{ sx={{

View File

@ -3,7 +3,7 @@ import { getPromptAndNegative } from 'common/util/getPromptAndNegative';
import * as InvokeAI from 'app/types/invokeai'; import * as InvokeAI from 'app/types/invokeai';
import promptToString from 'common/util/promptToString'; import promptToString from 'common/util/promptToString';
import { useAppDispatch } from 'app/store/storeHooks'; import { useAppDispatch } from 'app/store/storeHooks';
import { setNegativePrompt, setPrompt } from '../store/generationSlice'; import { setNegativePrompt, setPositivePrompt } from '../store/generationSlice';
import { useCallback } from 'react'; import { useCallback } from 'react';
// TECHDEBT: We have two metadata prompt formats and need to handle recalling either of them. // TECHDEBT: We have two metadata prompt formats and need to handle recalling either of them.
@ -20,7 +20,7 @@ const useSetBothPrompts = () => {
const [prompt, negativePrompt] = getPromptAndNegative(promptString); const [prompt, negativePrompt] = getPromptAndNegative(promptString);
dispatch(setPrompt(prompt)); dispatch(setPositivePrompt(prompt));
dispatch(setNegativePrompt(negativePrompt)); dispatch(setNegativePrompt(negativePrompt));
}, },
[dispatch] [dispatch]

View File

@ -16,7 +16,7 @@ export interface GenerationState {
initialImage?: ImageDTO; initialImage?: ImageDTO;
iterations: number; iterations: number;
perlin: number; perlin: number;
prompt: string; positivePrompt: string;
negativePrompt: string; negativePrompt: string;
scheduler: Scheduler; scheduler: Scheduler;
seamBlur: number; seamBlur: number;
@ -50,7 +50,7 @@ export const initialGenerationState: GenerationState = {
infillMethod: 'patchmatch', infillMethod: 'patchmatch',
iterations: 1, iterations: 1,
perlin: 0, perlin: 0,
prompt: '', positivePrompt: '',
negativePrompt: '', negativePrompt: '',
scheduler: 'lms', scheduler: 'lms',
seamBlur: 16, seamBlur: 16,
@ -83,12 +83,15 @@ export const generationSlice = createSlice({
name: 'generation', name: 'generation',
initialState, initialState,
reducers: { reducers: {
setPrompt: (state, action: PayloadAction<string | InvokeAI.Prompt>) => { setPositivePrompt: (
state,
action: PayloadAction<string | InvokeAI.Prompt>
) => {
const newPrompt = action.payload; const newPrompt = action.payload;
if (typeof newPrompt === 'string') { if (typeof newPrompt === 'string') {
state.prompt = newPrompt; state.positivePrompt = newPrompt;
} else { } else {
state.prompt = promptToString(newPrompt); state.positivePrompt = promptToString(newPrompt);
} }
}, },
setNegativePrompt: ( setNegativePrompt: (
@ -244,7 +247,7 @@ export const {
setInfillMethod, setInfillMethod,
setIterations, setIterations,
setPerlin, setPerlin,
setPrompt, setPositivePrompt,
setNegativePrompt, setNegativePrompt,
setScheduler, setScheduler,
setSeamBlur, setSeamBlur,

View File

@ -31,7 +31,7 @@ export const setAllParametersReducer = (
state.model = String(model); state.model = String(model);
} }
if (prompt !== undefined) { if (prompt !== undefined) {
state.prompt = String(prompt); state.positivePrompt = String(prompt);
} }
if (scheduler !== undefined) { if (scheduler !== undefined) {
const schedulerString = String(scheduler); const schedulerString = String(scheduler);

View File

@ -66,6 +66,7 @@ export type { PromptOutput } from './models/PromptOutput';
export type { RandomIntInvocation } from './models/RandomIntInvocation'; export type { RandomIntInvocation } from './models/RandomIntInvocation';
export type { RandomRangeInvocation } from './models/RandomRangeInvocation'; export type { RandomRangeInvocation } from './models/RandomRangeInvocation';
export type { RangeInvocation } from './models/RangeInvocation'; export type { RangeInvocation } from './models/RangeInvocation';
export type { RangeOfSizeInvocation } from './models/RangeOfSizeInvocation';
export type { ResizeLatentsInvocation } from './models/ResizeLatentsInvocation'; export type { ResizeLatentsInvocation } from './models/ResizeLatentsInvocation';
export type { RestoreFaceInvocation } from './models/RestoreFaceInvocation'; export type { RestoreFaceInvocation } from './models/RestoreFaceInvocation';
export type { ScaleLatentsInvocation } from './models/ScaleLatentsInvocation'; export type { ScaleLatentsInvocation } from './models/ScaleLatentsInvocation';

View File

@ -31,6 +31,7 @@ import type { PasteImageInvocation } from './PasteImageInvocation';
import type { RandomIntInvocation } from './RandomIntInvocation'; import type { RandomIntInvocation } from './RandomIntInvocation';
import type { RandomRangeInvocation } from './RandomRangeInvocation'; import type { RandomRangeInvocation } from './RandomRangeInvocation';
import type { RangeInvocation } from './RangeInvocation'; import type { RangeInvocation } from './RangeInvocation';
import type { RangeOfSizeInvocation } from './RangeOfSizeInvocation';
import type { ResizeLatentsInvocation } from './ResizeLatentsInvocation'; import type { ResizeLatentsInvocation } from './ResizeLatentsInvocation';
import type { RestoreFaceInvocation } from './RestoreFaceInvocation'; import type { RestoreFaceInvocation } from './RestoreFaceInvocation';
import type { ScaleLatentsInvocation } from './ScaleLatentsInvocation'; import type { ScaleLatentsInvocation } from './ScaleLatentsInvocation';
@ -48,7 +49,7 @@ export type Graph = {
/** /**
* The nodes in this graph * The nodes in this graph
*/ */
nodes?: Record<string, (LoadImageInvocation | ShowImageInvocation | CropImageInvocation | PasteImageInvocation | MaskFromAlphaInvocation | BlurInvocation | LerpInvocation | InverseLerpInvocation | CompelInvocation | AddInvocation | SubtractInvocation | MultiplyInvocation | DivideInvocation | RandomIntInvocation | ParamIntInvocation | NoiseInvocation | TextToLatentsInvocation | LatentsToImageInvocation | ResizeLatentsInvocation | ScaleLatentsInvocation | ImageToLatentsInvocation | CvInpaintInvocation | RangeInvocation | RandomRangeInvocation | UpscaleInvocation | RestoreFaceInvocation | TextToImageInvocation | InfillColorInvocation | InfillTileInvocation | InfillPatchMatchInvocation | GraphInvocation | IterateInvocation | CollectInvocation | LatentsToLatentsInvocation | ImageToImageInvocation | InpaintInvocation)>; nodes?: Record<string, (LoadImageInvocation | ShowImageInvocation | CropImageInvocation | PasteImageInvocation | MaskFromAlphaInvocation | BlurInvocation | LerpInvocation | InverseLerpInvocation | CompelInvocation | AddInvocation | SubtractInvocation | MultiplyInvocation | DivideInvocation | RandomIntInvocation | ParamIntInvocation | NoiseInvocation | TextToLatentsInvocation | LatentsToImageInvocation | ResizeLatentsInvocation | ScaleLatentsInvocation | ImageToLatentsInvocation | CvInpaintInvocation | RangeInvocation | RangeOfSizeInvocation | RandomRangeInvocation | UpscaleInvocation | RestoreFaceInvocation | TextToImageInvocation | InfillColorInvocation | InfillTileInvocation | InfillPatchMatchInvocation | GraphInvocation | IterateInvocation | CollectInvocation | LatentsToLatentsInvocation | ImageToImageInvocation | InpaintInvocation)>;
/** /**
* The connections between nodes and their fields in this graph * The connections between nodes and their fields in this graph
*/ */

View File

@ -59,7 +59,7 @@ export type ImageDTO = {
*/ */
node_id?: string; node_id?: string;
/** /**
* A limited subset of the image's metadata. Retrieve the image's session for full metadata. * A limited subset of the image's generation metadata. Retrieve the image's session for full metadata.
*/ */
metadata?: ImageMetadata; metadata?: ImageMetadata;
}; };

View File

@ -13,5 +13,13 @@ export type MaskOutput = {
* The output mask * The output mask
*/ */
mask: ImageField; mask: ImageField;
/**
* The width of the mask in pixels
*/
width?: number;
/**
* The height of the mask in pixels
*/
height?: number;
}; };

View File

@ -3,7 +3,7 @@
/* eslint-disable */ /* eslint-disable */
/** /**
* Creates a range * Creates a range of numbers from start to stop with step
*/ */
export type RangeInvocation = { export type RangeInvocation = {
/** /**

View File

@ -0,0 +1,27 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
/**
* Creates a range from start to start + size with step
*/
export type RangeOfSizeInvocation = {
/**
* The id of this node. Must be unique among all nodes.
*/
id: string;
type?: 'range_of_size';
/**
* The start of the range
*/
start?: number;
/**
* The number of values
*/
size?: number;
/**
* The step of the range
*/
step?: number;
};

View File

@ -89,6 +89,39 @@ export class ImagesService {
}); });
} }
/**
* Get Image Full
* Gets a full-resolution image file
* @returns any Return the full-resolution image
* @throws ApiError
*/
public static getImageFull({
imageType,
imageName,
}: {
/**
* The type of full-resolution image file to get
*/
imageType: ImageType,
/**
* The name of full-resolution image file to get
*/
imageName: string,
}): CancelablePromise<any> {
return __request(OpenAPI, {
method: 'GET',
url: '/api/v1/images/{image_type}/{image_name}',
path: {
'image_type': imageType,
'image_name': imageName,
},
errors: {
404: `Image not found`,
422: `Validation Error`,
},
});
}
/** /**
* Delete Image * Delete Image
* Deletes an image * Deletes an image
@ -150,39 +183,6 @@ export class ImagesService {
}); });
} }
/**
* Get Image Full
* Gets a full-resolution image file
* @returns any Return the full-resolution image
* @throws ApiError
*/
public static getImageFull({
imageType,
imageName,
}: {
/**
* The type of full-resolution image file to get
*/
imageType: ImageType,
/**
* The name of full-resolution image file to get
*/
imageName: string,
}): CancelablePromise<any> {
return __request(OpenAPI, {
method: 'GET',
url: '/api/v1/images/{image_type}/{image_name}/full',
path: {
'image_type': imageType,
'image_name': imageName,
},
errors: {
404: `Image not found`,
422: `Validation Error`,
},
});
}
/** /**
* Get Image Thumbnail * Get Image Thumbnail
* Gets a thumbnail image file * Gets a thumbnail image file

View File

@ -33,6 +33,7 @@ import type { PasteImageInvocation } from '../models/PasteImageInvocation';
import type { RandomIntInvocation } from '../models/RandomIntInvocation'; import type { RandomIntInvocation } from '../models/RandomIntInvocation';
import type { RandomRangeInvocation } from '../models/RandomRangeInvocation'; import type { RandomRangeInvocation } from '../models/RandomRangeInvocation';
import type { RangeInvocation } from '../models/RangeInvocation'; import type { RangeInvocation } from '../models/RangeInvocation';
import type { RangeOfSizeInvocation } from '../models/RangeOfSizeInvocation';
import type { ResizeLatentsInvocation } from '../models/ResizeLatentsInvocation'; import type { ResizeLatentsInvocation } from '../models/ResizeLatentsInvocation';
import type { RestoreFaceInvocation } from '../models/RestoreFaceInvocation'; import type { RestoreFaceInvocation } from '../models/RestoreFaceInvocation';
import type { ScaleLatentsInvocation } from '../models/ScaleLatentsInvocation'; import type { ScaleLatentsInvocation } from '../models/ScaleLatentsInvocation';
@ -150,7 +151,7 @@ export class SessionsService {
* The id of the session * The id of the session
*/ */
sessionId: string, sessionId: string,
requestBody: (LoadImageInvocation | ShowImageInvocation | CropImageInvocation | PasteImageInvocation | MaskFromAlphaInvocation | BlurInvocation | LerpInvocation | InverseLerpInvocation | CompelInvocation | AddInvocation | SubtractInvocation | MultiplyInvocation | DivideInvocation | RandomIntInvocation | ParamIntInvocation | NoiseInvocation | TextToLatentsInvocation | LatentsToImageInvocation | ResizeLatentsInvocation | ScaleLatentsInvocation | ImageToLatentsInvocation | CvInpaintInvocation | RangeInvocation | RandomRangeInvocation | UpscaleInvocation | RestoreFaceInvocation | TextToImageInvocation | InfillColorInvocation | InfillTileInvocation | InfillPatchMatchInvocation | GraphInvocation | IterateInvocation | CollectInvocation | LatentsToLatentsInvocation | ImageToImageInvocation | InpaintInvocation), requestBody: (LoadImageInvocation | ShowImageInvocation | CropImageInvocation | PasteImageInvocation | MaskFromAlphaInvocation | BlurInvocation | LerpInvocation | InverseLerpInvocation | CompelInvocation | AddInvocation | SubtractInvocation | MultiplyInvocation | DivideInvocation | RandomIntInvocation | ParamIntInvocation | NoiseInvocation | TextToLatentsInvocation | LatentsToImageInvocation | ResizeLatentsInvocation | ScaleLatentsInvocation | ImageToLatentsInvocation | CvInpaintInvocation | RangeInvocation | RangeOfSizeInvocation | RandomRangeInvocation | UpscaleInvocation | RestoreFaceInvocation | TextToImageInvocation | InfillColorInvocation | InfillTileInvocation | InfillPatchMatchInvocation | GraphInvocation | IterateInvocation | CollectInvocation | LatentsToLatentsInvocation | ImageToImageInvocation | InpaintInvocation),
}): CancelablePromise<string> { }): CancelablePromise<string> {
return __request(OpenAPI, { return __request(OpenAPI, {
method: 'POST', method: 'POST',
@ -187,7 +188,7 @@ export class SessionsService {
* The path to the node in the graph * The path to the node in the graph
*/ */
nodePath: string, nodePath: string,
requestBody: (LoadImageInvocation | ShowImageInvocation | CropImageInvocation | PasteImageInvocation | MaskFromAlphaInvocation | BlurInvocation | LerpInvocation | InverseLerpInvocation | CompelInvocation | AddInvocation | SubtractInvocation | MultiplyInvocation | DivideInvocation | RandomIntInvocation | ParamIntInvocation | NoiseInvocation | TextToLatentsInvocation | LatentsToImageInvocation | ResizeLatentsInvocation | ScaleLatentsInvocation | ImageToLatentsInvocation | CvInpaintInvocation | RangeInvocation | RandomRangeInvocation | UpscaleInvocation | RestoreFaceInvocation | TextToImageInvocation | InfillColorInvocation | InfillTileInvocation | InfillPatchMatchInvocation | GraphInvocation | IterateInvocation | CollectInvocation | LatentsToLatentsInvocation | ImageToImageInvocation | InpaintInvocation), requestBody: (LoadImageInvocation | ShowImageInvocation | CropImageInvocation | PasteImageInvocation | MaskFromAlphaInvocation | BlurInvocation | LerpInvocation | InverseLerpInvocation | CompelInvocation | AddInvocation | SubtractInvocation | MultiplyInvocation | DivideInvocation | RandomIntInvocation | ParamIntInvocation | NoiseInvocation | TextToLatentsInvocation | LatentsToImageInvocation | ResizeLatentsInvocation | ScaleLatentsInvocation | ImageToLatentsInvocation | CvInpaintInvocation | RangeInvocation | RangeOfSizeInvocation | RandomRangeInvocation | UpscaleInvocation | RestoreFaceInvocation | TextToImageInvocation | InfillColorInvocation | InfillTileInvocation | InfillPatchMatchInvocation | GraphInvocation | IterateInvocation | CollectInvocation | LatentsToLatentsInvocation | ImageToImageInvocation | InpaintInvocation),
}): CancelablePromise<GraphExecutionState> { }): CancelablePromise<GraphExecutionState> {
return __request(OpenAPI, { return __request(OpenAPI, {
method: 'PUT', method: 'PUT',