mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-10 21:42:37 +08:00
Merge branch 'comfyanonymous:master' into feature/clipspace
This commit is contained in:
commit
80ec9a5ecf
@ -455,11 +455,7 @@ class CrossAttentionPytorch(nn.Module):
|
|||||||
|
|
||||||
b, _, _ = q.shape
|
b, _, _ = q.shape
|
||||||
q, k, v = map(
|
q, k, v = map(
|
||||||
lambda t: t.unsqueeze(3)
|
lambda t: t.view(b, -1, self.heads, self.dim_head).transpose(1, 2),
|
||||||
.reshape(b, t.shape[1], self.heads, self.dim_head)
|
|
||||||
.permute(0, 2, 1, 3)
|
|
||||||
.reshape(b * self.heads, t.shape[1], self.dim_head)
|
|
||||||
.contiguous(),
|
|
||||||
(q, k, v),
|
(q, k, v),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -468,10 +464,7 @@ class CrossAttentionPytorch(nn.Module):
|
|||||||
if exists(mask):
|
if exists(mask):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
out = (
|
out = (
|
||||||
out.unsqueeze(0)
|
out.transpose(1, 2).reshape(b, -1, self.heads * self.dim_head)
|
||||||
.reshape(b, self.heads, out.shape[1], self.dim_head)
|
|
||||||
.permute(0, 2, 1, 3)
|
|
||||||
.reshape(b, out.shape[1], self.heads * self.dim_head)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return self.to_out(out)
|
return self.to_out(out)
|
||||||
|
|||||||
@ -1,21 +1,72 @@
|
|||||||
import { app } from "/scripts/app.js";
|
import { app } from "/scripts/app.js";
|
||||||
|
import { ComfyWidgets } from "/scripts/widgets.js";
|
||||||
// Adds defaults for quickly adding nodes with middle click on the input/output
|
// Adds defaults for quickly adding nodes with middle click on the input/output
|
||||||
|
|
||||||
app.registerExtension({
|
app.registerExtension({
|
||||||
name: "Comfy.SlotDefaults",
|
name: "Comfy.SlotDefaults",
|
||||||
|
suggestionsNumber: null,
|
||||||
init() {
|
init() {
|
||||||
LiteGraph.middle_click_slot_add_default_node = true;
|
LiteGraph.middle_click_slot_add_default_node = true;
|
||||||
LiteGraph.slot_types_default_in = {
|
this.suggestionsNumber = app.ui.settings.addSetting({
|
||||||
MODEL: "CheckpointLoaderSimple",
|
id: "Comfy.NodeSuggestions.number",
|
||||||
LATENT: "EmptyLatentImage",
|
name: "number of nodes suggestions",
|
||||||
VAE: "VAELoader",
|
type: "slider",
|
||||||
};
|
attrs: {
|
||||||
|
min: 1,
|
||||||
LiteGraph.slot_types_default_out = {
|
max: 100,
|
||||||
LATENT: "VAEDecode",
|
step: 1,
|
||||||
IMAGE: "SaveImage",
|
},
|
||||||
CLIP: "CLIPTextEncode",
|
defaultValue: 5,
|
||||||
};
|
onChange: (newVal, oldVal) => {
|
||||||
|
this.setDefaults(newVal);
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
slot_types_default_out: {},
|
||||||
|
slot_types_default_in: {},
|
||||||
|
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||||
|
var nodeId = nodeData.name;
|
||||||
|
var inputs = [];
|
||||||
|
inputs = nodeData["input"]["required"]; //only show required inputs to reduce the mess also not logical to create node with optional inputs
|
||||||
|
for (const inputKey in inputs) {
|
||||||
|
var input = (inputs[inputKey]);
|
||||||
|
if (typeof input[0] !== "string") continue;
|
||||||
|
|
||||||
|
var type = input[0]
|
||||||
|
if (type in ComfyWidgets) {
|
||||||
|
var customProperties = input[1]
|
||||||
|
if (!(customProperties?.forceInput)) continue; //ignore widgets that don't force input
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(type in this.slot_types_default_out)) {
|
||||||
|
this.slot_types_default_out[type] = ["Reroute"];
|
||||||
|
}
|
||||||
|
if (this.slot_types_default_out[type].includes(nodeId)) continue;
|
||||||
|
this.slot_types_default_out[type].push(nodeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
var outputs = nodeData["output"];
|
||||||
|
for (const key in outputs) {
|
||||||
|
var type = outputs[key];
|
||||||
|
if (!(type in this.slot_types_default_in)) {
|
||||||
|
this.slot_types_default_in[type] = ["Reroute"];// ["Reroute", "Primitive"]; primitive doesn't always work :'()
|
||||||
|
}
|
||||||
|
|
||||||
|
this.slot_types_default_in[type].push(nodeId);
|
||||||
|
}
|
||||||
|
var maxNum = this.suggestionsNumber.value;
|
||||||
|
this.setDefaults(maxNum);
|
||||||
|
},
|
||||||
|
setDefaults(maxNum) {
|
||||||
|
|
||||||
|
LiteGraph.slot_types_default_out = {};
|
||||||
|
LiteGraph.slot_types_default_in = {};
|
||||||
|
|
||||||
|
for (const type in this.slot_types_default_out) {
|
||||||
|
LiteGraph.slot_types_default_out[type] = this.slot_types_default_out[type].slice(0, maxNum);
|
||||||
|
}
|
||||||
|
for (const type in this.slot_types_default_in) {
|
||||||
|
LiteGraph.slot_types_default_in[type] = this.slot_types_default_in[type].slice(0, maxNum);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user