mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): control adapters require control images
There wasn't enough validation of control adapters during graph building. It would be possible for a graph to be built with empty collect node, causing an error. Addressed with an extra check. This should never happen in practice, because the invoke button should be disabled if an invalid CA is active.
This commit is contained in:
parent
4bb5aba70e
commit
ee3a1a95ef
@ -18,7 +18,13 @@ export const addControlNetToLinearGraph = async (
|
||||
baseNodeId: string
|
||||
): Promise<void> => {
|
||||
const validControlNets = selectValidControlNets(state.controlAdapters).filter(
|
||||
(ca) => ca.model?.base === state.generation.model?.base
|
||||
({ model, processedControlImage, processorType, controlImage, isEnabled }) => {
|
||||
const hasModel = Boolean(model);
|
||||
const doesBaseMatch = model?.base === state.generation.model?.base;
|
||||
const hasControlImage = (processedControlImage && processorType !== 'none') || controlImage;
|
||||
|
||||
return isEnabled && hasModel && doesBaseMatch && hasControlImage;
|
||||
}
|
||||
);
|
||||
|
||||
// const metadataAccumulator = graph.nodes[METADATA_ACCUMULATOR] as
|
||||
@ -83,7 +89,7 @@ export const addControlNetToLinearGraph = async (
|
||||
image_name: controlImage,
|
||||
};
|
||||
} else {
|
||||
// Skip ControlNets without an unprocessed image - should never happen if everything is working correctly
|
||||
// Skip CAs without an unprocessed image - should never happen, we already filtered the list of valid CAs
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -17,9 +17,12 @@ export const addIPAdapterToLinearGraph = async (
|
||||
graph: NonNullableGraph,
|
||||
baseNodeId: string
|
||||
): Promise<void> => {
|
||||
const validIPAdapters = selectValidIPAdapters(state.controlAdapters).filter(
|
||||
(ca) => ca.model?.base === state.generation.model?.base
|
||||
);
|
||||
const validIPAdapters = selectValidIPAdapters(state.controlAdapters).filter(({ model, controlImage, isEnabled }) => {
|
||||
const hasModel = Boolean(model);
|
||||
const doesBaseMatch = model?.base === state.generation.model?.base;
|
||||
const hasControlImage = controlImage;
|
||||
return isEnabled && hasModel && doesBaseMatch && hasControlImage;
|
||||
});
|
||||
|
||||
if (validIPAdapters.length) {
|
||||
// Even though denoise_latents' ip adapter input is collection or scalar, keep it simple and always use a collect
|
||||
|
@ -18,7 +18,13 @@ export const addT2IAdaptersToLinearGraph = async (
|
||||
baseNodeId: string
|
||||
): Promise<void> => {
|
||||
const validT2IAdapters = selectValidT2IAdapters(state.controlAdapters).filter(
|
||||
(ca) => ca.model?.base === state.generation.model?.base
|
||||
({ model, processedControlImage, processorType, controlImage, isEnabled }) => {
|
||||
const hasModel = Boolean(model);
|
||||
const doesBaseMatch = model?.base === state.generation.model?.base;
|
||||
const hasControlImage = (processedControlImage && processorType !== 'none') || controlImage;
|
||||
|
||||
return isEnabled && hasModel && doesBaseMatch && hasControlImage;
|
||||
}
|
||||
);
|
||||
|
||||
if (validT2IAdapters.length) {
|
||||
@ -77,7 +83,7 @@ export const addT2IAdaptersToLinearGraph = async (
|
||||
image_name: controlImage,
|
||||
};
|
||||
} else {
|
||||
// Skip ControlNets without an unprocessed image - should never happen if everything is working correctly
|
||||
// Skip CAs without an unprocessed image - should never happen, we already filtered the list of valid CAs
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user