mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
perf(ui): reduce control image processing to when it is needed
Only should reprocess if the processor settings or the image has changed.
This commit is contained in:
parent
387ab9cee7
commit
5bf4d37949
@ -12,6 +12,7 @@ import {
|
||||
selectControlAdapterById,
|
||||
} from 'features/controlAdapters/store/controlAdaptersSlice';
|
||||
import { isControlNetOrT2IAdapter } from 'features/controlAdapters/store/types';
|
||||
import { isEqual } from 'lodash-es';
|
||||
|
||||
type AnyControlAdapterParamChangeAction =
|
||||
| ReturnType<typeof controlAdapterProcessorParamsChanged>
|
||||
@ -52,6 +53,11 @@ const predicate: AnyListenerPredicate<RootState> = (action, state, prevState) =>
|
||||
return false;
|
||||
}
|
||||
|
||||
if (prevCA.controlImage === ca.controlImage && isEqual(prevCA.processorNode, ca.processorNode)) {
|
||||
// Don't re-process if the processor hasn't changed
|
||||
return false;
|
||||
}
|
||||
|
||||
const isProcessorSelected = processorType !== 'none';
|
||||
|
||||
const hasControlImage = Boolean(controlImage);
|
||||
|
@ -248,22 +248,23 @@ export const controlAdaptersSlice = createSlice({
|
||||
return;
|
||||
}
|
||||
|
||||
const update: Update<ControlNetConfig | T2IAdapterConfig, string> = {
|
||||
id,
|
||||
changes: { model, shouldAutoConfig: true },
|
||||
};
|
||||
|
||||
update.changes.processedControlImage = null;
|
||||
|
||||
if (modelConfig.type === 'ip_adapter') {
|
||||
// should never happen...
|
||||
return;
|
||||
}
|
||||
|
||||
// We always update the model
|
||||
const update: Update<ControlNetConfig | T2IAdapterConfig, string> = { id, changes: { model } };
|
||||
|
||||
// Build the default processor for this model
|
||||
const processor = buildControlAdapterProcessor(modelConfig);
|
||||
if (processor.processorType !== cn.processorNode.type) {
|
||||
// If the processor type has changed, update the processor node
|
||||
update.changes.shouldAutoConfig = true;
|
||||
update.changes.processedControlImage = null;
|
||||
update.changes.processorType = processor.processorType;
|
||||
update.changes.processorNode = processor.processorNode;
|
||||
|
||||
if (cn.controlImageDimensions) {
|
||||
const minDim = Math.min(cn.controlImageDimensions.width, cn.controlImageDimensions.height);
|
||||
if ('detect_resolution' in update.changes.processorNode) {
|
||||
|
Loading…
Reference in New Issue
Block a user