generator

package
v0.0.0-...-f3a1ebc Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	QueueSize atomic.Int64
)

Functions

This section is empty.

Types

type AcceptedResponse

type AcceptedResponse struct {
	Body AcceptedResponseBody
}

func PostGenerate

func PostGenerate(ctx context.Context, input *GenerateRequest) (*AcceptedResponse, error)

type AcceptedResponseBody

type AcceptedResponseBody struct {
	BatchId string `json:"batchId"`
	GenId   string `json:"genId"`
}

type AlwaysonScripts

type AlwaysonScripts struct {
	//add controlnet later
	GrpcClient GrpcArgs `json:"grpc_client" validate:"required"`
}

type ApiRequest

type ApiRequest struct {
	WebuiResponse
	SharedArgs
	IngestArgs
	NIter             int64                  `json:"n_iter,omitempty" validate:"omitempty"`
	Hide              bool                   `json:"hide" validate:"omitempty,boolean"`
	CheckpointModel   *ModelVersionReference `json:"checkpoint_model" validate:"required_without=SdModelCheckpoint"`
	LoraModels        []LoraVersionReference `json:"lora_models,omitempty" validate:"omitempty"`
	GroupId           string                 `json:"group_id" validate:"required"`
	HrCheckpointModel *ModelVersionReference `json:"hr_checkpoint_model,omitempty" validate:"omitempty,required_if=EnableHr true"`
	HrLoraModels      []LoraVersionReference `json:"hr_lora_models,omitempty" validate:"omitempty,dive,excluded_unless=EnableHr true"`
}

Recived from frontend & sent to sd-api

func (*ApiRequest) GetLogTags

func (req *ApiRequest) GetLogTags() string

func (*ApiRequest) LogWithTags

func (req *ApiRequest) LogWithTags(ctx context.Context, msg ...string)

func (*ApiRequest) StartGen

func (gen *ApiRequest) StartGen(ctx context.Context, url string) error

Sends the request to the generator and sends results to the api if it succeeds

type DownloadInfo

type DownloadInfo struct {
	Name        string `json:"name" validate:"required"`                 // The name of the file without the extension
	Filename    string `json:"filename" validate:"required"`             // The name of the file with the extension
	Extension   string `json:"ext" validate:"required"`                  // The extension type of the file
	DownloadUrl string `json:"downloadUrl" validate:"required,url"`      // The url to download the file
	Type        string `json:"type" validate:"oneof=ckpt lora lyco vae"` // The type of the file, should be one of the following: ckpt, lora, lyco
}

func (*DownloadInfo) GetLogTags

func (ref *DownloadInfo) GetLogTags() string

func (*DownloadInfo) LogWithTags

func (ref *DownloadInfo) LogWithTags(ctx context.Context, msg ...string)

type GenerateRequest

type GenerateRequest struct {
	Body struct {
		ApiRequest
	}
}

type GenerationModel

type GenerationModel struct {
	SharedArgs
	IngestArgs
	GroupId      string                `json:"group_id" validate:"omitempty"`
	Checkpoint   *ModelVersionDetails  `json:"checkpoint" validate:"required"`
	HrCheckpoint *ModelVersionDetails  `json:"hr_checkpoint" validate:"omitempty"`
	Loras        []ModelVersionDetails `json:"lora_models" validate:"omitempty"`
	HrLoras      []ModelVersionDetails `json:"hr_models" validate:"omitempty"`
}

func (*GenerationModel) GetLogTags

func (req *GenerationModel) GetLogTags() string

func (*GenerationModel) LogWithTags

func (req *GenerationModel) LogWithTags(ctx context.Context, msg ...string)

type Group

type Group struct {
	Id string `json:"id" validate:"required,uuid"`
}

type GrpcArgs

type GrpcArgs struct {
	Args []IngestArgs `json:"args" validate:"required"`
}

type HRArgs

type HRArgs struct {
	EnableHr bool `json:"enable_hr" validate:"omitempty"`
	//man composition would simplify this declaration a lot, but probably make the code more confusing
	HrScale           float32 `json:"hr_scale,omitempty" validate:"excluded_unless=EnableHr true"`
	HrSamplerName     string  `json:"hr_sampler_name,omitempty" validate:"excluded_unless=EnableHr true"`
	HrUpscaler        string  `json:"hr_upscaler,omitempty" validate:"excluded_unless=EnableHr true"`
	HrSecondPassSteps int32   `json:"hr_second_pass_steps,omitempty" validate:"excluded_unless=EnableHr true"`
	HrResizeX         int32   `json:"hr_resize_x,omitempty" validate:"excluded_unless=EnableHr true"`
	HrResizeY         int32   `json:"hr_resize_y,omitempty" validate:"excluded_unless=EnableHr true"`

	HrPrompt         string `json:"hr_prompt,omitempty" validate:"excluded_unless=EnableHr true"`
	HrNegativePrompt string `json:"hr_negative_prompt,omitempty" validate:"excluded_unless=EnableHr true"`
}

arguments to send when EnableHr is true

type IngestArgs

type IngestArgs struct {
	BatchId string `json:"batch_id" validate:"required,uuid"`
	UserId  string `json:"user_id,omitempty" validate:"required,uuid"`
	// Generation Id, unneeded in request context
	Id   string `json:"name,omitempty" validate:"required,uuid"`
	Type string `json:"type" validate:"oneof=txt2img img2img upscale"`
}

type LoraVersionReference

type LoraVersionReference struct {
	ModelVersionReference
	Multiplier float32 `json:"multiplier" validate:"required"`
}

