Skip to content

IRCVLab/Yolov8n-for-jetson-traffic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Screenshot from 2024-05-03 11-12-06

YOLOv8-for-Jetson-Orin-traffic

Before you go

This code is for Jetpack 5.1.3, so ENSURE that your jetson is using Jetpack 5.1.3

  • Jetpack 6.0 will work too but compatible with another version of Pytorch(2.1.0) & Torchvision(0.16.1)
  • So if you are in Jetpack 6.0, edit these versions in "startup.sh"

Version differences of main packages are described in appendix for someone in need

Virtual Environment User

If you are going to use this code in virtual environment, please check your OpenCV build informantion in your virtual environment(NOT HOST)

$ python3
$ >>> import cv2
$ >>> print(cv2.getBuildInformation())

From this information, you can run this code if only "GStreamer" is "YES"

  • If this is "NO", then you should use your host environment

Please check your host environment OpenCV too for sure

  • SDK will automatically installed OpenCV with GStreamer "YES"
  • But if it says "NO" in host environment, you may install "opencv-python" additionally so uninstall it
pip3 uninstall opencv-python

Start Up (DO NOT USE sudo FOR startup.sh)

Preparing environmet for running YOLOv8 in Jetson, using CSI Camera

OpenCV 4.5.4 (SDK already installed it for you)
GStreamer 1.16.3 (SDK already installed it for you)
Pytorch 1.13.0
Torchvision 0.14.1
ultralytics 8.1.37
onnx 1.16.0
numpy 1.20.3

Installation of Pytorch and Torchvision are from https://forums.developer.nvidia.com/t/pytorch-for-jetson/72048

DO NOT USE 'sudo' command

  • Since we build torchvision from source, if you execute startup.sh with sudo, torchvision will be accessible only with sudo command
sh startup.sh 

Demo Setup Description

This code is using YOLOv8 model for demonstration

Image Setting

Capture Width = 1920
Capture Height = 1080
Display Width = 640
Display Height = 360

Error Handling
For generality there are some "rm" and "export" command to cope with some errors may occur

  • Cannot allocate memory in static TLS block

For these error, we have to preload modules "libgstnvarguscamerasrc.so" and "libgstnvvidconv.so"

  • Stalled when building GStreamer pipeline

There are some cases that GStreamer register "libgstnvarguscamerasrc.so" to its BLACKLIST.
With this situation, demo.sh will just stunned with no error message which makes you suffer.
To solve this problem, we should remove GStreamer cache.

Model Setting

  • 5 classes to predict ( 'bus', 'crosswalk', 'left', 'right', 'straight' )
  • There is only one Original model available

Demonstration

After running "startup.sh" please reboot your jetson for safety.

  • Original: YOLOv8n model for detecting traffic sign from ultralytics package
  • Framerate: Recommanded about 15~25
sh demo.sh Original {FRAMERATE}  

Appendix

Jetpack 5.1.3

Ubuntu: 20.04
Linux kernel: 5.10 LTS
OS: L4T 35.5.0
CUDA: 11.4.19
cuDNN: 8.6.0
TensorRT 8.5.2
VPI: 2.4
OpenCV: 4.5.4
GStreamer: 1.16.3
Python2: 2.7.18
Python3: 3.8.10

Jetpack 6.0

Ubuntu: 22.04
Linux kernel: 5.15 LTS
OS: L4T 36.2
CUDA: 12.2.12
cuDNN: 8.9.4
TensorRT 8.6.2
VPI: 3.0
OpenCV: 4.8.0
GStreamer: 1.16.3
Python2: 2.7.18
Python3: 3.10.12

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published