mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2026-05-19 14:07:15 +08:00
New nodes and continue restructuring
This commit is contained in:
parent
edae7ef9d2
commit
f259e062c7
@ -2,6 +2,7 @@ from .nodes.nodes import *
|
|||||||
from .nodes.curve_nodes import *
|
from .nodes.curve_nodes import *
|
||||||
from .nodes.batchcrop_nodes import *
|
from .nodes.batchcrop_nodes import *
|
||||||
from .nodes.audioscheduler_nodes import *
|
from .nodes.audioscheduler_nodes import *
|
||||||
|
from .nodes.image_nodes import *
|
||||||
NODE_CLASS_MAPPINGS = {
|
NODE_CLASS_MAPPINGS = {
|
||||||
#constants
|
#constants
|
||||||
"INTConstant": INTConstant,
|
"INTConstant": INTConstant,
|
||||||
@ -80,6 +81,7 @@ NODE_CLASS_MAPPINGS = {
|
|||||||
"ScaleBatchPromptSchedule": ScaleBatchPromptSchedule,
|
"ScaleBatchPromptSchedule": ScaleBatchPromptSchedule,
|
||||||
"CameraPoseVisualizer": CameraPoseVisualizer,
|
"CameraPoseVisualizer": CameraPoseVisualizer,
|
||||||
"JoinStrings": JoinStrings,
|
"JoinStrings": JoinStrings,
|
||||||
|
"JoinStringMulti": JoinStringMulti,
|
||||||
"Sleep": Sleep,
|
"Sleep": Sleep,
|
||||||
"VRAM_Debug" : VRAM_Debug,
|
"VRAM_Debug" : VRAM_Debug,
|
||||||
"SomethingToString" : SomethingToString,
|
"SomethingToString" : SomethingToString,
|
||||||
|
|||||||
@ -217,6 +217,7 @@ class MaskOrImageToWeight:
|
|||||||
'list',
|
'list',
|
||||||
'pandas series',
|
'pandas series',
|
||||||
'tensor',
|
'tensor',
|
||||||
|
'string'
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
"default": 'list'
|
"default": 'list'
|
||||||
@ -228,7 +229,7 @@ class MaskOrImageToWeight:
|
|||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
RETURN_TYPES = ("FLOAT",)
|
RETURN_TYPES = ("FLOAT", "STRING",)
|
||||||
FUNCTION = "execute"
|
FUNCTION = "execute"
|
||||||
CATEGORY = "KJNodes"
|
CATEGORY = "KJNodes"
|
||||||
DESCRIPTION = """
|
DESCRIPTION = """
|
||||||
@ -249,18 +250,17 @@ and returns that as the selected output type.
|
|||||||
|
|
||||||
# Convert mean_values to the specified output_type
|
# Convert mean_values to the specified output_type
|
||||||
if output_type == 'list':
|
if output_type == 'list':
|
||||||
return mean_values,
|
out = mean_values,
|
||||||
elif output_type == 'pandas series':
|
elif output_type == 'pandas series':
|
||||||
try:
|
try:
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
except:
|
except:
|
||||||
raise Exception("MaskOrImageToWeight: pandas is not installed. Please install pandas to use this output_type")
|
raise Exception("MaskOrImageToWeight: pandas is not installed. Please install pandas to use this output_type")
|
||||||
return pd.Series(mean_values),
|
out = pd.Series(mean_values),
|
||||||
elif output_type == 'tensor':
|
elif output_type == 'tensor':
|
||||||
return torch.tensor(mean_values, dtype=torch.float32),
|
out = torch.tensor(mean_values, dtype=torch.float32),
|
||||||
else:
|
return (out, [str(value) for value in mean_values],)
|
||||||
raise ValueError(f"Unsupported output_type: {output_type}")
|
|
||||||
|
|
||||||
class WeightScheduleConvert:
|
class WeightScheduleConvert:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -287,7 +287,7 @@ class WeightScheduleConvert:
|
|||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
RETURN_TYPES = ("FLOAT",)
|
RETURN_TYPES = ("FLOAT", "STRING",)
|
||||||
FUNCTION = "execute"
|
FUNCTION = "execute"
|
||||||
CATEGORY = "KJNodes"
|
CATEGORY = "KJNodes"
|
||||||
DESCRIPTION = """
|
DESCRIPTION = """
|
||||||
@ -344,18 +344,18 @@ Converts different value lists/series to another type.
|
|||||||
float_values = float_values * repeat
|
float_values = float_values * repeat
|
||||||
|
|
||||||
if output_type == 'list':
|
if output_type == 'list':
|
||||||
return float_values,
|
out = float_values,
|
||||||
elif output_type == 'pandas series':
|
elif output_type == 'pandas series':
|
||||||
return pd.Series(float_values),
|
out = pd.Series(float_values),
|
||||||
elif output_type == 'tensor':
|
elif output_type == 'tensor':
|
||||||
if input_type == 'pandas series':
|
if input_type == 'pandas series':
|
||||||
return torch.tensor(float_values.values, dtype=torch.float32),
|
out = torch.tensor(float_values.values, dtype=torch.float32),
|
||||||
else:
|
else:
|
||||||
return torch.tensor(float_values, dtype=torch.float32),
|
out = torch.tensor(float_values, dtype=torch.float32),
|
||||||
elif output_type == 'match_input':
|
elif output_type == 'match_input':
|
||||||
return float_values,
|
out = float_values,
|
||||||
else:
|
return (out, [str(value) for value in float_values],)
|
||||||
raise ValueError(f"Unsupported output_type: {output_type}")
|
|
||||||
|
|
||||||
class FloatToMask:
|
class FloatToMask:
|
||||||
|
|
||||||
|
|||||||
1032
nodes/image_nodes.py
Normal file
1032
nodes/image_nodes.py
Normal file
File diff suppressed because it is too large
Load Diff
1100
nodes/nodes.py
1100
nodes/nodes.py
File diff suppressed because it is too large
Load Diff
@ -73,6 +73,28 @@ app.registerExtension({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "JoinStringMulti":
|
||||||
|
nodeType.prototype.onNodeCreated = function () {
|
||||||
|
this._type = "STRING"
|
||||||
|
this.inputs_offset = nodeData.name.includes("selective")?1:0
|
||||||
|
this.addWidget("button", "Update inputs", null, () => {
|
||||||
|
if (!this.inputs) {
|
||||||
|
this.inputs = [];
|
||||||
|
}
|
||||||
|
const target_number_of_inputs = this.widgets.find(w => w.name === "inputcount")["value"];
|
||||||
|
if(target_number_of_inputs===this.inputs.length)return; // already set, do nothing
|
||||||
|
|
||||||
|
if(target_number_of_inputs < this.inputs.length){
|
||||||
|
for(let i = this.inputs.length; i>=this.inputs_offset+target_number_of_inputs; i--)
|
||||||
|
this.removeInput(i)
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
for(let i = this.inputs.length+1-this.inputs_offset; i <= target_number_of_inputs; ++i)
|
||||||
|
this.addInput(`string_${i}`, this._type)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "SoundReactive":
|
case "SoundReactive":
|
||||||
nodeType.prototype.onNodeCreated = function () {
|
nodeType.prototype.onNodeCreated = function () {
|
||||||
let audioContext;
|
let audioContext;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user