From b66bc983861bae3bdf7894ad450650366d15236e Mon Sep 17 00:00:00 2001 From: aladac Date: Sun, 17 May 2026 15:54:47 +0200 Subject: [PATCH] feat(generate): expose --guidance flag for Flux models MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tensors/cli.py | 10 ++++++++++ tensors/remote.py | 3 +++ tensors/server/comfyui_api_routes.py | 7 +++++++ 3 files changed, 20 insertions(+) diff --git a/tensors/cli.py b/tensors/cli.py index 612c08c..d82cc36 100644 --- a/tensors/cli.py +++ b/tensors/cli.py @@ -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: diff --git a/tensors/remote.py b/tensors/remote.py index bafabbb..77e6824 100644 --- a/tensors/remote.py +++ b/tensors/remote.py @@ -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: diff --git a/tensors/server/comfyui_api_routes.py b/tensors/server/comfyui_api_routes.py index 7e30961..1ce44e2 100644 --- a/tensors/server/comfyui_api_routes.py +++ b/tensors/server/comfyui_api_routes.py @@ -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: