[Bug] Qwen-Image-2.1 validate_full 未加载训练权重,实际验证的是基座模型

Open Beginner friendly
#1,702 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
90/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, pytorch

Research direction

Start with examples/qwen_image_21/model_training/validate_full/Qwen-Image-2.1.py and compare it with examples/qwen_image/model_training/validate_full/Qwen-Image-2512.py and the sibling validate_lora script. Run the full-training validation command after checking the epoch output naming in the referenced training script. Done means the validation script reads models/train/Qwen-Image-2.1_full/epoch-1.safetensors and clearly produces the full-training validation image.

Written by the indexing model from the issue text.

Description

问题

examples/qwen_image_21/model_training/validate_full/Qwen-Image-2.1.py 加载的是原始 Qwen/Qwen-Image-2.1没有任何加载训练产物的语句,因此验证的是未微调的基座模型。

脚本不报错、能正常出图,容易被误判为"全量训练没效果"。

复现

全量训练输出到 models/train/Qwen-Image-2.1_full 后执行:

python examples/qwen_image_21/model_training/validate_full/Qwen-Image-2.1.py

epoch-1.safetensors 从未被读取。

判断依据
  1. 文档 docs/*/Pipeline_Usage/Model_Training.md 写明 validate_full 的用途是"全量训练完成后,运行这个脚本加载模型,验证效果"。

  2. 全仓库 136 个 validate_full/*.py只有这一个不加载任何权重(其余要么 pipe.dit.load_state_dict(...),要么 ModelConfig(path=<ckpt>)):

    $ for f in $(find examples -path "*validate_full*" -name "*.py"); do
        grep -qE "load_state_dict|load_lora|ModelConfig\(\s*path=|ckpt|checkpoint" "$f" \
          || echo "$f"
      done
    examples/qwen_image_21/model_training/validate_full/Qwen-Image-2.1.py
    # ↑ 唯一一个,1 / 136
    
  3. 该文件自 7f65ecc8 新增起就没有加载语句,7f31effa 仅删除了 num_inference_steps=50;当前 main7686e54d)仍未修复。

  4. 同目录的 validate_lora/Qwen-Image-2.1.py 是正确的,有
    pipe.load_lora(pipe.dit, "models/train/Qwen-Image-2.1_lora/epoch-4.safetensors")

建议修复

参考 examples/qwen_image/model_training/validate_full/Qwen-Image-2512.py

 from diffsynth.pipelines.qwen_image_21 import QwenImage21Pipeline, ModelConfig
+from diffsynth import load_state_dict
 import torch


 pipe = QwenImage21Pipeline.from_pretrained(
     ...
     processor_config=ModelConfig(model_id="Qwen/Qwen-Image-2.1", origin_file_pattern="processor/"),
 )
+state_dict = load_state_dict("models/train/Qwen-Image-2.1_full/epoch-1.safetensors")
+pipe.dit.load_state_dict(state_dict)
 prompt = "dog,white and brown dog, sitting on wall, under pink flowers"
 image = pipe(prompt, seed=0, height=1024, width=1024)
-image.save("image.png")
+image.save("image_full.png")

epoch-1 对应 full/Qwen-Image-2.1.sh 中的 --num_epochs 2ModelLogger.on_epoch_endepoch_id 从 0 开始,故最后一个 epoch 文件是 num_epochs - 1

环境
  • DiffSynth-Studio 2.1.8(d2d684ad),main7686e54d)仍可复现
  • 涉及文件:examples/qwen_image_21/model_training/validate_full/Qwen-Image-2.1.py
Dominant language
Python
Stars
13.1k
Forks
1.3k
Avg merge
13h 15m
Merged PRs (30d)
46

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from modelscope/DiffSynth-Studio

All issues in modelscope/DiffSynth-Studio

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.