From a4c44edf8d0393bad37e378636e6bd9f6c672dc4 Mon Sep 17 00:00:00 2001 From: Mary Hipp Date: Thu, 25 May 2023 15:17:02 -0400 Subject: [PATCH] more use parameter fixes --- .../gallery/components/HoverableImage.tsx | 3 +- .../features/parameters/hooks/usePrompt.ts | 6 ++-- .../store/setAllParametersReducer.ts | 35 +++++++++++++------ 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/invokeai/frontend/web/src/features/gallery/components/HoverableImage.tsx b/invokeai/frontend/web/src/features/gallery/components/HoverableImage.tsx index fccfba0a70..ed427f4984 100644 --- a/invokeai/frontend/web/src/features/gallery/components/HoverableImage.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/HoverableImage.tsx @@ -251,7 +251,8 @@ const HoverableImage = memo((props: HoverableImageProps) => { icon={} onClickCapture={handleUseAllParameters} isDisabled={ - !['txt2img', 'img2img', 'inpaint'].includes( + // what should these be + !['t2l', 'l2l', 'inpaint'].includes( String(image?.metadata?.type) ) } diff --git a/invokeai/frontend/web/src/features/parameters/hooks/usePrompt.ts b/invokeai/frontend/web/src/features/parameters/hooks/usePrompt.ts index cb39be6e1e..3fee0bcdd8 100644 --- a/invokeai/frontend/web/src/features/parameters/hooks/usePrompt.ts +++ b/invokeai/frontend/web/src/features/parameters/hooks/usePrompt.ts @@ -12,11 +12,9 @@ const useSetBothPrompts = () => { const dispatch = useAppDispatch(); return useCallback( - (inputPrompt: InvokeAI.Prompt, negativePrompt?: InvokeAI.Prompt) => { + (inputPrompt: InvokeAI.Prompt, negativePrompt: InvokeAI.Prompt) => { dispatch(setPositivePrompt(inputPrompt)); - if (negativePrompt) { - dispatch(setNegativePrompt(negativePrompt)); - } + dispatch(setNegativePrompt(negativePrompt)); }, [dispatch] ); diff --git a/invokeai/frontend/web/src/features/parameters/store/setAllParametersReducer.ts b/invokeai/frontend/web/src/features/parameters/store/setAllParametersReducer.ts index d6d1af0f8e..8f06c7d0ef 100644 --- a/invokeai/frontend/web/src/features/parameters/store/setAllParametersReducer.ts +++ b/invokeai/frontend/web/src/features/parameters/store/setAllParametersReducer.ts @@ -7,19 +7,29 @@ export const setAllParametersReducer = ( state: Draft, action: PayloadAction ) => { - const node = action.payload?.metadata.invokeai?.node; + const metadata = action.payload?.metadata; - if (!node) { + if (!metadata) { return; } + // not sure what this list should be if ( - node.type === 'txt2img' || - node.type === 'img2img' || - node.type === 'inpaint' + metadata.type === 't2l' || + metadata.type === 'l2l' || + metadata.type === 'inpaint' ) { - const { cfg_scale, height, model, prompt, scheduler, seed, steps, width } = - node; + const { + cfg_scale, + height, + model, + positive_conditioning, + negative_conditioning, + scheduler, + seed, + steps, + width, + } = metadata; if (cfg_scale !== undefined) { state.cfgScale = Number(cfg_scale); @@ -30,8 +40,11 @@ export const setAllParametersReducer = ( if (model !== undefined) { state.model = String(model); } - if (prompt !== undefined) { - state.positivePrompt = String(prompt); + if (positive_conditioning !== undefined) { + state.positivePrompt = String(positive_conditioning); + } + if (negative_conditioning !== undefined) { + state.negativePrompt = String(negative_conditioning); } if (scheduler !== undefined) { const schedulerString = String(scheduler); @@ -51,8 +64,8 @@ export const setAllParametersReducer = ( } } - if (node.type === 'img2img') { - const { fit, image } = node as ImageToImageInvocation; + if (metadata.type === 'l2l') { + const { fit, image } = metadata as ImageToImageInvocation; if (fit !== undefined) { state.shouldFitToWidthHeight = Boolean(fit);