mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-07-11 00:47:14 +08:00
Compare commits
4 Commits
0745106a9f
...
aabdcf11ed
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aabdcf11ed | ||
|
|
439bd807f8 | ||
|
|
3b87c2c397 | ||
|
|
44596029a1 |
@ -468,6 +468,9 @@ class CLIP:
|
||||
def decode(self, token_ids, skip_special_tokens=True):
|
||||
return self.tokenizer.decode(token_ids, skip_special_tokens=skip_special_tokens)
|
||||
|
||||
def is_dynamic(self):
|
||||
return self.patcher.is_dynamic()
|
||||
|
||||
class VAE:
|
||||
def __init__(self, sd=None, device=None, config=None, dtype=None, metadata=None):
|
||||
if 'decoder.up_blocks.0.resnets.0.norm1.weight' in sd.keys(): #diffusers format
|
||||
@ -1251,6 +1254,8 @@ class VAE:
|
||||
except:
|
||||
return None
|
||||
|
||||
def is_dynamic(self):
|
||||
return self.patcher.is_dynamic()
|
||||
|
||||
class StyleModel:
|
||||
def __init__(self, model, device="cpu"):
|
||||
|
||||
@ -503,6 +503,21 @@ RAM_CACHE_DEFAULT_RAM_USAGE = 0.05
|
||||
|
||||
RAM_CACHE_OLD_WORKFLOW_OOM_MULTIPLIER = 1.3
|
||||
|
||||
|
||||
def all_outputs_dynamic(outputs):
|
||||
if outputs is None:
|
||||
return False
|
||||
|
||||
for output in outputs:
|
||||
if isinstance(output, (list, tuple)):
|
||||
if not all_outputs_dynamic(output):
|
||||
return False
|
||||
elif not hasattr(output, "is_dynamic") or not output.is_dynamic():
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
class RAMPressureCache(LRUCache):
|
||||
|
||||
def __init__(self, key_class, enable_providers=False):
|
||||
@ -533,7 +548,11 @@ class RAMPressureCache(LRUCache):
|
||||
for key, cache_entry in self.cache.items():
|
||||
if not free_active and self.used_generation[key] == self.generation:
|
||||
continue
|
||||
oom_score = RAM_CACHE_OLD_WORKFLOW_OOM_MULTIPLIER ** (self.generation - self.used_generation[key])
|
||||
|
||||
if all_outputs_dynamic(cache_entry.outputs) and self.used_generation[key] == self.generation:
|
||||
continue
|
||||
|
||||
oom_score = RAM_CACHE_OLD_WORKFLOW_OOM_MULTIPLIER ** (self.generation - self.used_generation[key])
|
||||
|
||||
ram_usage = RAM_CACHE_DEFAULT_RAM_USAGE
|
||||
def scan_list_for_ram_usage(outputs):
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
"""Ideogram 4 sampling helper
|
||||
"""
|
||||
|
||||
import enum
|
||||
import math
|
||||
|
||||
import torch
|
||||
@ -10,6 +11,45 @@ from comfy_api.latest import ComfyExtension, io
|
||||
_LOGSNR_MIN = -15.0
|
||||
_LOGSNR_MAX = 18.0
|
||||
|
||||
class Ideogram4Enum(enum.Enum):
|
||||
QUALITY = "Quality"
|
||||
HIGH = "High"
|
||||
DEFAULT = "Default"
|
||||
FAST = "Fast"
|
||||
TURBO = "Turbo"
|
||||
|
||||
IDEOGRAM4_PRESET_CONFIGS = {
|
||||
Ideogram4Enum.QUALITY.value: {
|
||||
"num_steps": 48,
|
||||
"mu": 0.0,
|
||||
"std": 1.5,
|
||||
"preset_id": "V4_QUALITY_48"
|
||||
},
|
||||
Ideogram4Enum.HIGH.value: {
|
||||
"num_steps": 34,
|
||||
"mu": 0.0,
|
||||
"std": 1.6875,
|
||||
"preset_id": "V4_HIGH_34"
|
||||
},
|
||||
Ideogram4Enum.DEFAULT.value: {
|
||||
"num_steps": 20,
|
||||
"mu": 0.0,
|
||||
"std": 1.75,
|
||||
"preset_id": "V4_DEFAULT_20"
|
||||
},
|
||||
Ideogram4Enum.FAST.value: {
|
||||
"num_steps": 16,
|
||||
"mu": 0.25,
|
||||
"std": 1.8375,
|
||||
"preset_id": "V4_FAST_16"
|
||||
},
|
||||
Ideogram4Enum.TURBO.value: {
|
||||
"num_steps": 12,
|
||||
"mu": 0.5,
|
||||
"std": 1.75,
|
||||
"preset_id": "V4_TURBO_12"
|
||||
}
|
||||
}
|
||||
|
||||
def _logit_normal_schedule(u, mean, std):
|
||||
# Reference time (0=noise..1=clean) via the probit/ndtri quantile.
|
||||
@ -54,10 +94,41 @@ class Ideogram4Scheduler(io.ComfyNode):
|
||||
return io.NodeOutput(ideogram4_sigmas(steps, width, height, mu, std))
|
||||
|
||||
|
||||
class Ideogram4SchedulerPreset(Ideogram4Scheduler):
|
||||
@classmethod
|
||||
def define_schema(cls) -> io.Schema:
|
||||
return io.Schema(
|
||||
node_id="Ideogram4SchedulerPreset",
|
||||
display_name="Ideogram 4 Scheduler (Presets)",
|
||||
category="sampling/custom_sampling/schedulers",
|
||||
description="Schedule Presets for Ideogram 4. They are as follows: Quality=48, High=34, Default=20, Fast=16, Turbo=12",
|
||||
inputs=[
|
||||
io.Combo.Input("preset", options=[e.value for e in Ideogram4Enum], default=Ideogram4Enum.DEFAULT.value),
|
||||
io.Int.Input("width", default=1024, min=256, max=8192, step=16),
|
||||
io.Int.Input("height", default=1024, min=256, max=8192, step=16),
|
||||
],
|
||||
outputs=[io.Sigmas.Output()],
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def execute(cls, preset, width, height) -> io.NodeOutput:
|
||||
config = IDEOGRAM4_PRESET_CONFIGS.get(preset)
|
||||
if not config:
|
||||
raise ValueError(f"Invalid preset: {preset}")
|
||||
|
||||
return super().execute(
|
||||
steps=config["num_steps"],
|
||||
width=width,
|
||||
height=height,
|
||||
mu=config["mu"],
|
||||
std=config["std"]
|
||||
)
|
||||
|
||||
|
||||
class Ideogram4Extension(ComfyExtension):
|
||||
@override
|
||||
async def get_node_list(self) -> list[type[io.ComfyNode]]:
|
||||
return [Ideogram4Scheduler]
|
||||
return [Ideogram4Scheduler, Ideogram4SchedulerPreset]
|
||||
|
||||
|
||||
async def comfy_entrypoint() -> Ideogram4Extension:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user