Documentation
¶
Index ¶
- Constants
- func CGoString(cStr *uint8) string
- func CString(str string) *uint8
- func CacheParamsInit(params *SDCacheParams)
- func CleanupTempDir(tempDir string) error
- func Commit() string
- func ContextParamsInit(params *SDContextParams)
- func ContextParamsToStr(params *SDContextParams) string
- func Convert(inputPath, vaePath, outputPath string, outputType SDType, ...) bool
- func EncodePNG(img *SDImage) ([]byte, error)
- func EncodeVideo(inputDir, outputPath string, framerate int) error
- func FreeAudio(audio *SDAudio)
- func FreeCString(cStr *uint8)
- func FreeImage(img *SDImage)
- func FreeImages(imgs *SDImage, count int)
- func GetCpuAVX() string
- func GetGPUName() (string, error)
- func GetNumPhysicalCores() int
- func GetSystemInfo() string
- func GetVulkanGPU() (string, error)
- func HiresParamsInit(params *SDHiresParams)
- func ImgGenParamsInit(params *SDImgGenParams)
- func ImgGenParamsToStr(params *SDImgGenParams) string
- func Load(libDir string) (err error)
- func LoraApplyModeName(mode LoraApplyMode) string
- func PredictionName(prediction Prediction) string
- func PreprocessCanny(image SDImage, highThreshold, lowThreshold, weak, strong float32, inverse bool) bool
- func PreviewName(preview Preview) string
- func RNGTypeName(rngType RngType) string
- func SDHiresUpscalerName(upscaler SDHiresUpscaler) string
- func SDTypeName(typ SDType) string
- func SampleMethodName(method SampleMethod) string
- func SampleParamsInit(params *SDSampleParams)
- func SampleParamsToStr(params *SDSampleParams) string
- func SaveFrames(frames []SDImage, outputDir string) error
- func SaveImage(img *SDImage, path string) error
- func SchedulerName(scheduler Scheduler) string
- func SetLogCallback(cb SDLogCallbackType, data interface{})
- func SetPreviewCallback(...)
- func SetProgressCallback(cb func(step int, steps int, time float32, data interface{}), data interface{})
- func Version() string
- func VidGenParamsInit(params *SDVidGenParams)
- type GpuDevice
- type GpuDeviceType
- type LoraApplyMode
- type Prediction
- type Preview
- type RngType
- type SDAudio
- type SDCacheMode
- type SDCacheParams
- type SDCancelMode
- type SDContext
- func (ctx *SDContext) CancelGeneration(mode SDCancelMode)
- func (ctx *SDContext) Free()
- func (ctx *SDContext) GenerateImage(params *SDImgGenParams) (*SDImage, int)
- func (ctx *SDContext) GenerateVideo(params *SDVidGenParams) ([]SDImage, int)
- func (ctx *SDContext) GetDefaultSampleMethod() SampleMethod
- func (ctx *SDContext) GetDefaultScheduler(sampleMethod SampleMethod) Scheduler
- func (ctx *SDContext) SupportsImageGeneration() bool
- func (ctx *SDContext) SupportsVideoGeneration() bool
- type SDContextParams
- type SDEmbedding
- type SDGuidanceParams
- type SDHiresParams
- type SDHiresUpscaler
- type SDImage
- type SDImgGenParams
- type SDLogCallback
- type SDLogCallbackType
- type SDLogLevel
- type SDLogLevelType
- type SDLora
- type SDPMParams
- type SDPreviewCallback
- type SDProgressCallback
- type SDPulidParams
- type SDSLGParams
- type SDSampleParams
- type SDTilingParams
- type SDType
- type SDVAEFormat
- type SDVidGenParams
- type SampleMethod
- type Scheduler
- type UpscalerContext
Constants ¶
const ( SDTypeF32 SDType = iota SDTypeF16 SDTypeQ4_0 SDTypeQ4_1 // SDTypeQ4_2 = 4, support has been removed // SDTypeQ4_3 = 5, support has been removed SDTypeQ5_0 = 6 SDTypeQ5_1 = 7 SDTypeQ8_0 = 8 SDTypeQ8_1 = 9 SDTypeQ2_K = 10 SDTypeQ3_K = 11 SDTypeQ4_K = 12 SDTypeQ5_K = 13 SDTypeQ6_K = 14 SDTypeQ8_K = 15 SDTypeIQ2_XXS = 16 SDTypeIQ2_XS = 17 SDTypeIQ3_XXS = 18 SDTypeIQ1_S = 19 SDTypeIQ4_NL = 20 SDTypeIQ3_S = 21 SDTypeIQ2_S = 22 SDTypeIQ4_XS = 23 SDTypeI8 = 24 SDTypeI16 = 25 SDTypeI32 = 26 SDTypeI64 = 27 SDTypeF64 = 28 SDTypeIQ1_M = 29 SDTypeBF16 = 30 // SDTypeQ4_0_4_4 = 31, support has been removed from gguf files // SDTypeQ4_0_4_8 = 32, // SDTypeQ4_0_8_8 = 33, SDTypeTQ1_0 = 34 SDTypeTQ2_0 = 35 // SDTypeIQ4_NL_4_4 = 36, // SDTypeIQ4_NL_4_8 = 37, // SDTypeIQ4_NL_8_8 = 38, SDTypeMXFP4 = 39 SDTypeNVFP4 = 40 // NVFP4 (4 blocks, E4M3 scale) SDTypeQ1_0 = 41 SDTypeCount = 42 )
Variables ¶
This section is empty.
Functions ¶
func CacheParamsInit ¶
func CacheParamsInit(params *SDCacheParams)
CacheParamsInit initializes cache parameters
func CleanupTempDir ¶
CleanupTempDir cleans up temporary directory
func ContextParamsInit ¶
func ContextParamsInit(params *SDContextParams)
ContextParamsInit initializes context parameters
func ContextParamsToStr ¶
func ContextParamsToStr(params *SDContextParams) string
ContextParamsToStr converts context parameters to string
func Convert ¶
func Convert(inputPath, vaePath, outputPath string, outputType SDType, tensorTypeRules string, convertName bool) bool
Convert converts model
func EncodePNG ¶
EncodePNG encodes an SDImage as PNG and returns the bytes, without touching the filesystem — useful for serving generated images directly (e.g. base64 over an API) instead of round-tripping through a file.
func EncodeVideo ¶
EncodeVideo encodes PNG frame sequence to video using FFmpeg
func FreeAudio ¶
func FreeAudio(audio *SDAudio)
FreeAudio releases a native audio buffer returned by generate_video. It is safe to call with a nil audio or when the native binding is unavailable (the library has not been loaded / the symbol was not registered), in which case it does nothing — consistent with FreeImage/FreeImages.
func FreeImage ¶
func FreeImage(img *SDImage)
FreeImage frees a single SDImage returned by the native library: its pixel buffer and the struct allocation itself. It is safe to call with a nil image or when the free binding is unavailable (in which case it does nothing).
func FreeImages ¶
FreeImages frees an array of count SDImages returned by the native library (for example the result of generate_image, which mallocs an array of images, each owning a malloc'd pixel buffer). It frees every image's pixel buffer and then the backing array allocation. It is safe to call with a nil pointer, a non-positive count, or when the free binding is unavailable (in which case it does nothing).
When the library exports free_sd_images (added upstream in the master-802 resync) that is used, so the memory is released by the same C runtime that allocated it — the safe path on Windows, where the library and the process may link different CRTs. The manual free(3) walk is kept only as a fallback for the pathological case where the symbol failed to bind.
func GetNumPhysicalCores ¶
func GetNumPhysicalCores() int
GetNumPhysicalCores gets the number of physical cores
func HiresParamsInit ¶
func HiresParamsInit(params *SDHiresParams)
HiresParamsInit initializes hi-res fix parameters with library defaults.
func ImgGenParamsInit ¶
func ImgGenParamsInit(params *SDImgGenParams)
ImgGenParamsInit initializes image generation parameters
func ImgGenParamsToStr ¶
func ImgGenParamsToStr(params *SDImgGenParams) string
ImgGenParamsToStr converts image generation parameters to string
func Load ¶
Load resolves and dlopens the stable-diffusion shared library from libDir. An empty libDir falls back to the OS default search path. Load is idempotent and safe for concurrent use; it returns an error (and never panics) when the library is absent or incompatible, so that merely importing this package — or calling Load when the library is missing — keeps the caller healthy.
func LoraApplyModeName ¶
func LoraApplyModeName(mode LoraApplyMode) string
LoraApplyModeName gets LoRA apply mode name
func PredictionName ¶
func PredictionName(prediction Prediction) string
PredictionName gets prediction type name
func PreprocessCanny ¶
func PreprocessCanny(image SDImage, highThreshold, lowThreshold, weak, strong float32, inverse bool) bool
PreprocessCanny preprocesses Canny edge detection
func SDHiresUpscalerName ¶
func SDHiresUpscalerName(upscaler SDHiresUpscaler) string
SDHiresUpscalerName gets the hi-res upscaler name.
func SampleMethodName ¶
func SampleMethodName(method SampleMethod) string
SampleMethodName gets sample method name
func SampleParamsInit ¶
func SampleParamsInit(params *SDSampleParams)
SampleParamsInit initializes sample parameters
func SampleParamsToStr ¶
func SampleParamsToStr(params *SDSampleParams) string
SampleParamsToStr converts sample parameters to string
func SaveFrames ¶
SaveFrames saves all video frames as PNG files
func SchedulerName ¶
SchedulerName gets scheduler name
func SetLogCallback ¶
func SetLogCallback(cb SDLogCallbackType, data interface{})
SetLogCallback sets log callback
func SetPreviewCallback ¶
func SetPreviewCallback(cb func(step int, frameCount int, frames []SDImage, isNoisy bool, data interface{}), mode Preview, interval int, denoised bool, noisy bool, data interface{})
SetPreviewCallback sets preview callback
func SetProgressCallback ¶
func SetProgressCallback(cb func(step int, steps int, time float32, data interface{}), data interface{})
SetProgressCallback sets progress callback.
Windows limitation (handled gracefully): the C progress callback takes a `float` argument, and Windows' syscall.NewCallback — which purego uses to turn a Go func into a C callback there — supports neither float arguments nor float returns. Registering a progress callback on Windows would panic ("float arguments not supported"). Rather than leave that as a latent crash, SetProgressCallback is a no-op for a non-nil cb on Windows: progress reporting is simply unavailable there. Clearing (cb == nil) still works on every platform. The log and preview callbacks have no float in their signatures and work everywhere.
func VidGenParamsInit ¶
func VidGenParamsInit(params *SDVidGenParams)
VidGenParamsInit initializes video generation parameters
Types ¶
type GpuDevice ¶
type GpuDevice struct {
Name string // "CUDA0", "Metal", "Vulkan0", "CPU", ...
Type GpuDeviceType // CPU / GPU / IGPU (see constants)
FreeBytes uint64 // live free memory (real VRAM on CUDA; working-set on Metal)
TotalBytes uint64 // total memory
}
GpuDevice is one ggml backend device reported by the statically-linked ggml inside libstable-diffusion, with its live free/total memory.
func GpuDevices ¶
GpuDevices enumerates the ggml backend devices and their live free/total memory. ok is false when the library isn't loaded, or the running libstable-diffusion predates the sd_backend_dev_* wrappers (v0.3.0+). The enumeration is panic-safe: a misbehaving FFI call yields (nil, false) rather than crashing the caller, mirroring Load's contract.
type GpuDeviceType ¶
type GpuDeviceType int
GpuDeviceType classifies a ggml backend device (ggml_backend_dev_type).
const ( GpuDeviceCPU GpuDeviceType = 0 // GGML_BACKEND_DEVICE_TYPE_CPU GpuDeviceGPU GpuDeviceType = 1 // GGML_BACKEND_DEVICE_TYPE_GPU — dedicated VRAM GpuDeviceIGPU GpuDeviceType = 2 // GGML_BACKEND_DEVICE_TYPE_IGPU — shares host RAM )
type LoraApplyMode ¶
type LoraApplyMode int32
const ( LoraApplyAuto LoraApplyMode = iota LoraApplyImmediately LoraApplyAtRuntime LoraApplyModeCount )
func StrToLoraApplyMode ¶
func StrToLoraApplyMode(str string) LoraApplyMode
StrToLoraApplyMode converts string to LoRA apply mode
type Prediction ¶
type Prediction int32
const ( EPSPred Prediction = iota VPred EDMVPred FlowPred FluxFlowPred // SefiFlowPred occupies the enum slot that FLUX2_FLOW_PRED held before the // master-802 resync: upstream replaced FLUX2_FLOW_PRED with SEFI_FLOW_PRED // (same integer value, 5) and appended MINIT2I_FLOW_PRED. SefiFlowPred Minit2iFlowPred PredictionCount )
func StrToPrediction ¶
func StrToPrediction(str string) Prediction
StrToPrediction converts string to prediction type
type SDAudio ¶
SDAudio mirrors sd_audio_t. It is returned by generate_video for audio-capable video models (e.g. LTX2); the image path does not produce it.
type SDCacheMode ¶
type SDCacheMode int32
const ( SDCacheDisabled SDCacheMode = iota SDCacheEasycache SDCacheUcache SDCacheDbcache SDCacheTaylorseer SDCacheCacheDit SDCacheSpectrum )
type SDCacheParams ¶
type SDCacheParams struct {
Mode SDCacheMode
ReuseThreshold float32
StartPercent float32
EndPercent float32
ErrorDecayRate float32
UseRelativeThreshold bool
ResetErrorOnCompute bool
FnComputeBlocks int32
BnComputeBlocks int32
ResidualDiffThreshold float32
MaxWarmupSteps int32
MaxCachedSteps int32
MaxContinuousCachedSteps int32
TaylorseerNDerivatives int32
TaylorseerSkipInterval int32
ScmMask *uint8
ScmPolicyDynamic bool
SpectrumW float32
SpectrumM int32
SpectrumLam float32
SpectrumWindowSize int32
SpectrumFlexWindow float32
SpectrumWarmupSteps int32
SpectrumStopPercent float32
}
type SDCancelMode ¶
type SDCancelMode int32
SDCancelMode mirrors enum sd_cancel_mode_t (added upstream in the master-802 resync) and selects how sd_cancel_generation interrupts an in-flight generation.
const ( // CancelAll stops the current generation as soon as possible. CancelAll SDCancelMode = iota // CancelNewLatents finishes the current image sample, then skips // additional batch latents and returns the completed images. CancelNewLatents // CancelReset clears a pending cancellation request. CancelReset )
type SDContext ¶
type SDContext struct {
// contains filtered or unexported fields
}
Define context types
func NewContext ¶
func NewContext(params *SDContextParams) *SDContext
NewContext creates a new context
func (*SDContext) CancelGeneration ¶
func (ctx *SDContext) CancelGeneration(mode SDCancelMode)
CancelGeneration requests cancellation of the in-flight generation on this context (or clears a pending request, with CancelReset). It is safe to call from another goroutine while GenerateImage/GenerateVideo is running — that is its purpose.
func (*SDContext) GenerateImage ¶
func (ctx *SDContext) GenerateImage(params *SDImgGenParams) (*SDImage, int)
GenerateImage generates images. As of the master-802 upstream resync, generate_image returns a success bool and yields a malloc'd array of images through out-parameters (instead of returning the array directly), so this wrapper returns the native array pointer plus the number of images in it. On failure it returns (nil, 0). The caller owns the returned array and must release it with FreeImages(images, count) when done.
func (*SDContext) GenerateVideo ¶
func (ctx *SDContext) GenerateVideo(params *SDVidGenParams) ([]SDImage, int)
GenerateVideo generates video. As of the upstream resync, generate_video returns a success bool and also yields an audio buffer for audio-capable models (e.g. LTX2). This binding does not surface audio, so the buffer is freed immediately; the public ([]SDImage, int) signature is unchanged so existing callers keep working.
func (*SDContext) GetDefaultSampleMethod ¶
func (ctx *SDContext) GetDefaultSampleMethod() SampleMethod
GetDefaultSampleMethod gets default sample method
func (*SDContext) GetDefaultScheduler ¶
func (ctx *SDContext) GetDefaultScheduler(sampleMethod SampleMethod) Scheduler
GetDefaultScheduler gets default scheduler
func (*SDContext) SupportsImageGeneration ¶
SupportsImageGeneration reports whether the loaded model can generate images.
func (*SDContext) SupportsVideoGeneration ¶
SupportsVideoGeneration reports whether the loaded model can generate video.
type SDContextParams ¶
type SDContextParams struct {
ModelPath *uint8
ClipLPath *uint8
ClipGPath *uint8
ClipVisionPath *uint8
T5XXLPath *uint8
LLMPath *uint8
LLMVisionPath *uint8
DiffusionModelPath *uint8
HighNoiseDiffusionModelPath *uint8
UncondDiffusionModelPath *uint8
EmbeddingsConnectorsPath *uint8
VAEPath *uint8
AudioVAEPath *uint8
TAESDPath *uint8
ControlNetPath *uint8
IPAdapterPath *uint8
MotionModulePath *uint8
Embeddings *SDEmbedding
EmbeddingCount uint32
PhotoMakerPath *uint8
PulidWeightsPath *uint8
TensorTypeRules *uint8
NThreads int32
WType SDType
RNGType RngType
SamplerRNGType RngType
Prediction Prediction
LoraApplyMode LoraApplyMode
EnableMmap bool
FlashAttn bool
DiffusionFlashAttn bool
TAEPreviewOnly bool
DiffusionConvDirect bool
VAEConvDirect bool
ForceSDXLVAConvScale bool
VAEFormat SDVAEFormat
MaxVRAM *uint8
StreamLayers bool
EagerLoad bool
Backend *uint8
ParamsBackend *uint8
SplitMode *uint8
AutoFit bool
RPCServers *uint8
ModelArgs *uint8
}
SDContextParams mirrors sd_ctx_params_t at upstream master-802-e92e86f. Field order, types and implicit padding MUST match the C struct exactly — this layout is what crosses the FFI boundary. Notable drift from the previous pin (master-685-19bdfe2):
- added: IPAdapterPath, MotionModulePath (after ControlNetPath), PulidWeightsPath (after PhotoMakerPath), EagerLoad, SplitMode, AutoFit, RPCServers, ModelArgs
- removed: VAEDecodeOnly, FreeParamsImmediately, OffloadParamsToCPU, KeepClipOnCPU, KeepControlNetOnCPU, KeepVAEOnCPU, CircularX, CircularY (the latter two moved into the img/vid gen params), ChromaUseDitMask, ChromaUseT5Mask, ChromaT5MaskPad, QwenImageZeroCondT (chroma/qwen knobs moved into the free-form ModelArgs key=value list)
- changed: MaxVRAM is now a C string (GiB budget or backend assignment spec), no longer a float
type SDEmbedding ¶
type SDGuidanceParams ¶
type SDGuidanceParams struct {
TxtCfg float32
ImgCfg float32
DistilledGuidance float32
SLG SDSLGParams
}
type SDHiresParams ¶
type SDHiresUpscaler ¶
type SDHiresUpscaler int32
const ( HiresUpscalerNone SDHiresUpscaler = iota HiresUpscalerLatent HiresUpscalerLatentNearest HiresUpscalerLatentNearestExact HiresUpscalerLatentAntialiased HiresUpscalerLatentBicubic HiresUpscalerLatentBicubicAntialiased HiresUpscalerLanczos HiresUpscalerNearest HiresUpscalerModel HiresUpscalerCount )
func StrToSDHiresUpscaler ¶
func StrToSDHiresUpscaler(str string) SDHiresUpscaler
StrToSDHiresUpscaler converts a string to a hi-res upscaler.
type SDImage ¶
func GenerateImageFromPath ¶
GenerateImageFromPath generates SDImage from path
func GenerateImagesFromPaths ¶
type SDImgGenParams ¶
type SDImgGenParams struct {
Loras *SDLora
LoraCount uint32
Prompt *uint8
NegativePrompt *uint8
ClipSkip int32
InitImage SDImage
RefImages *SDImage
RefImagesCount int32
RefImageArgs *uint8
MaskImage SDImage
Width int32
Height int32
SampleParams SDSampleParams
Strength float32
Seed int64
BatchCount int32
ControlImage SDImage
ControlStrength float32
IPAdapterImage SDImage
IPAdapterStrength float32
PMParams SDPMParams
PulidParams SDPulidParams
VAETilingParams SDTilingParams
Cache SDCacheParams
Hires SDHiresParams
QwenImageLayers int32
CircularX bool
CircularY bool
}
SDImgGenParams mirrors sd_img_gen_params_t at upstream master-802-e92e86f. Drift from the previous pin: AutoResizeRefImage/IncreaseRefIndex were replaced by the free-form RefImageArgs C string; IPAdapterImage, IPAdapterStrength, PulidParams, QwenImageLayers, CircularX and CircularY were added.
type SDLogCallback ¶
type SDLogCallback func(level SDLogLevel, text *uint8, data unsafe.Pointer) uintptr
Define callback function types.
These mirror the C signatures, which are `void (*)(...)`. They are nonetheless declared to return uintptr because purego turns a Go func passed as a C callback into a machine callback via purego.NewCallback, and on Windows purego delegates to syscall.NewCallback -> runtime.compileCallback, which REQUIRES the callback return exactly one uintptr-sized result. A void Go callback panics there with "compileCallback: expected function with one uintptr-sized result" (the symptom seen during stable-diffusion image generation on Windows). The C caller declares these as void and simply ignores the returned register, so always returning 0 is safe on every platform. (This is the same shape used for ggml's log callback shim elsewhere in the ecosystem.)
type SDLogCallbackType ¶
type SDLogCallbackType func(level SDLogLevelType, text string, data interface{})
type SDLogLevel ¶
type SDLogLevel int32
const ( SDLogDebug SDLogLevel = iota SDLogInfo SDLogWarn SDLogError )
type SDPMParams ¶
type SDPreviewCallback ¶
type SDProgressCallback ¶
SDProgressCallback NOTE (Windows): this callback takes a float32 argument. purego's callback support on Windows is syscall.NewCallback, which supports neither float arguments nor float returns — so this callback cannot be wrapped on Windows. SetProgressCallback handles that gracefully (it skips registration on Windows rather than panicking), so progress reporting is simply unavailable there. The log and preview callbacks have no float in their signatures and work on every platform. Lifting this would require removing the float from the C-ABI signature.
type SDPulidParams ¶
SDPulidParams mirrors sd_pulid_params_t (added upstream in the master-802 resync).
type SDSLGParams ¶
type SDSampleParams ¶
type SDSampleParams struct {
Guidance SDGuidanceParams
Scheduler Scheduler
SampleMethod SampleMethod
SampleSteps int32
Eta float32
ShiftedTimestep int32
CustomSigmas *float32
CustomSigmasCount int32
FlowShift float32
ExtraSampleArgs *uint8
}
type SDTilingParams ¶
type SDTilingParams struct {
Enabled bool
TemporalTiling bool
TileSizeX int32
TileSizeY int32
TargetOverlap float32
RelSizeX float32
RelSizeY float32
ExtraTilingArgs *uint8
}
Define structs
type SDVAEFormat ¶
type SDVAEFormat int32
const ( VAEFormatAuto SDVAEFormat = -1 FluxVAEFormat SDVAEFormat = 0 SD3VAEFormat SDVAEFormat = 1 Flux2VAEFormat SDVAEFormat = 2 WanVAEFormat SDVAEFormat = 3 VAEFormatCount SDVAEFormat = 4 )
type SDVidGenParams ¶
type SDVidGenParams struct {
Loras *SDLora
LoraCount uint32
Prompt *uint8
NegativePrompt *uint8
ClipSkip int32
InitImage SDImage
EndImage SDImage
ControlFrames *SDImage
ControlFramesSize int32
Width int32
Height int32
SampleParams SDSampleParams
HighNoiseSampleParams SDSampleParams
MOEBoundary float32
Strength float32
Seed int64
VideoFrames int32
Fps int32
VaceStrength float32
VAETilingParams SDTilingParams
Cache SDCacheParams
Hires SDHiresParams
CircularX bool
CircularY bool
}
type SampleMethod ¶
type SampleMethod int32
const ( EulerSampleMethod SampleMethod = iota EulerASampleMethod HeunSampleMethod DPM2SampleMethod DPMPP2SASampleMethod DPMPP2MSampleMethod DPMPP2Mv2SampleMethod IPNDMSampleMethod IPNDMSampleMethodV LCMSampleMethod DDIMTrailingSampleMethod TCDSampleMethod ResMultistepSampleMethod Res2SSampleMethod ERSDESampleMethod EulerCFGPPSampleMethod EulerACFGPPSampleMethod EulerGESampleMethod DPMPP2MSDESampleMethod DPMPP2MSDEBTSampleMethod SampleMethodCount )
func StrToSampleMethod ¶
func StrToSampleMethod(str string) SampleMethod
StrToSampleMethod converts string to sample method
type Scheduler ¶
type Scheduler int32
const ( DiscreteScheduler Scheduler = iota KarrasScheduler ExponentialScheduler AYSScheduler GITScheduler SGMUniformScheduler SimpleScheduler SmoothstepScheduler KLOptimalScheduler LCMScheduler BongTangentScheduler LTX2Scheduler LogitNormalScheduler Flux2Scheduler FluxScheduler BetaScheduler SchedulerCount )
func StrToScheduler ¶
StrToScheduler converts string to scheduler
type UpscalerContext ¶
type UpscalerContext struct {
// contains filtered or unexported fields
}
func NewUpscalerContext ¶
func NewUpscalerContext(esrganPath string, direct bool, nThreads int, tileSize int, backend string, paramsBackend string) *UpscalerContext
NewUpscalerContext creates a new upscaler context. backend and paramsBackend select the runtime backend; empty strings fall back to the library default. (Upstream removed the offload_params_to_cpu argument in the master-802 resync; CPU offload is now expressed as a params-backend assignment spec, e.g. paramsBackend = "*=cpu".)
func (*UpscalerContext) Free ¶
func (ctx *UpscalerContext) Free()
FreeUpscalerContext frees upscaler context
func (*UpscalerContext) GetUpscaleFactor ¶
func (ctx *UpscalerContext) GetUpscaleFactor() int
GetUpscaleFactor gets upscale factor
func (*UpscalerContext) Upscale ¶
func (ctx *UpscalerContext) Upscale(inputImage SDImage, upscaleFactor uint32) (*SDImage, int)
Upscale upscales an image. As of the master-802 upstream resync, upscale returns a success bool and yields a malloc'd image array through out-parameters, so this wrapper returns the native array pointer plus the number of images in it ((nil, 0) on failure). The caller owns the returned array and must release it with FreeImages(images, count) when done.