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 EncodeVideo(inputDir, outputPath string, framerate int) error
- func FreeCString(cStr *uint8)
- func GetCpuAVX() string
- func GetGPUName() (string, error)
- func GetNumPhysicalCores() int
- func GetSDLibPath(libName string) string
- func GetSystemInfo() string
- func GetVulkanGPU() (string, error)
- func ImgGenParamsInit(params *SDImgGenParams)
- func ImgGenParamsToStr(params *SDImgGenParams) string
- 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 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 LoraApplyMode
- type Prediction
- type Preview
- type RngType
- type SDCacheMode
- type SDCacheParams
- type SDContext
- func (ctx *SDContext) Free()
- func (ctx *SDContext) GenerateImage(params *SDImgGenParams) *SDImage
- func (ctx *SDContext) GenerateVideo(params *SDVidGenParams) ([]SDImage, int)
- func (ctx *SDContext) GetDefaultSampleMethod() SampleMethod
- func (ctx *SDContext) GetDefaultScheduler(sampleMethod SampleMethod) Scheduler
- type SDContextParams
- type SDEmbedding
- type SDGuidanceParams
- type SDImage
- type SDImgGenParams
- type SDLogCallback
- type SDLogCallbackType
- type SDLogLevel
- type SDLogLevelType
- type SDLora
- type SDPMParams
- type SDPreviewCallback
- type SDProgressCallback
- type SDSLGParams
- type SDSampleParams
- type SDTilingParams
- type SDType
- 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 SDTypeCount = 40 )
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 EncodeVideo ¶
EncodeVideo encodes PNG frame sequence to video using FFmpeg
func GetNumPhysicalCores ¶
func GetNumPhysicalCores() int
GetNumPhysicalCores gets the number of physical cores
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 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 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
func VidGenParamsInit ¶
func VidGenParamsInit(params *SDVidGenParams)
VidGenParamsInit initializes video generation parameters
Types ¶
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 Flux2FlowPred PredictionCount )
func StrToPrediction ¶
func StrToPrediction(str string) Prediction
StrToPrediction converts string to prediction type
type SDCacheMode ¶
type SDCacheMode int32
const ( SDCacheDisabled SDCacheMode = iota SDCacheEasycache SDCacheUcache SDCacheDbcache SDCacheTaylorseer SDCacheCacheDit )
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
}
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) GenerateImage ¶
func (ctx *SDContext) GenerateImage(params *SDImgGenParams) *SDImage
GenerateImage generates image
func (*SDContext) GenerateVideo ¶
func (ctx *SDContext) GenerateVideo(params *SDVidGenParams) ([]SDImage, int)
GenerateVideo generates video
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
type SDContextParams ¶
type SDContextParams struct {
ModelPath *uint8
ClipLPath *uint8
ClipGPath *uint8
ClipVisionPath *uint8
T5XXLPath *uint8
LLMPath *uint8
LLMVisionPath *uint8
DiffusionModelPath *uint8
HighNoiseDiffusionModelPath *uint8
VAEPath *uint8
TAESDPath *uint8
ControlNetPath *uint8
Embeddings *SDEmbedding
EmbeddingCount uint32
PhotoMakerPath *uint8
TensorTypeRules *uint8
VAEDecodeOnly bool
FreeParamsImmediately bool
NThreads int32
WType SDType
RNGType RngType
SamplerRNGType RngType
Prediction Prediction
LoraApplyMode LoraApplyMode
OffloadParamsToCPU bool
EnableMmap bool
KeepClipOnCPU bool
KeepControlNetOnCPU bool
KeepVAEOnCPU bool
DiffusionFlashAttn bool
TAEPreviewOnly bool
DiffusionConvDirect bool
VAEConvDirect bool
CircularX bool
CircularY bool
ForceSDXLVAConvScale bool
ChromaUseDitMask bool
ChromaUseT5Mask bool
ChromaT5MaskPad int32
QwenImageZeroCondT bool
FlowShift float32
}
type SDEmbedding ¶
type SDGuidanceParams ¶
type SDGuidanceParams struct {
TxtCfg float32
ImgCfg float32
DistilledGuidance float32
SLG SDSLGParams
}
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
AutoResizeRefImage bool
IncreaseRefIndex bool
MaskImage SDImage
Width int32
Height int32
SampleParams SDSampleParams
Strength float32
Seed int64
BatchCount int32
ControlImage SDImage
ControlStrength float32
PMParams SDPMParams
VAETilingParams SDTilingParams
Cache SDCacheParams
}
type SDLogCallback ¶
type SDLogCallback func(level SDLogLevel, text *uint8, data unsafe.Pointer)
Define callback function types
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 ¶
type SDSLGParams ¶
type SDSampleParams ¶
type SDSampleParams struct {
Guidance SDGuidanceParams
Scheduler Scheduler
SampleMethod SampleMethod
SampleSteps int32
Eta float32
ShiftedTimestep int32
CustomSigmas *float32
CustomSigmasCount int32
}
type SDTilingParams ¶
type SDTilingParams struct {
Enabled bool
TileSizeX int32
TileSizeY int32
TargetOverlap float32
RelSizeX float32
RelSizeY float32
}
Define structs
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
VaceStrength float32
Cache SDCacheParams
}
type SampleMethod ¶
type SampleMethod int32
const ( EulerSampleMethod SampleMethod = iota EulerASampleMethod HeunSampleMethod DPM2SampleMethod DPMPP2SASampleMethod DPMPP2MSampleMethod DPMPP2Mv2SampleMethod IPNDMSampleMethod IPNDMSampleMethodV LCMSampleMethod DDIMTrailingSampleMethod TCDSampleMethod SampleMethodCount )
func StrToSampleMethod ¶
func StrToSampleMethod(str string) SampleMethod
StrToSampleMethod converts string to sample method
type Scheduler ¶
type Scheduler int32
func StrToScheduler ¶
StrToScheduler converts string to scheduler
type UpscalerContext ¶
type UpscalerContext struct {
// contains filtered or unexported fields
}
func NewUpscalerContext ¶
func NewUpscalerContext(esrganPath string, offloadParamsToCPU bool, direct bool, nThreads int, tileSize int) *UpscalerContext
NewUpscalerContext creates a new upscaler context
func (*UpscalerContext) Free ¶
func (ctx *UpscalerContext) Free()
FreeUpscalerContext frees upscaler context
func (*UpscalerContext) GetUpscaleFactor ¶
func (ctx *UpscalerContext) GetUpscaleFactor() int
GetUpscaleFactor gets upscale factor