-
Notifications
You must be signed in to change notification settings - Fork 0
01. Getting Started
This guide covers the basic setup required to get sd-optim running.
- Python: A working Python environment (version 3.10 or later recommended). Pip should also be available.
-
Supported WebUI: A functional local installation of a supported Stable Diffusion WebUI, such as:
- AUTOMATIC1111/stable-diffusion-webui
- lllyasviel/stable-diffusion-webui-forge
-
Stability-AI/StableSwarmUI
(Swarm not tested yet. Support for ComfyUI and others is planned).
You need to know how to launch your WebUI with the necessary API flags enabled (usually
--api).
- Git: Required for cloning the repository.
sd-optim is typically installed as an extension within your chosen WebUI's extensions directory.
-
Navigate to Extensions Directory: Open your terminal or command prompt and navigate into the
extensionsdirectory of your WebUI installation.# Example for A1111/Forge: cd /path/to/stable-diffusion-webui/extensions
-
Clone the Repository: Use
git cloneto download thesd-optimcode.git clone https://github.com/enferlain/sd-optim.git sd-optim
-
Install Dependencies: Navigate into the newly cloned
sd-optimdirectory and install the required Python packages.(Alternatively, if you are using A1111/Forge's environment, restarting the WebUI might trigger thecd sd-optim pip install -r requirements.txtinstall.pyscript, but running pip manually is often more reliable).
sd-optim uses Hydra for configuration, primarily through YAML files in the conf/ directory. You need to create your own configuration files from the provided templates (.tmpl.yaml).
-
Navigate to
conf/Directory:cd /path/to/stable-diffusion-webui/extensions/sd-optim/conf -
Copy Template Files: Copy the following template files, removing the
.tmplpart:-
config.tmpl.yaml->config.yaml -
optimization_guide/guide.tmpl.yaml->optimization_guide/guide.yaml -
payloads/cargo_WEBUI.tmpl.yaml->payloads/cargo_WEBUI.yaml(Copy the template corresponding to thewebuiyou set inconfig.yaml, e.g.,cargo_forge.yaml). -
payloads/cargo/payload.tmpl.yaml->payloads/cargo/payload.yaml(You will likely create multiple payload files later).
-
-
Edit Configuration Files: You must edit these newly created
.yamlfiles to match your setup:-
config.yaml:- Set the correct
webuiidentifier (e.g.,forge). - Update
model_pathsto point to your actual model files. - Update
wildcards_dirandscorer_model_dirto your local paths. - Review other settings like
merge_method,scorer_method, andoptimizersettings. See the 02. Configuration page for details.
- Set the correct
-
payloads/cargo/payload.yaml: Define at least one image generation payload with your desired prompt, settings, etc. See the 03. Payloads page for details. -
optimization_guide/guide.yaml: Configure which model parameters you want to optimize. See the 02. Configuration page for details.
-
-
Start Your WebUI: Launch your Stable Diffusion WebUI (A1111, Forge, etc.) with the API enabled (e.g., by adding the
--apicommand-line flag). Ensure it's running and accessible at theurlspecified in yourconfig.yaml. -
Run the Script: Open a new terminal or command prompt, navigate to the
sd-optimextension directory, and run the main script:(Note: Ensure the Python environment where you installed the requirements is active).cd /path/to/stable-diffusion-webui/extensions/sd-optim python sd_optim.py
The optimization process will begin, interacting with your running WebUI via its API to merge models, generate images, and score them based on your configuration. Logs and results will be saved in the logs/ directory within the sd-optim folder.
Now you're ready to explore the detailed 02. Configuration options!