pjreddie / darknet

Convolutional Neural Networks
http://pjreddie.com/darknet/
Other
25.86k stars 21.33k forks source link

Basic detection is very slow (> 20s) #1579

Open borgeser opened 5 years ago

borgeser commented 5 years ago

Hi all,

I've just installed darknet on my laptop and run the basic example of the website: ./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg (without openCV nor CUDA, just the first step).

However it's really slow and far from the 30FPS!

data/dog.jpg: Predicted in 21.585549 seconds.
bicycle: 99%
truck: 92%
dog: 100%

Even if I'm not using the GPU, I have a correct computer (MacBookPro 2017, 2,8 GHz Intel Core i7). I would have expected better performances.

Is there a bug in the last version of master (61c9d02)? In my setup? Somewhere else? Or is it normal and I need to have at least a Pascal Titan X in order to get good speed?

Thanks a lot.

Liedermaus commented 5 years ago

no bug ! This is expected behaviour, forget about using KIs/Yolo without some compatible GPU. For example I reach 35 FPS on a NVIDIA GTX 1080. And sorry, but your laptop with 2,8 GHz is even kind of slow...

borgeser commented 5 years ago

OK, thanks a lot for the quick reply. I'm a bit sad that my expensive Mac is described as "kind of slow" 😄 I'll try the tiny YOLO.

Last question, sorry for my newbieness but what's the meaning of "KI"?

Liedermaus commented 5 years ago

Sorry "Slowness" always depends on the context. A Mac (I also have one) is a nice machine, but that is due to the software and not due to its number crunching capabilites. For a desktop you get a CPU with 3,8 GHz for a decent price, that is what I meant. Actually I set up a computer with cheap components, Linux and an expensive graphics-card for artificial intelligence and use my mac for development. On this machine I analyse videos with up to 35 frames per second = less than 30 ms per image and the CPU is mostly bored ;-)

KI is some kind of lapse on my side, I'm from Germany and KI in German means the same as AI (Artificial Intelligence) in English. So sorry for the confusion...

Burnsing commented 5 years ago

 Future Neural Network Aimbot for AL Need good Trained config for apex legends

cbalthasart commented 5 years ago

no bug ! This is expected behaviour, forget about using KIs/Yolo without some compatible GPU. For example I reach 35 FPS on a NVIDIA GTX 1080. And sorry, but your laptop with 2,8 GHz is even kind of slow...

Hello,

I've a computer with 2 GTX 1080 and cuda 9 + cudnn and opencv 3.3.1. When I use this computer for training the 2 GPUs are almost full. But when I use Yolo for real time detection I only have something like 6 FPS with yolo v2 (the one with 80 objects, configured for 608X608) I use this command line : ./darknet detector demo cfg/coco.data cfg/yolov2.cfg yolov2.weights Here is my makefile for darknet (the flags): GPU=1 CUDNN=1 OPENCV=1 OPENMP=1 DEBUG=0 ARCH= -gencode arch=compute_61,code=compute_61

Have I made something wrong ?

Thanks a lot.

Christophe

Liedermaus commented 5 years ago

Hello,

I've a computer with 2 GTX 1080 and cuda 9 + cudnn and opencv 3.3.1. When I use this computer for training the 2 GPUs are almost full. But when I use Yolo for real time detection I only have something like 6 FPS with yolo v2 (the one with 80 objects, configured for 608X608) I use this command line : ./darknet detector demo cfg/coco.data cfg/yolov2.cfg yolov2.weights Here is my makefile for darknet (the flags): GPU=1 CUDNN=1 OPENCV=1 OPENMP=1 DEBUG=0 ARCH= -gencode arch=compute_61,code=compute_61

Have I made something wrong ?

Thanks a lot.

Christophe

Hi Christophe,

I'm not sure if YOU are doing something wrong ;-), but there is a problem. The only time I got this low frequency is when there were some problems with the camera. For example if you have a camera with 30 frames per second (fps) you con NOT get faster than 25-28 fps. How good is you C-knowledge ? Are you able to measure the time for retrieving images from the video and image recognition with YOLO separately (in demo.c) ? I get 14 ms for YOLO (512x512, Yolo V2 Net, Yolo V3 detector) and 24 ms for retrieving the image from the camera (uncompressed 1920x1080, 50 fps), my computer is a cheap Ryzen 3,6 GHz and one NVIDIA GTX 1080. These processes are executed in parallel, so the 24 ms basically determins the total time. When experimenting with the camera and YOLO to optimize this I had some problems, because some of these webcams are basically cheap junk. When toying with the setting I also got 6 fps once, but then I used the wrong format for retrieving the images, this should not (?) happen by default...

Another idea is to switch off OpenMP, this is used as a package for multi-processors in a server environment, you won't need it on a local machine and I have no idea if cudnn is used or OpenMP if you turn both on..

Regards

cbalthasart commented 5 years ago

My detection (network_predict function) takes 16.5ms on yolo v2 608x608 but the images conversions and post-computing takes so many time that I only get 8 FPS when yolo is integrated in my system. Now I get a 30fps on my computer. The problem comes from the conversion from an opencv Mat image to a yolo image, and from the conversion from yolo image to opencv Mat after network execution.

Liedermaus commented 5 years ago

May be you should check the format, when retrieving the images from the camera. If it is a Linux machine try the qv4l2 package. There you can test the different settings for your camera. When you find something with high enough fps, then in demo.c try to locate:

if(filename){
    printf("video file: %s\n", filename);
    cap = cvCaptureFromFile(filename);
}else{
    cap = cvCaptureFromCAM(cam_index);

    if(w){
        cvSetCaptureProperty(cap, CV_CAP_PROP_FRAME_WIDTH, w);
    }
    if(h){
        cvSetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT, h);
    }
    if(frames){
        cvSetCaptureProperty(cap, CV_CAP_PROP_FPS, 30);
    }
    cvSetCaptureProperty(cap, CV_CAP_PROP_FOURCC, CV_FOURCC_MACRO('M', 'J', 'P', 'G'));

Try to set w = 608 and h = 608 Check if Motion-JPEG is faster, see the 'M','J','P','G' above. As I said above, it strongly depends on the camera. On my cheap webcams, the best format is MJPG ond my professional camera uncompressed ARGB is by far the fastest (up to 60fps !)...

bvnp44 commented 5 years ago

Starting opencv 3.4.2 dnn module support yolov3 and its x10 faster on CPU than original darknet. Just use opencv guys.

AneTrotro commented 5 years ago

Starting opencv 3.4.2 dnn module support yolov3 and its x10 faster on CPU than original darknet. Just use opencv guys.

When you say 10*faster than original, you mean around 500ms to detect on one frame (~2fps) ? It is complicated when we want to analyze a video.

When I try with GPU and darknet (./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg ) I got 450ms for the inference time. I have a quadro M2200, do you find this result normal or kind of slow ?

tsvetiko commented 4 years ago

I think that's an expected behavior for YOLO v3. Try previous versions of YOLO. Also try to change the input size (image size) - e.g. from 1920x1080 to 300x300 px.