Open chenxiaolongqqqq opened 4 years ago
OpenCV DNN does lazy initialization. The initialization happens in the first forward pass. So you actually measured the initialization + inference time instead of just the inference. You have to ignore the first forward call in benchmarks.
Benchmark Code - reports initialization and inference time separately (does not include NMS, preprocessing and postprocessing)
Example: YOLOv4 in Python and C++ with OpenCV DNN - also displays FPS on terminal and screen (includes NMS, preprocessing and postprocessing)
oh, yes! i get it. thank you very much
1,i rebuild the opencv and
cuDNN: YES (ver 7.6.4)
2,my config:NVIDIA GeForce MX150 CUDA:10.1 CUDNN:8.0.2
3,the darknet can use gpu
4.my code is : auto net = cv::dnn::readNetFromDarknet("D://yolov4.cfg", "D://yolov4_last.weights"); net.setPreferableBackend(cv::dnn::DNN_BACKEND_CUDA); net.setPreferableTarget(cv::dnn::DNN_TARGET_CUDA); auto output_names = net.getUnconnectedOutLayersNames();
5,if i only use cpu,the time is 1.5 s . if i use the gpu ,the time is 5 s. i do not know why
hope giving me some tips . thank you