yolo-tensorrt
yolo-tensorrt copied to clipboard
Did anyone have done inference with custom anchors?
Hi guys, I'm using YOLOv5 3.0 and I've trained a yolov5L model generating 7 anchors for my custom dataset composed by 3x800x800 pixel images. The autoanchors function returns the array of generated anchors that I put in my yaml file, and they look like this:
# anchors
anchors:
- [23,24, 27,36, 38,29, 28,70, 53,49, 94,32, 187,26]
- [37,148, 72,95, 128,64, 38,286, 118,137, 403,76, 130,241]
- [217,159, 218,284, 191,548, 653,189, 391,316, 193,697, 697,717]
When I do some inference in Pytorch everything is ok.
Then I convert my model and the yaml to cfg file, and my cfg file look like this:
[net]
width=800
height=800
channels=3
batch=1
nc=6
depth_multiple=1.0
width_multiple=1.0
anchors=23, 24, 27, 34, 46, 32, 229, 66, 97, 29, 34, 146, 75, 88, 193, 40, 64, 210, 121, 129, 233, 161, 183, 248, 133, 556, 407, 234, 177, 765, 785, 269, 508, 599, 784, 813
Now I would like to use those anchors in this c++ solution, but for now I didn't have any success. I keep getting this error:
File does not exist : ../configs/yolov5-3.0/yolov5l_custom-kFLOAT-batch1.engine
Loading pre-trained weights...
Loading complete!
layer inp_size out_size
(1) Focus 3 x 800 x 800 64 x 400 x 400
(2) Conv 64 x 400 x 400 128 x 200 x 200
(3) BottleneckCSP 128 x 200 x 200 128 x 200 x 200
(4) Conv 128 x 200 x 200 256 x 100 x 100
(5) BottleneckCSP 256 x 100 x 100 256 x 100 x 100
(6) Conv 256 x 100 x 100 512 x 50 x 50
(7) BottleneckCSP 512 x 50 x 50 512 x 50 x 50
(8) Conv 512 x 50 x 50 1024 x 25 x 25
(9) SPP 1024 x 25 x 25 1024 x 25 x 25
(10) BottleneckCSP 1024 x 25 x 25 1024 x 25 x 25
(11) Conv 1024 x 25 x 25 512 x 25 x 25
(12) Upsample 512 x 25 x 25 512 x 50 x 50
(13) Concat 512 x 50 x 50 1024 x 50 x 50
(14) BottleneckCSP 1024 x 50 x 50 512 x 50 x 50
(15) Conv 512 x 50 x 50 256 x 50 x 50
(16) Upsample 256 x 50 x 50 256 x 100 x 100
(17) Concat 256 x 100 x 100 512 x 100 x 100
(18) BottleneckCSP 512 x 100 x 100 256 x 100 x 100
(19) Conv 256 x 100 x 100 256 x 50 x 50
(20) Concat 256 x 50 x 50 512 x 50 x 50
(21) BottleneckCSP 512 x 50 x 50 512 x 50 x 50
(22) Conv 512 x 50 x 50 512 x 25 x 25
(23) Concat 512 x 25 x 25 1024 x 25 x 25
(24) BottleneckCSP 1024 x 25 x 25 1024 x 25 x 25
Assertion failed: size == (map_wts_[s_layer_name_ + ".weight"].size()), file .\yolo_tensorrt\modules\trt_utils.cpp, line 854
The layer that seems to not have the right size is
s_layer_name = "model.24.m.0"
= 19712
and
int size = n_filters_ * chw[0] * n_kernel_size_ * n_kernel_size;
= 8448
So for some reason size is exactly the half of s_layer_name.
Can someone help me out with this? I'm using TensorRT 7.1.3.4, OpenCV 4.4.0. Thanks in advance!