From 36f72b5a49e0a8187e3a17ae8a674282e68f5b60 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Mon, 12 Jun 2023 15:35:21 +1000 Subject: [PATCH] fix(ui): check for valid controlnets before adding to graph --- .../features/nodes/util/addControlNetToLinearGraph.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/invokeai/frontend/web/src/features/nodes/util/addControlNetToLinearGraph.ts b/invokeai/frontend/web/src/features/nodes/util/addControlNetToLinearGraph.ts index 8baf7cdabe..36e02edadc 100644 --- a/invokeai/frontend/web/src/features/nodes/util/addControlNetToLinearGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/addControlNetToLinearGraph.ts @@ -1,5 +1,5 @@ import { RootState } from 'app/store/store'; -import { forEach, size } from 'lodash-es'; +import { filter, forEach, size } from 'lodash-es'; import { CollectInvocation, ControlNetInvocation } from 'services/api'; import { NonNullableGraph } from '../types/types'; @@ -12,10 +12,13 @@ export const addControlNetToLinearGraph = ( ): void => { const { isEnabled: isControlNetEnabled, controlNets } = state.controlNet; - const controlNetCount = size(controlNets); + const validControlNets = filter( + controlNets, + (c) => c.isEnabled && Boolean(c.processedControlImage) + ); // Add ControlNet - if (isControlNetEnabled && controlNetCount > 0) { + if (isControlNetEnabled && validControlNets.length > 0) { if (size(controlNets) > 1) { const controlNetIterateNode: CollectInvocation = { id: CONTROL_NET_COLLECT,