api

package module
v0.0.0-...-bca5be1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2023 License: MIT Imports: 10 Imported by: 0

README

AUTOMATIC1111's Webui API

AUTOMATIC1111's Webui API for GO. So you don't have to do it yourself.
Aim to be as easy to use as possible without performance in mind.

Currently Support (And also roadmap)

  • Auth Related ( DIDNT TEST | Please open an issue if you have encounter any problem )
  • Txt2Img
  • Img2Img
  • Extras (Single)
  • Extras (Batch)
  • PNG Info
  • Progress
  • Interrogate
  • Interrupt
  • Skip
  • Options
  • Get Available Model(s)

Getting Started

Required Stable Diffusion Web UI running with --api argument

go get github.com/colornote/webui-api

Then Import

import (
    ...
    "github.com/colornote/webui-api"
)

OR

Simply add package to import like this

import (
    ...
    "github.com/colornote/webui-api"
)

Then run go mod tidy


Initialize it like this

API := api.New()

Without passing anything it'll return http://127.0.0.1:7860 and all V1 API path as default.
If you wanna change it, just pass in a new config like this

API := api.New(api.Config{
    BaseURL: "colab.google.link",
    Path: &api.APIPath{
        Txt2Img: "/new/api/path/txt2img",
    },
})

Be aware, if you change Path field, you'll have to manually add all other path.

Say for above example, it'll be only Txt2Img path in there. When you call Img2Img, you'll get an unexpected response/error or worse like panic


Now that finished, we can start using it now. Let's say we'll do TXT2IMG

resp, err := API.Text2Image(&api.Txt2Image{
    Prompt: "masterpiece, best quality, solo, cute, blue hair, purple eyes",
    NegativePrompt: "lowres, bad anatomy, low quality, normal quality, worst quality",
})

Keep in mind that this will block your app until API done generating image(s)


When it's done, check for the error and then we can do

imageList, err := resp.DecodeAllImages()

Check for the error and then we can save it to disk

for index, image := range imageList {
    file, err := os.OpenFile(
        fmt.Sprintf("txt2img-result %v.png", index), 
        os.O_WRONLY|os.O_CREATE|os.O_TRUNC,
        0777,
    )
    if err != nil {
        panic(err)
    }
    
    file.Write(image)
    file.Close()
}

Hol'up, one tip tho. If you really care about performance, you can decode it yourself like this

Before called resp.DecodeAllImages()

for index := range resp.Images {
    decoded, err := resp.DecodeImage(index)
    if err != nil {
        panic(err)
    }
    
    file, err := os.OpenFile(
        fmt.Sprintf("txt2img-result %v.png", index), 
        os.O_WRONLY|os.O_CREATE|os.O_TRUNC,
        0777,
    )
    if err != nil {
        panic(err)
    }
    
    file.Write(image)
    file.Close()
}

Example

Move HERE

Default Value

var DefaultConfig = Config{
    BaseURL: "http://127.0.0.1:7860",
    Path: &APIPath{
        // Don't change any of these unless you know what you're doing. 
        // I purposely exported this as I don't know If I'll still maintain this pkg in the future
        Txt2Img:     "/sdapi/v1/txt2img",
        Img2Img:     "/sdapi/v1/img2img",
        ExtraSingle: "/sdapi/v1/extra-single-image",
        ExtraBatch:  "/sdapi/v1/extra-batch-images",
        PNGInfo:     "/sdapi/v1/png-info",
        Progress:    "/sdapi/v1/progress",
        Interrogate: "/sdapi/v1/interrogate",
        Interrupt:   "/sdapi/v1/interrupt",
        Skip:        "/sdapi/v1/skip",
        Options:     "/sdapi/v1/options",
        SDModels:    "/sdapi/v1/sd-models",
    },
}

Credits

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	API = &api{
		Config: setDefault(),
	}
)
View Source
var DefaultConfig = Config{
	BaseURL: "http://127.0.0.1:7860",
	Path: &APIPath{
		Txt2Img:     "/sdapi/v1/txt2img",
		Img2Img:     "/sdapi/v1/img2img",
		ExtraSingle: "/sdapi/v1/extra-single-image",
		ExtraBatch:  "/sdapi/v1/extra-batch-images",
		PNGInfo:     "/sdapi/v1/png-info",
		Progress:    "/sdapi/v1/progress",
		Interrogate: "/sdapi/v1/interrogate",
		Interrupt:   "/sdapi/v1/interrupt",
		Skip:        "/sdapi/v1/skip",
		Options:     "/sdapi/v1/options",
		SDModels:    "/sdapi/v1/sd-models",
	},
}
View Source
var DefaultValue = &Default{
	Sampler:  sampler.EULER_A,
	Steps:    20,
	CFGScale: 7,
	Width:    512,
	Height:   512,
}

