sd

package module
v0.0.1-beta1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2023 License: MIT Imports: 4 Imported by: 6

README

stable-diffusion

pure go for stable-diffusion and support cross-platform.

Go Reference

sd.go is a wrapper around stable-diffusion-cpp, which is an adaption of ggml.cpp.

Installation

go get github.com/seasonjs/stable-diffusion

Compatibility

Not complete yet.

Usage

Not complete yet. See binding_test.go for detail.

Packaging

To ship a working program that includes this AI, you will need to include the following files:

  • libstable-diffusion.dylib / libstable-diffusion.so / stable-diffusion.dll
  • the model file
  • the tokenizer file (buildin)

Low level API

This package also provide low level Api which is same as stable-diffusion-cpp. See detail at stable-diffusion-doc.

Thanks

License

Copyright (c) seasonjs. All rights reserved. Licensed under the MIT License. See License.txt in the project root for license information.

Documentation

Index

Constants

View Source
const (
	DEBUG SDLogLevel = "DEBUG"
	INFO             = "INFO"
	WARN             = "WARN"
	ERROR            = "ERROR"
)
View Source
const (
	EULER_A          SampleMethod = "EULER_A"
	EULER                         = "EULER"
	HEUN                          = "HEUN"
	DPM2                          = "DPM2"
	DPMPP2S_A                     = "DPMPP2S_A"
	DPMPP2M                       = "DPMPP2M"
	DPMPP2Mv2                     = "DPMPP2Mv2"
	N_SAMPLE_METHODS              = "N_SAMPLE_METHODS"
)
View Source
const (
	DEFAULT     Schedule = "DEFAULT"
	DISCRETE             = "DISCRETE"
	KARRAS               = "KARRAS"
	N_SCHEDULES          = "N_SCHEDULES"
)

Variables

This section is empty.

Functions

func NewStableDiffusionAutoModel

func NewStableDiffusionAutoModel(options StableDiffusionOptions)

Types

type CSDCtx

type CSDCtx struct {
	// contains filtered or unexported fields
}

func (*CSDCtx) Close

func (c *CSDCtx) Close()

func (*CSDCtx) StableDiffusionImageToImage

func (c *CSDCtx) StableDiffusionImageToImage(initImg []byte, prompt string, negativePrompt string, cfgScale float32, width int, height int, sampleMethod SampleMethod, sampleSteps int, strength float32, seed int64) []byte

func (*CSDCtx) StableDiffusionLoadFromFile

func (c *CSDCtx) StableDiffusionLoadFromFile(path string, schedule Schedule)

func (*CSDCtx) StableDiffusionTextToImage

func (c *CSDCtx) StableDiffusionTextToImage(prompt string, negativePrompt string, cfgScale float32, width int, height int, sampleMethod SampleMethod, sampleSteps int, seed int64) []byte

type CStableDiffusion

type CStableDiffusion struct {
	// contains filtered or unexported fields
}

func NewCStableDiffusion

func NewCStableDiffusion(libraryPath string) (*CStableDiffusion, error)

func (*CStableDiffusion) NewStableDiffusionCtx

func (cSD *CStableDiffusion) NewStableDiffusionCtx(nThreads int, vaeDecodeOnly bool, freeParamsImmediately bool, rngType RNGType) *CSDCtx

func (*CStableDiffusion) StableDiffusionGetSystemInfo

func (cSD *CStableDiffusion) StableDiffusionGetSystemInfo() string

func (*CStableDiffusion) StableDiffusionSetLogLevel

func (cSD *CStableDiffusion) StableDiffusionSetLogLevel(level SDLogLevel)

type RNGType

type RNGType string
const (
	STD_DEFAULT_RNG RNGType = "STD_DEFAULT_RNG"
	CUDA_RNG                = "CUDA_RNG"
)

type SDLogLevel

type SDLogLevel string

type SampleMethod

type SampleMethod string

type Schedule

type Schedule string

type StableDiffusionModel

type StableDiffusionModel struct {
	// contains filtered or unexported fields
}

func NewStableDiffusionModel

func NewStableDiffusionModel(path string, options StableDiffusionOptions) (*StableDiffusionModel, error)

func (*StableDiffusionModel) LoadFromFile

func (sd *StableDiffusionModel) LoadFromFile(path string) error

type StableDiffusionOptions

type StableDiffusionOptions struct {
	Threads               int
	VaeDecodeOnly         bool
	FreeParamsImmediately bool
	RngType               RNGType
	Schedule              Schedule
	NegativePrompt        string
	CfgScale              float32
	Width                 int
	Height                int
	SampleMethod          SampleMethod
	SampleSteps           int
	Strength              float32
	Seed                  int64
}

Directories

Path Synopsis
deps

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL