Documentation
ยถ
Index ยถ
Constants ยถ
This section is empty.
Variables ยถ
var LoraApplyModeMap = map[string]sd.LoraApplyMode{ "auto": sd.LoraApplyAuto, "immediately": sd.LoraApplyImmediately, "at_runtime": sd.LoraApplyAtRuntime, "lora_apply_mode_count": sd.LoraApplyModeCount, }
LoraApplyModeMap LoRA apply mode mapping
var PredictionMap = map[string]sd.Prediction{ "eps": sd.EPSPred, "v": sd.VPred, "edm_v": sd.EDMVPred, "flow": sd.FlowPred, "flux_flow": sd.FluxFlowPred, "flux2_flow": sd.Flux2FlowPred, "default": sd.PredictionCount, }
PredictionMap prediction type mapping
var PreviewMap = map[string]sd.Preview{ "none": sd.PreviewNone, "proj": sd.PreviewProj, "tae": sd.PreviewTAE, "vae": sd.PreviewVAE, "preview_count": sd.PreviewCount, }
PreviewMap preview type mapping
var RNGTypeMap = map[string]sd.RngType{ "default": sd.DefaultRNG, "cuda": sd.CUDARNG, "cpu": sd.CPURNG, "type_count": sd.RNGTypeCount, }
RNGTypeMap RNG type mapping
var SDTypeMap = map[string]sd.SDType{ "f32": sd.SDTypeF32, "f16": sd.SDTypeF16, "q4_0": sd.SDTypeQ4_0, "q4_1": sd.SDTypeQ4_1, "q5_0": sd.SDTypeQ5_0, "q5_1": sd.SDTypeQ5_1, "q8_0": sd.SDTypeQ8_0, "q8_1": sd.SDTypeQ8_1, "q2_k": sd.SDTypeQ2_K, "q3_k": sd.SDTypeQ3_K, "q4_k": sd.SDTypeQ4_K, "q5_k": sd.SDTypeQ5_K, "q6_k": sd.SDTypeQ6_K, "q8_k": sd.SDTypeQ8_K, "iq2_xxs": sd.SDTypeIQ2_XXS, "iq2_xs": sd.SDTypeIQ2_XS, "iq3_xxs": sd.SDTypeIQ3_XXS, "iq1_s": sd.SDTypeIQ1_S, "iq4_nl": sd.SDTypeIQ4_NL, "iq3_s": sd.SDTypeIQ3_S, "iq2_s": sd.SDTypeIQ2_S, "iq4_xs": sd.SDTypeIQ4_XS, "i8": sd.SDTypeI8, "i16": sd.SDTypeI16, "i32": sd.SDTypeI32, "i64": sd.SDTypeI64, "f64": sd.SDTypeF64, "iq1_m": sd.SDTypeIQ1_M, "bf16": sd.SDTypeBF16, "tq1_0": sd.SDTypeTQ1_0, "tq2_0": sd.SDTypeTQ2_0, "mxfp4": sd.SDTypeMXFP4, "default": sd.SDTypeCount, }
SDTypeMap SDType mapping
var SampleMethodMap = map[string]sd.SampleMethod{ "default": -1, "euler": sd.EulerSampleMethod, "euler_a": sd.EulerASampleMethod, "heun": sd.HeunSampleMethod, "dpm2": sd.DPM2SampleMethod, "dpm++2s_a": sd.DPMPP2SASampleMethod, "dpm++2m": sd.DPMPP2MSampleMethod, "dpm++2mv2": sd.DPMPP2Mv2SampleMethod, "ipndm": sd.IPNDMSampleMethod, "ipndm_v": sd.IPNDMSampleMethodV, "lcm": sd.LCMSampleMethod, "ddim_trailing": sd.DDIMTrailingSampleMethod, "tcd": sd.TCDSampleMethod, "sample_method_count": sd.SampleMethodCount, }
SampleMethodMap sampling method mapping
var SchedulerMap = map[string]sd.Scheduler{ "default": -1, "discrete": sd.DiscreteScheduler, "karras": sd.KarrasScheduler, "exponential": sd.ExponentialScheduler, "ays": sd.AYSScheduler, "gits": sd.GITScheduler, "sgm_uniform": sd.SGMUniformScheduler, "simple": sd.SimpleScheduler, "smoothstep": sd.SmoothstepScheduler, "kl_optimal": sd.KLOptimalScheduler, "lcm": sd.LCMScheduler, "scheduler_count": sd.SchedulerCount, }
SchedulerMap scheduler mapping
Functions ยถ
func Convert ยถ
func Convert(inputPath, vaePath, outputPath, outputType, tensorTypeRules string, convertName bool) error
Convert model conversion function, convert a model to gguf format. inputPath: Path to the input model. vaePath: Path to the vae. outputPath: Path to save the converted model. outputType: The weight type (default: auto). tensorTypeRules: Weight type per tensor pattern (example: "^vae\\\\.=f16,model\\\\.=q8_0")
Types ยถ
type ContextParams ยถ
type ContextParams struct {
ModelPath string // Full model path
ClipLPath string // CLIP-L text encoder path
ClipGPath string // CLIP-G text encoder path
ClipVisionPath string // CLIP Vision encoder path
T5XXLPath string // T5-XXL text encoder path
LLMPath string // LLM text encoder path (e.g., qwenvl2.5 for qwen-image, mistral-small3.2 for flux2)
LLMVisionPath string // LLM Vision encoder path
DiffusionModelPath string // Standalone diffusion model path
HighNoiseDiffusionModelPath string // Standalone high noise diffusion model path
VAEPath string // VAE model path
TAESDPath string // TAE-SD model path, uses Tiny AutoEncoder for fast decoding (low quality)
ControlNetPath string // ControlNet model path
Embeddings *Embedding // Embedding information
EmbeddingCount uint32 // Number of embeddings
PhotoMakerPath string // PhotoMaker model path
TensorTypeRules string // Weight type rules per tensor pattern (e.g., "^vae\.=f16,model\.=q8_0")
VAEDecodeOnly bool // Process VAE using only decode mode
FreeParamsImmediately bool // Whether to free parameters immediately
NThreads int32 // Number of threads to use for generation
WType string // Weight type (default: auto-detect from model file)
RNGType string // Random number generator type (default: "cuda")
SamplerRNGType string // Sampler random number generator type (default: "cuda")
Prediction string // Prediction type override
LoraApplyMode string // LoRA application mode (default: "auto")
OffloadParamsToCPU bool // Keep weights in RAM to save VRAM, auto-load to VRAM when needed
EnableMmap bool // Whether to enable memory mapping
KeepClipOnCPU bool // Keep CLIP on CPU (for low VRAM)
KeepControlNetOnCPU bool // Keep ControlNet on CPU (for low VRAM)
KeepVAEOnCPU bool // Keep VAE on CPU (for low VRAM)
DiffusionFlashAttn bool // Use Flash attention in diffusion model (significantly reduces memory usage)
TAEPreviewOnly bool // Prevent decoding final image with taesd (for preview="tae")
DiffusionConvDirect bool // Use Conv2d direct in diffusion model
VAEConvDirect bool // Use Conv2d direct in VAE model (should improve performance)
CircularX bool // Enable circular padding on X axis
CircularY bool // Enable circular padding on Y axis
ForceSDXLVAConvScale bool // Force conv scale on SDXL VAE
ChromaUseDitMask bool // Whether Chroma uses DiT mask
ChromaUseT5Mask bool // Whether Chroma uses T5 mask
ChromaT5MaskPad int32 // Chroma T5 mask padding size
QwenImageZeroCondT bool // Qwen-image zero condition T parameter
FlowShift float32 // Shift value for Flow models (e.g., SD3.x or WAN)
}
ContextParams context parameters structure for initializing Stable Diffusion context
type ImgGenParams ยถ
type ImgGenParams struct {
Loras *Lora // LoRA parameters
LoraCount uint32 // Number of LoRAs
Prompt string // Prompt to render
NegativePrompt string // Negative prompt
ClipSkip int32 // Skip last layers of CLIP network (1 = no skip, 2 = skip one layer, <=0 = not specified)
InitImagePath string // Initial image path for guidance
RefImagesPath []string // Array of reference image paths for Flux Kontext models
RefImagesCount int32 // Number of reference images
AutoResizeRefImage bool // Whether to auto-resize reference images
IncreaseRefIndex bool // Whether to auto-increase index based on reference image list order (starting from 1)
MaskImagePath string // Inpainting mask image path
Width int32 // Image width (pixels)
Height int32 // Image height (pixels)
CfgScale float32 // Unconditional guidance scale.
ImageCfgScale float32 // Image guidance scale for inpaint or instruct-pix2pix models (default: same as `CfgScale`).
DistilledGuidance float32 // Distilled guidance scale for models with guidance input.
SkipLayers []int32 // Layers to skip for SLG steps (SLG will be enabled at step int([STEPS]x[START]) and disabled at int([STEPS]x[END])).
SkipLayerStart float32 // SLG enabling point.
SkipLayerEnd float32 // SLG disabling point.
SlgScale float32 // Skip layer guidance (SLG) scale, only for DiT models.
Scheduler string // Denoiser sigma scheduler (default: discrete).
SampleMethod string // Sampling method (default: euler for Flux/SD3/Wan, euler_a otherwise).
SampleSteps int32 // Number of sample steps.
Eta float32 // Eta in DDIM, only for DDIM and TCD.
ShiftedTimestep int32 // Shift timestep for NitroFusion models, default: 0, recommended N for NitroSD-Realism around 250 and 500 for NitroSD-Vibrant.
CustomSigmas []float32 // Custom sigma values for the sampler, comma-separated (e.g. "14.61,7.8,3.5,0.0").
Strength float32 // Noise/denoise strength (range [0.0, 1.0])
Seed int64 // RNG seed (< 0 for random seed)
BatchCount int32 // Number of images to generate
ControlImagePath string // Control condition image path for ControlNet
ControlStrength float32 // Strength to apply ControlNet
PMParams *PMParams // PhotoMaker parameters
VAETilingParams sd.SDTilingParams // VAE tiling parameters for reducing memory usage
CacheParams sd.SDCacheParams // Cache parameters for DiT models
}
ImgGenParams image generation parameters structure for defining image generation related parameters
type Lora ยถ
type Lora struct {
IsHighNoise bool // Whether it's a high noise LoRA
Multiplier float32 // LoRA multiplier
Path string // LoRA file path
}
Lora LoRA structure for defining LoRA model parameters
type PMParams ยถ
type PMParams struct {
IDImages *sd.SDImage // ID images pointer
IDImagesCount int32 // Number of ID images
IDEmbedPath string // PhotoMaker v2 ID embedding path
StyleStrength float32 // Strength to keep PhotoMaker input identity
}
PMParams PhotoMaker parameters structure for defining PhotoMaker related parameters
type StableDiffusion ยถ
type StableDiffusion struct {
// contains filtered or unexported fields
}
StableDiffusion Stable Diffusion structure containing context pointer
func NewStableDiffusion ยถ
func NewStableDiffusion(ctxParams *ContextParams) (*StableDiffusion, error)
NewStableDiffusion creates a stable diffusion instance
func (*StableDiffusion) Free ยถ
func (sDiffusion *StableDiffusion) Free()
Free frees the stable diffusion context
func (*StableDiffusion) GenerateImage ยถ
func (sDiffusion *StableDiffusion) GenerateImage(imgGenParams *ImgGenParams, newImagePath string) error
GenerateImage generates image from text or image
func (*StableDiffusion) GenerateVideo ยถ
func (sDiffusion *StableDiffusion) GenerateVideo(vidGenParams *VidGenParams, newVideoPath string) error
GenerateVideo generates video
type Upscaler ยถ
type Upscaler struct {
// contains filtered or unexported fields
}
func NewUpscaler ยถ
func NewUpscaler(params *UpscalerParams) *Upscaler
NewUpscaler creates a new upscaler context
type UpscalerParams ยถ
type VidGenParams ยถ
type VidGenParams struct {
Loras *Lora // LoRA parameters
LoraCount uint32 // Number of LoRAs
Prompt string // Prompt to render
NegativePrompt string // Negative prompt
ClipSkip int32 // Skip last layers of CLIP network (1 = no skip, 2 = skip one layer, <=0 = not specified)
InitImagePath string // Initial image path for starting generation
EndImagePath string // End image path for ending generation (required for flf2v)
ControlFramesPath []string // Array of control frame image paths for video
ControlFramesSize int32 // Control frame size
Width int32 // Video width (pixels)
Height int32 // Video height (pixels)
CfgScale float32 // Unconditional guidance scale.
ImageCfgScale float32 // Image guidance scale for inpaint or instruct-pix2pix models (default: same as `CfgScale`).
DistilledGuidance float32 // Distilled guidance scale for models with guidance input.
SkipLayers []int32 // Layers to skip for SLG steps (SLG will be enabled at step int([STEPS]x[START]) and disabled at int([STEPS]x[END])).
SkipLayerStart float32 // SLG enabling point.
SkipLayerEnd float32 // SLG disabling point.
SlgScale float32 // Skip layer guidance (SLG) scale, only for DiT models.
Scheduler string // Denoiser sigma scheduler (default: discrete).
SampleMethod string // Sampling method (default: euler for Flux/SD3/Wan, euler_a otherwise).
SampleSteps int32 // Number of sample steps.
Eta float32 // Eta in DDIM, only for DDIM and TCD.
ShiftedTimestep int32 // Shift timestep for NitroFusion models, default: 0, recommended N for NitroSD-Realism around 250 and 500 for NitroSD-Vibrant.
CustomSigmas []float32 // Custom sigma values for the sampler, comma-separated (e.g. "14.61,7.8,3.5,0.0").
HighNoiseCfgScale float32 // High noise diffusion model equivalent of `cfg_scale`.
HighNoiseImageCfgScale float32 // High noise diffusion model equivalent of `image_cfg_scale`.
HighNoiseDistilledGuidance float32 // High noise diffusion model equivalent of `guidance`.
HighNoiseSkipLayers []int32 // High noise diffusion model equivalent of `skip_layers`.
HighNoiseSkipLayerStart float32 // High noise diffusion model equivalent of `skip_layer_start`.
HighNoiseSkipLayerEnd float32 // High noise diffusion model equivalent of `skip_layer_end`.
HighNoiseSlgScale float32 // High noise diffusion model equivalent of `slg_scale`.
HighNoiseScheduler string // High noise diffusion model equivalent of `scheduler`.
HighNoiseSampleMethod string // High noise diffusion model equivalent of `sample_method`.
HighNoiseSampleSteps int32 // High noise diffusion model equivalent of `sample_steps` (default: -1 = auto).
HighNoiseEta float32 // High noise diffusion model equivalent of `eta`.
HighNoiseShiftedTimestep int32 // Shift timestep for NitroFusion models, default: 0, recommended N for NitroSD-Realism around 250 and 500 for NitroSD-Vibrant.
HighNoiseCustomSigmas []float32 // Custom sigma values for the sampler, comma-separated (e.g. "14.61,7.8,3.5,0.0").
MOEBoundary float32 // Timestep boundary for Wan2.2 MoE models
Strength float32 // Noise/denoise strength (range [0.0, 1.0])
Seed int64 // RNG seed (< 0 for random seed)
VideoFrames int32 // Number of video frames to generate
VaceStrength float32 // Wan VACE strength
CacheParams sd.SDCacheParams // Cache parameters for DiT models
}
VidGenParams video generation parameters structure for defining video generation related parameters
