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,59 @@
|
||||
---
|
||||
name: genconfig_to_sdcli_args
|
||||
kind: function
|
||||
lang: go
|
||||
domain: ml
|
||||
version: "1.0.0"
|
||||
purity: pure
|
||||
signature: "func GenconfigToSdcliArgs(cfg GenerationConfig) []string"
|
||||
description: "Convierte un GenerationConfig en argumentos CLI para stable-diffusion.cpp. Espejo Go de genconfig_to_sdcpp_args_py_ml. Loras se emiten como pares repetidos --lora path:weight. Sampler traducido via samplerMap canonico."
|
||||
tags: [ml, stable-diffusion, cli, args, generation, pure]
|
||||
uses_functions: []
|
||||
uses_types: [generation_config_go_ml]
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: ""
|
||||
imports: ["fmt", "strconv"]
|
||||
params:
|
||||
- name: cfg
|
||||
desc: "Parametros completos de generacion de imagen. Sampler debe ser uno de los valores de SamplerName. Model.Path se emite como --model si no esta vacio."
|
||||
output: "Slice de strings listos para pasar a exec.Command o similar. Incluye --prompt, --seed, --steps, --cfg-scale, --width, --height, --sampling-method, opcionales --negative-prompt / --model / --clip-skip, y pares --lora path:weight por cada LoraRef."
|
||||
tested: true
|
||||
tests:
|
||||
- "config basico sin loras ni clip_skip"
|
||||
- "loras se emiten como pares path:weight"
|
||||
- "sampler dpm++2m se traduce a dpmpp2m"
|
||||
- "negative_prompt vacio no genera flag"
|
||||
test_file_path: "functions/ml/genconfig_test.go"
|
||||
file_path: "functions/ml/genconfig_to_sdcli_args.go"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```go
|
||||
clip := 2
|
||||
cfg := ml.GenerationConfig{
|
||||
Prompt: "a cat",
|
||||
Seed: 42,
|
||||
Steps: 20,
|
||||
CfgScale: 7.5,
|
||||
Sampler: "dpm++2m",
|
||||
Width: 512,
|
||||
Height: 512,
|
||||
Model: ml.ModelRef{Name: "v1-5", ModelType: "sd15", Quantization: "fp16", Path: "/models/v1-5.safetensors"},
|
||||
Loras: []ml.LoraRef{{Path: "/loras/detail.safetensors", Weight: 0.8}},
|
||||
ClipSkip: &clip,
|
||||
}
|
||||
args := ml.GenconfigToSdcliArgs(cfg)
|
||||
// args == ["--prompt","a cat","--seed","42","--steps","20",
|
||||
// "--cfg-scale","7.5","--width","512","--height","512",
|
||||
// "--sampling-method","dpmpp2m","--model","/models/v1-5.safetensors",
|
||||
// "--clip-skip","2","--lora","/loras/detail.safetensors:0.8"]
|
||||
```
|
||||
|
||||
## Notas
|
||||
|
||||
- `samplerMap` traduce nombres canonicos del dominio ml a los identificadores que acepta stable-diffusion.cpp. Si el sampler no esta en el mapa se usa el valor literal.
|
||||
- El flag de modelo (`--model`) solo se emite si `cfg.Model.Path != ""`.
|
||||
- `%g` en `fmt.Sprintf` para el peso de la lora elimina ceros insignificantes: `0.800000` → `0.8`.
|
||||
- Funcion pura: misma entrada, misma salida. Sin I/O ni estado global.
|
||||
Reference in New Issue
Block a user