mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-11 23:00:51 +08:00
filter-out model file from 0 weighted LoraLoader
This commit is contained in:
parent
436d9e2633
commit
21418d7f5c
@ -2,34 +2,43 @@
|
|||||||
const excludeExtensions = new Set(["png", "jpg", "webp", "jpeg", "safetensors", "ckpt", "pt", "pth"]);
|
const excludeExtensions = new Set(["png", "jpg", "webp", "jpeg", "safetensors", "ckpt", "pt", "pth"]);
|
||||||
|
|
||||||
function getFileExtension(filename) {
|
function getFileExtension(filename) {
|
||||||
return filename.slice((filename.lastIndexOf('.') - 1 >>> 0) + 2);
|
return filename.slice((filename.lastIndexOf('.') - 1 >>> 0) + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Util {
|
export class Util {
|
||||||
static workflow_security_filter(workflow) {
|
static workflow_security_filter(workflow) {
|
||||||
workflow.nodes.forEach((node) => {
|
workflow.nodes.forEach((node) => {
|
||||||
if (node.inputs) {
|
// filter for 0 weighted LoraLoader
|
||||||
node.inputs.forEach((input) => {
|
if(node.widgets_values && node.widgets_values.length == 3){
|
||||||
if (input.widget && input.widget.config) {
|
let wv = node.widgets_values;
|
||||||
const configArray = input.widget.config[0];
|
if(typeof(wv[0]) == "string" && wv[1] == 0 && wv[2] == 0){
|
||||||
if (Array.isArray(configArray) && configArray.every((filename) => excludeExtensions.has(getFileExtension(filename)))) {
|
if(excludeExtensions.has(getFileExtension(wv[0])))
|
||||||
input.widget.config[0] = [];
|
wv[0] = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
if (node.outputs) {
|
|
||||||
node.outputs.forEach((output) => {
|
|
||||||
if (output.widget && output.widget.config) {
|
|
||||||
const configArray = output.widget.config[0];
|
|
||||||
if (Array.isArray(configArray) && configArray.every((filename) => excludeExtensions.has(getFileExtension(filename)))) {
|
|
||||||
output.widget.config[0] = [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return workflow;
|
if (node.inputs) {
|
||||||
|
node.inputs.forEach((input) => {
|
||||||
|
if (input.widget && input.widget.config) {
|
||||||
|
const configArray = input.widget.config[0];
|
||||||
|
if (Array.isArray(configArray) && configArray.every((filename) => excludeExtensions.has(getFileExtension(filename)))) {
|
||||||
|
input.widget.config[0] = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (node.outputs) {
|
||||||
|
node.outputs.forEach((output) => {
|
||||||
|
if (output.widget && output.widget.config) {
|
||||||
|
const configArray = output.widget.config[0];
|
||||||
|
if (Array.isArray(configArray) && configArray.every((filename) => excludeExtensions.has(getFileExtension(filename)))) {
|
||||||
|
output.widget.config[0] = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return workflow;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user