chore: auto-commit (95 archivos)
- cmd/fn/doctor.go - cmd/fn/main.go - cpp/apps/primitives_gallery/playground/tables/CMakeLists.txt - cpp/apps/primitives_gallery/playground/tables/data_table.cpp - cpp/apps/primitives_gallery/playground/tables/data_table_logic.cpp - cpp/apps/primitives_gallery/playground/tables/data_table_logic.h - cpp/apps/primitives_gallery/playground/tables/self_test.cpp - cpp/apps/primitives_gallery/playground/tables/tql.cpp - cpp/apps/primitives_gallery/playground/tables/viz.cpp - cpp/apps/primitives_gallery/playground/tables/viz.h - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
"""genconfig_to_diffusers_kwargs — convierte GenerationConfig a kwargs para diffusers pipe()."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
|
||||
from generation_config import GenerationConfig
|
||||
|
||||
|
||||
def genconfig_to_diffusers_kwargs(cfg: GenerationConfig) -> dict:
|
||||
"""Convierte un GenerationConfig al dict de kwargs listo para pipe(**kwargs) de diffusers.
|
||||
|
||||
Solo mapea los campos que diffusers StableDiffusionPipeline.__call__ acepta
|
||||
directamente. Los LoRAs y el sampler/scheduler se configuran antes de la
|
||||
llamada via load_lora_weights() y pipe.scheduler = ...; no tienen mapping
|
||||
1:1 con kwargs de __call__.
|
||||
|
||||
El campo "generator" se devuelve como None; el caller debe asignar
|
||||
torch.Generator(device=device).manual_seed(cfg.seed) por separado para
|
||||
poder reutilizar el GenerationConfig en distintos devices sin importar torch
|
||||
aqui (funcion pura).
|
||||
|
||||
Args:
|
||||
cfg: Parametros de generacion validados. Debe ser instancia de GenerationConfig.
|
||||
|
||||
Returns:
|
||||
dict con claves: prompt, negative_prompt, num_inference_steps,
|
||||
guidance_scale, width, height, generator (None).
|
||||
"""
|
||||
return {
|
||||
"prompt": cfg.prompt,
|
||||
"negative_prompt": cfg.negative_prompt,
|
||||
"num_inference_steps": cfg.steps,
|
||||
"guidance_scale": cfg.cfg_scale,
|
||||
"width": cfg.width,
|
||||
"height": cfg.height,
|
||||
"generator": None,
|
||||
}
|
||||
Reference in New Issue
Block a user