Add CustomControlNetWeightsFluxFromList

This commit is contained in:
kijai 2024-09-19 14:24:41 +03:00
parent ca0e1ad28d
commit 912cbd2ab6
3 changed files with 37 additions and 2 deletions

1
.gitignore vendored
View File

@ -8,3 +8,4 @@ __pycache__
types types
models models
jsconfig.json jsconfig.json
custom_dimensions.json

View File

@ -138,6 +138,7 @@ NODE_CONFIG = {
"DifferentialDiffusionAdvanced": {"class": DifferentialDiffusionAdvanced, "name": "Differential Diffusion Advanced"}, "DifferentialDiffusionAdvanced": {"class": DifferentialDiffusionAdvanced, "name": "Differential Diffusion Advanced"},
"FluxBlockLoraLoader": {"class": FluxBlockLoraLoader, "name": "Flux Block Lora Loader"}, "FluxBlockLoraLoader": {"class": FluxBlockLoraLoader, "name": "Flux Block Lora Loader"},
"FluxBlockLoraSelect": {"class": FluxBlockLoraSelect, "name": "Flux Block Lora Select"}, "FluxBlockLoraSelect": {"class": FluxBlockLoraSelect, "name": "Flux Block Lora Select"},
"CustomControlNetWeightsFluxFromList": {"class": CustomControlNetWeightsFluxFromList, "name": "Custom ControlNet Weights Flux From List"},
#instance diffusion #instance diffusion
"CreateInstanceDiffusionTracking": {"class": CreateInstanceDiffusionTracking}, "CreateInstanceDiffusionTracking": {"class": CreateInstanceDiffusionTracking},

View File

@ -3,7 +3,7 @@ import numpy as np
from PIL import Image from PIL import Image
import json, re, os, io, time import json, re, os, io, time
import importlib
import model_management import model_management
import folder_paths import folder_paths
from nodes import MAX_RESOLUTION from nodes import MAX_RESOLUTION
@ -1991,3 +1991,36 @@ class FluxBlockLoraLoader:
print("NOT LOADED {}".format(x)) print("NOT LOADED {}".format(x))
return (new_modelpatcher, rank) return (new_modelpatcher, rank)
class CustomControlNetWeightsFluxFromList:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"list_of_floats": ("FLOAT", {"forceInput": True}, ),
},
"optional": {
"uncond_multiplier": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}, ),
"cn_extras": ("CN_WEIGHTS_EXTRAS",),
"autosize": ("ACNAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONTROL_NET_WEIGHTS", "TIMESTEP_KEYFRAME",)
RETURN_NAMES = ("CN_WEIGHTS", "TK_SHORTCUT")
FUNCTION = "load_weights"
DESCRIPTION = "Creates controlnet weights from a list of floats for Advanced-ControlNet"
CATEGORY = "KJNodes/controlnet"
def load_weights(self, list_of_floats: list[float],
uncond_multiplier: float=1.0, cn_extras: dict[str]={}):
acn_nodes = importlib.import_module("ComfyUI-Advanced-ControlNet")
ControlWeights = acn_nodes.adv_control.utils.ControlWeights
TimestepKeyframeGroup = acn_nodes.adv_control.utils.TimestepKeyframeGroup
TimestepKeyframe = acn_nodes.adv_control.utils.TimestepKeyframe
weights = ControlWeights.controlnet(weights_input=list_of_floats, uncond_multiplier=uncond_multiplier, extras=cn_extras)
print(weights.weights_input)
return (weights, TimestepKeyframeGroup.default(TimestepKeyframe(control_weights=weights)))