| | |
| | | # Yolo-v2 Windows and Linux version |
| | | # Yolo-v3 and Yolo-v2 for Windows and Linux |
| | | ### (neural network for object detection) |
| | | |
| | | [](https://circleci.com/gh/AlexeyAB/darknet) |
| | | |
| | |
| | | |---|---| |
| | | |
| | | |
| | | # "You Only Look Once: Unified, Real-Time Object Detection (version 2)" |
| | | # "You Only Look Once: Unified, Real-Time Object Detection (versions 2 & 3)" |
| | | A Yolo cross-platform Windows and Linux version (for object detection). Contributtors: https://github.com/pjreddie/darknet/graphs/contributors |
| | | |
| | | This repository is forked from Linux-version: https://github.com/pjreddie/darknet |
| | |
| | | * **GPU with CC >= 2.0** if you use CUDA, or **GPU CC >= 3.0** if you use cuDNN + CUDA: https://en.wikipedia.org/wiki/CUDA#GPUs_supported |
| | | |
| | | ##### Pre-trained models for different cfg-files can be downloaded from (smaller -> faster & lower quality): |
| | | * `yolo.cfg` (194 MB COCO-model) - require 4 GB GPU-RAM: http://pjreddie.com/media/files/yolo.weights |
| | | * `yolo-voc.cfg` (194 MB VOC-model) - require 4 GB GPU-RAM: http://pjreddie.com/media/files/yolo-voc.weights |
| | | * `tiny-yolo.cfg` (60 MB COCO-model) - require 1 GB GPU-RAM: http://pjreddie.com/media/files/tiny-yolo.weights |
| | | * `tiny-yolo-voc.cfg` (60 MB VOC-model) - require 1 GB GPU-RAM: http://pjreddie.com/media/files/tiny-yolo-voc.weights |
| | | * `yolov3.cfg` (236 MB COCO-model **v3**) - require 4 GB GPU-RAM: https://pjreddie.com/media/files/yolov3.weights |
| | | * `yolov2.cfg` (194 MB COCO-model v2) - require 4 GB GPU-RAM: https://pjreddie.com/media/files/yolov2.weights |
| | | * `yolo-voc.cfg` (194 MB VOC-model v2) - require 4 GB GPU-RAM: http://pjreddie.com/media/files/yolo-voc.weights |
| | | * `yolov2-tiny.cfg` (43 MB COCO-model v2) - require 1 GB GPU-RAM: https://pjreddie.com/media/files/yolov2-tiny.weights |
| | | * `yolov2-tiny-voc.cfg` (60 MB VOC-model v2) - require 1 GB GPU-RAM: http://pjreddie.com/media/files/yolov2-tiny-voc.weights |
| | | * `yolo9000.cfg` (186 MB Yolo9000-model) - require 4 GB GPU-RAM: http://pjreddie.com/media/files/yolo9000.weights |
| | | |
| | | Put it near compiled: darknet.exe |
| | |
| | | |
| | | ##### Example of usage in cmd-files from `build\darknet\x64\`: |
| | | |
| | | * `darknet_yolo_v3.cmd` - initialization with 236 MB **Yolo v3** COCO-model yolov3.weights & yolov3.cfg and show detection on the image: dog.jpg |
| | | |
| | | * `darknet_voc.cmd` - initialization with 194 MB VOC-model yolo-voc.weights & yolo-voc.cfg and waiting for entering the name of the image file |
| | | * `darknet_demo_voc.cmd` - initialization with 194 MB VOC-model yolo-voc.weights & yolo-voc.cfg and play your video file which you must rename to: test.mp4 |
| | | * `darknet_demo_store.cmd` - initialization with 194 MB VOC-model yolo-voc.weights & yolo-voc.cfg and play your video file which you must rename to: test.mp4, and store result to: res.avi |
| | |
| | | |
| | | ##### How to use on the command line: |
| | | |
| | | On Linux use `./darknet` instead of `darknet.exe`, like this:`./darknet detector test ./cfg/coco.data ./cfg/yolo.cfg ./yolo.weights` |
| | | On Linux use `./darknet` instead of `darknet.exe`, like this:`./darknet detector test ./cfg/coco.data ./cfg/yolov3.cfg ./yolov3.weights` |
| | | |
| | | * 194 MB COCO-model - image: `darknet.exe detector test data/coco.data yolo.cfg yolo.weights -i 0 -thresh 0.2` |
| | | * Alternative method 194 MB COCO-model - image: `darknet.exe detect yolo.cfg yolo.weights -i 0 -thresh 0.2` |
| | |
| | | * 186 MB Yolo9000 - image: `darknet.exe detector test cfg/combine9k.data yolo9000.cfg yolo9000.weights` |
| | | * 186 MB Yolo9000 - video: `darknet.exe detector demo cfg/combine9k.data yolo9000.cfg yolo9000.weights test.mp4` |
| | | * Remeber to put data/9k.tree and data/coco9k.map under the same folder of your app if you use the cpp api to build an app |
| | | * To process a list of images `image_list.txt` and save results of detection to `result.txt` use: |
| | | `darknet.exe detector test data/voc.data yolo-voc.cfg yolo-voc.weights < image_list.txt > result.txt` |
| | | * To process a list of images `data/train.txt` and save results of detection to `result.txt` use: |
| | | `darknet.exe detector test data/voc.data yolo-voc.cfg yolo-voc.weights -dont_show < data/train.txt > result.txt` |
| | | You can comment this line so that each image does not require pressing the button ESC: https://github.com/AlexeyAB/darknet/blob/6ccb41808caf753feea58ca9df79d6367dedc434/src/detector.c#L509 |
| | | |
| | | ##### For using network video-camera mjpeg-stream with any Android smartphone: |
| | |
| | | |
| | | ### How to compile on Windows: |
| | | |
| | | 1. If you have **MSVS 2015, CUDA 9.1 and OpenCV 3.0** (with paths: `C:\opencv_3.0\opencv\build\include` & `C:\opencv_3.0\opencv\build\x64\vc14\lib`), then start MSVS, open `build\darknet\darknet.sln`, set **x64** and **Release**, and do the: Build -> Build darknet |
| | | 1. If you have **MSVS 2015, CUDA 9.1, cuDNN 7.0 and OpenCV 3.x** (with paths: `C:\opencv_3.0\opencv\build\include` & `C:\opencv_3.0\opencv\build\x64\vc14\lib`), then start MSVS, open `build\darknet\darknet.sln`, set **x64** and **Release**, and do the: Build -> Build darknet. **NOTE:** If installing OpenCV, use OpenCV 3.4.0 or earlier. This is a bug in OpenCV 3.4.1 in the C API (see [#500](https://github.com/AlexeyAB/darknet/issues/500)). |
| | | |
| | | 1.1. Find files `opencv_world320.dll` and `opencv_ffmpeg320_64.dll` in `C:\opencv_3.0\opencv\build\x64\vc14\bin` and put it near with `darknet.exe` |
| | | 1.1. Find files `opencv_world320.dll` and `opencv_ffmpeg320_64.dll` (or `opencv_world340.dll` and `opencv_ffmpeg340_64.dll`) in `C:\opencv_3.0\opencv\build\x64\vc14\bin` and put it near with `darknet.exe` |
| | | |
| | | 1.2 Check that there are `bin` and `include` folders in the `C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1` if aren't, then copy them to this folder from the path where is CUDA installed |
| | | |
| | | 1.3. To install CUDNN (speedup neural network), do the following: |
| | | |
| | | * download and install **cuDNN 7.0 for CUDA 9.1**: https://developer.nvidia.com/cudnn |
| | | |
| | | * add Windows system variable `cudnn` with path to CUDNN: https://hsto.org/files/a49/3dc/fc4/a493dcfc4bd34a1295fd15e0e2e01f26.jpg |
| | | |
| | | 1.4. If you want to build **without CUDNN** then: open `\darknet.sln` -> (right click on project) -> properties -> C/C++ -> Preprocessor -> Preprocessor Definitions, and remove this: `CUDNN;` |
| | | |
| | | 2. If you have other version of **CUDA (not 9.1)** then open `build\darknet\darknet.vcxproj` by using Notepad, find 2 places with "CUDA 9.1" and change it to your CUDA-version, then do step 1 |
| | | |
| | |
| | | 4.1 (right click on project) -> properties -> C/C++ -> General -> Additional Include Directories: `C:\opencv_2.4.13\opencv\build\include` |
| | | |
| | | 4.2 (right click on project) -> properties -> Linker -> General -> Additional Library Directories: `C:\opencv_2.4.13\opencv\build\x64\vc14\lib` |
| | | |
| | | 5. If you want to build with CUDNN to speed up then: |
| | | |
| | | * download and install **cuDNN 7.0 for CUDA 9.1**: https://developer.nvidia.com/cudnn |
| | | |
| | | * add Windows system variable `cudnn` with path to CUDNN: https://hsto.org/files/a49/3dc/fc4/a493dcfc4bd34a1295fd15e0e2e01f26.jpg |
| | | |
| | | * open `\darknet.sln` -> (right click on project) -> properties -> C/C++ -> Preprocessor -> Preprocessor Definitions, and add at the beginning of line: `CUDNN;` |
| | | |
| | | |
| | | ### How to compile (custom): |
| | | |
| | |
| | | |
| | | 1. Before training: |
| | | * set flag `random=1` in your `.cfg`-file - it will increase precision by training Yolo for different resolutions: [link]https://github.com/AlexeyAB/darknet/blob/master/cfg/yolo-voc.2.0.cfg#L244) |
| | | |
| | | |
| | | * increase network resolution in your `.cfg`-file (`height=608`, `width=608` or any value multiple of 32) - it will increase precision |
| | | |
| | | * desirable that your training dataset include images with objects at diffrent: scales, rotations, lightings, from different sides |
| | | |
| | | * desirable that your training dataset include images with objects (without labels) that you do not want to detect - negative samples |
| | | |
| | | * for training on small objects, add the parameter `small_object=1` in the last layer [region] in your cfg-file |
| | | |
| | | * for training with a large number of objects in each image, add the parameter `max=200` or higher value in the last layer [region] in your cfg-file |
| | | |
| | | * to speedup training (with decreasing detection accuracy) do Fine-Tuning instead of Transfer-Learning, set param `stopbackward=1` in one of the penultimate convolutional layers, for example here: https://github.com/AlexeyAB/darknet/blob/cad4d1618fee74471d335314cb77070fee951a42/cfg/yolo-voc.2.0.cfg#L202 |
| | |
| | | |
| | | ## How to mark bounded boxes of objects and create annotation files: |
| | | |
| | | Here you can find repository with GUI-software for marking bounded boxes of objects and generating annotation files for Yolo v2: https://github.com/AlexeyAB/Yolo_mark |
| | | Here you can find repository with GUI-software for marking bounded boxes of objects and generating annotation files for Yolo v2 & v3: https://github.com/AlexeyAB/Yolo_mark |
| | | |
| | | With example of: `train.txt`, `obj.names`, `obj.data`, `yolo-obj.cfg`, `air`1-6`.txt`, `bird`1-4`.txt` for 2 classes of objects (air, bird) and `train_obj.cmd` with example how to train this image-set with Yolo v2 |
| | | With example of: `train.txt`, `obj.names`, `obj.data`, `yolo-obj.cfg`, `air`1-6`.txt`, `bird`1-4`.txt` for 2 classes of objects (air, bird) and `train_obj.cmd` with example how to train this image-set with Yolo v2 & v3 |
| | | |
| | | ## Using Yolo9000 |
| | | |