feat(ui): set w/h to multiple of 64 on add t2i

This commit is contained in:
psychedelicious 2023-10-12 23:41:25 +11:00
parent 58850ded22
commit 10fac5c085
2 changed files with 17 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import {
Update, Update,
createEntityAdapter, createEntityAdapter,
createSlice, createSlice,
isAnyOf,
} from '@reduxjs/toolkit'; } from '@reduxjs/toolkit';
import { import {
ControlNetModelParam, ControlNetModelParam,
@ -544,3 +545,9 @@ export const {
} = controlAdaptersSlice.actions; } = controlAdaptersSlice.actions;
export default controlAdaptersSlice.reducer; export default controlAdaptersSlice.reducer;
export const isAnyControlAdapterAdded = isAnyOf(
controlAdapterAdded,
controlAdapterAddedFromImage,
controlAdapterRecalled
);

View File

@ -5,6 +5,7 @@ import { configChanged } from 'features/system/store/configSlice';
import { clamp } from 'lodash-es'; import { clamp } from 'lodash-es';
import { ImageDTO } from 'services/api/types'; import { ImageDTO } from 'services/api/types';
import { isAnyControlAdapterAdded } from 'features/controlAdapters/store/controlAdaptersSlice';
import { clipSkipMap } from '../types/constants'; import { clipSkipMap } from '../types/constants';
import { import {
CanvasCoherenceModeParam, 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);
}
});
}, },
}); });