Default Values.

Sampler  = sampler.EULER_A,
Steps    = 28,
CFGScale = 7,
Width    = 512,
Height   = 512,

Functions

func BuildPrompt

func BuildPrompt(args ...string) string

Convenience function to build prompt.

BuildPrompt("masterpiece", "best quality", "solo") -> "masterpiece, best quality, solo"

func New

func New(newConfig ...Config) *api

Types

type APIPath

type APIPath struct {
	// Path to txt2img API
	//
	//  - Default: /sdapi/v1/txt2img
	Txt2Img string

	// Path to img2img API
	//
	//  - Default: /sdapi/v1/img2img
	Img2Img string

	// Path to extra single image API
	//
	//  - Default: /sdapi/v1/extra-single-image
	ExtraSingle string

	// Path to extra batch images API
	//
	//  - Default: /sdapi/v1/extra-batch-images
	ExtraBatch string

	// Path to png info API
	//
	//  - Default: /sdapi/v1/png-info
	PNGInfo string

	// Path to progress API
	//
	//  - Default: /sdapi/v1/progress
	Progress string

	// Path to interrogate API
	//
	//  - Default: /sdapi/v1/interrogate
	Interrogate string

	// Path to interrupt API
	//
	//  - Default: /sdapi/v1/interrupt
	Interrupt string

	// Path to skip API
	//
	//  - Default: /sdapi/v1/skip
	Skip string

	// Path to options API
	//
	//  - Default: /sdapi/v1/options
	Options string

	// Path to sd-models API
	//
	//  - Default: /sdapi/v1/sd-models
	SDModels string
}

type AlwaysonScripts

type AlwaysonScripts struct {
	Controlnet Controlnet `json:"controlnet"`
}

type Arg

type Arg struct {
	InputImage    string  `json:"input_image"`
	Model         string  `json:"model"`
	Module        string  `json:"module,omitempty"`
	Weight        float64 `json:"weight,omitempty"`
	Guessmode     bool    `json:"guessmode,omitempty"`
	ResizeMode    string  `json:"resize_mode,omitempty"`
	GuidanceStart float64 `json:"guidance_start,omitempty"`
	GuidanceEnd   float64 `json:"guidance_end,omitempty"`
}

type Config

type Config struct {
	// URL to API endpoint (e.g. http://127.0.0.1:7860, https://b645a912.gradio.app)
	//
	// - Default: http://127.0.0.1:7860
	BaseURL string

	// API path is stored here
	Path *APIPath

	// Default Value are store here.
	Default *Default
}

type Controlnet

type Controlnet struct {
	Args []Arg `json:"args,omitempty"`
}

type Default

type Default struct {
	// Sampling Method or Sampler (e.g. Euler a, DPM++ 2M Karras). You can type it in yourself or use built-in Helper Package: sampler
	//
	//   Default: "Euler a"
	Sampler string

	// Sampling Steps (e.g. 20, 120)
	//
	//   Default: 20
	Steps int

	// Classifier-Free Guidance Scale (e.g. 7, 12.0)
	//
	//   Default: 7.0
	CFGScale float64

	// Width of the image (e.g. 512, 1024)
	//
	//   Default: 512
	Width int

	// Height of the image (e.g. 512, 1024)
	//
	//   Default: 512
	Height int
}

type ExtraBatchImages

type ExtraBatchImages struct {
	// Resize Mode: Scale By || Scale To. See: webup-api/extra package for helper.
	//
	//  Default: 0 (Scale By)
	ResizeMode int `json:"resize_mode,omitempty"`

	// Don't even know what this is.
	//
	//  Default: true
	ShowExtrasResults bool `json:"show_extras_results,omitempty"`

	// GFPGAN Face restoration. Value must be between 0.0 - 1.0
	//
	//  Default: 0.0
	GfpganVisibility float64 `json:"gfpgan_visibility,omitempty"`

	// CodeFormer Face restoration. Value must be between 0.0 - 1.0
	//
	//  Default: 0.0
	CodeformerVisibility float64 `json:"codeformer_visibility,omitempty"`

	// CodeFormer Face restoration weight. 0 = Maximum Effect, 1 = Minimum Effect.
	//
	//  Default: 0.0
	CodeformerWeight float64 `json:"codeformer_weight,omitempty"`

	// Multiplier to width and height of the original image.
	//
	//  NOTE: Will only work if ResizeMode is 0
	//  Default: 2
	UpscalingResize int `json:"upscaling_resize,omitempty"`

	// Width of the result image.
	//
	//  NOTE: Will only work if ResizeMode is 1
	//  Default: 512
	UpscalingResizeW int `json:"upscaling_resize_w,omitempty"`

	// Height of the result image.
	//
	//  NOTE: Will only work if ResizeMode is 1
	//  Default: 512
	UpscalingResizeH int `json:"upscaling_resize_h,omitempty"`

	// Crop Image if the aspect ratio of original image and result image doesn't match.
	//
	//  NOTE: Will only work if ResizeMode is 1
	//  Default: true
	UpscalingCrop bool `json:"upscaling_crop,omitempty"`

	// First Upscaler Model. See: webui-api/extra package for helper.
	//
	//  Default: "None"
	Upscaler1 string `json:"upscaler_1,omitempty"`

	// Second Upscaler Model. See: webui-api/extra package for helper.
	//
	//  Default: "None"
	Upscaler2 string `json:"upscaler_2,omitempty"`

	// Second Upscaler Model Visibility. See: webui-api/extra package for helper.
	//
	//  Default: 0.0
	ExtrasUpscaler2Visibility float64 `json:"extras_upscaler_2_visibility,omitempty"`

	// Upscale first then do face restoration.
	//
	//  Default: false
	UpscaleFirst bool `json:"upscale_first,omitempty"`

	// Base64-encoded image to be upscale.
	//
	//  Default: Empty
	ImagesList []ImageData `json:"imageList,omitempty"`

	// If true, Will Decode Images after received response from API
	DecodeAfterResult bool `json:"-"`
}

type ExtraSingleImage

type ExtraSingleImage struct {
	// Resize Mode: Scale By || Scale To. See: webup-api/extra package for helper.
	//
	//  Default: 0 (Scale By)
	ResizeMode int `json:"resize_mode,omitempty"`

	// Don't even know what this is.
	//
	//  Default: true
	ShowExtrasResults bool `json:"show_extras_results,omitempty"`

	// GFPGAN Face restoration. Value must be between 0.0 - 1.0
	//
	//  Default: 0.0
	GfpganVisibility float64 `json:"gfpgan_visibility,omitempty"`

	// CodeFormer Face restoration. Value must be between 0.0 - 1.0
	//
	//  Default: 0.0
	CodeformerVisibility float64 `json:"codeformer_visibility,omitempty"`

	// CodeFormer Face restoration weight. 0 = Maximum Effect, 1 = Minimum Effect.
	//
	//  Default: 0.0
	CodeformerWeight float64 `json:"codeformer_weight,omitempty"`

	// Multiplier to width and height of the original image.
	//
	//  NOTE: Will only work if ResizeMode is 0
	//  Default: 2
	UpscalingResize int `json:"upscaling_resize,omitempty"`

	// Width of the result image.
	//
	//  NOTE: Will only work if ResizeMode is 1
	//  Default: 512
	UpscalingResizeW int `json:"upscaling_resize_w,omitempty"`

	// Height of the result image.
	//
	//  NOTE: Will only work if ResizeMode is 1
	//  Default: 512
	UpscalingResizeH int `json:"upscaling_resize_h,omitempty"`

	// Crop Image if the aspect ratio of original image and result image doesn't match.
	//
	//  NOTE: Will only work if ResizeMode is 1
	//  Default: true
	UpscalingCrop bool `json:"upscaling_crop,omitempty"`

	// First Upscaler Model. See: webui-api/extra package for helper.
	//
	//  Default: "None"
	Upscaler1 string `json:"upscaler_1,omitempty"`

	// Second Upscaler Model. See: webui-api/extra package for helper.
	//
	//  Default: "None"
	Upscaler2 string `json:"upscaler_2,omitempty"`

	// Second Upscaler Model Visibility. See: webui-api/extra package for helper.
	//
	//  Default: 0.0
	ExtrasUpscaler2Visibility float64 `json:"extras_upscaler_2_visibility,omitempty"`

	// Upscale first then do face restoration.
	//
	//  Default: false
	UpscaleFirst bool `json:"upscale_first,omitempty"`

	// Base64-encoded image to be upscale.
	//
	//  Default: ""
	Image string `json:"image,omitempty"`

	// If true, Will Decode Images after received response from API
	DecodeAfterResult bool `json:"-"`
}

type ImageData

type ImageData struct {
	// Base64-encoded image to be upscale.
	//
	//  Default: ""
	Data string `json:"data"`

	// I don't know what this is. I tried to read the source code for what it does but I don't think I get it.
	//
	// **NOT CONFIRM** Perhaps it is the temp file name
	//  Default: ""
	Name string `json:"name"`
}

type Img2Img

type Img2Img struct {
	InitImages             []string       `json:"init_images,omitempty"`        // List of base64-encoded images to send as base/original
	ResizeMode             int            `json:"resize_mode,omitempty"`        // I don't know If I got it right or not. See: webui-api/img2img RESIZE_MODE helper package
	DenoisingStrength      float64        `json:"denoising_strength,omitempty"` // Determines how little respect the algorithm should have for image's content. At 0, nothing will change, and at 1 you'll get an unrelated image.
	ImageCFGScale          float64        `json:"image_cfg_scale"`
	Mask                   string         `json:"mask,omitempty"`                     // base64-encoded mask image. What to put inside the masked area before processing it with Stable Diffusion.
	MaskBlur               int            `json:"mask_blur,omitempty"`                // How much to blur the mask before processing, in pixels.
	InpaintingFill         int            `json:"inpainting_fill,omitempty"`          // I don't know If I got it right or not. See: webui-api/img2img INPAINT_MASK_CONENT helper package
	InpaintFullRes         bool           `json:"inpaint_full_res,omitempty"`         // Upscale masked region to target resolution, do inpainting, downscale back and paste into original image
	InpaintFullResPadding  int            `json:"inpaint_full_res_padding,omitempty"` // Amount of pixels to take as sample around the inpaint areas
	InpaintingMaskInvert   int            `json:"inpainting_mask_invert,omitempty"`   // I don't know If I got it right or not. See: webui-api/img2img INPAINT_MODE helper package
	InitialNoiseMultiplier int            `json:"initial_noise_multiplier,omitempty"` // I don't even see this on the UI itself. Please, if you know, tell me about it.
	Prompt                 string         `json:"prompt,omitempty"`
	NegativePrompt         string         `json:"negative_prompt,omitempty"`
	Styles                 []string       `json:"styles,omitempty"`
	Seed                   int            `json:"seed,omitempty"` // A value that determines the output of random number generator - if you create an image with same parameters and seed as another image, you'll get the same result
	Subseed                int            `json:"subseed,omitempty"`
	SubseedStrength        int            `json:"subseed_strength,omitempty"`
	SeedResizeFromH        int            `json:"seed_resize_from_h,omitempty"`
	SeedResizeFromW        int            `json:"seed_resize_from_w,omitempty"`
	SamplerName            string         `json:"sampler_name,omitempty"`  // Either SamplerName or SamplerIndex will be used.
	SamplerIndex           string         `json:"sampler_index,omitempty"` // Either SamplerName or SamplerIndex will be used.
	BatchSize              int            `json:"batch_size,omitempty"`    // How many do you want to simultaneously generate.
	BatchCount             int            `json:"n_iter,omitempty"`        // How many times do you want to generate.
	Steps                  int            `json:"steps,omitempty"`         // How many times to improve the generated image iteratively; higher values take longer; very low values can produce bad results
	CFGScale               float64        `json:"cfg_scale,omitempty"`     // Classifier Free Guidance Scale - how strongly the image should conform to prompt - lower values produce more creative results
	Width                  int            `json:"width,omitempty"`
	Height                 int            `json:"height,omitempty"`
	RestoreFaces           bool           `json:"restore_faces,omitempty"`
	Tiling                 bool           `json:"tiling,omitempty"`
	DoNotSaveSamples       bool           `json:"do_not_save_samples,omitempty"`
	DoNotSaveGrid          bool           `json:"do_not_save_grid,omitempty"`
	Eta                    float64        `json:"eta,omitempty"`
	SChurn                 float64        `json:"s_churn,omitempty"`
	STmax                  float64        `json:"s_tmax,omitempty"`
	STmin                  float64        `json:"s_tmin,omitempty"`
	SNoise                 float64        `json:"s_noise,omitempty"`
	OverrideSettings       map[string]any `json:"override_settings,omitempty"`

	// Since API default value of this field is `true`, it can't be `omitempty`.
	//
	//  That means the default value of this lib is false
	OverrideSettingsRestoreAfterwards bool `json:"override_settings_restore_afterwards"`

	ScriptName string   `json:"script_name,omitempty"`
	ScriptArgs []string `json:"script_args,omitempty"`

	IncludeInitImages bool `json:"include_init_images,omitempty"` // I don't even know what this is. But it has just a little impact on the result images

	// Since API default value of this field is `true`, it can't be `omitempty`.
	//
	//  That means the default value of this lib is false
	SendImages bool `json:"send_images"`

	SaveImages bool `json:"save_iamges,omitempty"`
}

