Code Monkey home page Code Monkey logo

yolo-darknet-on-jetson-tx2's Introduction

YOLO-darknet-on-Jetson-TX2 and on-Jetson-TX1

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

alt text

How to run YOLO on Jetson TX2

After boot (Jetpack 3.1) and install OPENCV...

Copy original Yolo repository:

$ git clone https://github.com/pjreddie/darknet.git

$ cd darknet

$ sudo sed -i 's/GPU=0/GPU=1/g' Makefile

$ sudo sed -i 's/CUDNN=0/CUDNN=1/g' Makefile

$ sudo sed -i 's/OPENCV=0/OPENCV=1/g' Makefile

$ make -j4

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.

$ wget https://pjreddie.com/media/files/yolo.weights

$ wget https://pjreddie.com/media/files/tiny-yolo-voc.weights

For TX1 and change the batch size and subdivisions if you run out od memory:

$ sudo nano cfg/yolov3.cfg

increase the batch size and reduce the subdivisions:

#batch=64 batch=32 #subdvisions=16 subdivisions=32

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:

overclock

$ sudo ./jetson_clocks.sh

$ ./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"

Or if you wan to run using tiny-yolo only need to change

$ ./darknet detector test cfg/voc.data cfg/tiny-yolo-voc.cfg tiny-yolo-voc.weights 

Run in videos


$ ./darknet detector demo cfg/coco.data cfg/yolo.cfg yolo.weights data/<file-name>

Run in image


$ ./darknet detect cfg/yolo.cfg yolo.weights data/<file-name>

I recommend to take a look...https://pjreddie.com/darknet/yolo/ for more details of YOLO!

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. See this videos:

https://www.youtube.com/watch?v=ZpQgRdg8RmA&t=4s

YOLOV3 on Jetson TX2 (last update)

alt text

After boot Jetson TX2 with Jetpack 3.2 (CUDA 9 and cuDNN 7) and install openCV (https://github.com/AlexanderRobles21/OpenCVTX2)

Build darknet:


$ git clone https://github.com/pjreddie/darknet.git

$ cd darknet

$ sudo sed -i 's/GPU=0/GPU=1/g' Makefile

$ sudo sed -i 's/CUDNN=0/CUDNN=1/g' Makefile

$ sudo sed -i 's/OPENCV=0/OPENCV=1/g' Makefile

$ make -j4

Download weights


$ wget https://pjreddie.com/media/files/yolov3.weights

$ wget https://pjreddie.com/media/files/yolov3-tiny.weights

Run on JETSON TX2 using onboard cam

For yolov3:


$ ./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"

Performance: 2-4fps

For tiny-yolov3:


$ ./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"

You are able to change the resolution just modify this part: width=(int)1280, height=(int)720.

Performance: 12fps

Using usb webcam:


$ ./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights /dev/video1

This information was useful for your project? Consider to cite my repository!

yolo-darknet-on-jetson-tx2's People

Contributors

alro10 avatar cyborg-girl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

yolo-darknet-on-jetson-tx2's Issues

pkg_config_path issue

Salut,

I am currently trying to implement object detection using darknet on JetsonTX2 Development Board.

I builded opencv using "https://github.com/raspberry-pi-maker/NVIDIA-Jetson". After building process I can import cv2 and getBuildInformation succesfully. Now my next step is to implement object detection with darknet and yolo.

However,eventough I can import opencv in python codes during the compilation process of the darknet I face with

gcc -Iinclude/ -Isrc/ -DOPENCV `pkg-config --cflags opencv`  -DGPU -I/usr/local/cuda/include/ -DCUDNN  -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -DOPENCV -DGPU -DCUDNN -c ./src/gemm.c -o obj/gemm.o
gcc -Iinclude/ -Isrc/ -DOPENCV `pkg-config --cflags opencv`  -DGPU -I/usr/local/cuda/include/ -DCUDNN  -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -DOPENCV -DGPU -DCUDNN -c ./src/utils.c -o obj/utils.o
gcc -Iinclude/ -Isrc/ -DOPENCV `pkg-config --cflags opencv`  -DGPU -I/usr/local/cuda/include/ -DCUDNN  -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -DOPENCV -DGPU -DCUDNN -c ./src/cuda.c -o obj/cuda.o
gcc -Iinclude/ -Isrc/ -DOPENCV `pkg-config --cflags opencv`  -DGPU -I/usr/local/cuda/include/ -DCUDNN  -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -DOPENCV -DGPU -DCUDNN -c ./src/deconvolutional_layer.c -o obj/deconvolutional_layer.o
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable

when I check my enviroment variables I can not see any PKG_CONFIG_PATH
also installation of opencv did not produce opencv.pc file anywhere in jetson.

memory usage

Hello, can you tell me the memory usage of yolo v3 on TX2? Thanks a lot

Tx2 Onboard camera issue

Hi!
I'm working on running yolo on Tx2 Dev kit. I have installed all of requirements for yolo, OpenCV, CUDA, Cudnn.
I've tested if the onboard camera's working via gstreamer : gst-launch-1.0 nvarguscamerasrc ! nvvidconv ! xvimagesink
It works properly.
Then, I tried to run yolo by your code ./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"
The result is "Video-stream stopped!"
How could i track the issue?
Thanks!

jetson in built cam with darknet

./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"

is throwing the following error
Couldn't connect to webcam.
: No such file or directory
darknet: ./src/utils.c:256: error: Assertion `0' failed.

Run Onboard Camera on Jetson

Hey Alex,

thanks for your great github.

But unfortuantely the command for running the onboard camera on the jetson tx2 does not longer work.

Could you update it?

Would be awesome, thanks!

Gustav

overclock

Hi there!

thanks for the nice walkthrough.
I found that you can even speed up yolo by overclocking the Jetson.
See this forum thread for reference.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.