mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
- simplify access to app logger - spruce up and make consistent log format - improve messaging
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { RootState } from 'app/store/store';
|
|
import { NonNullableGraph } from 'features/nodes/types/types';
|
|
import { ImageDTO } from 'services/api/types';
|
|
import { buildCanvasImageToImageGraph } from './buildCanvasImageToImageGraph';
|
|
import { buildCanvasInpaintGraph } from './buildCanvasInpaintGraph';
|
|
import { buildCanvasTextToImageGraph } from './buildCanvasTextToImageGraph';
|
|
|
|
export const buildCanvasGraph = (
|
|
state: RootState,
|
|
generationMode: 'txt2img' | 'img2img' | 'inpaint' | 'outpaint',
|
|
canvasInitImage: ImageDTO | undefined,
|
|
canvasMaskImage: ImageDTO | undefined
|
|
) => {
|
|
let graph: NonNullableGraph;
|
|
|
|
if (generationMode === 'txt2img') {
|
|
graph = buildCanvasTextToImageGraph(state);
|
|
} else if (generationMode === 'img2img') {
|
|
if (!canvasInitImage) {
|
|
throw new Error('Missing canvas init image');
|
|
}
|
|
graph = buildCanvasImageToImageGraph(state, canvasInitImage);
|
|
} else {
|
|
if (!canvasInitImage || !canvasMaskImage) {
|
|
throw new Error('Missing canvas init and mask images');
|
|
}
|
|
graph = buildCanvasInpaintGraph(state, canvasInitImage, canvasMaskImage);
|
|
}
|
|
|
|
return graph;
|
|
};
|