forked from Tossy0423/darknet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev/alexey/master' into dev/cenit/setup
- Loading branch information
Showing
66 changed files
with
9,240 additions
and
443 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# These are supported funding model platforms | ||
|
||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] | ||
patreon: # Replace with a single Patreon username | ||
open_collective: # Replace with a single Open Collective username | ||
ko_fi: # Replace with a single Ko-fi username | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
otechie: # Replace with a single Otechie username | ||
custom: ['https://paypal.me/alexeyab84', 'https://blockchain.coinmarketcap.com/address/bitcoin/36La9T7DoLVMrUQzm6rBDGsxutyvDzbHnp', 'https://etherscan.io/address/0x193d56BE3C65e3Fb8f48c291B17C0702e211A588#', 'https://explorer.zcha.in/accounts/t1PzwJ28Prb7Nk8fgfT3RXCr6Xtw54tgjoy'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,11 @@ More details: http://pjreddie.com/darknet/yolo/ | |
|
||
0. [Improvements in this repository](#improvements-in-this-repository) | ||
1. [How to use](#how-to-use-on-the-command-line) | ||
2. [How to compile on Linux](#how-to-compile-on-linux) | ||
2. How to compile on Linux | ||
* [Using cmake](#how-to-compile-on-linux-using-cmake) | ||
* [Using make](#how-to-compile-on-linux-using-make) | ||
3. How to compile on Windows | ||
* [Using CMake-GUI](#how-to-compile-on-windows-using-cmake-gui) | ||
* [Using vcpkg](#how-to-compile-on-windows-using-vcpkg) | ||
* [Legacy way](#how-to-compile-on-windows-legacy-way) | ||
4. [How to train (Pascal VOC Data)](#how-to-train-pascal-voc-data) | ||
|
@@ -51,10 +54,6 @@ More details: http://pjreddie.com/darknet/yolo/ | |
* **GPU with CC >= 3.0**: https://en.wikipedia.org/wiki/CUDA#GPUs_supported | ||
* on Linux **GCC or Clang**, on Windows **MSVC 2015/2017/2019** https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community | ||
|
||
Compiling on **Windows** by using `Cmake-GUI` as on this [**IMAGE**](https://user-images.githubusercontent.com/4096485/55107892-6becf380-50e3-11e9-9a0a-556a943c429a.png): Configure -> Optional platform for generator (Set: x64) -> Finish -> Generate -> Open Project -> x64 & Release -> Build -> Build solution | ||
|
||
Compiling on **Linux** by using command `make` (or alternative way by using command: `cmake . && make` ) | ||
|
||
#### Pre-trained models | ||
|
||
There are weights-file for different cfg-files (smaller size -> faster speed & lower accuracy: | ||
|
@@ -63,12 +62,18 @@ There are weights-file for different cfg-files (smaller size -> faster speed & l | |
* `yolov3-spp.cfg` (240 MB COCO **Yolo v3**) - requires 4 GB GPU-RAM: https://pjreddie.com/media/files/yolov3-spp.weights | ||
* `yolov3.cfg` (236 MB COCO **Yolo v3**) - requires 4 GB GPU-RAM: https://pjreddie.com/media/files/yolov3.weights | ||
* `yolov3-tiny.cfg` (34 MB COCO **Yolo v3 tiny**) - requires 1 GB GPU-RAM: https://pjreddie.com/media/files/yolov3-tiny.weights | ||
* `enet-coco.cfg` (EfficientNetb0-Yolo- 45.5% [email protected] - 3.7 BFlops) [enetb0-coco_final.weights](https://drive.google.com/file/d/1FlHeQjWEQVJt0ay1PVsiuuMzmtNyv36m/view) and `yolov3-tiny-prn.cfg` (33.1% [email protected] - 3.5 BFlops - [more](https://github.com/WongKinYiu/PartialResidualNetworks)) | ||
|
||
<details><summary><b>CLICK ME</b> - Yolo v2 models</summary> | ||
|
||
* `yolov2.cfg` (194 MB COCO Yolo v2) - requires 4 GB GPU-RAM: https://pjreddie.com/media/files/yolov2.weights | ||
* `yolo-voc.cfg` (194 MB VOC Yolo v2) - requires 4 GB GPU-RAM: http://pjreddie.com/media/files/yolo-voc.weights | ||
* `yolov2-tiny.cfg` (43 MB COCO Yolo v2) - requires 1 GB GPU-RAM: https://pjreddie.com/media/files/yolov2-tiny.weights | ||
* `yolov2-tiny-voc.cfg` (60 MB VOC Yolo v2) - requires 1 GB GPU-RAM: http://pjreddie.com/media/files/yolov2-tiny-voc.weights | ||
* `yolo9000.cfg` (186 MB Yolo9000-model) - requires 4 GB GPU-RAM: http://pjreddie.com/media/files/yolo9000.weights | ||
|
||
</details> | ||
|
||
Put it near compiled: darknet.exe | ||
|
||
You can get cfg-files by path: `darknet/cfg/` | ||
|
@@ -165,7 +170,23 @@ On Linux find executable file `./darknet` in the root directory, while on Window | |
|
||
* Yolo v3 COCO-model: `darknet.exe detector demo data/coco.data yolov3.cfg yolov3.weights http://192.168.0.80:8080/video?dummy=param.mjpg -i 0` | ||
|
||
### How to compile on Linux | ||
### How to compile on Linux (using `cmake`) | ||
|
||
The `CMakeLists.txt` will attempt to find installed optional dependencies like | ||
CUDA, cudnn, ZED and build against those. It will also create a shared object | ||
library file to use `darknet` for code development. | ||
|
||
Do inside the cloned repository: | ||
|
||
``` | ||
mkdir build-release | ||
cd build-release | ||
cmake .. | ||
make | ||
make install | ||
``` | ||
|
||
### How to compile on Linux (using `make`) | ||
|
||
Just do `make` in the darknet directory. | ||
Before make, you can set such options in the `Makefile`: [link](https://github.com/AlexeyAB/darknet/blob/9c1b9a2cf6363546c152251be578a21f3c3caec6/Makefile#L1) | ||
|
@@ -183,9 +204,28 @@ Before make, you can set such options in the `Makefile`: [link](https://github.c | |
|
||
To run Darknet on Linux use examples from this article, just use `./darknet` instead of `darknet.exe`, i.e. use this command: `./darknet detector test ./cfg/coco.data ./cfg/yolov3.cfg ./yolov3.weights` | ||
|
||
### How to compile on Windows (using `CMake-GUI`) | ||
|
||
This is the recommended approach to build Darknet on Windows if you have already | ||
installed Visual Studio 2015/2017/2019, CUDA > 10.0, cuDNN > 7.0, and | ||
OpenCV > 2.4. | ||
|
||
Use `CMake-GUI` as shown here on this [**IMAGE**](https://user-images.githubusercontent.com/4096485/55107892-6becf380-50e3-11e9-9a0a-556a943c429a.png): | ||
|
||
1. Configure | ||
2. Optional platform for generator (Set: x64) | ||
3. Finish | ||
4. Generate | ||
5. Open Project | ||
6. Set: x64 & Release | ||
7. Build | ||
8. Build solution | ||
|
||
### How to compile on Windows (using `vcpkg`) | ||
|
||
If you have already installed Visual Studio 2015/2017/2019, CUDA > 10.0, cuDNN > 7.0, OpenCV > 2.4, then compile Darknet by using `C:\Program Files\CMake\bin\cmake-gui.exe` as on this [**IMAGE**](https://user-images.githubusercontent.com/4096485/55107892-6becf380-50e3-11e9-9a0a-556a943c429a.png): Configure -> Optional platform for generator (Set: x64) -> Finish -> Generate -> Open Project -> x64 & Release -> Build -> Build solution | ||
If you have already installed Visual Studio 2015/2017/2019, CUDA > 10.0, | ||
cuDNN > 7.0, OpenCV > 2.4, then to compile Darknet it is recommended to use | ||
[CMake-GUI](#how-to-compile-on-windows-using-cmake-gui). | ||
|
||
Otherwise, follow these steps: | ||
|
||
|
@@ -327,7 +367,7 @@ Training Yolo v3: | |
|
||
* change line batch to [`batch=64`](https://github.com/AlexeyAB/darknet/blob/0039fd26786ab5f71d5af725fc18b3f521e7acfd/cfg/yolov3.cfg#L3) | ||
* change line subdivisions to [`subdivisions=8`](https://github.com/AlexeyAB/darknet/blob/0039fd26786ab5f71d5af725fc18b3f521e7acfd/cfg/yolov3.cfg#L4) | ||
* change line max_batches to (`classes*2000`), f.e. [`max_batches=6000`](https://github.com/AlexeyAB/darknet/blob/0039fd26786ab5f71d5af725fc18b3f521e7acfd/cfg/yolov3.cfg#L20) if you train for 3 classes | ||
* change line max_batches to (`classes*2000` but not less than `4000`), f.e. [`max_batches=6000`](https://github.com/AlexeyAB/darknet/blob/0039fd26786ab5f71d5af725fc18b3f521e7acfd/cfg/yolov3.cfg#L20) if you train for 3 classes | ||
* change line steps to 80% and 90% of max_batches, f.e. [`steps=4800,5400`](https://github.com/AlexeyAB/darknet/blob/0039fd26786ab5f71d5af725fc18b3f521e7acfd/cfg/yolov3.cfg#L22) | ||
* change line `classes=80` to your number of objects in each of 3 `[yolo]`-layers: | ||
* https://github.com/AlexeyAB/darknet/blob/0039fd26786ab5f71d5af725fc18b3f521e7acfd/cfg/yolov3.cfg#L610 | ||
|
@@ -445,11 +485,11 @@ Usually sufficient 2000 iterations for each class(object), but not less than 400 | |
> Region Avg IOU: 0.798363, Class: 0.893232, Obj: 0.700808, No Obj: 0.004567, Avg Recall: 1.000000, count: 8 | ||
> Region Avg IOU: 0.800677, Class: 0.892181, Obj: 0.701590, No Obj: 0.004574, Avg Recall: 1.000000, count: 8 | ||
> | ||
> **9002**: 0.211667, **0.060730 avg**, 0.001000 rate, 3.868000 seconds, 576128 images | ||
> **9002**: 0.211667, **0.60730 avg**, 0.001000 rate, 3.868000 seconds, 576128 images | ||
> Loaded: 0.000000 seconds | ||
* **9002** - iteration number (number of batch) | ||
* **0.060730 avg** - average loss (error) - **the lower, the better** | ||
* **0.60730 avg** - average loss (error) - **the lower, the better** | ||
|
||
When you see that average loss **0.xxxxxx avg** no longer decreases at many iterations then you should stop training. The final avgerage loss can be from `0.05` (for a small model and easy dataset) to `3.0` (for a big model and a difficult dataset). | ||
|
||
|
@@ -530,10 +570,14 @@ Example of custom object detection: `darknet.exe detector test data/obj.data yol | |
|
||
* check that each object that you want to detect is mandatory labeled in your dataset - no one object in your data set should not be without label. In the most training issues - there are wrong labels in your dataset (got labels by using some conversion script, marked with a third-party tool, ...). Always check your dataset by using: https://github.com/AlexeyAB/Yolo_mark | ||
|
||
* my Loss is very high and mAP is very low, is training wrong? Run training with ` -show_imgs` flag at the end of training command, do you see correct bounded boxes of objects (in windows or in files `aug_...jpg`)? If no - your training dataset is wrong. | ||
|
||
* for each object which you want to detect - there must be at least 1 similar object in the Training dataset with about the same: shape, side of object, relative size, angle of rotation, tilt, illumination. So desirable that your training dataset include images with objects at diffrent: scales, rotations, lightings, from different sides, on different backgrounds - you should preferably have 2000 different images for each class or more, and you should train `2000*classes` iterations or more | ||
|
||
* desirable that your training dataset include images with non-labeled objects that you do not want to detect - negative samples without bounded box (empty `.txt` files) - use as many images of negative samples as there are images with objects | ||
|
||
* What is the best way to mark objects: label only the visible part of the object, or label the visible and overlapped part of the object, or label a little more than the entire object (with a little gap)? Mark as you like - how would you like it to be detected. | ||
|
||
* for training with a large number of objects in each image, add the parameter `max=200` or higher value in the last `[yolo]`-layer or `[region]`-layer in your cfg-file (the global maximum number of objects that can be detected by YoloV3 is `0,0615234375*(width*height)` where are width and height are parameters from `[net]` section in cfg-file) | ||
|
||
* for training for small objects (smaller than 16x16 after the image is resized to 416x416) - set `layers = -1, 11` instead of https://github.com/AlexeyAB/darknet/blob/6390a5a2ab61a0bdf6f1a9a6b4a739c16b36e0d7/cfg/yolov3.cfg#L720 | ||
|
@@ -563,7 +607,9 @@ Example of custom object detection: `darknet.exe detector test data/obj.data yol | |
|
||
* each: `model of object, side, illimination, scale, each 30 grad` of the turn and inclination angles - these are *different objects* from an internal perspective of the neural network. So the more *different objects* you want to detect, the more complex network model should be used. | ||
|
||
* recalculate anchors for your dataset for `width` and `height` from cfg-file: | ||
* to make the detected bounded boxes more accurate, you can add 3 parameters `ignore_thresh = .9 iou_normalizer=0.5 iou_loss=giou` to each `[yolo]` layer and train, it will increase [email protected], but decrease [email protected]. | ||
|
||
* Only if you are an **expert** in neural detection networks - recalculate anchors for your dataset for `width` and `height` from cfg-file: | ||
`darknet.exe detector calc_anchors data/obj.data -num_of_clusters 9 -width 416 -height 416` | ||
then set the same 9 `anchors` in each of 3 `[yolo]`-layers in your cfg-file. But you should change indexes of anchors `masks=` for each [yolo]-layer, so that 1st-[yolo]-layer has anchors larger than 60x60, 2nd larger than 30x30, 3rd remaining. Also you should change the `filters=(classes + 5)*<number of mask>` before each [yolo]-layer. If many of the calculated anchors do not fit under the appropriate layers - then just try using all the default anchors. | ||
|
||
|
@@ -581,6 +627,14 @@ Here you can find repository with GUI-software for marking bounded boxes of obje | |
|
||
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 | ||
|
||
Different tools for marking objects in images: | ||
1. in C++: https://github.com/AlexeyAB/Yolo_mark | ||
2. in Python: https://github.com/tzutalin/labelImg | ||
3. in Python: https://github.com/Cartucho/OpenLabeling | ||
4. in C++: https://www.ccoderun.ca/darkmark/ | ||
5. in JavaScript: https://github.com/opencv/cvat | ||
|
||
|
||
## Using Yolo9000 | ||
|
||
Simultaneous detection and classification of 9000 objects: `darknet.exe detector test cfg/combine9k.data cfg/yolo9000.cfg yolo9000.weights data/dog.jpg` | ||
|
@@ -605,8 +659,14 @@ With example of: `train.txt`, `obj.names`, `obj.data`, `yolo-obj.cfg`, `air`1-6` | |
|
||
## How to use Yolo as DLL and SO libraries | ||
|
||
* on Linux - set `LIBSO=1` in the `Makefile` and do `make` | ||
* on Windows - compile `build\darknet\yolo_cpp_dll.sln` or `build\darknet\yolo_cpp_dll_no_gpu.sln` solution | ||
* on Linux | ||
* using `build.sh` or | ||
* build `darknet` using `cmake` or | ||
* set `LIBSO=1` in the `Makefile` and do `make` | ||
* on Windows | ||
* using `build.ps1` or | ||
* build `darknet` using `cmake` or | ||
* compile `build\darknet\yolo_cpp_dll.sln` solution or `build\darknet\yolo_cpp_dll_no_gpu.sln` solution | ||
|
||
There are 2 APIs: | ||
* C API: https://github.com/AlexeyAB/darknet/blob/master/include/darknet.h | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.