update simple upscale metadata to match upscale metadata

This commit is contained in:
chainchompa 2024-07-23 12:15:26 -04:00
parent b46b20210d
commit cbce89162b
2 changed files with 12 additions and 5 deletions

View File

@ -39,7 +39,7 @@ export const addUpscaleRequestedListener = (startAppListening: AppStartListening
const enqueueBatchArg: BatchConfig = {
prepend: true,
batch: {
graph: buildAdHocUpscaleGraph({
graph: await buildAdHocUpscaleGraph({
image: imageDTO,
state,
}),

View File

@ -1,8 +1,14 @@
import type { RootState } from 'app/store/store';
import type { Graph, ImageDTO, Invocation, NonNullableGraph } from 'services/api/types';
import { fetchModelConfigWithTypeGuard } from 'features/metadata/util/modelFetchingHelpers';
import {
type ImageDTO,
type Invocation,
isSpandrelImageToImageModelConfig,
type NonNullableGraph,
} from 'services/api/types';
import { assert } from 'tsafe';
import { addCoreMetadataNode, upsertMetadata } from './canvas/metadata';
import { addCoreMetadataNode, getModelMetadataField, upsertMetadata } from './canvas/metadata';
import { SPANDREL } from './constants';
type Arg = {
@ -10,7 +16,7 @@ type Arg = {
state: RootState;
};
export const buildAdHocUpscaleGraph = ({ image, state }: Arg): Graph => {
export const buildAdHocUpscaleGraph = async ({ image, state }: Arg): Promise<NonNullableGraph> => {
const { simpleUpscaleModel } = state.upscale;
assert(simpleUpscaleModel, 'No upscale model found in state');
@ -30,10 +36,11 @@ export const buildAdHocUpscaleGraph = ({ image, state }: Arg): Graph => {
},
edges: [],
};
const modelConfig = await fetchModelConfigWithTypeGuard(simpleUpscaleModel.key, isSpandrelImageToImageModelConfig);
addCoreMetadataNode(graph, {}, SPANDREL);
upsertMetadata(graph, {
spandrel_model: simpleUpscaleModel,
upscale_model: getModelMetadataField(modelConfig),
});
return graph;