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,74 @@
|
||||
---
|
||||
name: genconfig_to_sdcpp_args
|
||||
kind: function
|
||||
lang: py
|
||||
domain: ml
|
||||
version: "1.0.0"
|
||||
purity: pure
|
||||
signature: "def genconfig_to_sdcpp_args(cfg: GenerationConfig) -> list[str]"
|
||||
description: "Convierte un GenerationConfig a lista de args CLI para stable-diffusion.cpp (sd-cli). Mapea sampler via _SAMPLER_MAP, aplana LoRAs como pares --lora path:weight. Sin I/O ni dependencias externas."
|
||||
tags: [ml, sdcpp, stable-diffusion-cpp, cli, converter, pure]
|
||||
params:
|
||||
- name: cfg
|
||||
desc: "Instancia de GenerationConfig con los parametros de generacion validados."
|
||||
output: "Lista de strings con los argumentos CLI en orden. Listo para subprocess.run(['sd'] + args, ...)."
|
||||
uses_functions: []
|
||||
uses_types:
|
||||
- generation_config_py_ml
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: ""
|
||||
imports: []
|
||||
tested: true
|
||||
tests:
|
||||
- "sampler euler_a se mapea a euler_a en el flag --sampling-method"
|
||||
- "sampler dpm++2m se mapea a dpmpp2m"
|
||||
- "lora con path y weight se agrega como --lora path:weight"
|
||||
- "multiples loras generan multiples pares --lora"
|
||||
- "negative_prompt None produce string vacio en --negative-prompt"
|
||||
- "model.path tiene prioridad sobre model.name en -m"
|
||||
- "args contiene --prompt --seed --steps --cfg-scale --sampling-method -W -H -m"
|
||||
test_file_path: "python/functions/ml/tests/test_genconfig_to_sdcpp_args.py"
|
||||
file_path: "python/functions/ml/genconfig_to_sdcpp_args.py"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```python
|
||||
from ml.genconfig_to_sdcpp_args import genconfig_to_sdcpp_args
|
||||
from ml.generation_config import GenerationConfig
|
||||
from ml.model_ref import ModelRef
|
||||
from ml.lora_ref import LoraRef
|
||||
|
||||
cfg = GenerationConfig(
|
||||
prompt="a cat",
|
||||
seed=1,
|
||||
steps=20,
|
||||
cfg_scale=7.0,
|
||||
sampler="dpm++2m",
|
||||
width=512,
|
||||
height=512,
|
||||
model=ModelRef(name="v1-5", model_type="sd15", path="/models/v1-5.ckpt"),
|
||||
loras=[LoraRef(path="/loras/detail.safetensors", weight=0.8)],
|
||||
)
|
||||
|
||||
args = genconfig_to_sdcpp_args(cfg)
|
||||
# ["--prompt", "a cat", "--negative-prompt", "", "--seed", "1",
|
||||
# "--steps", "20", "--cfg-scale", "7.0", "--sampling-method", "dpmpp2m",
|
||||
# "-W", "512", "-H", "512", "-m", "/models/v1-5.ckpt",
|
||||
# "--lora", "/loras/detail.safetensors:0.8"]
|
||||
```
|
||||
|
||||
## Notas
|
||||
|
||||
Mapa de samplers (_SAMPLER_MAP):
|
||||
- euler → euler
|
||||
- euler_a → euler_a
|
||||
- dpm++2m → dpmpp2m
|
||||
- dpm++2m_v2 → dpmpp2mv2
|
||||
- heun → heun
|
||||
- dpm2 → dpm2
|
||||
- lcm → lcm
|
||||
|
||||
Si cfg.model.path es None, se usa cfg.model.name (nombre de hub o path relativo
|
||||
segun configuracion del entorno sdcpp). Los LoRAs sin path se omiten silenciosamente.
|
||||
Reference in New Issue
Block a user