mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): fix control adapters recall
This commit is contained in:
parent
913fc83cbf
commit
dcfbd49e1b
@ -7,6 +7,18 @@ import {
|
|||||||
CONTROLNET_MODEL_DEFAULT_PROCESSORS,
|
CONTROLNET_MODEL_DEFAULT_PROCESSORS,
|
||||||
CONTROLNET_PROCESSORS,
|
CONTROLNET_PROCESSORS,
|
||||||
} from 'features/controlNet/store/constants';
|
} from 'features/controlNet/store/constants';
|
||||||
|
import {
|
||||||
|
controlAdapterRecalled,
|
||||||
|
controlAdaptersReset,
|
||||||
|
} from 'features/controlNet/store/controlAdaptersSlice';
|
||||||
|
import {
|
||||||
|
ControlNetConfig,
|
||||||
|
IPAdapterConfig,
|
||||||
|
} from 'features/controlNet/store/types';
|
||||||
|
import {
|
||||||
|
initialControlNet,
|
||||||
|
initialIPAdapter,
|
||||||
|
} from 'features/controlNet/util/buildControlAdapter';
|
||||||
import {
|
import {
|
||||||
ControlNetMetadataItem,
|
ControlNetMetadataItem,
|
||||||
CoreMetadata,
|
CoreMetadata,
|
||||||
@ -449,8 +461,6 @@ export const useRecallParameters = () => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const controlNetId = uuidv4();
|
|
||||||
|
|
||||||
let processorType = initialControlNet.processorType;
|
let processorType = initialControlNet.processorType;
|
||||||
for (const modelSubstring in CONTROLNET_MODEL_DEFAULT_PROCESSORS) {
|
for (const modelSubstring in CONTROLNET_MODEL_DEFAULT_PROCESSORS) {
|
||||||
if (matchingControlNetModel.model_name.includes(modelSubstring)) {
|
if (matchingControlNetModel.model_name.includes(modelSubstring)) {
|
||||||
@ -463,6 +473,7 @@ export const useRecallParameters = () => {
|
|||||||
const processorNode = CONTROLNET_PROCESSORS[processorType].default;
|
const processorNode = CONTROLNET_PROCESSORS[processorType].default;
|
||||||
|
|
||||||
const controlnet: ControlNetConfig = {
|
const controlnet: ControlNetConfig = {
|
||||||
|
type: 'controlnet',
|
||||||
isEnabled: true,
|
isEnabled: true,
|
||||||
model: matchingControlNetModel,
|
model: matchingControlNetModel,
|
||||||
weight:
|
weight:
|
||||||
@ -481,7 +492,7 @@ export const useRecallParameters = () => {
|
|||||||
? processorNode
|
? processorNode
|
||||||
: initialControlNet.processorNode,
|
: initialControlNet.processorNode,
|
||||||
shouldAutoConfig: true,
|
shouldAutoConfig: true,
|
||||||
controlNetId,
|
id: uuidv4(),
|
||||||
};
|
};
|
||||||
|
|
||||||
return { controlnet, error: null };
|
return { controlnet, error: null };
|
||||||
@ -498,11 +509,7 @@ export const useRecallParameters = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch(
|
dispatch(controlAdapterRecalled(result.controlnet));
|
||||||
controlAdapterRecalled({
|
|
||||||
...result.controlnet,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
parameterSetToast();
|
parameterSetToast();
|
||||||
},
|
},
|
||||||
@ -558,11 +565,14 @@ export const useRecallParameters = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ipAdapter: IPAdapterConfig = {
|
const ipAdapter: IPAdapterConfig = {
|
||||||
adapterImage: image?.image_name ?? null,
|
id: uuidv4(),
|
||||||
|
type: 'ip_adapter',
|
||||||
|
isEnabled: true,
|
||||||
|
controlImage: image?.image_name ?? null,
|
||||||
model: matchingIPAdapterModel,
|
model: matchingIPAdapterModel,
|
||||||
weight: weight ?? initialIPAdapterState.weight,
|
weight: weight ?? initialIPAdapter.weight,
|
||||||
beginStepPct: begin_step_percent ?? initialIPAdapterState.beginStepPct,
|
beginStepPct: begin_step_percent ?? initialIPAdapter.beginStepPct,
|
||||||
endStepPct: end_step_percent ?? initialIPAdapterState.endStepPct,
|
endStepPct: end_step_percent ?? initialIPAdapter.endStepPct,
|
||||||
};
|
};
|
||||||
|
|
||||||
return { ipAdapter, error: null };
|
return { ipAdapter, error: null };
|
||||||
@ -579,13 +589,7 @@ export const useRecallParameters = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch(
|
dispatch(controlAdapterRecalled(result.ipAdapter));
|
||||||
ipAdapterRecalled({
|
|
||||||
...result.ipAdapter,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
dispatch(isIPAdapterEnabledChanged(true));
|
|
||||||
|
|
||||||
parameterSetToast();
|
parameterSetToast();
|
||||||
},
|
},
|
||||||
@ -727,9 +731,6 @@ export const useRecallParameters = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
dispatch(controlAdaptersReset());
|
dispatch(controlAdaptersReset());
|
||||||
if (controlnets?.length) {
|
|
||||||
dispatch(controlNetEnabled());
|
|
||||||
}
|
|
||||||
controlnets?.forEach((controlnet) => {
|
controlnets?.forEach((controlnet) => {
|
||||||
const result = prepareControlNetMetadataItem(controlnet);
|
const result = prepareControlNetMetadataItem(controlnet);
|
||||||
if (result.controlnet) {
|
if (result.controlnet) {
|
||||||
@ -737,13 +738,10 @@ export const useRecallParameters = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (ipAdapters?.length) {
|
|
||||||
dispatch(isIPAdapterEnabledChanged(true));
|
|
||||||
}
|
|
||||||
ipAdapters?.forEach((ipAdapter) => {
|
ipAdapters?.forEach((ipAdapter) => {
|
||||||
const result = prepareIPAdapterMetadataItem(ipAdapter);
|
const result = prepareIPAdapterMetadataItem(ipAdapter);
|
||||||
if (result.ipAdapter) {
|
if (result.ipAdapter) {
|
||||||
dispatch(ipAdapterRecalled(result.ipAdapter));
|
dispatch(controlAdapterRecalled(result.ipAdapter));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user