merge-models  by eyriewow

Script for latent diffusion model merging

Created 3 years ago
264 stars

Top 96.8% on SourcePulse

GitHubView on GitHub
Project Summary

This repository provides a Python script for merging two latent diffusion models (like Stable Diffusion checkpoints) at a user-defined ratio. It's designed for users of Stable Diffusion, particularly those using Automatic1111's Web UI, to easily combine model weights and create new, hybrid models.

How It Works

The script implements a weighted average of the model weights. Given two models, model0 and model1, and an alpha value, it calculates the merged model's weights as (1 - alpha) * model0_weights + alpha * model1_weights. This allows for fine-grained control over the influence of each base model on the resulting merged model.

Quick Start & Requirements

  • Install: Download the repository, place it in your Stable Diffusion installation folder, and copy the models to be merged into the script's folder.
  • Run: Execute merge.bat (Windows) or python merge.py model0 model1 --alpha 0.5 --output merged (command line).
  • Prerequisites: Python, torch library.
  • VRAM: Approximately 1.15x the combined size of the two models being merged. Merging two 3.76GB models required ~8.6GB VRAM. Can run on CPU if VRAM is insufficient.
  • Docs: README

Highlighted Details

  • User-defined merge ratio (--alpha) for precise control.
  • Option to specify output filename (--output).
  • Supports GPU merging (--device "cuda:x") for faster processing if sufficient VRAM is available.
  • Can fall back to CPU merging if VRAM is limited.

Maintenance & Community

  • The script is a standalone utility, with code adapted from Automatic1111's Web UI and mlfoundations/wise-ft.
  • No explicit community channels or roadmap are mentioned in the README.

Licensing & Compatibility

  • The README does not explicitly state a license. The code is derived from other projects, whose licenses would apply.

Limitations & Caveats

The script's licensing is unclear, which may impact commercial use. The README does not detail compatibility with different Stable Diffusion versions or other model merging tools.

Health Check
Last Commit

2 years ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
0 stars in the last 30 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Eric Jang Eric Jang(VP AI at 1X), and
2 more.

civitai by civitai

0.2%
7k
Platform for sharing AI models
Created 2 years ago
Updated 1 day ago
Feedback? Help us improve.