Skip to content

Instantly share code, notes, and snippets.

@saftle
saftle / state_dict_config_creator.py
Last active March 10, 2025 20:25
SD-Mecha State Dict Config Creator
import torch
import yaml
import os
def create_complete_config(checkpoint_path, output_yaml_path):
"""Create a complete SD Mecha configuration that preserves all keys"""
print(f"Loading checkpoint from {checkpoint_path}...")
# Load original checkpoint
state_dict = torch.load(checkpoint_path, map_location="cpu", weights_only=False)
@saftle
saftle / replace_vae.py
Last active January 21, 2023 10:00 — forked from ProGamerGov/replace_vae.py
Fixed script to work with models that were merged with Automatic1111, and included the numpy dependency which the script uses.
# Script by https://github.com/ProGamerGov
import copy
import torch
import numpy as np
# Path to model and VAE files that you want to merge
vae_file_path = "vae-ft-mse-840000-ema-pruned.ckpt"
model_file_path = "v1-5-pruned-emaonly.ckpt"
# Name to use for new model file