kohya-ss / kohya-ss/sd-scripts

Some trained Flux models have state_dict keys starting with `model.diffusion_model.` causing error in loading

Open
#1,516 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
7.2k
Forks
1.2k
Avg merge
11m
Merged PRs (30d)
2

Description

I noticed this when trying to load a non base flux dev model from CivitAI to train a Lora on top of. This basic script seemed to help convert it:

```
from safetensors.torch import load_file, save_file

dict = load_file("", device="cuda")
keys = dict.keys()
fixed= {k.replace("model.diffusion_model.", ""): dict[k] for k in keys}

print(fixed.keys())
save_file(fixed, "

Contributor guide

No contributing guide indexed for this repository

Research direction

No repository file or test is named. Start by reproducing the loading error with a non-base Flux model from CivitAI and compare its state_dict keys with the provided safetensors script; done means the affected model loads for LoRA training without a manual conversion step.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.