From 10fac5c085d7c2b672393e753aefc94d09c56f65 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Thu, 12 Oct 2023 23:41:25 +1100 Subject: [PATCH] feat(ui): set w/h to multiple of 64 on add t2i --- .../controlAdapters/store/controlAdaptersSlice.ts | 7 +++++++ .../src/features/parameters/store/generationSlice.ts | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/invokeai/frontend/web/src/features/controlAdapters/store/controlAdaptersSlice.ts b/invokeai/frontend/web/src/features/controlAdapters/store/controlAdaptersSlice.ts index 8cbd9978ae..a3645fad9d 100644 --- a/invokeai/frontend/web/src/features/controlAdapters/store/controlAdaptersSlice.ts +++ b/invokeai/frontend/web/src/features/controlAdapters/store/controlAdaptersSlice.ts @@ -3,6 +3,7 @@ import { Update, createEntityAdapter, createSlice, + isAnyOf, } from '@reduxjs/toolkit'; import { ControlNetModelParam, @@ -544,3 +545,9 @@ export const { } = controlAdaptersSlice.actions; export default controlAdaptersSlice.reducer; + +export const isAnyControlAdapterAdded = isAnyOf( + controlAdapterAdded, + controlAdapterAddedFromImage, + controlAdapterRecalled +); diff --git a/invokeai/frontend/web/src/features/parameters/store/generationSlice.ts b/invokeai/frontend/web/src/features/parameters/store/generationSlice.ts index ea6aaf28ca..84d26b6476 100644 --- a/invokeai/frontend/web/src/features/parameters/store/generationSlice.ts +++ b/invokeai/frontend/web/src/features/parameters/store/generationSlice.ts @@ -5,6 +5,7 @@ import { configChanged } from 'features/system/store/configSlice'; import { clamp } from 'lodash-es'; import { ImageDTO } from 'services/api/types'; +import { isAnyControlAdapterAdded } from 'features/controlAdapters/store/controlAdaptersSlice'; import { clipSkipMap } from '../types/constants'; import { CanvasCoherenceModeParam, @@ -302,6 +303,15 @@ export const generationSlice = createSlice({ } } }); + + // TODO: This is a temp fix to reduce issues with T2I adapter having a different downscaling + // factor than the UNet. Hopefully we get an upstream fix in diffusers. + builder.addMatcher(isAnyControlAdapterAdded, (state, action) => { + if (action.payload.type === 't2i_adapter') { + state.width = roundToMultiple(state.width, 64); + state.height = roundToMultiple(state.height, 64); + } + }); }, });