Documentation ¶
Overview ¶
Package stablediffusion provides utilities to generate images with Stable Diffusion.
Index ¶
- type ContainerRunner
- type XL
- type XLImage
- func (i *XLImage) ASCII() (string, error)
- func (i *XLImage) ColdBaseDuration() time.Duration
- func (i *XLImage) ColdRefinerDuration() time.Duration
- func (i *XLImage) Image() (image.Image, error)
- func (i *XLImage) TotalDuration() time.Duration
- func (i *XLImage) WarmBaseDuration() time.Duration
- func (i *XLImage) WarmRefinerDuration() time.Duration
- type XLPrompt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContainerRunner ¶
type ContainerRunner interface { // Run runs a container with the given image and arguments to completion, // and returns its stdout/stderr streams as two byte strings. Run(ctx context.Context, image string, argv []string) ([]byte, []byte, error) }
ContainerRunner is an interface to run containers.
type XL ¶
type XL struct {
// contains filtered or unexported fields
}
XL generates images using Stable Diffusion XL.
func NewDockerXL ¶
NewDockerXL returns a new Stable Diffusion XL generator using Docker containers on the local machine.
func NewXL ¶
func NewXL(sdxlImage string, runner ContainerRunner) *XL
NewXL returns a new Stable Diffusion XL generator.
type XLImage ¶
type XLImage struct { Prompt *XLPrompt // contains filtered or unexported fields }
XLImage is an image generated by Stable Diffusion XL.
func (*XLImage) ColdBaseDuration ¶
ColdBaseDuration returns time taken to run the base image generation model the first time the image was generated (i.e. the model was cold).
func (*XLImage) ColdRefinerDuration ¶
ColdRefinerDuration returns time taken to run the refiner model the first time the image was generated (i.e. the model was cold). Returns -1 if the refiner was not run.
func (*XLImage) TotalDuration ¶
TotalDuration returns the total time taken to generate the image.
func (*XLImage) WarmBaseDuration ¶
WarmBaseDuration returns time taken to run the base image generation model the second time the image was generated (i.e. the model was warm).
func (*XLImage) WarmRefinerDuration ¶
WarmRefinerDuration returns time taken to run the refiner model the second time the image was generated (i.e. the model was warm). Returns -1 if the refiner was not run.
type XLPrompt ¶
type XLPrompt struct { // Query is the text query to generate the image with. Query string // AllowCPUOffload is whether to allow offloading parts of the model to CPU. AllowCPUOffload bool // UseRefiner is whether to use the refiner model after the base model. // This takes more VRAM and more time but produces a better image. UseRefiner bool // NoiseFraction is the fraction of noise to seed the image with. // Must be between 0.0 and 1.0 inclusively. NoiseFraction float64 // Steps is the number of diffusion steps to run for the base and refiner // models. More steps generally means sharper results but more time to // generate the image. A reasonable value is between 30 and 50. Steps int // Warm controls whether the image will be generated while the model is // warm. This will double the running time, as the image will still be // generated with a cold model first. Warm bool }
XLPrompt is the input to Stable Diffusion XL to generate an image.