├── LICENSE ├── README.md ├── jetsontx2.jpg └── output1.jpg /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Alexander Robles 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # YOLO-darknet-on-Jetson-TX2 and on-Jetson-TX1 2 | 3 | Yolo darknet is an amazing algorithm that uses deep learning for real-time object detection but needs a good GPU, many CUDA cores. For **Jetson TX2 and TX1 I would like to recommend to you use this repository if you want to achieve better performance, more fps, and detect more objects [real-time object detection on Jetson TX2](https://github.com/Alro10/realtime_object_detection)** 4 | 5 |

6 | alt text 7 |

8 | 9 | 10 | ## How to run YOLO on Jetson TX2 11 | 12 | After boot (Jetpack 3.1) and install OPENCV... 13 | 14 | Copy original Yolo repository: 15 | 16 | $ git clone https://github.com/pjreddie/darknet.git 17 | 18 | $ cd darknet 19 | 20 | $ sudo sed -i 's/GPU=0/GPU=1/g' Makefile 21 | 22 | $ sudo sed -i 's/CUDNN=0/CUDNN=1/g' Makefile 23 | 24 | $ sudo sed -i 's/OPENCV=0/OPENCV=1/g' Makefile 25 | 26 | $ make -j4 27 | 28 | You will have to download the pre-trained weight file yolo.weights or tiny-yolo but this is much faster but less accurate than the normal YOLO model. 29 | 30 | $ wget https://pjreddie.com/media/files/yolo.weights 31 | 32 | $ wget https://pjreddie.com/media/files/tiny-yolo-voc.weights 33 | 34 | For TX1 and change the batch size and subdivisions if you run out od memory: 35 | 36 | $ sudo nano cfg/yolov3.cfg 37 | 38 | increase the batch size and reduce the subdivisions: 39 | 40 | #batch=64 41 | batch=32 42 | #subdvisions=16 43 | subdivisions=32 44 | 45 | ### How to run YOLO using onboard camara Jetson TX2? It's a really hard question, I needed to find many sites but I found the right solution: 46 | 47 | *overclock* 48 | ``` 49 | $ sudo ./jetson_clocks.sh 50 | 51 | $ ./darknet detector demo cfg/coco.data cfg/yolo.cfg yolo.weights "nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720,format=(string)I420, framerate=(fraction)30/1 ! nvvidconv flip-method=0 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink" 52 | ``` 53 | Or if you wan to run using tiny-yolo only need to change 54 | 55 | ``` 56 | $ ./darknet detector test cfg/voc.data cfg/tiny-yolo-voc.cfg tiny-yolo-voc.weights 57 | 58 | ``` 59 | 60 | Run in videos 61 | 62 | ``` 63 | 64 | $ ./darknet detector demo cfg/coco.data cfg/yolo.cfg yolo.weights data/ 65 | 66 | ``` 67 | 68 | Run in image 69 | 70 | ``` 71 | 72 | $ ./darknet detect cfg/yolo.cfg yolo.weights data/ 73 | 74 | ``` 75 | 76 | I recommend to take a look...https://pjreddie.com/darknet/yolo/ for more details of YOLO! 77 | 78 | I think it is important to install a SSD and setup to work as the root directory. Also build a kernel and extra modules, you can do the last recommendation after o before build and run YOLO. Jetson only has 32gb. 79 | See this videos: 80 | 81 | https://www.youtube.com/watch?v=ZpQgRdg8RmA&t=4s 82 | 83 | 84 | # YOLOV3 on Jetson TX2 (last update) 85 | 86 |

87 | alt text 88 |

89 | 90 | 91 | After boot Jetson TX2 with Jetpack 3.2 (CUDA 9 and cuDNN 7) and install openCV (https://github.com/AlexanderRobles21/OpenCVTX2) 92 | 93 | ## Build darknet: 94 | 95 | ``` 96 | 97 | $ git clone https://github.com/pjreddie/darknet.git 98 | 99 | $ cd darknet 100 | 101 | $ sudo sed -i 's/GPU=0/GPU=1/g' Makefile 102 | 103 | $ sudo sed -i 's/CUDNN=0/CUDNN=1/g' Makefile 104 | 105 | $ sudo sed -i 's/OPENCV=0/OPENCV=1/g' Makefile 106 | 107 | $ make -j4 108 | 109 | ``` 110 | 111 | ## Download weights 112 | 113 | ``` 114 | 115 | $ wget https://pjreddie.com/media/files/yolov3.weights 116 | 117 | $ wget https://pjreddie.com/media/files/yolov3-tiny.weights 118 | 119 | ``` 120 | 121 | ## Run on JETSON TX2 using onboard cam 122 | 123 | ### For yolov3: 124 | 125 | ``` 126 | 127 | $ ./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights "nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720,format=(string)I420, framerate=(fraction)30/1 ! nvvidconv flip-method=0 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink" 128 | 129 | ``` 130 | 131 | **Performance: 2-4fps** 132 | 133 | 134 | ### For tiny-yolov3: 135 | 136 | ``` 137 | 138 | $ ./darknet detector demo cfg/coco.data cfg/yolov3-tiny.cfg yolov3-tiny.weights "nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720,format=(string)I420, framerate=(fraction)30/1 ! nvvidconv flip-method=0 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink" 139 | 140 | ``` 141 | 142 | You are able to change the resolution just modify this part: **width=(int)1280, height=(int)720**. 143 | 144 | **Performance: 12fps** 145 | 146 | ### Using usb webcam: 147 | 148 | ``` 149 | 150 | $ ./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights /dev/video1 151 | 152 | ``` 153 | 154 | *This information was useful for your project? Consider to cite my repository!* 155 | 156 | -------------------------------------------------------------------------------- /jetsontx2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alro10/YOLO-darknet-on-Jetson-TX2/b54a352d1265ea241445a36177950785626b4621/jetsontx2.jpg -------------------------------------------------------------------------------- /output1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alro10/YOLO-darknet-on-Jetson-TX2/b54a352d1265ea241445a36177950785626b4621/output1.jpg --------------------------------------------------------------------------------