mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix: SDXL Metadata not being retrieved
This commit is contained in:
parent
72708eb53c
commit
c5caf1e8fe
@ -139,8 +139,19 @@ const CurrentImageButtons = (props: CurrentImageButtonsProps) => {
|
|||||||
useHotkeys('s', handleUseSeed, [imageDTO]);
|
useHotkeys('s', handleUseSeed, [imageDTO]);
|
||||||
|
|
||||||
const handleUsePrompt = useCallback(() => {
|
const handleUsePrompt = useCallback(() => {
|
||||||
recallBothPrompts(metadata?.positive_prompt, metadata?.negative_prompt);
|
recallBothPrompts(
|
||||||
}, [metadata?.negative_prompt, metadata?.positive_prompt, recallBothPrompts]);
|
metadata?.positive_prompt,
|
||||||
|
metadata?.negative_prompt,
|
||||||
|
metadata?.positive_style_prompt,
|
||||||
|
metadata?.negative_style_prompt
|
||||||
|
);
|
||||||
|
}, [
|
||||||
|
metadata?.negative_prompt,
|
||||||
|
metadata?.positive_prompt,
|
||||||
|
metadata?.positive_style_prompt,
|
||||||
|
metadata?.negative_style_prompt,
|
||||||
|
recallBothPrompts,
|
||||||
|
]);
|
||||||
|
|
||||||
useHotkeys('p', handleUsePrompt, [imageDTO]);
|
useHotkeys('p', handleUsePrompt, [imageDTO]);
|
||||||
|
|
||||||
|
@ -102,8 +102,19 @@ const SingleSelectionMenuItems = (props: SingleSelectionMenuItemsProps) => {
|
|||||||
|
|
||||||
// Recall parameters handlers
|
// Recall parameters handlers
|
||||||
const handleRecallPrompt = useCallback(() => {
|
const handleRecallPrompt = useCallback(() => {
|
||||||
recallBothPrompts(metadata?.positive_prompt, metadata?.negative_prompt);
|
recallBothPrompts(
|
||||||
}, [metadata?.negative_prompt, metadata?.positive_prompt, recallBothPrompts]);
|
metadata?.positive_prompt,
|
||||||
|
metadata?.negative_prompt,
|
||||||
|
metadata?.positive_style_prompt,
|
||||||
|
metadata?.negative_style_prompt
|
||||||
|
);
|
||||||
|
}, [
|
||||||
|
metadata?.negative_prompt,
|
||||||
|
metadata?.positive_prompt,
|
||||||
|
metadata?.positive_style_prompt,
|
||||||
|
metadata?.negative_style_prompt,
|
||||||
|
recallBothPrompts,
|
||||||
|
]);
|
||||||
|
|
||||||
const handleRecallSeed = useCallback(() => {
|
const handleRecallSeed = useCallback(() => {
|
||||||
recallSeed(metadata?.seed);
|
recallSeed(metadata?.seed);
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
import { useAppToaster } from 'app/components/Toaster';
|
import { useAppToaster } from 'app/components/Toaster';
|
||||||
import { useAppDispatch } from 'app/store/storeHooks';
|
import { useAppDispatch } from 'app/store/storeHooks';
|
||||||
|
import {
|
||||||
|
refinerModelChanged,
|
||||||
|
setNegativeStylePromptSDXL,
|
||||||
|
setPositiveStylePromptSDXL,
|
||||||
|
setRefinerAestheticScore,
|
||||||
|
setRefinerCFGScale,
|
||||||
|
setRefinerScheduler,
|
||||||
|
setRefinerStart,
|
||||||
|
setRefinerSteps,
|
||||||
|
} from 'features/sdxl/store/sdxlSlice';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { UnsafeImageMetadata } from 'services/api/endpoints/images';
|
import { UnsafeImageMetadata } from 'services/api/endpoints/images';
|
||||||
@ -22,6 +32,10 @@ import {
|
|||||||
isValidMainModel,
|
isValidMainModel,
|
||||||
isValidNegativePrompt,
|
isValidNegativePrompt,
|
||||||
isValidPositivePrompt,
|
isValidPositivePrompt,
|
||||||
|
isValidSDXLNegativeStylePrompt,
|
||||||
|
isValidSDXLPositiveStylePrompt,
|
||||||
|
isValidSDXLRefinerAestheticScore,
|
||||||
|
isValidSDXLRefinerStart,
|
||||||
isValidScheduler,
|
isValidScheduler,
|
||||||
isValidSeed,
|
isValidSeed,
|
||||||
isValidSteps,
|
isValidSteps,
|
||||||
@ -74,17 +88,34 @@ export const useRecallParameters = () => {
|
|||||||
* Recall both prompts with toast
|
* Recall both prompts with toast
|
||||||
*/
|
*/
|
||||||
const recallBothPrompts = useCallback(
|
const recallBothPrompts = useCallback(
|
||||||
(positivePrompt: unknown, negativePrompt: unknown) => {
|
(
|
||||||
|
positivePrompt: unknown,
|
||||||
|
negativePrompt: unknown,
|
||||||
|
positiveStylePrompt: unknown,
|
||||||
|
negativeStylePrompt: unknown
|
||||||
|
) => {
|
||||||
if (
|
if (
|
||||||
isValidPositivePrompt(positivePrompt) ||
|
isValidPositivePrompt(positivePrompt) ||
|
||||||
isValidNegativePrompt(negativePrompt)
|
isValidNegativePrompt(negativePrompt) ||
|
||||||
|
isValidSDXLPositiveStylePrompt(positiveStylePrompt) ||
|
||||||
|
isValidSDXLNegativeStylePrompt(negativeStylePrompt)
|
||||||
) {
|
) {
|
||||||
if (isValidPositivePrompt(positivePrompt)) {
|
if (isValidPositivePrompt(positivePrompt)) {
|
||||||
dispatch(setPositivePrompt(positivePrompt));
|
dispatch(setPositivePrompt(positivePrompt));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isValidNegativePrompt(negativePrompt)) {
|
if (isValidNegativePrompt(negativePrompt)) {
|
||||||
dispatch(setNegativePrompt(negativePrompt));
|
dispatch(setNegativePrompt(negativePrompt));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isValidSDXLPositiveStylePrompt(positiveStylePrompt)) {
|
||||||
|
dispatch(setPositiveStylePromptSDXL(positiveStylePrompt));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isValidSDXLPositiveStylePrompt(negativeStylePrompt)) {
|
||||||
|
dispatch(setNegativeStylePromptSDXL(negativeStylePrompt));
|
||||||
|
}
|
||||||
|
|
||||||
parameterSetToast();
|
parameterSetToast();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -123,6 +154,36 @@ export const useRecallParameters = () => {
|
|||||||
[dispatch, parameterSetToast, parameterNotSetToast]
|
[dispatch, parameterSetToast, parameterNotSetToast]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recall SDXL Positive Style Prompt with toast
|
||||||
|
*/
|
||||||
|
const recallSDXLPositiveStylePrompt = useCallback(
|
||||||
|
(positiveStylePrompt: unknown) => {
|
||||||
|
if (!isValidSDXLPositiveStylePrompt(positiveStylePrompt)) {
|
||||||
|
parameterNotSetToast();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dispatch(setPositiveStylePromptSDXL(positiveStylePrompt));
|
||||||
|
parameterSetToast();
|
||||||
|
},
|
||||||
|
[dispatch, parameterSetToast, parameterNotSetToast]
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recall SDXL Negative Style Prompt with toast
|
||||||
|
*/
|
||||||
|
const recallSDXLNegativeStylePrompt = useCallback(
|
||||||
|
(negativeStylePrompt: unknown) => {
|
||||||
|
if (!isValidSDXLNegativeStylePrompt(negativeStylePrompt)) {
|
||||||
|
parameterNotSetToast();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dispatch(setNegativeStylePromptSDXL(negativeStylePrompt));
|
||||||
|
parameterSetToast();
|
||||||
|
},
|
||||||
|
[dispatch, parameterSetToast, parameterNotSetToast]
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recall seed with toast
|
* Recall seed with toast
|
||||||
*/
|
*/
|
||||||
@ -271,6 +332,14 @@ export const useRecallParameters = () => {
|
|||||||
steps,
|
steps,
|
||||||
width,
|
width,
|
||||||
strength,
|
strength,
|
||||||
|
positive_style_prompt,
|
||||||
|
negative_style_prompt,
|
||||||
|
refiner_model,
|
||||||
|
refiner_cfg_scale,
|
||||||
|
refiner_steps,
|
||||||
|
refiner_scheduler,
|
||||||
|
refiner_aesthetic_store,
|
||||||
|
refiner_start,
|
||||||
} = metadata;
|
} = metadata;
|
||||||
|
|
||||||
if (isValidCfgScale(cfg_scale)) {
|
if (isValidCfgScale(cfg_scale)) {
|
||||||
@ -304,6 +373,38 @@ export const useRecallParameters = () => {
|
|||||||
dispatch(setImg2imgStrength(strength));
|
dispatch(setImg2imgStrength(strength));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isValidSDXLPositiveStylePrompt(positive_style_prompt)) {
|
||||||
|
dispatch(setPositiveStylePromptSDXL(positive_style_prompt));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isValidSDXLNegativeStylePrompt(negative_style_prompt)) {
|
||||||
|
dispatch(setNegativeStylePromptSDXL(negative_style_prompt));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isValidMainModel(refiner_model)) {
|
||||||
|
dispatch(refinerModelChanged(refiner_model));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isValidSteps(refiner_steps)) {
|
||||||
|
dispatch(setRefinerSteps(refiner_steps));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isValidCfgScale(refiner_cfg_scale)) {
|
||||||
|
dispatch(setRefinerCFGScale(refiner_cfg_scale));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isValidScheduler(refiner_scheduler)) {
|
||||||
|
dispatch(setRefinerScheduler(refiner_scheduler));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isValidSDXLRefinerAestheticScore(refiner_aesthetic_store)) {
|
||||||
|
dispatch(setRefinerAestheticScore(refiner_aesthetic_store));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isValidSDXLRefinerStart(refiner_start)) {
|
||||||
|
dispatch(setRefinerStart(refiner_start));
|
||||||
|
}
|
||||||
|
|
||||||
allParameterSetToast();
|
allParameterSetToast();
|
||||||
},
|
},
|
||||||
[allParameterNotSetToast, allParameterSetToast, dispatch]
|
[allParameterNotSetToast, allParameterSetToast, dispatch]
|
||||||
@ -313,6 +414,8 @@ export const useRecallParameters = () => {
|
|||||||
recallBothPrompts,
|
recallBothPrompts,
|
||||||
recallPositivePrompt,
|
recallPositivePrompt,
|
||||||
recallNegativePrompt,
|
recallNegativePrompt,
|
||||||
|
recallSDXLPositiveStylePrompt,
|
||||||
|
recallSDXLNegativeStylePrompt,
|
||||||
recallSeed,
|
recallSeed,
|
||||||
recallCfgScale,
|
recallCfgScale,
|
||||||
recallModel,
|
recallModel,
|
||||||
|
@ -310,6 +310,39 @@ export type PrecisionParam = z.infer<typeof zPrecision>;
|
|||||||
export const isValidPrecision = (val: unknown): val is PrecisionParam =>
|
export const isValidPrecision = (val: unknown): val is PrecisionParam =>
|
||||||
zPrecision.safeParse(val).success;
|
zPrecision.safeParse(val).success;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zod schema for SDXL refiner aesthetic score parameter
|
||||||
|
*/
|
||||||
|
export const zSDXLRefinerAestheticScore = z.number().min(1).max(10);
|
||||||
|
/**
|
||||||
|
* Type alias for SDXL refiner aesthetic score parameter, inferred from its zod schema
|
||||||
|
*/
|
||||||
|
export type SDXLRefinerAestheticScoreParam = z.infer<
|
||||||
|
typeof zSDXLRefinerAestheticScore
|
||||||
|
>;
|
||||||
|
/**
|
||||||
|
* Validates/type-guards a value as a SDXL refiner aesthetic score parameter
|
||||||
|
*/
|
||||||
|
export const isValidSDXLRefinerAestheticScore = (
|
||||||
|
val: unknown
|
||||||
|
): val is SDXLRefinerAestheticScoreParam =>
|
||||||
|
zSDXLRefinerAestheticScore.safeParse(val).success;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zod schema for SDXL start parameter
|
||||||
|
*/
|
||||||
|
export const zSDXLRefinerstart = z.number().min(0).max(1);
|
||||||
|
/**
|
||||||
|
* Type alias for SDXL start, inferred from its zod schema
|
||||||
|
*/
|
||||||
|
export type SDXLRefinerStartParam = z.infer<typeof zSDXLRefinerstart>;
|
||||||
|
/**
|
||||||
|
* Validates/type-guards a value as a SDXL refiner aesthetic score parameter
|
||||||
|
*/
|
||||||
|
export const isValidSDXLRefinerStart = (
|
||||||
|
val: unknown
|
||||||
|
): val is SDXLRefinerStartParam => zSDXLRefinerstart.safeParse(val).success;
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Zod schema for BaseModelType
|
// * Zod schema for BaseModelType
|
||||||
// */
|
// */
|
||||||
|
@ -21,8 +21,8 @@ export default function ParamSDXLConcatButton() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<IAIIconButton
|
<IAIIconButton
|
||||||
aria-label="Concat"
|
aria-label="Concatenate Prompt & Style"
|
||||||
tooltip="Concatenates Basic Prompt with Style (Recommended)"
|
tooltip="Concatenate Prompt & Style"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
isChecked={shouldConcatSDXLStylePrompt}
|
isChecked={shouldConcatSDXLStylePrompt}
|
||||||
onClick={handleShouldConcatPromptChange}
|
onClick={handleShouldConcatPromptChange}
|
||||||
|
Loading…
Reference in New Issue
Block a user