Sign In

Efficient Management of Diffusion Models Across Multiple Applications

11
Efficient Management of Diffusion Models Across Multiple Applications

If you are running multiple apps for Stable Diffusion (i.e., ComfyUI, Automatic1111, Forge, etc.), then chances are that you have duplicate copies of models, control nets, etc., on your hard drive taking up space.

Here are a few tips and tricks to reduce redundancy and streamline your model management process.

Here's a video that explains the process as well:

Optimal Strategy for Model Storage

Centralizing your model storage outside any specific application's folder is typically the best route to take. This prevents data loss due to updates or uninstalls. You also have one central record of truth, making it easier to manage.

Selecting a storage location is subjective.

I prefer keeping everything within a designated folder in my home directory and purposely omitting this folder from any cloud sync services like Dropbox or Google Drive so it doesn't kill my network or go to other devices.

Consideration: Utilizing cloud storage could be beneficial for collaborative projects needing shared access to assets.

Additionally, you'll want to keep the models on an SSD or NVMe drive for faster loading times. For older projects or less frequently accessed models, consider storing them on external drives or network-attached storage (NAS) devices.

Your Options for Centralized Model Referencing

Leveraging native application support or creating symbolic links are two ways you can approach this problem. Here's how to implement both of these strategies:

Native Application Features

Several popular Stable Diffusion applications provide built-in options for external model referencing:

1. Automatic1111 WebUI

Set specific paths using the webui-user.bat (Windows) or webui-user.sh (Linux/Mac) files as shown below:

--ckpt-dir "C:\Models\StableDiffusion"
--lora-dir "C:\Models\LoRAs"
--embeddings-dir "C:\Models\Embeddings"

This will look for the models in each of the specified directories upon launch. If you want to move your entire data directory, you can use the --data-dir command.

2. WebUI Forge & Vladmatic SD.Next

These are forks of Automatic1111 WebUI and offer the same command-line arguments as above.

Forge, in particular, has the --forge-ref-a1111-home command which can reference the base directory of your Automatic1111 WebUI installation.

3. ComfyUI

In the root directory is the extra_model_paths.yaml.example file:

#Rename this to extra_model_paths.yaml and ComfyUI will load it


#config for a1111 ui
#all you have to do is change the base_path to where yours is installed
a111:
    base_path: path/to/stable-diffusion-webui/

    checkpoints: models/Stable-diffusion
    configs: models/Stable-diffusion
    vae: models/VAE
    loras: |
         models/Lora
         models/LyCORIS
    upscale_models: |
                  models/ESRGAN
                  models/RealESRGAN
                  models/SwinIR
    embeddings: embeddings
    hypernetworks: models/hypernetworks
    controlnet: models/ControlNet

#config for comfyui
#your base path should be either an existing comfy install or a central folder where you store all of your models, loras, etc.

#comfyui:
#     base_path: path/to/comfyui/
#     checkpoints: models/checkpoints/
#     clip: models/clip/
#     clip_vision: models/clip_vision/
#     configs: models/configs/
#     controlnet: models/controlnet/
#     embeddings: models/embeddings/
#     loras: models/loras/
#     upscale_models: models/upscale_models/
#     vae: models/vae/

#other_ui:
#    base_path: path/to/ui
#    checkpoints: models/checkpoints
#    gligen: models/gligen
#    custom_nodes: path/custom_nodes

ComfyUI built in the functionality to either reference your base Automatic1111 directory or specify individual directories that are stored elsewhere.

This JSON file is pretty self-explanatory, and you can add or remove directories as needed.

Just be sure when modifying this file that you drop the .example extension and restart ComfyUI to apply the changes.

4. Fooocus

Modify the config.txt post-initial launch to point towards your centralized model directory.

Be sure to add in the \\ between each directory:

{
    "path_checkpoints": "D:\\Fooocus\\models\\checkpoints",
    "path_loras": "D:\\Fooocus\\models\\loras",
    "path_embeddings": "D:\\Fooocus\\models\\embeddings",
    "path_vae_approx": "D:\\Fooocus\\models\\vae_approx",
    "path_upscale_models": "D:\\Fooocus\\models\\upscale_models",
    "path_inpaint": "D:\\Fooocus\\models\\inpaint",
    "path_controlnet": "D:\\Fooocus\\models\\controlnet",
    "path_clip_vision": "D:\\Fooocus\\models\\clip_vision",
    "path_fooocus_expansion": "D:\\Fooocus\\models\\prompt_expansion\\fooocus_expansion",
    "path_outputs": "D:\\Fooocus\\outputs",
    "default_model": "realisticStockPhoto_v10.safetensors",
    "default_refiner": "",
    "default_loras": [["lora_filename_1.safetensors", 0.5], ["lora_filename_2.safetensors", 0.5]],
    "default_cfg_scale": 3.0,
    "default_sampler": "dpmpp_2m",
    "default_scheduler": "karras",
    "default_negative_prompt": "low quality",
    "default_positive_prompt": "",
    "default_styles": [
        "Fooocus V2",
        "Fooocus Photograph",
        "Fooocus Negative"
    ]
}

Symlinks act as bridges to the original files, maintaining a single file instance accessible across multiple locations.

Creating Symlinks:

Windows: Use mklink in Command Prompt with administrator rights. Syntax: mklink /D Link Target for directories.

macOS/Linux: Use ln -s Target Link, ensuring proper permissions.

These steps simplify model management, ensuring efficient and organized access to necessary files across various applications.

There are lots of great videos on YouTube demonstrating this process if you need a visual guide.

Conclusion

By centralizing and efficiently linking model data, users can streamline their workflow, reduce redundancy, and maintain a cleaner system architecture. Employing the strategies outlined here will lead to a more organized and efficient handling of diffusion models and other assets across multiple creative platforms.

👉 Consider checking out the Prompting Pixels for other helpful guides, workflows, tools, and more.

11

Comments