isarsoft / yolov4-triton-tensorrt

This repository deploys YOLOv4 as an optimized TensorRT engine to Triton Inference Server
http://www.isarsoft.com
Other
276 stars 63 forks source link

关于类别修改需要改那些参数? #38

Closed xiulianzw closed 2 years ago

xiulianzw commented 3 years ago

谢谢博主提供的代码! 我darknet官方提供的yolov4的模型可以很成功将模型转换为engin,但是如果我想修改类别的话,需要更改那些文件的参数呢? 1.我替换了cfg文件的配置参数 2.修改了yolov4.h文件里面的类别数量,但是没找到filter修改的地方 3.重写编译生成了main,然后执行./main的时候报错了

是不是因为yolov4.h文件里面的filter没有改的原因,我看代码里面定义了yolov4的很多层参数

xiulianzw commented 3 years ago

[Info] Creating builder [Info] Creating model yolov4 [06/06/2021-15:36:23] [E] [TRT] Parameter check failed at: ../builder/Network.cpp::addScale::494, condition: shift.count > 0 ? (shift.values != nullptr) : (shift.values == nullptr) main: /yolov4-triton-tensorrt/yolov4-triton-tensorrt/networks/yolov4.h:65: nvinfer1::IScaleLayer yolov4::addBatchNorm2d(nvinfer1::INetworkDefinition, std::map<std::__cxx11::basic_string, nvinfer1::Weights>&, nvinfer1::ITensor&, std::string, float): Assertion `scale_1' failed. Aborted (core dumped)

Amanda-Barbara commented 3 years ago

@xiulianzw 除了修改network/yolov4.h中的CLASS_NUM参数外,还需要下载https://github.com/Tianxiaomo/pytorch-YOLOv4,把tool文件夹放到https://github.com/isarsoft/yolov4-triton-tensorrt/tree/master/converter目录下面,然后再把你训练的darknet模型转换成以wts结尾的权重文件即可,我定制的yolov4模型已经在triton-21.03上成功运行了,

philipp-schmidt commented 3 years ago

Hi everybody, I'm happy to help but I'd need an english explanation of the issue to be of any help :)

xiulianzw commented 3 years ago

谢谢,找到问题了,我已经转换成wts文件了。原因是因为两个模型文件里面的参数名称不一样 @Amanda-Barbara

xiulianzw commented 3 years ago

thank you very much!I have found the reason for the error, which is caused by the naming of the parameter names of the model files,update yolov4.h file paramter names。 original weightMap parameter name: model.0.bn.bias model.0.bn.num_batches_tracked model.0.bn.running_mean model.0.bn.running_var

my weightMap module_list.0.BatchNorm2d.bias module_list.0.BatchNorm2d.num_batches_tracked module_list.0.BatchNorm2d.running_mean module_list.0.BatchNorm2d.running_var @philipp-schmidt

philipp-schmidt commented 3 years ago

Yes we changed the pytorch implementation for exporting the weights and the layer names changed because of this. More info coming soon. Use the repo pytorch_YOLOv4 as suggested in this issue.

xiulianzw commented 3 years ago

I use darknet to train yolov4,update yolov4.h model to module_list,bn to BatchNorm2d,they also can work very well.