Forge-Fun
Forge-Fun is a privacy-focused build of Stable Diffusion WebUI Forge (itself built on AUTOMATIC1111's Stable Diffusion WebUI and Gradio). It keeps everything Forge does and adds one main feature: Secure Presets, passphrase-protected, encrypted prompt and settings presets for txt2img and img2img. It also turns off the places where Forge normally leaves your prompts in plaintext.
The original Forge README is preserved in docs/README.upstream.md. Forge's own docs, news and discussions live in the upstream project.
Contents
- What's different from stock Forge
- Requirements
- Install and run
- Using Secure Presets
- Application waterfall
- Privacy hardening
- Security model and limits
- What is and isn't in the repo
- Repo map
- Staying current with upstream
- Troubleshooting
- License and credits
What's different from stock Forge
| Area |
Change |
Where |
| New feature |
Secure Presets: an accordion in the txt2img and img2img tabs to save, load, delete and re-key encrypted presets |
extensions-builtin/secure-presets/, modules/secure_store.py |
| Encryption |
AES-256-GCM, key derived from your passphrase with scrypt; nothing readable is written to disk |
modules/secure_store.py |
| Image metadata |
Infotext (prompt, settings) is never embedded in generated images, even if a config file or the API asks for it |
modules/options.py, modules/ui_tempdir.py |
| Side files |
.txt infotext files and log.csv are never written |
modules/options.py, modules/shared_options.py |
| Last-generation memory |
Removed: Forge normally writes your last prompt to params.txt and the paste button (↙️) reads it back. Both are gone |
modules/processing.py, modules/infotext_utils.py, modules/ui.py, modules/ui_toprow.py |
| Cleanup |
Leftover params.txt and secure_presets/params.enc are overwritten with zeros and deleted at startup, never read |
extensions-builtin/secure-presets/scripts/secure_presets.py |
| Packaging |
Added pip-constraints.txt; cryptography is installed on first launch by the extension's install.py |
pip-constraints.txt, extensions-builtin/secure-presets/install.py |
Behavior you will notice if you are used to stock Forge
- Images do not carry their generation parameters, so PNG Info and "send to txt2img" from a saved file will not recover a prompt.
- The ↙️ paste-parameters button next to the prompt box is removed.
- The three options above show "(always off: Secure Presets)" in Settings and cannot be turned on.
Requirements
- A GPU that stock Forge supports (NVIDIA recommended). Forge-Fun adds no extra hardware needs.
- Python 3.10 (the launcher warns if you use another version; it is tested with 3.10.6).
- Git.
- Internet access on first launch: PyTorch (default
torch==2.3.1, torchvision==0.18.1 from the CUDA 12.1 index), Python requirements, helper repositories, and cryptography.
Overrides use the same environment variables as Forge, such as TORCH_COMMAND, TORCH_INDEX_URL, REQS_FILE and COMMANDLINE_ARGS.
Install and run
git clone https://github.com/Adutchguy/Forge-Fun.git
cd Forge-Fun
- Windows: double-click or run
webui.bat.
- Linux / macOS: run
./webui.sh (macOS also reads webui-macos-env.sh).
On first launch the script creates a virtual environment, installs everything, and opens the UI in your browser (default http://127.0.0.1:7860). That first run can take a long time.
Command-line options: create webui-user.bat (Windows) or webui-user.sh (Linux/macOS) and set COMMANDLINE_ARGS. Those two files are git-ignored on purpose so your personal options never get committed. Example for webui-user.bat:
@echo off
set COMMANDLINE_ARGS=--cuda-malloc --cuda-stream
call webui.bat
Models: put checkpoints in models/Stable-diffusion/, VAEs in models/VAE/, and so on. Model files (*.safetensors, *.ckpt, *.pth) are git-ignored.
Using Secure Presets
Open Secure Presets 🔒 in the txt2img or img2img tab. The two tabs share one library and stay in sync.
- First time: choose a passphrase of at least 12 characters and click Create encrypted vault. There is no recovery. If you forget the passphrase, the presets are gone.
- Each session: enter the passphrase and click Unlock. Click Lock when done, which wipes the key from memory.
- Save: type a name (1-80 characters; reusing a name overwrites it) and click Save current prompts + settings as preset.
- Load: pick a preset and click Load preset. Every saved field that exists on the current tab is applied.
- Delete: pick a preset, tick Confirm delete, click Delete selected preset.
- Change passphrase: open the nested accordion; the whole vault is re-encrypted under a new salt and key.
What a preset stores
| Group |
Fields |
| Both tabs |
prompt, negative prompt, sampler, scheduler, steps, width, height, batch count, batch size, CFG scale, distilled CFG scale, seed, and the top-of-page UI choice (sd / xl / flux / all) |
| txt2img only |
hires prompt and negative prompt, hires enable, upscaler, hires steps, denoise, scale, resize X/Y, hires CFG and distilled CFG, hires sampler and scheduler |
| img2img only |
denoising strength, resize scale |
Presets do not store the checkpoint, LoRAs or ControlNet settings.
Your vault is the file secure_presets/vault.json, created next to the app. It is git-ignored; back it up yourself if you care about it.
Application waterfall
This section traces what runs, in order, from the moment you start the app. File and function names are real; follow them in the code.
A. Startup waterfall
webui.bat / webui.sh
│ sets up venv, reads webui.settings.bat / webui-user.*, COMMANDLINE_ARGS
▼
launch.py : main()
│ 1. --dump-sysinfo? write sysinfo file and exit
│ 2. startup_timer.record("initial startup")
│ 3. prepare_environment() (skipped by --skip-prepare-environment)
│ ├─ check Python version, print version/commit
│ ├─ install torch + torchvision if missing (or --reinstall-torch)
│ ├─ CUDA availability test (skip: --skip-torch-cuda-test)
│ ├─ install clip / open_clip / xformers / ngrok when requested or missing
│ ├─ git clone helper repos into repositories/
│ │ (assets, huggingface_guess, BLIP)
│ ├─ pip install -r requirements_versions.txt if not already met
│ └─ run_extensions_installers() (skip: --skip-install)
│ └─ runs every extension's install.py, including
│ extensions-builtin/secure-presets/install.py → pip install cryptography
│ 4. --test-server / --forge-ref-a1111-home handling (dev only)
│ 5. start()
▼
launch_utils.start()
│ import webui ← the import itself runs the heavy initialization below
▼
webui.py (module level, in order)
│ startup_timer.record("launcher")
│ initialize_forge() modules_forge/initialization.py
│ └─ adds packages_3rdparty/ to sys.path, warns about removed flags
│ (--lowvram etc.), applies --gpu-device-id / --cuda-malloc,
│ initializes the memory manager
│ initialize.imports() torch, gradio, paths, shared, misc
│ initialize.check_versions() (skip: --skip-version-check)
│ initialize.initialize()
│ ├─ torch / lightning / asyncio / TLS / SIGINT fixes
│ ├─ configure_opts_onchange()
│ ├─ sd_models.setup_model()
│ ├─ codeformer + gfpgan setup
│ └─ initialize_rest()
│ ├─ set samplers
│ ├─ list extensions → restore config state file
│ ├─ list SD models, localizations
│ ├─ scripts.load_scripts() ← loads every extension's scripts/,
│ │ including secure_presets.py, which registers its component
│ │ capture hook and wipes any legacy params files
│ ├─ load upscalers, VAE list, UNets, hypernetworks
│ └─ initialize extra networks (LoRA etc.)
▼
back in start()
│ webui.webui() → starts webui_worker in a daemon thread (see B)
│ main_thread.loop() → the main thread now only runs GPU tasks (see C)
▼
app is serving requests
Two threads matter after startup:
webui_worker thread: builds the UI, runs the Gradio/FastAPI server, and handles stop/restart.
- Main thread (
modules_forge/main_thread.py): a loop that pulls queued generation tasks one at a time. Keeping all heavy model work on one thread is what makes model moving fast in Forge.
B. Web server waterfall (webui_worker)
webui_worker() (webui.py) — runs inside `while 1:` so it can restart the UI
│ 1. clean temp dir if the setting is on
│ 2. script_callbacks.before_ui_callback()
│ 3. shared.demo = ui.create_ui()
│ ├─ builds the top row (modules/ui_toprow.py), txt2img, img2img, extras,
│ │ settings, extensions tabs
│ ├─ every component created fires on_after_component → Secure Presets
│ │ records the ones it needs by elem_id
│ └─ each script's ui() is called → Secure Presets builds its accordion
│ 4. demo.queue(64) (skip: --no-gradio-queue)
│ 5. demo.launch(...) host, port, TLS, auth, allowed paths
│ 6. strip CORSMiddleware (blocks hostile web pages from driving the app)
│ 7. initialize_util.setup_middleware(app)
│ 8. progress API, UI API, optional REST API (--api), extra-network pages
│ 9. script_callbacks.app_started_callback(demo, app)
│ 10. print startup time summary
│ 11. wait loop: poll shared.state for "stop" / "restart" every 5 s
│
├─ "stop" → demo.close(), exit loop
└─ "restart" → demo.close(), app_reload_callback, script_unloaded_callback,
initialize.initialize_rest(reload_script_modules=True), loop to step 1
On a UI restart the vault state is not lost: Secure Presets rebuilds its panels when the txt2img tab is constructed again, and the unlock state lives in modules/secure_store.py, not in the page.
C. Generation request waterfall
What happens when you press Generate on txt2img (img2img is the same shape through modules/img2img.py).
Browser: Generate button
▼
Gradio event → modules/call_queue.py : wrap_gradio_gpu_call
│ registers the task, takes queue_lock, shared.state.begin()
▼
modules/txt2img.py : txt2img()
│ main_thread.run_and_wait_result(txt2img_function, ...)
▼ (task handed to the main thread loop)
modules_forge/main_thread.py : loop() → Task.work()
▼
txt2img_function → txt2img_create_processing(...) builds the processing object `p`
│ (prompt, sampler, size, CFG, hires, scripts, override settings)
▼
modules/processing.py : process_images(p) → process_images_inner(p)
│ per batch:
│ ├─ run script hooks (process, process_batch, ...)
│ ├─ encode prompts, sample, decode
│ ├─ post-process, hires pass if enabled
│ └─ [removed in Forge-Fun] write last-generation params.txt
▼
modules/images.py : save_image(...)
│ [Forge-Fun] enable_pnginfo is forced False → no infotext in file metadata
│ [Forge-Fun] save_txt is forced False → no .txt next to the image
▼
result returns to the UI; Gradio serves previews through modules/ui_tempdir.py
[Forge-Fun] the "parameters" metadata key is dropped when temp files are made
D. Secure Presets waterfall
Building the panel (during UI creation, see B step 3)
script_callbacks.on_after_component(_capture)
│ for each Gradio component, if its elem_id is in _WANTED and it is a real
│ input component (not a layout), store it in _components
▼
SecurePresetsScript.ui(is_img2img) one call per tab; txt2img resets shared state
│ ├─ pair preset keys with captured components (missing ones are logged and skipped)
│ ├─ pick the panel state: no vault / locked / unlocked / cryptography missing
│ ├─ build the accordion: setup, unlock, and main groups
│ └─ wire buttons; link the txt2img and img2img panels so lock state and the
│ preset list refresh in both without a page reload
Vault lifecycle (modules/secure_store.py)