feat(generate): expose --guidance flag for Flux models

Threads guidance value through CLI → remote payload → server schema →
generate_image() → FluxGuidance node. Ignored for non-Flux families.

Use cases:
- Lower guidance (2.0-3.0) for looser, more photorealistic Flux output
- Higher guidance (4.0-6.0) for tighter prompt adherence
This commit is contained in:
2026-05-17 15:54:47 +02:00
parent 338a7fe267
commit b66bc98386
3 changed files with 20 additions and 0 deletions
+10
View File
@@ -758,6 +758,14 @@ def generate( # noqa: PLR0915
height: Annotated[int | None, typer.Option("-H", "--height", help="Image height (auto from checkpoint)")] = None, height: Annotated[int | None, typer.Option("-H", "--height", help="Image height (auto from checkpoint)")] = None,
steps: Annotated[int | None, typer.Option("--steps", help="Sampling steps (auto from checkpoint)")] = None, steps: Annotated[int | None, typer.Option("--steps", help="Sampling steps (auto from checkpoint)")] = None,
cfg: Annotated[float | None, typer.Option("--cfg", help="CFG scale (auto from checkpoint)")] = None, cfg: Annotated[float | None, typer.Option("--cfg", help="CFG scale (auto from checkpoint)")] = None,
guidance: Annotated[
float | None,
typer.Option(
"--guidance",
"-g",
help="FluxGuidance value (Flux only; default 3.5). Ignored for non-Flux models.",
),
] = None,
seed: Annotated[int, typer.Option("--seed", "-s", help="Random seed (-1 for random)")] = -1, seed: Annotated[int, typer.Option("--seed", "-s", help="Random seed (-1 for random)")] = -1,
sampler: Annotated[str | None, typer.Option("--sampler", help="Sampler name (auto from checkpoint)")] = None, sampler: Annotated[str | None, typer.Option("--sampler", help="Sampler name (auto from checkpoint)")] = None,
scheduler: Annotated[str | None, typer.Option("--scheduler", help="Scheduler name (auto from checkpoint)")] = None, scheduler: Annotated[str | None, typer.Option("--scheduler", help="Scheduler name (auto from checkpoint)")] = None,
@@ -1032,6 +1040,7 @@ def generate( # noqa: PLR0915
vae=vae, vae=vae,
lora_name=lora, lora_name=lora,
lora_strength=lora_strength, lora_strength=lora_strength,
guidance=guidance,
console=console, console=console,
) )
@@ -1090,6 +1099,7 @@ def generate( # noqa: PLR0915
batch_size=count, batch_size=count,
vae=vae, vae=vae,
orientation=orientation, orientation=orientation,
guidance=guidance,
) )
if not result_local: if not result_local:
+3
View File
@@ -37,6 +37,7 @@ def remote_generate(
vae: str | None = None, vae: str | None = None,
lora_name: str | None = None, lora_name: str | None = None,
lora_strength: float = 0.8, lora_strength: float = 0.8,
guidance: float | None = None,
console: Console | None = None, console: Console | None = None,
) -> dict[str, Any] | None: ) -> dict[str, Any] | None:
"""Generate an image via remote tensors server. """Generate an image via remote tensors server.
@@ -73,6 +74,8 @@ def remote_generate(
payload["vae"] = vae payload["vae"] = vae
if lora_name: if lora_name:
payload["lora_name"] = lora_name payload["lora_name"] = lora_name
if guidance is not None:
payload["guidance"] = guidance
try: try:
with _build_client(base_url) as client: with _build_client(base_url) as client:
+7
View File
@@ -49,6 +49,12 @@ class GenerateRequest(PydanticBaseModel):
vae: str | None = Field(default=None, description="VAE model name (defaults to sdxl_vae.safetensors)") vae: str | None = Field(default=None, description="VAE model name (defaults to sdxl_vae.safetensors)")
lora_name: str | None = Field(default=None, description="LoRA model filename") lora_name: str | None = Field(default=None, description="LoRA model filename")
lora_strength: float = Field(default=0.8, ge=0.0, le=2.0, description="LoRA strength") lora_strength: float = Field(default=0.8, ge=0.0, le=2.0, description="LoRA strength")
guidance: float | None = Field(
default=None,
ge=0.0,
le=30.0,
description="FluxGuidance value (Flux models only; default 3.5). Ignored for non-Flux models.",
)
class GenerateResponse(PydanticBaseModel): class GenerateResponse(PydanticBaseModel):
@@ -303,6 +309,7 @@ def comfyui_generate(request: GenerateRequest) -> dict[str, Any]:
vae=vae, vae=vae,
lora_name=request.lora_name, lora_name=request.lora_name,
lora_strength=request.lora_strength, lora_strength=request.lora_strength,
guidance=request.guidance,
) )
if not result: if not result: