Documentation
¶
Overview ¶
Package fooocus implements reading and writing Fooocus metadata (image generation parameters).
To read embedded metadata, use NewImageInfo:
path := "testdata/sample.jpg" image, err := NewImageInfo(path) fmt.Println(image.FooocusMetadata.Version) // prints "Fooocus v2.5.5"
To read from the private log file, use ParsePrivateLog:
path := "testdata/log.html" images, err := ParsePrivateLog(privateLogFile) meta := images["fooocus-meta.jpeg"] fmt.Println(image.FooocusMetadata.Version) // prints "Fooocus v2.5.5"
To write metadata into a PNG, use EmbedMetadataAsPngText:
meta := &Metadata{} target, err := os.OpenFile("out.png", os.O_CREATE|os.O_WRONLY, 0644) err = EmbedMetadataAsPngText(nil, target, meta)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EmbedMetadataAsPngText ¶
Types ¶
type AdmGuidance ¶
type AdmGuidance [3]float32
string: python tuple (p: float, n: float, e: float)
func (*AdmGuidance) MarshalJSON ¶
func (a *AdmGuidance) MarshalJSON() ([]byte, error)
func (*AdmGuidance) UnmarshalJSON ¶
func (a *AdmGuidance) UnmarshalJSON(p []byte) error
type File ¶
type ImageFile ¶
func NewImageInfo ¶
type Lora ¶
Encoded as nested list of format: list [string, float32, string] (lora name, lora weight, lora hash)
func (*Lora) MarshalJSON ¶
func (*Lora) UnmarshalJSON ¶
type LoraCombined ¶
type LoraCombined Lora
String of format "<name> : <weight>"
func (*LoraCombined) MarshalJSON ¶
func (l *LoraCombined) MarshalJSON() ([]byte, error)
func (*LoraCombined) UnmarshalJSON ¶
func (l *LoraCombined) UnmarshalJSON(p []byte) error
type Metadata ¶
type Metadata struct { AdaptiveCfg float32 `json:"adaptive_cfg,omitempty"` AdmGuidance AdmGuidance `json:"adm_guidance"` BaseModel string `json:"base_model"` BaseModelHash string `json:"base_model_hash"` ClipSkip uint8 `json:"clip_skip"` CreatedBy string `json:"created_by,omitempty"` FreeU string `json:"freeu,omitempty"` // string: python tuple (b1: float, b2: float, s1: float, s2: float) FullNegativePrompt []string `json:"full_negative_prompt,omitempty"` FullPrompt []string `json:"full_prompt,omitempty"` GuidanceScale float32 `json:"guidance_scale"` ImageNumber uint `json:"image_number,omitempty"` InpaintEngineVersion string `json:"inpaint_engine_version,omitempty"` InpaintMode string `json:"inpaint_method,omitempty"` LoraCombined1 *LoraCombined `json:"lora_combined_1,omitempty"` LoraCombined2 *LoraCombined `json:"lora_combined_2,omitempty"` LoraCombined3 *LoraCombined `json:"lora_combined_3,omitempty"` LoraCombined4 *LoraCombined `json:"lora_combined_4,omitempty"` LoraCombined5 *LoraCombined `json:"lora_combined_5,omitempty"` Loras []Lora `json:"loras"` MetadataScheme string `json:"metadata_scheme"` NegativePrompt string `json:"negative_prompt"` Performance string `json:"performance"` Prompt string `json:"prompt"` PromptExpansion string `json:"prompt_expansion"` RefinerModel string `json:"refiner_model,omitempty"` RefinerModelHash string `json:"refiner_model_hash,omitempty"` RefinerSwapMethod string `json:"refiner_swap_method,omitempty"` RefinerSwitch float32 `json:"refiner_switch"` Resolution Resolution `json:"resolution"` Sampler string `json:"sampler"` Scheduler string `json:"scheduler"` Seed string `json:"seed"` Sharpness float32 `json:"sharpness"` Steps uint8 `json:"steps"` Styles Styles `json:"styles"` Vae string `json:"vae"` Version string `json:"version"` }
Fooocus metadata scheme (json).
Implemented in Fooocus v2.2.0 and newer.
Reference implementation:
type MetadataLegacy ¶
type MetadataLegacy struct { AdmGuidance AdmGuidance `json:"ADM Guidance"` BaseModel string `json:"Base Model"` CFGMimicking float32 `json:"CFG Mimicking from TSNR,omitempty"` ClipSkip uint8 `json:"CLIP Skip,omitempty"` FooocusV2Expansion string `json:"Fooocus V2 Expansion"` FreeU string `json:"FreeU,omitempty"` GuidanceScale float32 `json:"Guidance Scale"` ImageNumber uint `json:"Image Number,omitempty"` InpaintEngineVersion string `json:"Inpaint Engine Version,omitempty"` InpaintMode string `json:"Inpaint Mode,omitempty"` Lora1 *LoraCombined `json:"LoRA 1,omitempty"` Lora2 *LoraCombined `json:"LoRA 2,omitempty"` Lora3 *LoraCombined `json:"LoRA 3,omitempty"` Lora4 *LoraCombined `json:"LoRA 4,omitempty"` Lora5 *LoraCombined `json:"LoRA 5,omitempty"` Lora6 *LoraCombined `json:"LoRA 6,omitempty"` NegativePrompt string `json:"Negative Prompt"` OverWriteSwitch float32 `json:"Overwrite Switch,omitempty"` Performance string `json:"Performance"` Prompt string `json:"Prompt"` RefinerModel string `json:"Refiner Model"` RefinerSwapMethod string `json:"Refiner Swap Method,omitempty"` RefinerSwitch float32 `json:"Refiner Switch"` Resolution Resolution `json:"Resolution"` Sampler string `json:"Sampler"` Scheduler string `json:"Scheduler"` Seed int `json:"Seed"` Sharpness float32 `json:"Sharpness"` Steps uint8 `json:"Steps,omitempty"` // TODO: post process default from Performance Styles Styles `json:"Styles"` Vae string `json:"VAE,omitempty"` Version string `json:"Version"` }
Fooocus legacy metadata schema (json).
This format is only found in the private log HTML file generated by Fooocus v2.1.0 and older.
Reference implementation:
type Resolution ¶
type Resolution [2]uint16
string: python tuple (width: int, height: int)
func (*Resolution) MarshalJSON ¶
func (r *Resolution) MarshalJSON() ([]byte, error)
func (*Resolution) UnmarshalJSON ¶
func (r *Resolution) UnmarshalJSON(p []byte) error
type Styles ¶
type Styles []string
Styles are encoded within a string using single-quoted values, e.g.: "['Fooocus V2', 'Fooocus Enhance', 'Fooocus Sharp']"