Issue with running yolo v3 object detection application

Hi,

I have setup the Jetson TX2 with Jetpack 4.2 and trying to run yolo v3 object detection on this board. But i am facing this below error,

$ python3 yolo.py -i images/living_room.jpg -y yolo-coco/
[INFO] loading YOLO from disk…
OpenCV Error: Parsing error (Unknown layer type: shortcut) in ReadDarknetFromCfgFile, file /home/nvidia/build_opencv/opencv/modules/dnn/src/darknet/darknet_io.cpp, line 503
Traceback (most recent call last):
File “yolo.py”, line 38, in
net = cv2.dnn.readNetFromDarknet(configPath, weightsPath)
cv2.error: /home/nvidia/build_opencv/opencv/modules/dnn/src/darknet/darknet_io.cpp:503: error: (-212) Unknown layer type: shortcut in function ReadDarknetFromCfgFile

One more thing i notice from the error is, it is referring to “/home/nvidia” where as my home dir name on Jetson TX2 is “/home/jetson”. Is that something problem?

I have not explicitly installed opencv. I am using the opencv 3.3.1 which comes with Jetpack 4.2. Please advise and guide me to resolve this error. thanks.

Hi,

There are some limitation in the Darknet:
https://github.com/pjreddie/darknet/issues/1072#issuecomment-418523136

for Yolo v3 from Darknet - you should use OpenCV <= 3.4.0
for Yolo v3 from OpenCV  - you should use OpenCV >= 3.4.2

Based on your log, you will need to manually update OpenCV into v3.4.2 or above.
Here are our script for your reference:
https://github.com/AastaNV/JEP/blob/master/script/install_opencv4.0.0_Nano.sh

Please update the cmake command into this for TX2 GPU capacity support:

cmake -D WITH_CUDA=ON -D CUDA_ARCH_BIN="6.2" -D CUDA_ARCH_PTX="" -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.0.0/modules -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON -D BUILD_opencv_python2=ON -D BUILD_opencv_python3=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..

Thanks.

Hi,

I just built opencv as you mentioned, but i can’t import cv2 from python3. Is there any path setting issue?


– Installing: /usr/local/bin/opencv_visualisation
– Set runtime path of “/usr/local/bin/opencv_visualisation” to “/usr/local/lib:/usr/local/cuda-10.0/lib64”
– Installing: /usr/local/bin/opencv_interactive-calibration
– Set runtime path of “/usr/local/bin/opencv_interactive-calibration” to “/usr/local/lib:/usr/local/cuda-10.0/lib64”
– Installing: /usr/local/bin/opencv_version
– Set runtime path of “/usr/local/bin/opencv_version” to “/usr/local/lib:/usr/local/cuda-10.0/lib64”
** Install opencv-4.0.0 successfully
** Bye :)

jetson@jetson-desktop: ~/JEP/script
$ python3
Python 3.6.8 (default, Aug 20 2019, 17:12:48)
[GCC 8.3.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import cv2
Traceback (most recent call last):
File “”, line 1, in
ModuleNotFoundError: No module named ‘cv2’

Hi,
I have created link (cv2.so) on /usr/loal/lib and the issue is fixed. and also i can run yolo object detection application now.

But the performance or FPS is very low which 0.23 FPS.

I have measured the time for forward() call.

start = time.time()
layerOutputs = net.forward(ln)
end = time.time()

It always taking around ~4sec for every frame which is very slow. Is there any way to improve this computing performance.?

Please help!

Hi,

The pipeline is not optimized for the Jetson platform.

Are you using one of the following models? YOLOv2, YOLOv3, YOLOv2Tiny, YOLOv3Tiny
If yes, it’s recommended to try our Deepstream SDK first:
https://developer.nvidia.com/deepstream-sdk
/opt/nvidia/deepstream/deepstream-4.0/sources/objectDetector_Yolo

We got around 26 fps on the Jetson Xavier.

Thanks.

Yes, i am using Yolov3 model on my opencv based python application; Will try on your local model and update you.

Hi,

Update the software version for your reference:

Thanks.