mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-02 22:17:17 +08:00
Merge branch 'master' of https://github.com/comfyanonymous/ComfyUI
This commit is contained in:
commit
8115b76a89
@ -63,6 +63,11 @@ except:
|
|||||||
print("checking out master branch") # noqa: T201
|
print("checking out master branch") # noqa: T201
|
||||||
branch = repo.lookup_branch('master')
|
branch = repo.lookup_branch('master')
|
||||||
if branch is None:
|
if branch is None:
|
||||||
|
try:
|
||||||
|
ref = repo.lookup_reference('refs/remotes/origin/master')
|
||||||
|
except:
|
||||||
|
print("pulling.") # noqa: T201
|
||||||
|
pull(repo)
|
||||||
ref = repo.lookup_reference('refs/remotes/origin/master')
|
ref = repo.lookup_reference('refs/remotes/origin/master')
|
||||||
repo.checkout(ref)
|
repo.checkout(ref)
|
||||||
branch = repo.lookup_branch('master')
|
branch = repo.lookup_branch('master')
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class BOFTAdapter(WeightAdapterBase):
|
|||||||
) -> Optional["BOFTAdapter"]:
|
) -> Optional["BOFTAdapter"]:
|
||||||
if loaded_keys is None:
|
if loaded_keys is None:
|
||||||
loaded_keys = set()
|
loaded_keys = set()
|
||||||
blocks_name = "{}.boft_blocks".format(x)
|
blocks_name = "{}.oft_blocks".format(x)
|
||||||
rescale_name = "{}.rescale".format(x)
|
rescale_name = "{}.rescale".format(x)
|
||||||
|
|
||||||
blocks = None
|
blocks = None
|
||||||
@ -32,17 +32,18 @@ class BOFTAdapter(WeightAdapterBase):
|
|||||||
blocks = lora[blocks_name]
|
blocks = lora[blocks_name]
|
||||||
if blocks.ndim == 4:
|
if blocks.ndim == 4:
|
||||||
loaded_keys.add(blocks_name)
|
loaded_keys.add(blocks_name)
|
||||||
|
else:
|
||||||
|
blocks = None
|
||||||
|
if blocks is None:
|
||||||
|
return None
|
||||||
|
|
||||||
rescale = None
|
rescale = None
|
||||||
if rescale_name in lora.keys():
|
if rescale_name in lora.keys():
|
||||||
rescale = lora[rescale_name]
|
rescale = lora[rescale_name]
|
||||||
loaded_keys.add(rescale_name)
|
loaded_keys.add(rescale_name)
|
||||||
|
|
||||||
if blocks is not None:
|
|
||||||
weights = (blocks, rescale, alpha, dora_scale)
|
weights = (blocks, rescale, alpha, dora_scale)
|
||||||
return cls(loaded_keys, weights)
|
return cls(loaded_keys, weights)
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def calculate_weight(
|
def calculate_weight(
|
||||||
self,
|
self,
|
||||||
@ -71,7 +72,7 @@ class BOFTAdapter(WeightAdapterBase):
|
|||||||
# Get r
|
# Get r
|
||||||
I = torch.eye(boft_b, device=blocks.device, dtype=blocks.dtype)
|
I = torch.eye(boft_b, device=blocks.device, dtype=blocks.dtype)
|
||||||
# for Q = -Q^T
|
# for Q = -Q^T
|
||||||
q = blocks - blocks.transpose(1, 2)
|
q = blocks - blocks.transpose(-1, -2)
|
||||||
normed_q = q
|
normed_q = q
|
||||||
if alpha > 0: # alpha in boft/bboft is for constraint
|
if alpha > 0: # alpha in boft/bboft is for constraint
|
||||||
q_norm = torch.norm(q) + 1e-8
|
q_norm = torch.norm(q) + 1e-8
|
||||||
@ -79,9 +80,8 @@ class BOFTAdapter(WeightAdapterBase):
|
|||||||
normed_q = q * alpha / q_norm
|
normed_q = q * alpha / q_norm
|
||||||
# use float() to prevent unsupported type in .inverse()
|
# use float() to prevent unsupported type in .inverse()
|
||||||
r = (I + normed_q) @ (I - normed_q).float().inverse()
|
r = (I + normed_q) @ (I - normed_q).float().inverse()
|
||||||
r = r.to(original_weight)
|
r = r.to(weight)
|
||||||
|
inp = org = weight
|
||||||
inp = org = original_weight
|
|
||||||
|
|
||||||
r_b = boft_b//2
|
r_b = boft_b//2
|
||||||
for i in range(boft_m):
|
for i in range(boft_m):
|
||||||
@ -91,14 +91,14 @@ class BOFTAdapter(WeightAdapterBase):
|
|||||||
if strength != 1:
|
if strength != 1:
|
||||||
bi = bi * strength + (1-strength) * I
|
bi = bi * strength + (1-strength) * I
|
||||||
inp = (
|
inp = (
|
||||||
inp.unflatten(-1, (-1, g, k))
|
inp.unflatten(0, (-1, g, k))
|
||||||
.transpose(-2, -1)
|
.transpose(1, 2)
|
||||||
.flatten(-3)
|
.flatten(0, 2)
|
||||||
.unflatten(-1, (-1, boft_b))
|
.unflatten(0, (-1, boft_b))
|
||||||
)
|
)
|
||||||
inp = torch.einsum("b n m, b n ... -> b m ...", inp, bi)
|
inp = torch.einsum("b i j, b j ...-> b i ...", bi, inp)
|
||||||
inp = (
|
inp = (
|
||||||
inp.flatten(-2).unflatten(-1, (-1, k, g)).transpose(-2, -1).flatten(-3)
|
inp.flatten(0, 1).unflatten(0, (-1, k, g)).transpose(1, 2).flatten(0, 2)
|
||||||
)
|
)
|
||||||
|
|
||||||
if rescale is not None:
|
if rescale is not None:
|
||||||
@ -109,7 +109,7 @@ class BOFTAdapter(WeightAdapterBase):
|
|||||||
if dora_scale is not None:
|
if dora_scale is not None:
|
||||||
weight = weight_decompose(dora_scale, weight, lora_diff, alpha, strength, intermediate_dtype, function)
|
weight = weight_decompose(dora_scale, weight, lora_diff, alpha, strength, intermediate_dtype, function)
|
||||||
else:
|
else:
|
||||||
weight += function(((strength * alpha) * lora_diff).type(weight.dtype))
|
weight += function((strength * lora_diff).type(weight.dtype))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error("ERROR {} {} {}".format(self.name, key, e))
|
logging.error("ERROR {} {} {}".format(self.name, key, e))
|
||||||
return weight
|
return weight
|
||||||
|
|||||||
@ -32,17 +32,18 @@ class OFTAdapter(WeightAdapterBase):
|
|||||||
blocks = lora[blocks_name]
|
blocks = lora[blocks_name]
|
||||||
if blocks.ndim == 3:
|
if blocks.ndim == 3:
|
||||||
loaded_keys.add(blocks_name)
|
loaded_keys.add(blocks_name)
|
||||||
|
else:
|
||||||
|
blocks = None
|
||||||
|
if blocks is None:
|
||||||
|
return None
|
||||||
|
|
||||||
rescale = None
|
rescale = None
|
||||||
if rescale_name in lora.keys():
|
if rescale_name in lora.keys():
|
||||||
rescale = lora[rescale_name]
|
rescale = lora[rescale_name]
|
||||||
loaded_keys.add(rescale_name)
|
loaded_keys.add(rescale_name)
|
||||||
|
|
||||||
if blocks is not None:
|
|
||||||
weights = (blocks, rescale, alpha, dora_scale)
|
weights = (blocks, rescale, alpha, dora_scale)
|
||||||
return cls(loaded_keys, weights)
|
return cls(loaded_keys, weights)
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def calculate_weight(
|
def calculate_weight(
|
||||||
self,
|
self,
|
||||||
@ -79,16 +80,17 @@ class OFTAdapter(WeightAdapterBase):
|
|||||||
normed_q = q * alpha / q_norm
|
normed_q = q * alpha / q_norm
|
||||||
# use float() to prevent unsupported type in .inverse()
|
# use float() to prevent unsupported type in .inverse()
|
||||||
r = (I + normed_q) @ (I - normed_q).float().inverse()
|
r = (I + normed_q) @ (I - normed_q).float().inverse()
|
||||||
r = r.to(original_weight)
|
r = r.to(weight)
|
||||||
|
_, *shape = weight.shape
|
||||||
lora_diff = torch.einsum(
|
lora_diff = torch.einsum(
|
||||||
"k n m, k n ... -> k m ...",
|
"k n m, k n ... -> k m ...",
|
||||||
(r * strength) - strength * I,
|
(r * strength) - strength * I,
|
||||||
original_weight,
|
weight.view(block_num, block_size, *shape),
|
||||||
)
|
).view(-1, *shape)
|
||||||
if dora_scale is not None:
|
if dora_scale is not None:
|
||||||
weight = weight_decompose(dora_scale, weight, lora_diff, alpha, strength, intermediate_dtype, function)
|
weight = weight_decompose(dora_scale, weight, lora_diff, alpha, strength, intermediate_dtype, function)
|
||||||
else:
|
else:
|
||||||
weight += function(((strength * alpha) * lora_diff).type(weight.dtype))
|
weight += function((strength * lora_diff).type(weight.dtype))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error("ERROR {} {} {}".format(self.name, key, e))
|
logging.error("ERROR {} {} {}".format(self.name, key, e))
|
||||||
return weight
|
return weight
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import math
|
||||||
import comfy.samplers
|
import comfy.samplers
|
||||||
import comfy.sample
|
import comfy.sample
|
||||||
from comfy.k_diffusion import sampling as k_diffusion_sampling
|
from comfy.k_diffusion import sampling as k_diffusion_sampling
|
||||||
@ -249,6 +250,55 @@ class SetFirstSigma:
|
|||||||
sigmas[0] = sigma
|
sigmas[0] = sigma
|
||||||
return (sigmas, )
|
return (sigmas, )
|
||||||
|
|
||||||
|
class ExtendIntermediateSigmas:
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(s):
|
||||||
|
return {"required":
|
||||||
|
{"sigmas": ("SIGMAS", ),
|
||||||
|
"steps": ("INT", {"default": 2, "min": 1, "max": 100}),
|
||||||
|
"start_at_sigma": ("FLOAT", {"default": -1.0, "min": -1.0, "max": 20000.0, "step": 0.01, "round": False}),
|
||||||
|
"end_at_sigma": ("FLOAT", {"default": 12.0, "min": 0.0, "max": 20000.0, "step": 0.01, "round": False}),
|
||||||
|
"spacing": (['linear', 'cosine', 'sine'],),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RETURN_TYPES = ("SIGMAS",)
|
||||||
|
CATEGORY = "sampling/custom_sampling/sigmas"
|
||||||
|
|
||||||
|
FUNCTION = "extend"
|
||||||
|
|
||||||
|
def extend(self, sigmas: torch.Tensor, steps: int, start_at_sigma: float, end_at_sigma: float, spacing: str):
|
||||||
|
if start_at_sigma < 0:
|
||||||
|
start_at_sigma = float("inf")
|
||||||
|
|
||||||
|
interpolator = {
|
||||||
|
'linear': lambda x: x,
|
||||||
|
'cosine': lambda x: torch.sin(x*math.pi/2),
|
||||||
|
'sine': lambda x: 1 - torch.cos(x*math.pi/2)
|
||||||
|
}[spacing]
|
||||||
|
|
||||||
|
# linear space for our interpolation function
|
||||||
|
x = torch.linspace(0, 1, steps + 1, device=sigmas.device)[1:-1]
|
||||||
|
computed_spacing = interpolator(x)
|
||||||
|
|
||||||
|
extended_sigmas = []
|
||||||
|
for i in range(len(sigmas) - 1):
|
||||||
|
sigma_current = sigmas[i]
|
||||||
|
sigma_next = sigmas[i+1]
|
||||||
|
|
||||||
|
extended_sigmas.append(sigma_current)
|
||||||
|
|
||||||
|
if end_at_sigma <= sigma_current <= start_at_sigma:
|
||||||
|
interpolated_steps = computed_spacing * (sigma_next - sigma_current) + sigma_current
|
||||||
|
extended_sigmas.extend(interpolated_steps.tolist())
|
||||||
|
|
||||||
|
# Add the last sigma value
|
||||||
|
if len(sigmas) > 0:
|
||||||
|
extended_sigmas.append(sigmas[-1])
|
||||||
|
|
||||||
|
extended_sigmas = torch.FloatTensor(extended_sigmas)
|
||||||
|
|
||||||
|
return (extended_sigmas,)
|
||||||
|
|
||||||
class KSamplerSelect:
|
class KSamplerSelect:
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(s):
|
def INPUT_TYPES(s):
|
||||||
@ -735,6 +785,7 @@ NODE_CLASS_MAPPINGS = {
|
|||||||
"SplitSigmasDenoise": SplitSigmasDenoise,
|
"SplitSigmasDenoise": SplitSigmasDenoise,
|
||||||
"FlipSigmas": FlipSigmas,
|
"FlipSigmas": FlipSigmas,
|
||||||
"SetFirstSigma": SetFirstSigma,
|
"SetFirstSigma": SetFirstSigma,
|
||||||
|
"ExtendIntermediateSigmas": ExtendIntermediateSigmas,
|
||||||
|
|
||||||
"CFGGuider": CFGGuider,
|
"CFGGuider": CFGGuider,
|
||||||
"DualCFGGuider": DualCFGGuider,
|
"DualCFGGuider": DualCFGGuider,
|
||||||
|
|||||||
@ -276,7 +276,7 @@ class CLIPSave:
|
|||||||
comfy.model_management.load_models_gpu([clip.load_model()], force_patch_weights=True)
|
comfy.model_management.load_models_gpu([clip.load_model()], force_patch_weights=True)
|
||||||
clip_sd = clip.get_sd()
|
clip_sd = clip.get_sd()
|
||||||
|
|
||||||
for prefix in ["clip_l.", "clip_g.", ""]:
|
for prefix in ["clip_l.", "clip_g.", "clip_h.", "t5xxl.", "pile_t5xl.", "mt5xl.", "umt5xxl.", "t5base.", "gemma2_2b.", "llama.", "hydit_clip.", ""]:
|
||||||
k = list(filter(lambda a: a.startswith(prefix), clip_sd.keys()))
|
k = list(filter(lambda a: a.startswith(prefix), clip_sd.keys()))
|
||||||
current_clip_sd = {}
|
current_clip_sd = {}
|
||||||
for x in k:
|
for x in k:
|
||||||
|
|||||||
43
comfy_extras/nodes_preview_any.py
Normal file
43
comfy_extras/nodes_preview_any.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import json
|
||||||
|
from comfy.comfy_types.node_typing import IO
|
||||||
|
|
||||||
|
# Preview Any - original implement from
|
||||||
|
# https://github.com/rgthree/rgthree-comfy/blob/main/py/display_any.py
|
||||||
|
# upstream requested in https://github.com/Kosinkadink/rfcs/blob/main/rfcs/0000-corenodes.md#preview-nodes
|
||||||
|
class PreviewAny():
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(cls):
|
||||||
|
return {
|
||||||
|
"required": {"source": (IO.ANY, {})},
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_TYPES = ()
|
||||||
|
FUNCTION = "main"
|
||||||
|
OUTPUT_NODE = True
|
||||||
|
|
||||||
|
CATEGORY = "utils"
|
||||||
|
|
||||||
|
def main(self, source=None):
|
||||||
|
value = 'None'
|
||||||
|
if isinstance(source, str):
|
||||||
|
value = source
|
||||||
|
elif isinstance(source, (int, float, bool)):
|
||||||
|
value = str(source)
|
||||||
|
elif source is not None:
|
||||||
|
try:
|
||||||
|
value = json.dumps(source)
|
||||||
|
except Exception:
|
||||||
|
try:
|
||||||
|
value = str(source)
|
||||||
|
except Exception:
|
||||||
|
value = 'source exists, but could not be serialized.'
|
||||||
|
|
||||||
|
return {"ui": {"text": (value,)}}
|
||||||
|
|
||||||
|
NODE_CLASS_MAPPINGS = {
|
||||||
|
"PreviewAny": PreviewAny,
|
||||||
|
}
|
||||||
|
|
||||||
|
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||||
|
"PreviewAny": "Preview Any",
|
||||||
|
}
|
||||||
@ -1,3 +1,3 @@
|
|||||||
# This file is automatically generated by the build process when version is
|
# This file is automatically generated by the build process when version is
|
||||||
# updated in pyproject.toml.
|
# updated in pyproject.toml.
|
||||||
__version__ = "0.3.30"
|
__version__ = "0.3.31"
|
||||||
|
|||||||
2
main.py
2
main.py
@ -13,7 +13,7 @@ import logging
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
#NOTE: These do not do anything on core ComfyUI which should already have no communication with the internet, they are for custom nodes.
|
#NOTE: These do not do anything on core ComfyUI, they are for custom nodes.
|
||||||
os.environ['HF_HUB_DISABLE_TELEMETRY'] = '1'
|
os.environ['HF_HUB_DISABLE_TELEMETRY'] = '1'
|
||||||
os.environ['DO_NOT_TRACK'] = '1'
|
os.environ['DO_NOT_TRACK'] = '1'
|
||||||
|
|
||||||
|
|||||||
1
nodes.py
1
nodes.py
@ -2336,6 +2336,7 @@ def init_builtin_extra_nodes():
|
|||||||
"nodes_optimalsteps.py",
|
"nodes_optimalsteps.py",
|
||||||
"nodes_hidream.py",
|
"nodes_hidream.py",
|
||||||
"nodes_fresca.py",
|
"nodes_fresca.py",
|
||||||
|
"nodes_preview_any.py",
|
||||||
]
|
]
|
||||||
|
|
||||||
api_nodes_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "comfy_api_nodes")
|
api_nodes_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "comfy_api_nodes")
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "ComfyUI"
|
name = "ComfyUI"
|
||||||
version = "0.3.30"
|
version = "0.3.31"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = { file = "LICENSE" }
|
license = { file = "LICENSE" }
|
||||||
requires-python = ">=3.9"
|
requires-python = ">=3.9"
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
comfyui-frontend-package==1.18.5
|
comfyui-frontend-package==1.18.6
|
||||||
comfyui-workflow-templates==0.1.3
|
comfyui-workflow-templates==0.1.3
|
||||||
torch
|
torch
|
||||||
torchsde
|
torchsde
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user