MNN icon indicating copy to clipboard operation
MNN copied to clipboard

sd1.5以训练模式导出模型问题

Open simon886212 opened this issue 1 year ago • 2 comments

背景,期望通过MNN搭建sd1.5模型的反向流程,遇到了如下问题: 1.因为unet以fp32导出超过了2g限制,使用了--fp16选项,但是NN::Utils::ExtractConvolution的实现中似乎没有对op->common->buffer的对应处理,weight未正确初始化。 2.导出路径是通过修改diffuser文件夹中onnx_export.py,修改了如下几处

  • do_constant_folding=True
  • Training=True
  • 在convert_mnn.py中加入了"--fortraining",,并设置了saveExternalData=0(saveExternalData=1,在nn::extract中似乎无法正确加载)。

不知道通过这种方式导出训练模型是否正确,想知道有推荐的训练模型导出流程吗

simon886212 avatar Apr 15 '25 14:04 simon886212

  1. 建议是转换时加上 --saveExternalWeight 分离权重
  2. NN::Utils::ExtractConvolution 现在估计不支持 external weight ,需要修改一下代码

jxt1234 avatar Apr 17 '25 06:04 jxt1234

Marking as stale. No activity in 60 days.

github-actions[bot] avatar Jun 16 '25 09:06 github-actions[bot]