generator

package
v0.0.0-...-ab2e974 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AddHeaders = utils.AuthedRequest

Functions

This section is empty.

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

func (g *ApiRequest) ToGenerateRequestV2() GenerateRequestV2

TOOD: replace ApiRequest with GenerateRequestV2 on endpoint eventually

func (*ApiRequest) Validate

func (g *ApiRequest) Validate() error

type GenerateRequestV2

type GenerateRequestV2 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"`
}

Post request to sd-api

func (*GenerateRequestV2) GetLogTags

func (req *GenerateRequestV2) GetLogTags() string

func (*GenerateRequestV2) LogWithTags

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

func (*GenerateRequestV2) MakeBatch

func (g *GenerateRequestV2) MakeBatch(size int64) <-chan *GenerateRequestV2

func (*GenerateRequestV2) SendToApi

func (genRequest *GenerateRequestV2) SendToApi(ctx context.Context) error

func (*GenerateRequestV2) Validate

func (g *GenerateRequestV2) 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:"omitempty,excluded_unless=EnableHr true"`
	HrNegativePrompt string `json:"hr_negative_prompt,omitempty" validate:"omitempty,excluded_unless=EnableHr true"`
}

arguments to send when EnableHr is true

type HRParams

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

type ImageBatch

type ImageBatch struct {
	CreatedAt string `json:"created_at"`
	Id        string `json:"id"`
	UserId    string `json:"user_id"`
}

type ImageDetailResponse

type ImageDetailResponse struct {
	Batch              ImageBatch          `json:"batch"`
	Groups             []ImageGroup        `json:"groups"`
	HrParams           HRParams            `json:"hr_params,omitempty"`
	Id                 string              `json:"id"`
	Image              ImageParams         `json:"image"`
	ImageToImageParams *ImageToImageParams `json:"image_to_image_params,omitempty" validate:"omitempty"`
	Metadata           ImageMetadata       `json:"metadata"`
	Models             ImageModels         `json:"models"`
	Url                string              `json:"url"`
}

ImageDetailResponse struct for ImageDetailResponse

func GetGenerationRequestFromApi

func GetGenerationRequestFromApi(ctx context.Context, genId string) (*ImageDetailResponse, error)

func (*ImageDetailResponse) UpdateStatus

func (gen *ImageDetailResponse) UpdateStatus(ctx context.Context, status string) error

UpdateStatus updates the status of a generation in the API status is one of Queued, Generating, Done, Canceled, Failed, Deleted

type ImageGroup

type ImageGroup struct {
	GroupId string `json:"group_id"`
	ImageId string `json:"image_id"`
}

ImageGroup struct for ImageGroup

type ImageMetadata

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

type ImageModel

type ImageModel struct {
	ModelId          string  `json:"model_id"` // actually a version id
	RelationshipType string  `json:"relationship_type"`
	Weight           float32 `json:"weight,string"`
}

ImageModel struct for ImageModel

func (ImageModel) Multiplier

func (m ImageModel) Multiplier() float32

func (ImageModel) VersionId

func (m ImageModel) VersionId() string

type ImageModels

type ImageModels struct {
	Checkpoint   ImageModel   `json:"checkpoint"`
	Controlnet   *ImageModel  `json:"controlnet,omitempty"`
	Embeddings   []ImageModel `json:"embeddings,omitempty"`
	HrCheckpoint ImageModel   `json:"hr_checkpoint,omitempty"`
	HrLoras      []ImageModel `json:"hr_loras,omitempty"`
	Loras        []ImageModel `json:"loras"`
}

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,string"`
	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"`
	ClipSkip                 int32   `json:"clip_skip,omitempty" validate:"omitempty"`
	CfgEnd                   float32 `json:"cfg_end,omitempty,string" validate:"omitempty,gte=0,lte=1"`
	DiffusersGuidanceRescale float32 `json:"diffusers_guidance_rescale,omitempty,string" validate:"omitempty,gte=0,lte=1"`
	FullQuality              bool    `json:"full_quality,omitempty" validate:"omitempty"`
	PagScale                 float32 `json:"pag_scale,omitempty,string" validate:"omitempty,gte=0,lte=1"`
	PagAdaptive              float32 `json:"pag_adaptive,omitempty,string" validate:"omitempty,gte=0,lte=1"`
}

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
	Mult float32 `json:"multiplier" validate:"required"`
}

Lora Ref as passed from ui

func (LoraVersionReference) Multiplier

func (m LoraVersionReference) Multiplier() float32

func (LoraVersionReference) VersionId

func (m LoraVersionReference) VersionId() string

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,string"`
}

type ModelVersionReference

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

func (ModelVersionReference) VersionId

func (m ModelVersionReference) VersionId() string

type PutHrParams

type PutHrParams struct {
	Prompt         string `json:"prompt,omitempty" validate:"omitempty"`
	NegativePrompt string `json:"negative_prompt,omitempty" validate:"omitempty"`
}

type PutImage

type PutImage struct {
	Image    *PutImageDetails  `json:"image"`
	HrParams *PutHrParams      `json:"hr_params,omitempty"`
	Metadata *PutImageMetadata `json:"metadata,omitempty"`
}

func (*PutImage) Validate

func (g *PutImage) Validate() error

type PutImageDetails

type PutImageDetails struct {
	Status         string `json:"status,omitempty" validate:"omitempty,oneof=Queued Generating Done Canceled Failed Deleted"`
	Prompt         string `json:"prompt,omitempty" validate:"omitempty"`
	NegativePrompt string `json:"negative_prompt,omitempty" validate:"omitempty"`
}

type PutImageMetadata

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

type SDNextArgs

type SDNextArgs struct {
	ClipSkip                 int32   `json:"clip_skip,omitempty" validate:"omitempty"`
	CfgEnd                   float32 `json:"cfg_end,omitempty" validate:"omitempty,gte=0,lte=1"`
	DiffusersGuidanceRescale float32 `json:"diffusers_guidance_rescale,omitempty" validate:"omitempty,gte=0,lte=1"`
	PagScale                 float32 `json:"pag_scale,omitempty" validate:"omitempty,gte=0,lte=1"`
	PagAdaptive              float32 `json:"pag_adaptive,omitempty" validate:"omitempty,gte=0,lte=1"`
	FullQuality              bool    `json:"full_quality,omitempty" validate:"omitempty"`
	// Not sure what this is but it should be exposed elsewhere
	Hidiffusion bool `json:"hidiffusion,omitempty" validate:"omitempty"`
}

New Shared parameters for the webui request after switching to sdnext

type SharedArgs

type SharedArgs struct {
	HRArgs
	SDNextArgs
	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"`
	Prompt         string `json:"prompt"`
	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