Lora Ref as passed from ui

type ModelDownloadRequest

type ModelDownloadRequest struct {
	DownloadUrl string `json:"downloadUrl" validate:"required,url"`
	Filename    string `json:"filename" validate:"required"`
	Type        string `json:"type" validate:"oneof=ckpt lora lyco"`
}
type ControlnetGenerationSend struct {
	GenerationSend
	EmbeddingModels  []ModelVersionReference `json:"embedding_models,omitempty" validate:"omitempty"`
	ControlnetModels []ModelVersionReference `json:"controlnet_models,omitempty" validate:"omitempty"`
}

Wrapper class to send to extras/model/download

type ModelOptions

type ModelOptions struct {
	SdModelCheckpoint string `json:"sd_model_checkpoint"`
}

type ModelVersionDetails

type ModelVersionDetails struct {
	ModelVersionResponse
	Multiplier float32       `json:"multiplier" validate:"omitempty"` // Only used for Lora models
	Vae        *DownloadInfo `json:"vae" validate:"omitempty"`        // VAE file reference
	Model      *DownloadInfo `json:"model" validate:"required"`       // Model file reference
}

func (*ModelVersionDetails) GetLogTags

func (ref *ModelVersionDetails) GetLogTags() string

func (*ModelVersionDetails) LogWithTags

func (req *ModelVersionDetails) LogWithTags(ctx context.Context, msg ...string)

type ModelVersionFile

type ModelVersionFile struct {
	Name        string `json:"name" validate:"required"`
	FileType    string `json:"type" validate:"required"` // Training Data, Negative, Pruned Model, VAE, Model
	DownloadUrl string `json:"downloadUrl" validate:"required,url"`
}

type ModelVersionReference

type ModelVersionReference struct {
	ModelUuid   string `json:"modelUuid" validate:"required,uuid"`
	VersionUuid string `json:"versionUuid" validate:"required,uuid"`
}

Generic ModelRef as passed from ui

func (*ModelVersionReference) GetLogTags

func (ref *ModelVersionReference) GetLogTags() string

func (*ModelVersionReference) LogWithTags

func (req *ModelVersionReference) LogWithTags(ctx context.Context, msg ...string)

type ModelVersionResponse

type ModelVersionResponse struct {
	Uuid      string             `json:"uuid" validate:"required,uuid"`      // Version uuid
	ModelUUID string             `json:"modelUUID" validate:"required,uuid"` // Model uuid
	Name      string             `json:"name" validate:"required"`
	Files     []ModelVersionFile `json:"files" validate:"required"`
	Type      string             `json:"type" validate:"oneof=LORA LoCon Checkpoint TextualInversion"`
}

The response from /model/version/details/{uuid}

type SharedArgs

type SharedArgs struct {
	HRArgs
	Prompt         string `json:"prompt" validate:"required"`
	NegativePrompt string `json:"negative_prompt" validate:"omitempty"`

	SamplerIndex string `json:"sampler_index" validate:"required"`

	Width  int32 `json:"width" validate:"required,min=64,max=4096"`
	Height int32 `json:"height" validate:"required,min=64,max=4096"`

	DenoisingStrength float32 `json:"denoising_strength,omitempty" validate:"required_if=type txt2img,required_if=EnableHr true"`
	BatchSize         int64   `json:"batch_size,omitempty" validate:"omitempty"`

	Steps    int32   `json:"steps" validate:"required,min=1"`
	CfgScale float32 `json:"cfg_scale" validate:"required,min=1"`

	RestoreFaces     bool                   `json:"restore_faces" validate:"omitempty"`
	Tiling           bool                   `json:"tiling" validate:"omitempty"`
	OverrideSettings map[string]interface{} `json:"override_settings" validate:"omitempty"`

	Seed            string  `json:"seed,omitempty" validate:"omitempty"`
	Subseed         string  `json:"subseed,omitempty" validate:"omitempty"`
	SubseedStrength float32 `json:"subseed_strength,omitempty" validate:"omitempty"`

	SeedResizeFromH int32 `json:"seed_resize_from_h,omitempty" validate:"omitempty"`
	SeedResizeFromW int32 `json:"seed_resize_from_w,omitempty" validate:"omitempty"`

	SChurn int32 `json:"s_churn,omitempty" validate:"omitempty"`
	STmax  int32 `json:"s_tmax,omitempty" validate:"omitempty"`
	STmin  int32 `json:"s_tmin,omitempty" validate:"omitempty"`
	SNoise int32 `json:"s_noise,omitempty" validate:"omitempty"`
}

Args shared between webui and api

type WebuiRequest

type WebuiRequest struct {
	SharedArgs
	SdModelCheckpoint string          `json:"sd_model_checkpoint" validate:"required"` // String representation of ModelVersionReference to send to webui
	SendImage         bool            `json:"send_image" validate:"omitempty"`         // should always be false
	AlwaysonScripts   AlwaysonScripts `json:"alwayson_scripts" validate:"omitempty"`   // additonal values, unstructured json, probably need real models for this
}

sent to automatic1111 webui

func (*WebuiRequest) GetLogTags

func (msg *WebuiRequest) GetLogTags() string

TODO: add prompt/negative prompt length

func (*WebuiRequest) LogWithTags

func (req *WebuiRequest) LogWithTags(ctx context.Context, msg ...string)

func (*WebuiRequest) Validate

func (req *WebuiRequest) Validate() error

type WebuiResponse

type WebuiResponse struct {
	Info string `json:"info,omitempty" validate:"omitempty"`
}

Jump to

Keyboard shortcuts

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