stable_diffusion

package
v0.0.0-...-098f5f7 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64File

func Base64File(fp string) (b64 string, err error)

func Imgs2Files

func Imgs2Files(imgs []string, dir string, id *uuid.UUID) (prefix string, err error)

func Info2File

func Info2File(info, prefix string) (err error)

func Version

func Version() string

Types

type Client

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

func ClientFromViper

func ClientFromViper(vp *viper.Viper, field string) (client *Client, err error)

func NewClient

func NewClient(fp, key string) (client *Client, err error)

func (*Client) Img2Img

func (client *Client) Img2Img(ctx context.Context, req *Img2ImgReq, exts ...Extension) (
	res *Img2ImgRes, err error)

func (*Client) Interrogate

func (client *Client) Interrogate(ctx context.Context, req *InterrogateReq) (
	res *InterrogateRes, err error)

Interrogate

func (*Client) InterrogateCLIP

func (client *Client) InterrogateCLIP(fp string) (res *InterrogateRes, err error)

func (*Client) InterrogateDeepDanBooru

func (client *Client) InterrogateDeepDanBooru(fp string) (res *InterrogateRes, err error)

func (*Client) Interrogate_url

func (client *Client) Interrogate_url() string

func (*Client) Txt2Img

func (client *Client) Txt2Img(ctx context.Context, req *Txt2ImgReq, exts ...Extension) (
	res *Txt2ImgRes, err error)

func (*Client) Txt2ImgPromot

func (client *Client) Txt2ImgPromot(prompt string, batchSize uint32) (res *Txt2ImgRes, err error)

func (*Client) ValidateControlnet

func (client *Client) ValidateControlnet(item *Controlnet) (err error)

type Config

type Config struct {
	Url        string `mapstructure:"url"`
	Controlnet struct {
		Module string   `mapstructure:"module"`
		Models []string `mapstructure:"models"`
	} `mapstructure:"controlnet"`
}

func NewConfg

func NewConfg(fp, key string) (config *Config, err error)

type Controlnet

type Controlnet struct {
	InputImage string  `json:"input_image,omitempty" mapstructure:"input_image"` // default=""
	Mask       string  `json:"mask,omitempty" mapstructure:"mask"`               // default=""
	Module     string  `json:"module,omitempty" mapstructure:"module"`           // default="none"
	Model      string  `json:"model,omitempty" mapstructure:"model"`             // default="none"
	Guessmode  bool    `json:"guessmode,omitempty" mapstructure:"guessmode"`     // default=true
	Lowvram    bool    `json:"lowvram,omitempty" mapstructure:"lowvram"`         // default: false
	Weight     float64 `json:"weight,omitempty" mapstructure:"weight"`           // default=1.0
	// enum: 0=Just Resize, 1=Scale to Fit (Inner Fit), 2=Envelope (Outer Fit)
	// default=1, "Scale to Fit (Inner Fit)"
	ResizeMode    uint    `json:"resize_mode,omitempty" mapstructure:"resize_mode"`
	ProcessorRes  int     `json:"enabled,omitempty" mapstructure:"resize_mode"`           // default=64
	GuidanceStart float64 `json:"guidance_start,omitempty" mapstructure:"guidance_start"` // default=0.0
	GuidanceEnd   float64 `json:"guidance_end,omitempty" mapstructure:"guidance_end"`     // default=1.0

}

func (*Controlnet) Key

func (item *Controlnet) Key() string

func (*Controlnet) Value

func (item *Controlnet) Value() map[string]any

type Extension

type Extension interface {
	Key() string
	Value() map[string]any
}

type Extensions

type Extensions struct {
	Controlnet *Controlnet `json:"controlnet,omitempty"`
}

func (*Extensions) HasControlnetImg

func (exts *Extensions) HasControlnetImg() bool

func (*Extensions) List

func (exts *Extensions) List() (results []Extension)

type Img2ImgReq

type Img2ImgReq struct {
	Prompt         string   `json:"prompt,omitempty"`
	NegativePrompt string   `json:"negative_prompt,omitempty"`
	InitImages     []string `json:"init_images,omitempty"`
	// ResizeMode     uint     `json:"resize_mode,omitempty"` // default 0, Just resize
	SamplerName       string  `json:"sampler_name,omitempty"`       // default "Euler a", sampling method
	Steps             uint    `json:"steps,omitempty"`              // default 20, sampling steps
	RestoreFaces      bool    `json:"restore_faces,omitempty"`      // default: false, Restore faces
	Tiling            bool    `json:"tiling,omitempty"`             // default: false, Tiling
	Width             uint32  `json:"width,omitempty"`              // default 512
	Height            uint32  `json:"height,omitempty"`             // default 512
	CfgScale          float64 `json:"cfg_scale,omitempty"`          // default 7.0
	DenoisingStrength float64 `json:"denoising_strength,omitempty"` // default 0.75
	BatchSize         uint32  `json:"batch_size,omitempty"`         // default 1
	// NIter          uint32 `json:"n_iter,omitempty"`     // default 1
	AlwaysonScripts map[string]any `json:"alwayson_scripts,omitempty"` // extensions
}

func (*Img2ImgReq) Validate

func (req *Img2ImgReq) Validate() (err error)

type Img2ImgRes

type Img2ImgRes struct {
	Images []string `json:"images,omitempty"`
	// Parameters map[string]any   `json:"parameters,omitempty"`
	Info string `json:"info,omitempty"`
}

type InterrogateReq

type InterrogateReq struct {
	Image string `json:"image"`
	Model string `json:"model"`
}

func (*InterrogateReq) Validate

func (req *InterrogateReq) Validate() (err error)

type InterrogateRes

type InterrogateRes struct {
	Caption string `json:"caption"`
}

type SDError

type SDError struct {
	Detail []SDErrorDetail `json:"detail"`
}

type SDErrorDetail

type SDErrorDetail struct {
	Msg  string `json:"msg"`
	Type string `json:"type"`
}

type Txt2ImgReq

type Txt2ImgReq struct {
	Prompt         string `json:"prompt,omitempty"`
	NegativePrompt string `json:"negative_prompt,omitempty"`
	SamplerName    string `json:"sampler_name,omitempty"`  // default "Euler a", sampling method
	Steps          uint   `json:"steps,omitempty"`         // default 20, sampling steps
	RestoreFaces   bool   `json:"restore_faces,omitempty"` // default false, Restore faces
	Tiling         bool   `json:"tiling,omitempty"`        // default false, Tiling
	// EnableHr bool `json:"enable_hr,omitempty"` // default false, Hires. fix
	Width     uint32 `json:"width,omitempty"`      // default 512
	Height    uint32 `json:"height,omitempty"`     // default 512
	BatchSize uint32 `json:"batch_size,omitempty"` // default 1
	// NIter          uint32 `json:"n_iter,omitempty"`     // default 1
	CfgScale        float64        `json:"cfg_scale,omitempty"`        // default 7.0
	AlwaysonScripts map[string]any `json:"alwayson_scripts,omitempty"` // extensions
}

func (*Txt2ImgReq) Validate

func (req *Txt2ImgReq) Validate() (err error)

type Txt2ImgRes

type Txt2ImgRes struct {
	Images []string `json:"images,omitempty"`
	// Parameters map[string]any   `json:"parameters,omitempty"`
	Info string `json:"info,omitempty"`
}

Jump to

Keyboard shortcuts

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