What to Save Alongside Weights for Repeatable Local Image Generation
To reliably reproduce an image you generated locally, you must save not only the model weights but also the full generation configuration: the exact prompt, negative prompt, sampler, steps, CFG scale, seed, and any model-specific settings like LoRA weights or VAE. Without this metadata, the same weights will produce a different image every time, making true repeatability impossible.
The Core Problem: Why Weights Alone Are Not Enough
Local image generation models like Stable Diffusion are deterministic given a fixed set of inputs. The same seed, prompt, and settings will always produce the same output on the same hardware and software version. However, the model weights are only one of many variables. The sampler (e.g., Euler, DPM++ 2M, DDIM) determines the denoising schedule; the CFG scale controls how strongly the prompt is followed; the step count changes the quality and style; and the seed initializes the random noise. Change any one of these, and the output changes, often dramatically. So, to “save” a generation for later reproduction, you must capture the entire input vector, not just the model file.
What Exactly to Save: The Complete Metadata List
Below is the definitive list of every parameter that must be recorded for a fully repeatable generation. This applies to AUTOMATIC1111, ComfyUI, InvokeAI, and most other local tools.
- Model identifier: The exact checkpoint file name (e.g., “dreamshaper_8.safetensors”) and its SHA-256 hash if you want to be absolutely certain it hasn’t changed.
- Prompt: The full positive prompt, including any weighted syntax like
(word:1.2)or[word]. - Negative prompt: The full negative prompt, often critical for style and quality.
- Sampler: The exact sampler name (e.g., “DPM++ 2M Karras”) and its scheduler variant (Karras, exponential, etc.).
- Steps: The number of denoising steps (e.g., 30).
- CFG scale: The classifier-free guidance scale (e.g., 7.0).
- Seed: The random seed used for the initial noise (e.g., 123456789).
- Size: Width and height in pixels (e.g., 512×512).
- Model-specific extras: LoRA names and their weights, Textual Inversion embeddings, VAE filename (if not baked in), and any hypernetwork settings.
- Software version: The UI and its version (e.g., AUTOMATIC1111 v1.7.0) and the underlying diffusers/transformers library versions, because even minor updates can change results.
How to Save This Metadata Automatically
Most modern local interfaces already embed this metadata into the PNG file itself. AUTOMATIC1111 writes a parameters text chunk into every generated PNG, containing the prompt and settings. ComfyUI embeds the entire workflow graph as a JSON in the PNG. To retrieve it later, you can simply drag the image back into the UI (ComfyUI) or use the “PNG Info” tab (AUTOMATIC1111) to see the full generation parameters. For non-PNG outputs (like JPEG or WebP), you must save the metadata separately. A common practice is to save a small .txt file with the same base name as the image, containing all the parameters. Some users also use a spreadsheet or a dedicated tool like stable-diffusion-metadata to catalog generations.
How to Choose What to Save: A Practical Decision Tree
Not every generation is worth saving in full detail. Here is a practical way to decide how much metadata to keep:
- For quick experiments: Save only the seed and prompt. If you like the result, you can always regenerate the full metadata later from the PNG.
- For final images: Save everything listed above, plus the exact model file hash. This guarantees you can reproduce the image even if you later update the model or the software.
- For sharing: Save the prompt, negative prompt, sampler, steps, CFG, seed, and model name, but omit the software version unless you are sharing with someone using the exact same UI. Most people can reproduce with the core settings.
- For reproducibility across machines: Save the model hash and the full library versions. Different GPUs can sometimes produce slightly different floating-point results, so this is the only way to be 100% sure.
Common Problems and Misconceptions
One common misconception is that the seed alone is enough to reproduce an image. This is false: the seed only sets the initial noise; the sampler and steps transform that noise into an image, so they are equally important. Another issue is that changing the image size changes the noise pattern, so a seed that works at 512×512 will not produce the same composition at 768×768. Also, many users forget to save the negative prompt, which can be just as influential as the positive prompt. Finally, a frequent problem is that after updating the UI or the model, the same settings produce a different image. This is usually due to a change in the default scheduler or a subtle change in the model file. Saving the software version and the model hash helps diagnose this.
Comparison: PNG Metadata vs. External Files vs. Workflow Files
There are three main ways to store generation metadata, each with trade-offs.
- PNG metadata (embedded): The most convenient because it travels with the image. It works for PNG only, and some image viewers strip it. It is also human-readable in AUTOMATIC1111’s PNG Info tab.
- External .txt or .json files: These are robust and human-readable, but they can be lost if you move or rename the image. They also require a naming convention to keep pairs together.
- Workflow files (ComfyUI): These are JSON files that contain the entire node graph, including all settings and model references. They are the most complete and reproducible, but they are tied to ComfyUI and require the exact same custom nodes to be installed.
Costs and Storage Considerations
Saving metadata is nearly free in terms of disk space—a few kilobytes per image. The real cost is organizational: you need a consistent naming and filing system to keep the metadata with the image. If you use PNG metadata, you avoid extra files but risk losing it if you convert to JPEG. If you use external files, you double the file count. A good compromise is to keep the PNG as-is and use a folder structure like YYYY-MM-DD_project/ to group images and their optional .txt files. No special hardware or software is required beyond what you already use for generation.
Safety and Accuracy Tips
When saving metadata, be careful not to include personal information in the prompt or filename, as the metadata is embedded in the image and can be read by anyone who receives the file. Also, be aware that model files can be large (2-7 GB), so if you are archiving the model alongside the metadata, you need significant storage. For accuracy, always note the exact model file name and its hash. A SHA-256 hash can be computed with a simple command-line tool and stored in the metadata. This protects against accidentally using a re-downloaded or modified model that produces different results.
Frequently Asked Questions
Q: Can I reproduce an image if I only have the seed and the prompt?
A: No, not reliably. The seed and prompt are necessary but not sufficient. You also need the sampler, steps, CFG, size, and model. Without those, the output will be different.
Q: Does saving the model file itself guarantee the same result?
A: No, because the model is only one input. You still need the exact generation settings. Also, if the model file is modified (e.g., merged or converted), the result will change. Saving the file hash ensures you have the exact same version.
Q: How do I extract metadata from an existing PNG?
A: In AUTOMATIC1111, go to the “PNG Info” tab and drag the image in. In ComfyUI, drag the image onto the canvas to load the workflow. For other tools, you can use a script to read the tEXt chunks of the PNG.
Q: What if I generate in WebP or JPEG format?
A: Those formats do not reliably store metadata. You must save the parameters in a separate .txt or .json file. Some tools allow you to set the output format to PNG specifically to preserve metadata.
Q: Why does the same seed and prompt give a different image after I update my software?
A: Software updates can change default sampler settings, numerical precision, or the underlying algorithms. To avoid this, record the software version and the exact sampler name, and consider pinning your environment to a specific version.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.