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:
@@ -758,6 +758,14 @@ def generate( # noqa: PLR0915
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
@@ -1032,6 +1040,7 @@ def generate( # noqa: PLR0915
|
||||
vae=vae,
|
||||
lora_name=lora,
|
||||
lora_strength=lora_strength,
|
||||
guidance=guidance,
|
||||
console=console,
|
||||
)
|
||||
|
||||
@@ -1090,6 +1099,7 @@ def generate( # noqa: PLR0915
|
||||
batch_size=count,
|
||||
vae=vae,
|
||||
orientation=orientation,
|
||||
guidance=guidance,
|
||||
)
|
||||
|
||||
if not result_local:
|
||||
|
||||
@@ -37,6 +37,7 @@ def remote_generate(
|
||||
vae: str | None = None,
|
||||
lora_name: str | None = None,
|
||||
lora_strength: float = 0.8,
|
||||
guidance: float | None = None,
|
||||
console: Console | None = None,
|
||||
) -> dict[str, Any] | None:
|
||||
"""Generate an image via remote tensors server.
|
||||
@@ -73,6 +74,8 @@ def remote_generate(
|
||||
payload["vae"] = vae
|
||||
if lora_name:
|
||||
payload["lora_name"] = lora_name
|
||||
if guidance is not None:
|
||||
payload["guidance"] = guidance
|
||||
|
||||
try:
|
||||
with _build_client(base_url) as client:
|
||||
|
||||
@@ -49,6 +49,12 @@ class GenerateRequest(PydanticBaseModel):
|
||||
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_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):
|
||||
@@ -303,6 +309,7 @@ def comfyui_generate(request: GenerateRequest) -> dict[str, Any]:
|
||||
vae=vae,
|
||||
lora_name=request.lora_name,
|
||||
lora_strength=request.lora_strength,
|
||||
guidance=request.guidance,
|
||||
)
|
||||
|
||||
if not result:
|
||||
|
||||
Reference in New Issue
Block a user