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,65 @@
|
||||
---
|
||||
name: genconfig_to_diffusers_kwargs
|
||||
kind: function
|
||||
lang: py
|
||||
domain: ml
|
||||
version: "1.0.0"
|
||||
purity: pure
|
||||
signature: "def genconfig_to_diffusers_kwargs(cfg: GenerationConfig) -> dict"
|
||||
description: "Convierte un GenerationConfig al dict de kwargs listo para pipe(**kwargs) de diffusers. Mapea prompt, steps, cfg_scale, width, height. LoRAs y sampler se aplican antes de la llamada; generator=None para que el caller setee torch.Generator por separado."
|
||||
tags: [ml, diffusers, generation, converter, pure]
|
||||
params:
|
||||
- name: cfg
|
||||
desc: "Instancia de GenerationConfig con los parametros de generacion validados."
|
||||
output: "dict con claves prompt, negative_prompt, num_inference_steps, guidance_scale, width, height, generator (None). Listo para desempaquetar con pipe(**kwargs)."
|
||||
uses_functions: []
|
||||
uses_types:
|
||||
- generation_config_py_ml
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: ""
|
||||
imports: []
|
||||
tested: true
|
||||
tests:
|
||||
- "kwargs contiene todas las claves requeridas"
|
||||
- "negative_prompt None se pasa tal cual"
|
||||
- "steps y cfg_scale se mapean a num_inference_steps y guidance_scale"
|
||||
- "generator siempre es None"
|
||||
test_file_path: "python/functions/ml/tests/test_genconfig_to_diffusers_kwargs.py"
|
||||
file_path: "python/functions/ml/genconfig_to_diffusers_kwargs.py"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```python
|
||||
from ml.genconfig_to_diffusers_kwargs import genconfig_to_diffusers_kwargs
|
||||
from ml.generation_config import GenerationConfig
|
||||
from ml.model_ref import ModelRef
|
||||
|
||||
cfg = GenerationConfig(
|
||||
prompt="a dog in the park",
|
||||
seed=42,
|
||||
steps=30,
|
||||
cfg_scale=7.5,
|
||||
sampler="euler_a",
|
||||
width=512,
|
||||
height=512,
|
||||
model=ModelRef(name="runwayml/stable-diffusion-v1-5", model_type="sd15"),
|
||||
)
|
||||
|
||||
kwargs = genconfig_to_diffusers_kwargs(cfg)
|
||||
# kwargs["num_inference_steps"] == 30
|
||||
# kwargs["guidance_scale"] == 7.5
|
||||
# kwargs["generator"] is None
|
||||
|
||||
# El caller asigna el generator:
|
||||
# kwargs["generator"] = torch.Generator(device=device).manual_seed(cfg.seed)
|
||||
# image = pipe(**kwargs).images[0]
|
||||
```
|
||||
|
||||
## Notas
|
||||
|
||||
Funcion pura: sin I/O, sin torch, sin imports opcionales en tiempo de ejecucion.
|
||||
Los LoRAs se aplican via `pipe.load_lora_weights(lora.path, adapter_name=...)` antes
|
||||
de la llamada. El scheduler/sampler se configura via `pipe.scheduler = ...` tambien
|
||||
antes. Ambos no tienen mapping directo a kwargs de `__call__`.
|
||||
Reference in New Issue
Block a user