Skip to content

Latest commit

 

History

History
89 lines (71 loc) · 4.64 KB

generation_metadata.md

File metadata and controls

89 lines (71 loc) · 4.64 KB

Generation results and metadata

sd_generate_image(), sd_generate_video() and sd_upscale() all execute dgl. sd_result_get_generation_info(result, index) returns the exact UTF-8 program submitted to the DGL compiler. It is not a JSON parameter snapshot.

Debug logging also prints the actual compiled program immediately before execution. Use --log-level debug in the CLI. Each image in a batch logs its own resolved program and seed. Source logging is independent of file metadata embedding; tensor bindings remain separate inputs and are not dumped.

Results and rerunning

Each generated image records its actual seed and executed source. Image batches execute individual programs in the same context, reusing loaded models. Multiple layers decoded from one latent share the same source. A video records one program for the entire sequence, returned for every valid frame index. Partial batch cancellation returns records only for completed images; full cancellation returns no result.

Rerun a self-contained program through sd-cli -M dgl --script FILE or the DGL C API. Programs with fn main(input_image, ...) require the original host tensor bindings through the DGL C API. Generated programs retain component paths, resolved options and ordinary LoRA application order. They do not embed model weights or input media. Keep the same files, inputs and backends when comparing numerical results.

Standalone image upscaling records the complete DGL operation, including every requested repeat. No source diffusion settings are invented for an imported image. There is no postprocessing JSON merge or separate replay mode.

WebUI infotext

CLI and server derive WebUI infotext from the DGL source on a best-effort basis. Known image flows can expose prompts, seed, dimensions, sampler, scheduler, steps, CFG, strength, components and ordinary LoRAs. Ambiguous multi-stage fields are omitted. Conversion never changes the executed source or causes inference to fail. Standalone upscaling can have empty infotext.

sd_get_generation_metadata(source) returns UTF-8 JSON containing these parameters and an infotext field in one call. It does not execute the program or read model files. Unrecognized image flows return {}. The returned string is borrowed until the next call on the same thread; copy or parse it before then. A null result indicates an API error available through sd_get_last_error().

Native server generation_info values are DGL strings. WebUI-compatible routes also fill infotexts separately. Clients must not parse the DGL string as JSON.

File metadata

The CLI and server image writers store native DGL and WebUI text separately:

Container DGL source WebUI text
PNG UTF-8 iTXt, keyword dgl UTF-8 iTXt, keyword parameters
JPEG COM segment labeled dgl COM segment labeled parameters
WebP / animated WebP XMP sdcpp:dgl XMP sdcpp:parameters
AVI RIFF INFO ICMT Not stored separately
WebM / Matroska COMMENT tag Not stored separately

Video comments contain the DGL program. The XMP namespace is https://github.com/leejet/stable-diffusion.cpp/ns/1.0/. JPEG labels and values are separated by NUL bytes. A JPEG COM payload is limited to 65,533 bytes including labels and terminators; an oversized record makes encoding fail rather than silently truncating the program. Other container capacity checks follow the same rule.

Memory encoding and file saving use the same metadata writer. Disabling metadata still disables embedding. Previously generated files with combined WebUI text and SDCPP: JSON remain readable.

DGL image and video encoders use the current script as the metadata source by default. An explicit metadata argument supplies a different source. The image writer includes WebUI infotext when it can infer image-generation parameters from that source. Set the DGL context option embed_metadata to off to disable automatic source embedding. An explicit empty metadata argument also produces output without embedded generation metadata. sd-cli uses --disable-image-metadata for both ordinary generation and DGL scripts. Server SD API responses populate infotexts independently of this setting.

Inspect metadata with sd-cli -M metadata --image FILE, optionally adding --metadata-format json for a structured report. This command reads container metadata without loading a model.

DGL provides the same report through media::read_metadata(path) as text. Set format="json" for a JSON string. Use raw=true for raw payloads, brief=true for a compact text report, or structural=true to include structural entries. The read follows the DGL context's file access policy.