huawei-noah / Efficient-Computing

Efficient computing methods developed by Huawei Noah's Ark Lab
1.2k stars 211 forks source link

about ONNX #94

Closed QiqLiang closed 10 months ago

QiqLiang commented 1 year ago

你好,我使用你们提供的预训练模型gold-yolo-n.pt在自己的6类数据集上进行微调,在将微调后的pytorch模型转换为onnx模型的时候,我遇到了以下的报错: File "Gold-YOLO/yolov6/layers/common.py", line 314,in _fuse_bn_tensor assert isinstance (branch, nn.BatchNorm2d), 最开始是在export_onnx.py的53行报错的(抱歉由于电脑无法复制粘贴只能这样简单地重述报错)。 请问是什么原因呢?是需要设置什么参数吗?

lose4578 commented 1 year ago

Hi, whether it is an error caused by SyncBN. If yes, you can add the

from gold_yolo.switch_tool import switch_to_deploy
model = switch_to_deploy(model)

in here https://github.com/huawei-noah/Efficient-Computing/blob/master/Detection/Gold-YOLO/deploy/ONNX/export_onnx.py#L50