Skip to content

Instantly share code, notes, and snippets.

@josephrocca
Last active April 1, 2025 07:56
Show Gist options
  • Save josephrocca/ae401cf33fc82f79807e0b98d160980b to your computer and use it in GitHub Desktop.
Save josephrocca/ae401cf33fc82f79807e0b98d160980b to your computer and use it in GitHub Desktop.
Convert Chroma to Schnell-compatible safetensors format
apt-get update && apt-get install aria2 -y && pip install safetensors
# Create Schnell-compatible variant of Chroma by downloading both Chroma and Schnell safetensor files, and copying Chroma's matching weights over to Schnell.
CHROMA_VERSION="18"
aria2c -x 16 -s 16 -o "./chroma.safetensors" "https://huggingface.co/lodestones/Chroma/resolve/main/chroma-unlocked-v${CHROMA_VERSION}.safetensors?download=true"
aria2c -x 16 -s 16 -o "./flux1-schnell.safetensors" "https://huggingface.co/black-forest-labs/FLUX.1-schnell/resolve/main/flux1-schnell.safetensors?download=true"
python3 -c '
from safetensors import safe_open
from safetensors.torch import save_file
with safe_open("./chroma.safetensors", framework="pt", device="cpu") as chroma, safe_open("./flux1-schnell.safetensors", framework="pt", device="cpu") as schnell:
chroma_tensors = {key: chroma.get_tensor(key) for key in chroma.keys()}
schnell_tensors = {key: schnell.get_tensor(key) for key in schnell.keys()}
matching_keys = set(chroma_tensors).intersection(schnell_tensors)
for key in matching_keys:
schnell_tensors[key] = chroma_tensors[key]
save_file(schnell_tensors, "./chroma-schnell-compat.safetensors")'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment