lewes6369 / TensorRT-Yolov3

TensorRT for Yolov3
MIT License
489 stars 165 forks source link

Yolov3-tiny Does not show any detection results #58

Open Techyee opened 5 years ago

Techyee commented 5 years ago

I tried to use yolov3-tiny model from Mobilenet-YOLO.

Step 1. I modified last layer of yolov3-tiny as below.

layer { bottom: "layer17-yolo" bottom: "layer23-conv" top: "yolo-det" name: "yolo-det" type: "Yolo" }

Step 2. I modified YoloConfig.h as below, with the information of tinyyolo prototxt.

  //tinyYolo layer17 layer23
  YoloKernel yolo1 = {
      13,
      13,
      {81,82, 135,169, 344,319}
  };
  YoloKernel yolo2 = {
      26,
      26,
      {10,14, 23,27, 37,58}
  };

}

Step3. Since tinyyolo only gets 2 yolokernel, so I marked yolo3 on yololayer.cu

    mYoloKernel.push_back(yolo1);
    mYoloKernel.push_back(yolo2);

// mYoloKernel.push_back(yolo3);

and It looked like I did all conversion works. Even engine builds and inference did not emit any errors. However, there was no red box at all. result Picture above is result from yolov3-608 test Picture above is result from tinyyolo.

Any advice?

P.S Oh, I also downloaded tinyyolo.caffemodel and used it during inference. P.S.2. my cmd line for execution was ./install/runYolov3 --caffemodel=./yolov3-tiny.caffemodel --prototxt=./yolov3-tiny.prototxt --input=./test.jpg --W=416 --H=416 --class=80 --nms=0

ElonKou commented 5 years ago

hi,did you solved the question?I'd like to run tiny-yolo3 on my TX2, But I can't find "tinyyolo.caffemodel", can you share the download link for me,thanks you very much.

lewes6369 commented 5 years ago

Can you show me the prototxt for your model. What is the type of "layer17-yolo"? And is there any log info about runing the cmd line? Maybe you have to try the cpu version of yoloLayer and cout some information to debug it.

lidapengpeng commented 4 years ago

I encountered the same problem as you. How did you solve this problem in the end?

liudakai2 commented 3 years ago

I don't know if it is too late. I happened to find out that the key issue that caused yolov3-tiny not working is the "layer12-maxpool". To be specific, in darknet yolov3-tiny take the maxpool layer with kernel-size=2 and stride=1, while in order to avoid changing the tensor shape after the maxpool layer, in caffe or pytorch or tensorrt or anything, we must set the kernel-size/stride to 1/1 or 3/1 respactively. That is the culprit.

One solution to fix it out is to manually change the kernel-size in this maxpool layer or just remove it, and retrain your network in darknet, and then convert the darknet.weights to caffe.caffemodel. When you get your new trt.engine, you will find it finally works.