AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.65k stars 7.96k forks source link

Why was yolo4 slower to test than your said #5519

Closed ioir123ju closed 4 years ago

ioir123ju commented 4 years ago

Hi! GPU:V100 yolov4.cfg:608x608 command: ./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights fall_down_test_2.avi -dont_show -ext_output FPS:39 command: python darknet.py in darknet.py start = time.time() for i in range(100): ret = detect_image(net, meta, im, thresh, hier_thresh, nms, debug) end = time.time() print(end-start) fps:31 but your result is 62(V) FPS

AlexeyAB commented 4 years ago

GPU:V100 yolov4.cfg:608x608 command: ./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights fall_down_test_2.avi -dont_show -ext_output FPS:39

image


python darknet.py in darknet.py start = time.time() for i in range(100): ret = detect_image(net, meta, im, thresh, hier_thresh, nms, debug) end = time.time() print(end-start) fps:31 but your result is 62(V) FPS

Don't use python.py

For checking FPS you should use: https://github.com/AlexeyAB/darknet/wiki/How-to-evaluate-accuracy-and-speed-of-YOLOv4 ./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights fall_down_test_2.avi -dont_show -ext_output or ./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights fall_down_test_2.avi -dont_show -ext_output -benchmark

ioir123ju commented 4 years ago
  • Do you use the latest version of Darknet?
  • Did you compile Darknet with GPU=1 CUDNN=1 CUDNN_HALF=1 ?
  • Do you run something else on this server?

GPU:V100 yolov4.cfg:608x608 command: ./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights fall_down_test_2.avi -dont_show -ext_output FPS:39

  • Just now I get 33 FPS on RTX 2070 for yolov4.cfg/weights 608x608, while V100 is 2x faster

image

  • Show screenshot of AVG FPS. ./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights fall_down_test_2.avi -dont_show -ext_output
  • Show such screenshot: image

python darknet.py in darknet.py start = time.time() for i in range(100): ret = detect_image(net, meta, im, thresh, hier_thresh, nms, debug) end = time.time() print(end-start) fps:31 but your result is 62(V) FPS

Don't use python.py

For checking FPS you should use: https://github.com/AlexeyAB/darknet/wiki/How-to-evaluate-accuracy-and-speed-of-YOLOv4 ./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights fall_down_test_2.avi -dont_show -ext_output or ./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights fall_down_test_2.avi -dont_show -ext_output -benchmark

yes, I use the latest version of Darknet. I use cmake to compiled code, COMMAND:./build.sh GPU=1 CUDNN=1 CUDNN_HALF=1 is ON. I use your command retest it and get the results: ./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights fall_down_test_2.avi -dont_show -ext_output FPS:42.5 AVG_FPS:42.7 image

AlexeyAB commented 4 years ago
AlexeyAB commented 4 years ago

I added 2 small fixes: https://github.com/AlexeyAB/darknet/commit/ccafff912bd42728aa873be7b4c7add2366858a8 and https://github.com/AlexeyAB/darknet/commit/da050367a8b174f751a2c9720195d51a369c4a4a

Try again with the latest repo:

./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights fall_down_test_2.avi -dont_show -ext_output and ./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights fall_down_test_2.avi -dont_show -ext_output -benchmark

ioir123ju commented 4 years ago

I added 2 small fixes: ccafff9 and da05036

Try again with the latest repo:

./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights fall_down_test_2.avi -dont_show -ext_output and ./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights fall_down_test_2.avi -dont_show -ext_output -benchmark

I found a problem。 option(ENABLE_CUDNN_HALF "Enable CUDNN Half precision" ON) in the CMakeLists.txt BUT when I run ./darknet ..., result is 'CUDNN_HALF=0'. So I tried to compile with Makefile. It is working! Everything is all right. CUDNN_HALF=1. image FPS:59. Maybe you should check the CMakelist.txt.

Thank you for your answer.

AlexeyAB commented 4 years ago

@ioir123ju It should work for any GPU with CC 7.0(V100), 7.2, 7.5(RTX) https://github.com/AlexeyAB/darknet/commit/f14054ec2b49440ad488c3e28612e7a76780bc5f#diff-af3b638bc2a3e6c650974192a53c7291R68

It will not work only if you use older commit.

Li505358678 commented 4 years ago

with MSCOCO. I valided with ./darknet detector valid cfg/coco.data cfg/yolov4.cfg yolov4.weights. It took about 1200 seconds to process 20288 images.

and evaluated FPS of YOLOv4 on GPU by ./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights test.mp4 -dont_show -ext_output. FPS is around 30.

Both of them were too slow . I sure that CUDNN_HALF=1. What's wrong with it?

AlexeyAB commented 4 years ago

@Li505358678


and evaluated FPS of YOLOv4 on GPU by ./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights test.mp4 -dont_show -ext_output. FPS is around 30.

Li505358678 commented 4 years ago

@Li505358678

  • Show such screenshot: image

and evaluated FPS of YOLOv4 on GPU by ./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights test.mp4 -dont_show -ext_output. FPS is around 30.

  • Show screenshot

image

Li505358678 commented 4 years ago

@AlexeyAB from this. is there any wrong?I've had a headache for a day because this

AlexeyAB commented 4 years ago

Compile OpenCV and Darknet in Release mode instead of Debug.

Li505358678 commented 4 years ago

debug change to 0?

AlexeyAB commented 4 years ago

Yes, and recompile.

And show screenshot of FPS of these two commands: ./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights test.mp4 -dont_show -ext_output

./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights test.mp4 -dont_show -ext_output -benchmark

Li505358678 commented 4 years ago

thank you very much! the fps of video is 65 ok ,

but fps of the images is bad about 30 .Specifically, 20288 pictures of testdev2017.txt and test2017 took about 800 seconds(812s) commands:./darknet detector valid cfg/coco.data cfg/yolov4.cfg yolov4.weights

AlexeyAB commented 4 years ago

./darknet detector valid - isn't optimized for high speed, there is performance bottleneck in your CPU or HDD.

Li505358678 commented 4 years ago

./darknet detector valid - isn't optimized for high speed, there is performance bottleneck in your CPU or HDD.

so is there any good way which valid images with high speed

AlexeyAB commented 4 years ago
Li505358678 commented 4 years ago

I just do as https://github.com/AlexeyAB/darknet/wiki/How-to-evaluate-accuracy-and-speed-of-YOLOv4 . the images are test2017 which has more than 20288 images,but testdev2017.txt only have 20288. with debug=0 use 835s

AlexeyAB commented 4 years ago

So you got only 23 FPS for images, while 65 FPS for video. What about other questions?

Li505358678 commented 4 years ago

As you said. what's mean of other question?

AlexeyAB commented 4 years ago

The bottleneck is in your HDD disk, buy SSD.

Li505358678 commented 4 years ago

I see. Thank you very much for your help!