type Interrogate

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

type Opt

type Opt map[string]any

Shorthand for map[string]any

type Options

type Options struct {
	SamplesSave                        bool     `json:"samples_save,omitempty"`
	SamplesFormat                      string   `json:"samples_format,omitempty"`
	SamplesFilenamePattern             string   `json:"samples_filename_pattern,omitempty"`
	SaveImagesAddNumber                bool     `json:"save_images_add_number,omitempty"`
	GridSave                           bool     `json:"grid_save,omitempty"`
	GridFormat                         string   `json:"grid_format,omitempty"`
	GridExtendedFilename               bool     `json:"grid_extended_filename,omitempty"`
	GridOnlyIfMultiple                 bool     `json:"grid_only_if_multiple,omitempty"`
	GridPreventEmptySpots              bool     `json:"grid_prevent_empty_spots,omitempty"`
	NRows                              int      `json:"n_rows,omitempty"`
	EnablePnginfo                      bool     `json:"enable_pnginfo,omitempty"`
	SaveTxt                            bool     `json:"save_txt,omitempty"`
	SaveImagesBeforeFaceRestoration    bool     `json:"save_images_before_face_restoration,omitempty"`
	SaveImagesBeforeHighresFix         bool     `json:"save_images_before_highres_fix,omitempty"`
	SaveImagesBeforeColorCorrection    bool     `json:"save_images_before_color_correction,omitempty"`
	JpegQuality                        int      `json:"jpeg_quality,omitempty"`
	WebpLossless                       bool     `json:"webp_lossless,omitempty"`
	ExportFor4Chan                     bool     `json:"export_for_4chan,omitempty"`
	ImgDownscaleThreshold              int      `json:"img_downscale_threshold,omitempty"`
	TargetSideLength                   int      `json:"target_side_length,omitempty"`
	ImgMaxSizeMp                       int      `json:"img_max_size_mp,omitempty"`
	UseOriginalNameBatch               bool     `json:"use_original_name_batch,omitempty"`
	UseUpscalerNameAsSuffix            bool     `json:"use_upscaler_name_as_suffix,omitempty"`
	SaveSelectedOnly                   bool     `json:"save_selected_only,omitempty"`
	DoNotAddWatermark                  bool     `json:"do_not_add_watermark,omitempty"`
	TempDir                            string   `json:"temp_dir,omitempty"`
	CleanTempDirAtStart                bool     `json:"clean_temp_dir_at_start,omitempty"`
	OutdirSamples                      string   `json:"outdir_samples,omitempty"`
	OutdirTxt2ImgSamples               string   `json:"outdir_txt2img_samples,omitempty"`
	OutdirImg2ImgSamples               string   `json:"outdir_img2img_samples,omitempty"`
	OutdirExtrasSamples                string   `json:"outdir_extras_samples,omitempty"`
	OutdirGrids                        string   `json:"outdir_grids,omitempty"`
	OutdirTxt2ImgGrids                 string   `json:"outdir_txt2img_grids,omitempty"`
	OutdirImg2ImgGrids                 string   `json:"outdir_img2img_grids,omitempty"`
	OutdirSave                         string   `json:"outdir_save,omitempty"`
	SaveToDirs                         bool     `json:"save_to_dirs,omitempty"`
	GridSaveToDirs                     bool     `json:"grid_save_to_dirs,omitempty"`
	UseSaveToDirsForUI                 bool     `json:"use_save_to_dirs_for_ui,omitempty"`
	DirectoriesFilenamePattern         string   `json:"directories_filename_pattern,omitempty"`
	DirectoriesMaxPromptWords          int      `json:"directories_max_prompt_words,omitempty"`
	ESRGANTile                         int      `json:"ESRGAN_tile,omitempty"`
	ESRGANTileOverlap                  int      `json:"ESRGAN_tile_overlap,omitempty"`
	RealesrganEnabledModels            []string `json:"realesrgan_enabled_models,omitempty"`
	UpscalerForImg2Img                 string   `json:"upscaler_for_img2img,omitempty"`
	FaceRestorationModel               string   `json:"face_restoration_model,omitempty"`
	CodeFormerWeight                   float64  `json:"code_former_weight,omitempty"`
	FaceRestorationUnload              bool     `json:"face_restoration_unload,omitempty"`
	ShowWarnings                       bool     `json:"show_warnings,omitempty"`
	MemmonPollRate                     int      `json:"memmon_poll_rate,omitempty"`
	SamplesLogStdout                   bool     `json:"samples_log_stdout,omitempty"`
	MultipleTqdm                       bool     `json:"multiple_tqdm,omitempty"`
	PrintHypernetExtra                 bool     `json:"print_hypernet_extra,omitempty"`
	UnloadModelsWhenTraining           bool     `json:"unload_models_when_training,omitempty"`
	PinMemory                          bool     `json:"pin_memory,omitempty"`
	SaveOptimizerState                 bool     `json:"save_optimizer_state,omitempty"`
	SaveTrainingSettingsToTxt          bool     `json:"save_training_settings_to_txt,omitempty"`
	DatasetFilenameWordRegex           string   `json:"dataset_filename_word_regex,omitempty"`
	DatasetFilenameJoinString          string   `json:"dataset_filename_join_string,omitempty"`
	TrainingImageRepeatsPerEpoch       int      `json:"training_image_repeats_per_epoch,omitempty"`
	TrainingWriteCsvEvery              int      `json:"training_write_csv_every,omitempty"`
	TrainingXattentionOptimizations    bool     `json:"training_xattention_optimizations,omitempty"`
	TrainingEnableTensorboard          bool     `json:"training_enable_tensorboard,omitempty"`
	TrainingTensorboardSaveImages      bool     `json:"training_tensorboard_save_images,omitempty"`
	TrainingTensorboardFlushEvery      int      `json:"training_tensorboard_flush_every,omitempty"`
	SdModelCheckpoint                  string   `json:"sd_model_checkpoint,omitempty"`
	SdCheckpointCache                  int      `json:"sd_checkpoint_cache,omitempty"`
	SdVaeCheckpointCache               int      `json:"sd_vae_checkpoint_cache,omitempty"`
	SdVae                              string   `json:"sd_vae,omitempty"`
	SdVaeAsDefault                     bool     `json:"sd_vae_as_default,omitempty"`
	InpaintingMaskWeight               int      `json:"inpainting_mask_weight,omitempty"`
	InitialNoiseMultiplier             int      `json:"initial_noise_multiplier,omitempty"`
	Img2ImgColorCorrection             bool     `json:"img2img_color_correction,omitempty"`
	Img2ImgFixSteps                    bool     `json:"img2img_fix_steps,omitempty"`
	Img2ImgBackgroundColor             string   `json:"img2img_background_color,omitempty"`
	EnableQuantization                 bool     `json:"enable_quantization,omitempty"`
	EnableEmphasis                     bool     `json:"enable_emphasis,omitempty"`
	EnableBatchSeeds                   bool     `json:"enable_batch_seeds,omitempty"`
	CommaPaddingBacktrack              int      `json:"comma_padding_backtrack,omitempty"`
	CLIPStopAtLastLayers               int      `json:"CLIP_stop_at_last_layers,omitempty"`
	UpcastAttn                         bool     `json:"upcast_attn,omitempty"`
	UseOldEmphasisImplementation       bool     `json:"use_old_emphasis_implementation,omitempty"`
	UseOldKarrasSchedulerSigmas        bool     `json:"use_old_karras_scheduler_sigmas,omitempty"`
	NoDpmppSdeBatchDeterminism         bool     `json:"no_dpmpp_sde_batch_determinism,omitempty"`
	UseOldHiresFixWidthHeight          bool     `json:"use_old_hires_fix_width_height,omitempty"`
	InterrogateKeepModelsInMemory      bool     `json:"interrogate_keep_models_in_memory,omitempty"`
	InterrogateReturnRanks             bool     `json:"interrogate_return_ranks,omitempty"`
	InterrogateClipNumBeams            int      `json:"interrogate_clip_num_beams,omitempty"`
	InterrogateClipMinLength           int      `json:"interrogate_clip_min_length,omitempty"`
	InterrogateClipMaxLength           int      `json:"interrogate_clip_max_length,omitempty"`
	InterrogateClipDictLimit           int      `json:"interrogate_clip_dict_limit,omitempty"`
	InterrogateClipSkipCategories      []any    `json:"interrogate_clip_skip_categories,omitempty"`
	InterrogateDeepbooruScoreThreshold float64  `json:"interrogate_deepbooru_score_threshold,omitempty"`
	DeepbooruSortAlpha                 bool     `json:"deepbooru_sort_alpha,omitempty"`
	DeepbooruUseSpaces                 bool     `json:"deepbooru_use_spaces,omitempty"`
	DeepbooruEscape                    bool     `json:"deepbooru_escape,omitempty"`
	DeepbooruFilterTags                string   `json:"deepbooru_filter_tags,omitempty"`
	ExtraNetworksDefaultView           string   `json:"extra_networks_default_view,omitempty"`
	ExtraNetworksDefaultMultiplier     int      `json:"extra_networks_default_multiplier,omitempty"`
	ExtraNetworksAddTextSeparator      string   `json:"extra_networks_add_text_separator,omitempty"`
	SdHypernetwork                     string   `json:"sd_hypernetwork,omitempty"`
	ReturnGrid                         bool     `json:"return_grid,omitempty"`
	DoNotShowImages                    bool     `json:"do_not_show_images,omitempty"`
	AddModelHashToInfo                 bool     `json:"add_model_hash_to_info,omitempty"`
	AddModelNameToInfo                 bool     `json:"add_model_name_to_info,omitempty"`
	DisableWeightsAutoSwap             bool     `json:"disable_weights_auto_swap,omitempty"`
	SendSeed                           bool     `json:"send_seed,omitempty"`
	SendSize                           bool     `json:"send_size,omitempty"`
	Font                               string   `json:"font,omitempty"`
	JsModalLightbox                    bool     `json:"js_modal_lightbox,omitempty"`
	JsModalLightboxInitiallyZoomed     bool     `json:"js_modal_lightbox_initially_zoomed,omitempty"`
	ShowProgressInTitle                bool     `json:"show_progress_in_title,omitempty"`
	SamplersInDropdown                 bool     `json:"samplers_in_dropdown,omitempty"`
	DimensionsAndBatchTogether         bool     `json:"dimensions_and_batch_together,omitempty"`
	KeyeditPrecisionAttention          float64  `json:"keyedit_precision_attention,omitempty"`
	KeyeditPrecisionExtra              float64  `json:"keyedit_precision_extra,omitempty"`
	Quicksettings                      string   `json:"quicksettings,omitempty"`
	HiddenTabs                         []any    `json:"hidden_tabs,omitempty"`
	UIReorder                          string   `json:"ui_reorder,omitempty"`
	UIExtraNetworksTabReorder          string   `json:"ui_extra_networks_tab_reorder,omitempty"`
	Localization                       string   `json:"localization,omitempty"`
	ShowProgressbar                    bool     `json:"show_progressbar,omitempty"`
	LivePreviewsEnable                 bool     `json:"live_previews_enable,omitempty"`
	ShowProgressGrid                   bool     `json:"show_progress_grid,omitempty"`
	ShowProgressEveryNSteps            int      `json:"show_progress_every_n_steps,omitempty"`
	ShowProgressType                   string   `json:"show_progress_type,omitempty"`
	LivePreviewContent                 string   `json:"live_preview_content,omitempty"`
	LivePreviewRefreshPeriod           int      `json:"live_preview_refresh_period,omitempty"`
	HideSamplers                       []any    `json:"hide_samplers,omitempty"`
	EtaDdim                            float64  `json:"eta_ddim,omitempty"`
	EtaAncestral                       float64  `json:"eta_ancestral,omitempty"`
	DdimDiscretize                     string   `json:"ddim_discretize,omitempty"`
	SChurn                             float64  `json:"s_churn,omitempty"`
	STmin                              float64  `json:"s_tmin,omitempty"`
	SNoise                             float64  `json:"s_noise,omitempty"`
	EtaNoiseSeedDelta                  int      `json:"eta_noise_seed_delta,omitempty"`
	AlwaysDiscardNextToLastSigma       bool     `json:"always_discard_next_to_last_sigma,omitempty"`
	UniPcVariant                       string   `json:"uni_pc_variant,omitempty"`
	UniPcSkipType                      string   `json:"uni_pc_skip_type,omitempty"`
	UniPcOrder                         int      `json:"uni_pc_order,omitempty"`
	UniPcLowerOrderFinal               bool     `json:"uni_pc_lower_order_final,omitempty"`
	PostprocessingEnableInMainUI       []any    `json:"postprocessing_enable_in_main_ui,omitempty"`
	PostprocessingOperationOrder       []any    `json:"postprocessing_operation_order,omitempty"`
	UpscalingMaxImagesInCache          int      `json:"upscaling_max_images_in_cache,omitempty"`
	DisabledExtensions                 []string `json:"disabled_extensions,omitempty"`
	SdCheckpointHash                   string   `json:"sd_checkpoint_hash,omitempty"`
	SdLora                             string   `json:"sd_lora,omitempty"`
	LoraApplyToOutputs                 bool     `json:"lora_apply_to_outputs,omitempty"`
}

Only contains original options (without extension options. Can't posssibly do that.)

type Txt2Image

type Txt2Image struct {
	EnableHR          bool    `json:"enable_hr,omitempty"`          // Hi-res fix.
	DenoisingStrength float64 `json:"denoising_strength,omitempty"` // Hi-res fix option. Determines how little respect the algorithm should have for image's content. At 0, nothing will change, and at 1 you'll get an unrelated image.
	FirstphaseWidth   int     `json:"firstphase_width,omitempty"`   // Hi-res fix option. Might not work anymore
	FirstphaseHeight  int     `json:"firstphase_height,omitempty"`  // Hi-res fix option. Might not work anymore

	// Hi-res fix option. Multiplier to original width and height.
	//
	// HRScale = 2 will work like this: 384x512 will result in 768x1024
	//
	//  Only HRScale or HRResizeX / HRResizeY will be used
	HRScale float64 `json:"hr_scale,omitempty"`

	// Hi-res fix option. Which Hi-res upscale model will be used.
	//
	//  See: `upscaler` helper package (github.com/colornote/webui-api/upscaler)
	HRUpscaler string `json:"hr_upscaler,omitempty"`

	// Hi-res fix option. After denoising and upscale, use this amount of steps instead of the amount before denoise and upscale.
	HRSecondPassSteps int `json:"hr_second_pass_steps,omitempty"`

	// Hi-res fix option. The width of the result image
	//
	//  Only HRScale or HRResizeX / HRResizeY will be used
	HRResizeX int `json:"hr_resize_x,omitempty"`

	// Hi-res fix option. The height of the result image
	//
	//  Only HRScale or HRResizeX / HRResizeY will be used
	HRResizeY int `json:"hr_resize_y,omitempty"`

	Prompt           string         `json:"prompt"`
	NegativePrompt   string         `json:"negative_prompt,omitempty"`
	Styles           []string       `json:"styles,omitempty"`
	Seed             int64          `json:"seed,omitempty"` // A value that determines the output of random number generator - if you create an image with same parameters and seed as another image, you'll get the same result
	Subseed          int            `json:"subseed,omitempty"`
	SubseedStrength  int            `json:"subseed_strength,omitempty"`
	SeedResizeFromH  int            `json:"seed_resize_from_h,omitempty"`
	SeedResizeFromW  int            `json:"seed_resize_from_w,omitempty"`
	SamplerName      string         `json:"sampler_name,omitempty"`  // Either SamplerName or SamplerIndex will be used.
	SamplerIndex     string         `json:"sampler_index,omitempty"` // Either SamplerName or SamplerIndex will be used.
	BatchSize        int            `json:"batch_size,omitempty"`    // How many do you want to simultaneously generate.
	BatchCount       int            `json:"n_iter,omitempty"`        // How many times do you want to generate.
	Steps            int            `json:"steps,omitempty"`         // How many times to improve the generated image iteratively; higher values take longer; very low values can produce bad results
	CFGScale         float64        `json:"cfg_scale,omitempty"`     // Classifier Free Guidance Scale - how strongly the image should conform to prompt - lower values produce more creative results
	Width            int            `json:"width,omitempty"`
	Height           int            `json:"height,omitempty"`
	RestoreFaces     bool           `json:"restore_faces,omitempty"`
	Tiling           bool           `json:"tiling,omitempty"`
	DoNotSaveSamples bool           `json:"do_not_save_samples,omitempty"`
	DoNotSaveGrid    bool           `json:"do_not_save_grid,omitempty"`
	Eta              float64        `json:"eta,omitempty"`
	SChurn           float64        `json:"s_churn,omitempty"`
	STmax            int            `json:"s_tmax,omitempty"`
	STmin            float64        `json:"s_tmin,omitempty"`
	SNoise           float64        `json:"s_noise,omitempty"`
	OverrideSettings map[string]any `json:"override_settings,omitempty"`

	// Since API default value of this field is `true`, it can't be `omitempty`.
	//
	//  That means the default value of this lib is false
	OverrideSettingsRestoreAfterwards bool `json:"override_settings_restore_afterwards"`

	ScriptName string   `json:"script_name,omitempty"`
	ScriptArgs []string `json:"script_args,omitempty"`

	// Since API default value of this field is `true`, it can't be `omitempty`.
	//
	//  That means the default value of this lib is false
	SendImages bool `json:"send_images"`

	SaveImages bool `json:"save_iamges,omitempty"`

	AlwaysonScripts AlwaysonScripts `json:"alwayson_scripts"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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