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 = { const enqueueBatchArg: BatchConfig = {
prepend: true, prepend: true,
batch: { batch: {
graph: buildAdHocUpscaleGraph({ graph: await buildAdHocUpscaleGraph({
image: imageDTO, image: imageDTO,
state, state,
}), }),

View File

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