generator

package
v0.0.0-...-30b734a Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AddHeaders = utils.AuthedRequest
View Source
var (
	QueueSize atomic.Int64
)

Functions

func SendResults

func SendResults(ctx context.Context, gen *ApiRequest) error

Types

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) AddToQueue

func (g *ApiRequest) AddToQueue(ctx context.Context) error

func (*ApiRequest) CleanRequest

func (g *ApiRequest) CleanRequest() error

clean the request, do this before putting on message queue, public to simplify mocking/testing a bit

func (*ApiRequest) GetLogTags

func (req *ApiRequest) GetLogTags() string

func (*ApiRequest) LogWithTags

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

func (*ApiRequest) MakeBatch

func (g *ApiRequest) MakeBatch() <-chan *ApiRequest

func (*ApiRequest) Validate

func (g *ApiRequest) Validate() error

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:"required_if=EnableHr true"`
	HrSamplerName     string  `json:"hr_sampler_name,omitempty" validate:"required_if=EnableHr true"`
	HrUpscaler        string  `json:"hr_upscaler,omitempty" validate:"required_if=EnableHr true"`
	HrSecondPassSteps int32   `json:"hr_second_pass_steps,omitempty" validate:"required_if=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:"required_if=EnableHr true"`
	HrNegativePrompt string `json:"hr_negative_prompt,omitempty" validate:"required_if=EnableHr true"`
}

arguments to send when EnableHr is true

type HRParams

type HRParams struct {
	SharedParams
	DenoisingStrength float32 `json:"denoising_strength,omitempty"`
	Upscaler          string  `json:"upscaler,omitempty" validate:"omitempty"`
	ResizeX           int32   `json:"resize_x,omitempty"`
	ResizeY           int32   `json:"resize_y,omitempty"`
	Scale             float32 `json:"scale,omitempty"`
}

type ImageMetadata

type ImageMetadata struct {
	AlwaysonScripts       string                 `json:"alwayson_scripts"`
	ExtraGenerationParams string                 `json:"extra_generation_params"`
	Info                  string                 `json:"info"`
	ModelHash             string                 `json:"model_hash"`
	OverrideSettings      map[string]interface{} `json:"override_settings"`
	ScriptArgs            []string               `json:"script_args"`
	ScriptName            string                 `json:"script_name"`
}

type ImageParams

type ImageParams struct {
	SharedParams
	Id              string  `json:"id"`
	UserId          string  `json:"user_id"`
	BatchId         string  `json:"batch_id"`
	CfgScale        float32 `json:"cfg_scale"`
	EnableHr        bool    `json:"enable_hr"`
	Filepath        string  `json:"filepath"`
	Hide            bool    `json:"hide"`
	RestoreFaces    bool    `json:"restore_faces"`
	Seed            string  `json:"seed"`
	SeedResizeFromH int32   `json:"seed_resize_from_h"`
	SeedResizeFromW int32   `json:"seed_resize_from_w"`
	Subseed         string  `json:"subseed"`
	Tiling          bool    `json:"tiling"`
	Type            string  `json:"type"`
	Height          int32   `json:"height"`
	Width           int32   `json:"width"`
}

type ImageToImageParams

type ImageToImageParams struct {
	DenoisingStrength     float32 `json:"denoising_strength,omitempty"`
	FirstphaseHeight      int32   `json:"firstphase_height,omitempty"`
	FirstphaseWidth       int32   `json:"firstphase_width,omitempty"`
	InpaintFullRes        bool    `json:"inpaint_full_res,omitempty"`
	InpaintFullResPadding int32   `json:"inpaint_full_res_padding,omitempty"`
	InpaintingFill        int32   `json:"inpainting_fill,omitempty"`
	InpaintingMaskInvert  int32   `json:"inpainting_mask_invert,omitempty"`
	Mask                  []int32 `json:"mask,omitempty"`
	MaskBlur              int32   `json:"mask_blur,omitempty"`
}

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 ModelReference

type ModelReference struct {
	ModelID          string  `json:"model_id"`
	RelationshipType string  `json:"relationship_type" validate:"oneof=Checkpoint Lora Embedding Controlnet HrLora HrCheckpoint"`
	Weight           float64 `json:"weight"`
}

type ModelVersionReference

type ModelVersionReference struct {
	ModelId   string `json:"modelUuid" validate:"required,uuid"`
	VersionId 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 SdApiRequest

type SdApiRequest struct {
	GroupId            string              `json:"group_id,omitempty" validate:"omitempty"`
	HrImageParams      *HRParams           `json:"hr_image_params,omitempty" validate:"omitempty"`
	Image              ImageParams         `json:"image" validate:"required"`
	ImageMetadata      ImageMetadata       `json:"image_metadata" validate:"required"`
	ImageToImageParams *ImageToImageParams `json:"image_to_image_params,omitempty" validate:"omitempty"`
	Models             []ModelReference    `json:"models"`
}

Sent to rust-sd-api

func (*SdApiRequest) GetLogTags

func (req *SdApiRequest) GetLogTags() string

func (*SdApiRequest) LogWithTags

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

func (*SdApiRequest) Validate

func (g *SdApiRequest) Validate() error

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 SharedParams

type SharedParams struct {
	NegativePrompt string `json:"negative_prompt,omitempty"`
	Prompt         string `json:"prompt,omitempty"`
	Sampler        string `json:"sampler,omitempty"`
	Steps          int32  `json:"steps,omitempty"`
}

Shared Params between HR and base Image

type WebuiResponse

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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