kohya-ss / kohya-ss/sd-scripts

UNet cannot be saved in `diffusers` nor `diffusers_safetensors` format

Open
#966 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
7.2k
Forks
1.2k
Avg merge
11m
Merged PRs (30d)
2

Description

Hi,
I was running the script on Google Colab via the following command:
```bash
!accelerate launch --num_cpu_threads_per_process 1 sd-scripts/train_db.py \
--pretrained_model_name_or_path=$MODEL_NAME \
--dataset_config=$repo_path_conc/initial.toml \
--output_dir=$OUTPUT_DIR \
--save_model_as=diffusers \
--prior_loss_weight=1.0 \
--max_train_steps=$SAVE_MAX_STEPS \
--save_every_n_steps=$SAVE_INTERVAL \
--learning_rate=3.4e-7 \
--lr_scheduler="cosine" \
--optimizer_type="AdamW8bit" \
--xformers \
--mixed_precision="fp16" \
--gradient_checkpointing \
--sample_every_n_steps=$SAVE_INTERVAL \
--sample_sampler="k_euler" \
--sample_prompts="/content/prompts-initial.txt"
```
Everything went fine, the samples became more and more pretty, the loss found its minimum... but at the end of training I noticed absence of the main part - UNet files!

![image](https://github.com/kohya-ss/sd-scripts/assets/5008131/dda9224b-724c-4cf2-9d26-9daab1a7729c)

What am I doing wrong?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with sd-scripts/train_db.py and trace how --save_model_as=diffusers and diffusers_safetensors are handled during the save path. Reproduce the Google Colab command or a reduced training run, then verify that the resulting output includes the UNet files in the requested format.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.