mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): do not add promptless conditioning nodes
This commit is contained in:
parent
a6e64423d9
commit
964e2236b9
@ -107,6 +107,10 @@ export const addRegionalPromptsToGraph = async (state: RootState, graph: NonNull
|
|||||||
const layer = layers.find((l) => l.id === layerId);
|
const layer = layers.find((l) => l.id === layerId);
|
||||||
assert(layer, `Layer ${layerId} not found`);
|
assert(layer, `Layer ${layerId} not found`);
|
||||||
|
|
||||||
|
if (!layer.positivePrompt && !layer.negativePrompt) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const file = new File([blob], `${layerId}_mask.png`, { type: 'image/png' });
|
const file = new File([blob], `${layerId}_mask.png`, { type: 'image/png' });
|
||||||
const req = dispatch(
|
const req = dispatch(
|
||||||
imagesApi.endpoints.uploadImage.initiate({ file, image_category: 'mask', is_intermediate: true })
|
imagesApi.endpoints.uploadImage.initiate({ file, image_category: 'mask', is_intermediate: true })
|
||||||
@ -145,6 +149,7 @@ export const addRegionalPromptsToGraph = async (state: RootState, graph: NonNull
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (layer.positivePrompt) {
|
||||||
// The main positive conditioning node
|
// The main positive conditioning node
|
||||||
const regionalPositiveCondNode: S['SDXLCompelPromptInvocation'] = {
|
const regionalPositiveCondNode: S['SDXLCompelPromptInvocation'] = {
|
||||||
type: 'sdxl_compel_prompt',
|
type: 'sdxl_compel_prompt',
|
||||||
@ -166,6 +171,18 @@ export const addRegionalPromptsToGraph = async (state: RootState, graph: NonNull
|
|||||||
destination: { node_id: posCondCollectNode.id, field: 'item' },
|
destination: { node_id: posCondCollectNode.id, field: 'item' },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Copy the connections to the "global" positive conditioning node to the regional cond
|
||||||
|
for (const edge of graph.edges) {
|
||||||
|
if (edge.destination.node_id === POSITIVE_CONDITIONING && edge.destination.field !== 'prompt') {
|
||||||
|
graph.edges.push({
|
||||||
|
source: edge.source,
|
||||||
|
destination: { node_id: regionalPositiveCondNode.id, field: edge.destination.field },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (layer.negativePrompt) {
|
||||||
// The main negative conditioning node
|
// The main negative conditioning node
|
||||||
const regionalNegativeCondNode: S['SDXLCompelPromptInvocation'] = {
|
const regionalNegativeCondNode: S['SDXLCompelPromptInvocation'] = {
|
||||||
type: 'sdxl_compel_prompt',
|
type: 'sdxl_compel_prompt',
|
||||||
@ -187,14 +204,8 @@ export const addRegionalPromptsToGraph = async (state: RootState, graph: NonNull
|
|||||||
destination: { node_id: negCondCollectNode.id, field: 'item' },
|
destination: { node_id: negCondCollectNode.id, field: 'item' },
|
||||||
});
|
});
|
||||||
|
|
||||||
// Copy the connections to the "global" positive and negative conditioning nodes to our regional nodes
|
// Copy the connections to the "global" negative conditioning node to the regional cond
|
||||||
for (const edge of graph.edges) {
|
for (const edge of graph.edges) {
|
||||||
if (edge.destination.node_id === POSITIVE_CONDITIONING && edge.destination.field !== 'prompt') {
|
|
||||||
graph.edges.push({
|
|
||||||
source: edge.source,
|
|
||||||
destination: { node_id: regionalPositiveCondNode.id, field: edge.destination.field },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (edge.destination.node_id === NEGATIVE_CONDITIONING && edge.destination.field !== 'prompt') {
|
if (edge.destination.node_id === NEGATIVE_CONDITIONING && edge.destination.field !== 'prompt') {
|
||||||
graph.edges.push({
|
graph.edges.push({
|
||||||
source: edge.source,
|
source: edge.source,
|
||||||
@ -202,9 +213,10 @@ export const addRegionalPromptsToGraph = async (state: RootState, graph: NonNull
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we are using the "invert" auto-negative setting, we need to add an additional negative conditioning node
|
// If we are using the "invert" auto-negative setting, we need to add an additional negative conditioning node
|
||||||
if (layer.autoNegative === 'invert') {
|
if (layer.autoNegative === 'invert' && layer.positivePrompt) {
|
||||||
// We re-use the mask image, but invert it when converting to tensor
|
// We re-use the mask image, but invert it when converting to tensor
|
||||||
// TODO: Probably faster to invert the tensor from the earlier mask rather than read the mask image and convert...
|
// TODO: Probably faster to invert the tensor from the earlier mask rather than read the mask image and convert...
|
||||||
const invertedMaskToTensorNode: S['AlphaMaskToTensorInvocation'] = {
|
const invertedMaskToTensorNode: S['AlphaMaskToTensorInvocation'] = {
|
||||||
|
Loading…
Reference in New Issue
Block a user