more use parameter fixes

This commit is contained in:
Mary Hipp 2023-05-25 15:17:02 -04:00 committed by psychedelicious
parent 1e94d7739a
commit a4c44edf8d
3 changed files with 28 additions and 16 deletions

View File

@ -251,7 +251,8 @@ const HoverableImage = memo((props: HoverableImageProps) => {
icon={<IoArrowUndoCircleOutline />} icon={<IoArrowUndoCircleOutline />}
onClickCapture={handleUseAllParameters} onClickCapture={handleUseAllParameters}
isDisabled={ isDisabled={
!['txt2img', 'img2img', 'inpaint'].includes( // what should these be
!['t2l', 'l2l', 'inpaint'].includes(
String(image?.metadata?.type) String(image?.metadata?.type)
) )
} }

View File

@ -12,11 +12,9 @@ const useSetBothPrompts = () => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
return useCallback( return useCallback(
(inputPrompt: InvokeAI.Prompt, negativePrompt?: InvokeAI.Prompt) => { (inputPrompt: InvokeAI.Prompt, negativePrompt: InvokeAI.Prompt) => {
dispatch(setPositivePrompt(inputPrompt)); dispatch(setPositivePrompt(inputPrompt));
if (negativePrompt) { dispatch(setNegativePrompt(negativePrompt));
dispatch(setNegativePrompt(negativePrompt));
}
}, },
[dispatch] [dispatch]
); );

View File

@ -7,19 +7,29 @@ export const setAllParametersReducer = (
state: Draft<GenerationState>, state: Draft<GenerationState>,
action: PayloadAction<ImageDTO | undefined> action: PayloadAction<ImageDTO | undefined>
) => { ) => {
const node = action.payload?.metadata.invokeai?.node; const metadata = action.payload?.metadata;
if (!node) { if (!metadata) {
return; return;
} }
// not sure what this list should be
if ( if (
node.type === 'txt2img' || metadata.type === 't2l' ||
node.type === 'img2img' || metadata.type === 'l2l' ||
node.type === 'inpaint' metadata.type === 'inpaint'
) { ) {
const { cfg_scale, height, model, prompt, scheduler, seed, steps, width } = const {
node; cfg_scale,
height,
model,
positive_conditioning,
negative_conditioning,
scheduler,
seed,
steps,
width,
} = metadata;
if (cfg_scale !== undefined) { if (cfg_scale !== undefined) {
state.cfgScale = Number(cfg_scale); state.cfgScale = Number(cfg_scale);
@ -30,8 +40,11 @@ export const setAllParametersReducer = (
if (model !== undefined) { if (model !== undefined) {
state.model = String(model); state.model = String(model);
} }
if (prompt !== undefined) { if (positive_conditioning !== undefined) {
state.positivePrompt = String(prompt); state.positivePrompt = String(positive_conditioning);
}
if (negative_conditioning !== undefined) {
state.negativePrompt = String(negative_conditioning);
} }
if (scheduler !== undefined) { if (scheduler !== undefined) {
const schedulerString = String(scheduler); const schedulerString = String(scheduler);
@ -51,8 +64,8 @@ export const setAllParametersReducer = (
} }
} }
if (node.type === 'img2img') { if (metadata.type === 'l2l') {
const { fit, image } = node as ImageToImageInvocation; const { fit, image } = metadata as ImageToImageInvocation;
if (fit !== undefined) { if (fit !== undefined) {
state.shouldFitToWidthHeight = Boolean(fit); state.shouldFitToWidthHeight = Boolean(fit);