DDRNet icon indicating copy to clipboard operation
DDRNet copied to clipboard

Merge conv2d and bn

Open zptang1210 opened this issue 3 years ago • 4 comments

I am using your model to do segmentation, and its performance is really amazing. However, the inference speed is not ideal. I noticed that you merged conv2d and batchnorm during inference. This is probably the potential reason for low speed. However, after I started to work on this, I realized this is not easy work. Could you provide us with the source code for merging conv2d and batchnorm? Thanks in advance!

zptang1210 avatar Apr 01 '21 21:04 zptang1210

I am using your model to do segmentation, and its performance is really amazing. However, the inference speed is not ideal. I noticed that you merged conv2d and batchnorm during inference. This is probably the potential reason for low speed. However, after I started to work on this, I realized this is not easy work. Could you provide us with the source code for merging conv2d and batchnorm? Thanks in advance!

The official Pytorch has provided this method in https://github.com/pytorch/pytorch/blob/master/torch/nn/utils/fusion.py.

ydhongHIT avatar Apr 02 '21 01:04 ydhongHIT

Thanks for your reply! I know that pytorch has incorporated that function, but it seems that I need to rewrite your model structure with all consecutive conv2ds and bns replaced by conv2ds, and then copy the pre-trained parameters to the new model structure. Is there any easier way to convert the pre-trained model to the new model structure?

zptang1210 avatar Apr 02 '21 02:04 zptang1210

I am using your model to do segmentation, and its performance is really amazing. However, the inference speed is not ideal. I noticed that you merged conv2d and batchnorm during inference. This is probably the potential reason for low speed. However, after I started to work on this, I realized this is not easy work. Could you provide us with the source code for merging conv2d and batchnorm? Thanks in advance!

我融合了,但只提升了一些,在2080ti上可达60多fps,和作者提供的eval_speed.py测出来的差不多,我想论文中说的101fps可能是trt加速后的吧

DirtyBit64 avatar Apr 07 '23 04:04 DirtyBit64