From 382e2139bd15c844752f2b5465d0c67bdfbd7a71 Mon Sep 17 00:00:00 2001 From: Ryan Dick Date: Mon, 18 Sep 2023 12:57:23 -0400 Subject: [PATCH] Clear incompatible IP-Adapter when base model changes in the Linear UI. --- .../listeners/modelSelected.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/modelSelected.ts b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/modelSelected.ts index eb25b22293..ba42fce950 100644 --- a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/modelSelected.ts +++ b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/modelSelected.ts @@ -1,6 +1,9 @@ import { logger } from 'app/logging/logger'; import { setBoundingBoxDimensions } from 'features/canvas/store/canvasSlice'; -import { controlNetRemoved } from 'features/controlNet/store/controlNetSlice'; +import { + controlNetRemoved, + ipAdapterStateReset, +} from 'features/controlNet/store/controlNetSlice'; import { loraRemoved } from 'features/lora/store/loraSlice'; import { modelSelected } from 'features/parameters/store/actions'; import { @@ -56,6 +59,7 @@ export const addModelSelectedListener = () => { modelsCleared += 1; } + // handle incompatible controlnets const { controlNets } = state.controlNet; forEach(controlNets, (controlNet, controlNetId) => { if (controlNet.model?.base_model !== base_model) { @@ -64,6 +68,16 @@ export const addModelSelectedListener = () => { } }); + // handle incompatible IP-Adapter + const { ipAdapterInfo } = state.controlNet; + if ( + ipAdapterInfo.model && + ipAdapterInfo.model.base_model !== base_model + ) { + dispatch(ipAdapterStateReset()); + modelsCleared += 1; + } + if (modelsCleared > 0) { dispatch( addToast(