recall initial image from metadata and set to image2image

This commit is contained in:
Jennifer Player 2024-04-04 10:56:25 -04:00 committed by psychedelicious
parent f56b9537cd
commit 8a17616bf4
4 changed files with 28 additions and 0 deletions

View File

@ -189,6 +189,11 @@ export const handlers = {
recaller: recallers.cfgScale,
}),
height: buildHandlers({ getLabel: () => t('metadata.height'), parser: parsers.height, recaller: recallers.height }),
initialImage: buildHandlers({
getLabel: () => t('metadata.initImage'),
parser: parsers.initialImage,
recaller: recallers.initialImage,
}),
negativePrompt: buildHandlers({
getLabel: () => t('metadata.negativePrompt'),
parser: parsers.negativePrompt,

View File

@ -20,6 +20,7 @@ import type {
ParameterHeight,
ParameterHRFEnabled,
ParameterHRFMethod,
ParameterInitialImage,
ParameterModel,
ParameterNegativePrompt,
ParameterNegativeStylePromptSDXL,
@ -135,6 +136,9 @@ const parseCFGRescaleMultiplier: MetadataParseFunc<ParameterCFGRescaleMultiplier
const parseScheduler: MetadataParseFunc<ParameterScheduler> = (metadata) =>
getProperty(metadata, 'scheduler', isParameterScheduler);
const parseInitialImage: MetadataParseFunc<ParameterInitialImage> = (metadata) =>
getProperty(metadata, 'init_image', isString);
const parseWidth: MetadataParseFunc<ParameterWidth> = (metadata) => getProperty(metadata, 'width', isParameterWidth);
const parseHeight: MetadataParseFunc<ParameterHeight> = (metadata) =>
@ -402,6 +406,7 @@ export const parsers = {
cfgScale: parseCFGScale,
cfgRescaleMultiplier: parseCFGRescaleMultiplier,
scheduler: parseScheduler,
initialImage: parseInitialImage,
width: parseWidth,
height: parseHeight,
steps: parseSteps,

View File

@ -17,6 +17,7 @@ import type {
import { modelSelected } from 'features/parameters/store/actions';
import {
heightRecalled,
initialImageChanged,
setCfgRescaleMultiplier,
setCfgScale,
setImg2imgStrength,
@ -34,6 +35,7 @@ import type {
ParameterHeight,
ParameterHRFEnabled,
ParameterHRFMethod,
ParameterInitialImage,
ParameterModel,
ParameterNegativePrompt,
ParameterNegativeStylePromptSDXL,
@ -61,6 +63,7 @@ import {
setRefinerStart,
setRefinerSteps,
} from 'features/sdxl/store/sdxlSlice';
import type { ImageDTO } from 'services/api/types';
const recallPositivePrompt: MetadataRecallFunc<ParameterPositivePrompt> = (positivePrompt) => {
getStore().dispatch(setPositivePrompt(positivePrompt));
@ -94,6 +97,13 @@ const recallScheduler: MetadataRecallFunc<ParameterScheduler> = (scheduler) => {
getStore().dispatch(setScheduler(scheduler));
};
const recallInitialImage: MetadataRecallFunc<ParameterInitialImage> = (initialImage) => {
const image = {
image_name: initialImage,
};
getStore().dispatch(initialImageChanged(image as ImageDTO));
};
const recallWidth: MetadataRecallFunc<ParameterWidth> = (width) => {
getStore().dispatch(widthRecalled(width));
};
@ -235,6 +245,7 @@ export const recallers = {
cfgScale: recallCFGScale,
cfgRescaleMultiplier: recallCFGRescaleMultiplier,
scheduler: recallScheduler,
initialImage: recallInitialImage,
width: recallWidth,
height: recallHeight,
steps: recallSteps,

View File

@ -126,6 +126,13 @@ const zParameterT2IAdapterModel = zModelIdentifierField;
export type ParameterT2IAdapterModel = z.infer<typeof zParameterT2IAdapterModel>;
// #endregion
// #region I2I Initial Image
const zParameterInitialImage = z.string();
export type ParameterInitialImage = z.infer<typeof zParameterInitialImage>;
export const isParameterInitialImage = (val: unknown): val is ParameterInitialImage =>
zParameterInitialImage.safeParse(val).success;
// #endregion
// #region Strength (l2l strength)
const zParameterStrength = z.number().min(0).max(1);
export type ParameterStrength = z.infer<typeof zParameterStrength>;