a802f59f55
- 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>
60 lines
1.6 KiB
Go
60 lines
1.6 KiB
Go
package ml
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
)
|
|
|
|
// samplerMap traduce nombres canonicos del dominio ml a flags de stable-diffusion.cpp.
|
|
var samplerMap = map[string]string{
|
|
"euler": "euler",
|
|
"euler_a": "euler_a",
|
|
"dpm++2m": "dpmpp2m",
|
|
"dpm++2m_v2": "dpmpp2mv2",
|
|
"heun": "heun",
|
|
"dpm2": "dpm2",
|
|
"lcm": "lcm",
|
|
}
|
|
|
|
// GenconfigToSdcliArgs convierte un GenerationConfig en una lista de argumentos
|
|
// CLI para stable-diffusion.cpp (sd.exe / sd binario).
|
|
// Espejo Go de genconfig_to_sdcpp_args_py_ml.
|
|
//
|
|
// Loras se emiten como pares repetidos "--lora" "path:weight".
|
|
// Si el sampler no existe en samplerMap se usa el valor literal sin traducir.
|
|
// La funcion es pura: sin I/O, sin estado, determinista.
|
|
func GenconfigToSdcliArgs(cfg GenerationConfig) []string {
|
|
args := []string{
|
|
"--prompt", cfg.Prompt,
|
|
"--seed", strconv.FormatInt(cfg.Seed, 10),
|
|
"--steps", strconv.Itoa(cfg.Steps),
|
|
"--cfg-scale", strconv.FormatFloat(cfg.CfgScale, 'f', -1, 64),
|
|
"--width", strconv.Itoa(cfg.Width),
|
|
"--height", strconv.Itoa(cfg.Height),
|
|
}
|
|
|
|
if cfg.NegativePrompt != "" {
|
|
args = append(args, "--negative-prompt", cfg.NegativePrompt)
|
|
}
|
|
|
|
sampler := cfg.Sampler
|
|
if mapped, ok := samplerMap[sampler]; ok {
|
|
sampler = mapped
|
|
}
|
|
args = append(args, "--sampling-method", sampler)
|
|
|
|
if cfg.Model.Path != "" {
|
|
args = append(args, "--model", cfg.Model.Path)
|
|
}
|
|
|
|
if cfg.ClipSkip != nil {
|
|
args = append(args, "--clip-skip", strconv.Itoa(*cfg.ClipSkip))
|
|
}
|
|
|
|
for _, lora := range cfg.Loras {
|
|
args = append(args, "--lora", fmt.Sprintf("%s:%g", lora.Path, lora.Weight))
|
|
}
|
|
|
|
return args
|
|
}
|