|  | 
| 1 |  | -# yolov4 working in progress | 
|  | 1 | +# yolov4 | 
| 2 | 2 | 
 | 
|  | 3 | +The Pytorch implementation is from [ultralytics/yolov3](https://github.com/ultralytics/yolov3). It can load yolov4.cfg and yolov4.weights(from AlexeyAB/darknet). | 
|  | 4 | + | 
|  | 5 | +Following tricks are used in this yolov4: | 
|  | 6 | + | 
|  | 7 | +- Three yololayer are implemented in one plugin to improve speed, codes derived from [lewes6369/TensorRT-Yolov3](https://github.com/lewes6369/TensorRT-Yolov3) | 
|  | 8 | +- Mish activation, implemented in a plugin. | 
|  | 9 | +- Batchnorm layer, implemented by scale layer. | 
|  | 10 | + | 
|  | 11 | +## Excute: | 
|  | 12 | + | 
|  | 13 | +``` | 
|  | 14 | +1. generate yolov4.wts from pytorch implementation with yolov4.cfg and yolov4.weights | 
|  | 15 | +
 | 
|  | 16 | +git clone https://github.com/wang-xinyu/tensorrtx.git | 
|  | 17 | +git clone https://github.com/ultralytics/yolov3.git | 
|  | 18 | +// download yolov4.weights from https://github.com/AlexeyAB/darknet#pre-trained-models | 
|  | 19 | +cd yolov3 | 
|  | 20 | +cp ../tensorrtx/yolov4/gen_wts.py . | 
|  | 21 | +python gen_wts.py yolov4.weights | 
|  | 22 | +// a file 'yolov4.wts' will be generated. | 
|  | 23 | +// the master branch of yolov3 should work, if not, you can checkout be87b41aa2fe59be8e62f4b488052b24ad0bd450 | 
|  | 24 | +
 | 
|  | 25 | +2. put yolov4.wts into ./yolov4, build and run | 
|  | 26 | +
 | 
|  | 27 | +mv yolov4.wts ../tensorrtx/yolov4/ | 
|  | 28 | +cd ../tensorrtx/yolov4 | 
|  | 29 | +mkdir build | 
|  | 30 | +cd build | 
|  | 31 | +cmake .. | 
|  | 32 | +make | 
|  | 33 | +sudo ./yolov4 -s             // serialize model to plan file i.e. 'yolov4.engine' | 
|  | 34 | +sudo ./yolov4 -d  ../../yolov3-spp/samples // deserialize plan file and run inference, the images in samples will be processed. | 
|  | 35 | +
 | 
|  | 36 | +3. check the images generated, as follows. _zidane.jpg and _bus.jpg | 
|  | 37 | +``` | 
|  | 38 | + | 
|  | 39 | +<p align="center"> | 
|  | 40 | +<img src="https://user-images.githubusercontent.com/15235574/80863728-cbd3a780-8cb0-11ea-8640-7983bb41c354.jpg"> | 
|  | 41 | +</p> | 
|  | 42 | + | 
|  | 43 | +<p align="center"> | 
|  | 44 | +<img src="https://user-images.githubusercontent.com/15235574/80863730-cfffc500-8cb0-11ea-810e-94d693e71d80.jpg"> | 
|  | 45 | +</p> | 
0 commit comments