mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-13 01:35:17 -05:00
feat(ui): images always added to gallery in simple session
This commit is contained in:
@@ -9,7 +9,7 @@ import { getGlobalReferenceImageWarnings } from 'features/controlLayers/store/va
|
||||
import { type ImageField, zModelIdentifierField } from 'features/nodes/types/common';
|
||||
import { getGenerationMode } from 'features/nodes/util/graph/generation/getGenerationMode';
|
||||
import { Graph } from 'features/nodes/util/graph/generation/Graph';
|
||||
import { CANVAS_OUTPUT_PREFIX, selectPresetModifiedPrompts } from 'features/nodes/util/graph/graphBuilderUtils';
|
||||
import { selectCanvasOutputFields, selectPresetModifiedPrompts } from 'features/nodes/util/graph/graphBuilderUtils';
|
||||
import { type GraphBuilderReturn, UnsupportedGenerationModeError } from 'features/nodes/util/graph/types';
|
||||
import { t } from 'i18next';
|
||||
import type { Equals } from 'tsafe';
|
||||
@@ -64,14 +64,11 @@ export const buildChatGPT4oGraph = async (
|
||||
const gptImage = g.addNode({
|
||||
// @ts-expect-error: These nodes are not available in the OSS application
|
||||
type: 'chatgpt_4o_generate_image',
|
||||
id: getPrefixedId(CANVAS_OUTPUT_PREFIX),
|
||||
model: zModelIdentifierField.parse(model),
|
||||
positive_prompt: positivePrompt,
|
||||
aspect_ratio: bbox.aspectRatio.id,
|
||||
reference_images,
|
||||
use_cache: false,
|
||||
is_intermediate: true,
|
||||
board: undefined,
|
||||
...selectCanvasOutputFields(state),
|
||||
});
|
||||
g.upsertMetadata({
|
||||
positive_prompt: positivePrompt,
|
||||
@@ -96,15 +93,12 @@ export const buildChatGPT4oGraph = async (
|
||||
const gptImage = g.addNode({
|
||||
// @ts-expect-error: These nodes are not available in the OSS application
|
||||
type: 'chatgpt_4o_edit_image',
|
||||
id: getPrefixedId(CANVAS_OUTPUT_PREFIX),
|
||||
model: zModelIdentifierField.parse(model),
|
||||
positive_prompt: positivePrompt,
|
||||
aspect_ratio: bbox.aspectRatio.id,
|
||||
base_image: { image_name },
|
||||
reference_images,
|
||||
use_cache: false,
|
||||
is_intermediate: true,
|
||||
board: undefined,
|
||||
...selectCanvasOutputFields(state),
|
||||
});
|
||||
g.upsertMetadata({
|
||||
positive_prompt: positivePrompt,
|
||||
|
||||
@@ -14,8 +14,8 @@ import { addWatermarker } from 'features/nodes/util/graph/generation/addWatermar
|
||||
import { getGenerationMode } from 'features/nodes/util/graph/generation/getGenerationMode';
|
||||
import { Graph } from 'features/nodes/util/graph/generation/Graph';
|
||||
import {
|
||||
CANVAS_OUTPUT_PREFIX,
|
||||
getSizes,
|
||||
selectCanvasOutputFields,
|
||||
selectPresetModifiedPrompts,
|
||||
} from 'features/nodes/util/graph/graphBuilderUtils';
|
||||
import type { GraphBuilderReturn, ImageOutputNodes } from 'features/nodes/util/graph/types';
|
||||
@@ -175,12 +175,7 @@ export const buildCogView4Graph = async (
|
||||
|
||||
g.upsertMetadata(selectCanvasMetadata(state));
|
||||
|
||||
g.updateNode(canvasOutput, {
|
||||
id: getPrefixedId(CANVAS_OUTPUT_PREFIX),
|
||||
is_intermediate: true,
|
||||
use_cache: false,
|
||||
board: undefined,
|
||||
});
|
||||
g.updateNode(canvasOutput, selectCanvasOutputFields(state));
|
||||
|
||||
g.setMetadataReceivingNode(canvasOutput);
|
||||
return {
|
||||
|
||||
@@ -17,8 +17,8 @@ import { addWatermarker } from 'features/nodes/util/graph/generation/addWatermar
|
||||
import { getGenerationMode } from 'features/nodes/util/graph/generation/getGenerationMode';
|
||||
import { Graph } from 'features/nodes/util/graph/generation/Graph';
|
||||
import {
|
||||
CANVAS_OUTPUT_PREFIX,
|
||||
getSizes,
|
||||
selectCanvasOutputFields,
|
||||
selectPresetModifiedPrompts,
|
||||
} from 'features/nodes/util/graph/graphBuilderUtils';
|
||||
import {
|
||||
@@ -334,12 +334,7 @@ export const buildFLUXGraph = async (state: RootState, manager?: CanvasManager |
|
||||
|
||||
g.upsertMetadata(selectCanvasMetadata(state));
|
||||
|
||||
g.updateNode(canvasOutput, {
|
||||
id: getPrefixedId(CANVAS_OUTPUT_PREFIX),
|
||||
is_intermediate: true,
|
||||
use_cache: false,
|
||||
board: undefined,
|
||||
});
|
||||
g.updateNode(canvasOutput, selectCanvasOutputFields(state));
|
||||
|
||||
g.setMetadataReceivingNode(canvasOutput);
|
||||
return {
|
||||
|
||||
@@ -8,7 +8,7 @@ import { isImagenAspectRatioID } from 'features/controlLayers/store/types';
|
||||
import { zModelIdentifierField } from 'features/nodes/types/common';
|
||||
import { getGenerationMode } from 'features/nodes/util/graph/generation/getGenerationMode';
|
||||
import { Graph } from 'features/nodes/util/graph/generation/Graph';
|
||||
import { CANVAS_OUTPUT_PREFIX, selectPresetModifiedPrompts } from 'features/nodes/util/graph/graphBuilderUtils';
|
||||
import { selectCanvasOutputFields, selectPresetModifiedPrompts } from 'features/nodes/util/graph/graphBuilderUtils';
|
||||
import { type GraphBuilderReturn, UnsupportedGenerationModeError } from 'features/nodes/util/graph/types';
|
||||
import { t } from 'i18next';
|
||||
import type { Equals } from 'tsafe';
|
||||
@@ -44,16 +44,13 @@ export const buildImagen3Graph = async (
|
||||
const imagen3 = g.addNode({
|
||||
// @ts-expect-error: These nodes are not available in the OSS application
|
||||
type: 'google_imagen3_generate_image',
|
||||
id: getPrefixedId(CANVAS_OUTPUT_PREFIX),
|
||||
model: zModelIdentifierField.parse(model),
|
||||
positive_prompt: positivePrompt,
|
||||
negative_prompt: negativePrompt,
|
||||
aspect_ratio: bbox.aspectRatio.id,
|
||||
enhance_prompt: true,
|
||||
// When enhance_prompt is true, Imagen3 will return a new image every time, ignoring the seed.
|
||||
use_cache: false,
|
||||
is_intermediate: true,
|
||||
board: undefined,
|
||||
enhance_prompt: true,
|
||||
...selectCanvasOutputFields(state),
|
||||
});
|
||||
g.upsertMetadata({
|
||||
positive_prompt: positivePrompt,
|
||||
|
||||
@@ -8,7 +8,7 @@ import { isImagenAspectRatioID } from 'features/controlLayers/store/types';
|
||||
import { zModelIdentifierField } from 'features/nodes/types/common';
|
||||
import { getGenerationMode } from 'features/nodes/util/graph/generation/getGenerationMode';
|
||||
import { Graph } from 'features/nodes/util/graph/generation/Graph';
|
||||
import { CANVAS_OUTPUT_PREFIX, selectPresetModifiedPrompts } from 'features/nodes/util/graph/graphBuilderUtils';
|
||||
import { selectCanvasOutputFields, selectPresetModifiedPrompts } from 'features/nodes/util/graph/graphBuilderUtils';
|
||||
import { type GraphBuilderReturn, UnsupportedGenerationModeError } from 'features/nodes/util/graph/types';
|
||||
import { t } from 'i18next';
|
||||
import type { Equals } from 'tsafe';
|
||||
@@ -44,16 +44,13 @@ export const buildImagen4Graph = async (
|
||||
const imagen4 = g.addNode({
|
||||
// @ts-expect-error: These nodes are not available in the OSS application
|
||||
type: 'google_imagen4_generate_image',
|
||||
id: getPrefixedId(CANVAS_OUTPUT_PREFIX),
|
||||
model: zModelIdentifierField.parse(model),
|
||||
positive_prompt: positivePrompt,
|
||||
negative_prompt: negativePrompt,
|
||||
aspect_ratio: bbox.aspectRatio.id,
|
||||
enhance_prompt: true,
|
||||
// When enhance_prompt is true, Imagen4 will return a new image every time, ignoring the seed.
|
||||
use_cache: false,
|
||||
is_intermediate: true,
|
||||
board: undefined,
|
||||
enhance_prompt: true,
|
||||
...selectCanvasOutputFields(state),
|
||||
});
|
||||
g.upsertMetadata({
|
||||
positive_prompt: positivePrompt,
|
||||
|
||||
@@ -18,8 +18,8 @@ import { addWatermarker } from 'features/nodes/util/graph/generation/addWatermar
|
||||
import { getGenerationMode } from 'features/nodes/util/graph/generation/getGenerationMode';
|
||||
import { Graph } from 'features/nodes/util/graph/generation/Graph';
|
||||
import {
|
||||
CANVAS_OUTPUT_PREFIX,
|
||||
getSizes,
|
||||
selectCanvasOutputFields,
|
||||
selectPresetModifiedPrompts,
|
||||
} from 'features/nodes/util/graph/graphBuilderUtils';
|
||||
import type { GraphBuilderReturn, ImageOutputNodes } from 'features/nodes/util/graph/types';
|
||||
@@ -306,12 +306,7 @@ export const buildSD1Graph = async (state: RootState, manager?: CanvasManager |
|
||||
|
||||
g.upsertMetadata(selectCanvasMetadata(state));
|
||||
|
||||
g.updateNode(canvasOutput, {
|
||||
id: getPrefixedId(CANVAS_OUTPUT_PREFIX),
|
||||
is_intermediate: true,
|
||||
use_cache: false,
|
||||
board: undefined,
|
||||
});
|
||||
g.updateNode(canvasOutput, selectCanvasOutputFields(state));
|
||||
|
||||
g.setMetadataReceivingNode(canvasOutput);
|
||||
return {
|
||||
|
||||
@@ -13,8 +13,8 @@ import { addWatermarker } from 'features/nodes/util/graph/generation/addWatermar
|
||||
import { getGenerationMode } from 'features/nodes/util/graph/generation/getGenerationMode';
|
||||
import { Graph } from 'features/nodes/util/graph/generation/Graph';
|
||||
import {
|
||||
CANVAS_OUTPUT_PREFIX,
|
||||
getSizes,
|
||||
selectCanvasOutputFields,
|
||||
selectPresetModifiedPrompts,
|
||||
} from 'features/nodes/util/graph/graphBuilderUtils';
|
||||
import type { GraphBuilderReturn, ImageOutputNodes } from 'features/nodes/util/graph/types';
|
||||
@@ -196,12 +196,7 @@ export const buildSD3Graph = async (state: RootState, manager?: CanvasManager |
|
||||
|
||||
g.upsertMetadata(selectCanvasMetadata(state));
|
||||
|
||||
g.updateNode(canvasOutput, {
|
||||
id: getPrefixedId(CANVAS_OUTPUT_PREFIX),
|
||||
is_intermediate: true,
|
||||
use_cache: false,
|
||||
board: undefined,
|
||||
});
|
||||
g.updateNode(canvasOutput, selectCanvasOutputFields(state));
|
||||
|
||||
g.setMetadataReceivingNode(canvasOutput);
|
||||
return {
|
||||
|
||||
@@ -18,8 +18,8 @@ import { addWatermarker } from 'features/nodes/util/graph/generation/addWatermar
|
||||
import { getGenerationMode } from 'features/nodes/util/graph/generation/getGenerationMode';
|
||||
import { Graph } from 'features/nodes/util/graph/generation/Graph';
|
||||
import {
|
||||
CANVAS_OUTPUT_PREFIX,
|
||||
getSizes,
|
||||
selectCanvasOutputFields,
|
||||
selectPresetModifiedPrompts,
|
||||
} from 'features/nodes/util/graph/graphBuilderUtils';
|
||||
import type { GraphBuilderReturn, ImageOutputNodes } from 'features/nodes/util/graph/types';
|
||||
@@ -312,12 +312,7 @@ export const buildSDXLGraph = async (state: RootState, manager?: CanvasManager |
|
||||
|
||||
g.upsertMetadata(selectCanvasMetadata(state));
|
||||
|
||||
g.updateNode(canvasOutput, {
|
||||
id: getPrefixedId(CANVAS_OUTPUT_PREFIX),
|
||||
is_intermediate: true,
|
||||
use_cache: false,
|
||||
board: undefined,
|
||||
});
|
||||
g.updateNode(canvasOutput, selectCanvasOutputFields(state));
|
||||
|
||||
g.setMetadataReceivingNode(canvasOutput);
|
||||
return {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
import type { RootState } from 'app/store/store';
|
||||
import { getPrefixedId } from 'features/controlLayers/konva/util';
|
||||
import { selectCanvasSessionType } from 'features/controlLayers/store/canvasStagingAreaSlice';
|
||||
import { selectParamsSlice } from 'features/controlLayers/store/paramsSlice';
|
||||
import type { CanvasState, ParamsState } from 'features/controlLayers/store/types';
|
||||
import type { BoardField } from 'features/nodes/types/common';
|
||||
@@ -24,6 +26,28 @@ export const getBoardField = (state: RootState): BoardField | undefined => {
|
||||
return { board_id: autoAddBoardId };
|
||||
};
|
||||
|
||||
/**
|
||||
* Builds the common fields for canvas output:
|
||||
* - id
|
||||
* - use_cache
|
||||
* - is_intermediate
|
||||
* - board
|
||||
*/
|
||||
export const selectCanvasOutputFields = (state: RootState) => {
|
||||
// Advanced session means working on canvas - images are not saved to gallery or added to a board.
|
||||
// Simple session means working in YOLO mode - images are saved to gallery & board.
|
||||
const sessionType = selectCanvasSessionType(state);
|
||||
const is_intermediate = sessionType === 'advanced';
|
||||
const board = sessionType === 'advanced' ? undefined : getBoardField(state);
|
||||
|
||||
return {
|
||||
is_intermediate,
|
||||
board,
|
||||
use_cache: false,
|
||||
id: getPrefixedId(CANVAS_OUTPUT_PREFIX),
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the prompts, modified for the active style preset.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user