yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
Transbot SE📖
01.Introduction to Transbot SE
  • 01. Introduction to Transbot SE
  • 02. Precautions for use and battery safety
  • 03. First Trial
02.First Trial
  • 2.1.APP control
  • 2.2.USB wireless handle control(Optional)
  • 2.3.Handle video control Transbot(Optional)
  • 2.4.Network configuration tutorial in hotspot mode
03.Hardware control course
  • 3.1About expansion board and update firmware
  • 3.2.Close self-starting process
  • 3.3.Install Transbot library
  • 3.4.Control buzzer and button
  • 3.5.Control PWM servo
  • 3.6.Control bus servo
  • 3.7.Control motor
  • 3.8.Control robot movement
04.Linux operating system
  • 1. Virtual machine installation and use
  • 2. Linux basics
  • 3. Remote control
  • 4. Multi-machine communication configuration
  • 5. Static IP and hotspot mode
  • 6. Web page real-time monitoring
  • 7. Expansion tutorial
  • 8. Write system images
05.Docker couse(For Pi5)
  • 1.Docker overview and docker installation
  • 2.Common commands for docker image containers
  • 3.Docker images deeply understand and publish images
  • 4.Docker hardware interaction and data processing
  • 5.Start the transbot se container
06.ROS basic course
  • 1.ROS introduction
  • 2.Project file structure
  • 3.Common commands and tools
  • 4.Publisher
  • 5.Subscribers
  • 6.Customize topic messages and use
  • 7.Client
  • 8.Server
  • 9.Custom service messages and usage
  • 10.TF release and monitoring
07.OpenCV courses
  • 1. Getting started with Open Source CV
  • 2. Open Source CV geometric transformation
  • 3. Open Source CV image processing and drawing text line segments
  • 4. Open Source CV image beautification
  • 5. Opencv application
  • 6. AR vision
  • 7. AR QR code
  • 8. ROS+Opencv foundation
  • 9. ROS+Opencv application
  • 10. MediaPipe development
08.ROS robot course
  • 1.PID algorithm
  • 2.Basic communication
  • 3.Keyboard control
  • 4.Handle control(Optional)
  • 5.Robot state estimation
  • 6.Data calibration
09.ROS simple camera course
  • 1.HD camera calibration
  • 2.HD camera color tracking
  • 3.HD camera color tracking (robotic arm)
  • 4.HD camera object tracking
  • 5. KCF target tracking
  • 6.HD camera face tracking
  • 7.HD camera robotic arm carrying
  • 8.HD camera Autopilot
10.ROS robotic arm control tutorial
  • 1.MoveIt configuration
  • 2.MoveIt control the real machine
  • 3.MoveIt moves randomly
  • 4.MoveIt kinematics design
  • 5.MoveIt cartesian path
  • 6.MoveIt avoiding
  • 7.MoveIt scene design
  • 8.MoveIt trajectory planning
  • 9.Mediapipe palm control car
  • 10.Mediapipe gesture control robotic arm
  • 11.Mediapipe gesture control car
  • 12.Mediapipe arm attitude control robotic arm
11.ROS multi-robot control(Optional)
  • 1. Multi-robot control(Optional)
  • 2. Multi-robot queue performance(Optional)
  • 3. Multi-robot robot arm dancing(Optional)
12.Deep learning courses
  • 1.KNN recognizes handwritten digits
  • 2.Basic use of TensorFlow
  • 3.Basic use of PyTorch(jetson)
  • 4.yolov5 model training(jetson)
  • 5.yolov5+tensorrt acceleration(jetson)
  • 6.yolov4-tiny
13.Installation Video
  • Part18
  • Part1-6
  • Part7-12
  • Part13.1-13.3.3
  • Part13.4.1-17
14.FAQnew
  • 1.Using your own Jetson board,Transbot-SE cannot start normally
Download
  • APP(iOS/Android)
  • System_File-Pi5
  • System_File-Pi4
  • System_File-Jetson
  • VM_File
  • Appendix
  • Code
  • InstructionManual
  • Jetson_Boot_USB.tar.gz
  • Hardware_Info
Download ZIP

Welcome to Transbot SE repository

5.yolov5+tensorrt acceleration(jetson)

5 Yolov5+tensorrt acceleration(jetson)

5 Yolov5+tensorrt acceleration(jetson) 5.1 Introduction 5.2 tensorrt deployment process 5.2.1 Generate .wts file 5.2.2 Generate .engine file 5.2.3 Test 5.3 ROS deployment 5.4 Use

tensorrt source code: https://github.com/wang-xinyu/tensorrtx

Official installation tutorial: https://docs.nvidia.com/deeplearning/tensorrt/install-guide/index.html

Official tutorial: https://docs.nvidia.com/deeplearning/tensorrt/developer-guide/index.html

5.1 Introduction

TensorRT is a high-performance deep learning inference(Inference) optimizer that provides low-latency, high-throughput deployment inference for deep learning applications. TensorRT can be used to accelerate inference in hyperscale data centers, embedded platforms, or autonomous driving platforms. TensorRT can now support almost all deep learning frameworks such as TensorFlow, Caffe, Mxnet, Pytorch, etc. The combination of TensorRT and NVIDIA GPU can perform fast and efficient deployment inference in almost all frameworks.

Can TensorRT accelerate the model?

can!According to official documents, using TensorRT, it can provide 10X or even 100X acceleration in CPU or GPU mode. TensorRT provides 20X speedup.

TensorRT is only responsible for the inference process of the model and optimizes the trained model. Generally, TensorRT is not used to train the model. tensorRT is just an inference optimizer. After your network is trained, you can directly drop the training model file into tensorRT without relying on the deep learning framework(Caffe, TensorFlow, etc.), as follows:

1351

1352

It can be considered that tensorRT is a deep learning framework with only forward propagation. This framework can parse the network models of Caffe and TensorFlow, and then map them one by one with the corresponding layers in tensorRT, and convert all the models of other frameworks into tensorRT. Then in tensorRT, you can implement optimization strategies for NVIDIA's own GPUs and accelerate deployment.

5.2 tensorrt deployment process

5.2.1 Generate .wts file

For example: yolov5s.wts

Copy tensorrtx_yolov5_jetson/gen_wts.py and [yolov5-5.0/weights/yolov5s.pt] weight file(or the weight file downloaded by Baidu, take [yolov5s.pt] as an example)) to [~/software/yolov5-5.0 ] folder, and execute gen_wts.py in this directory to generate the .wts file.

python3 gen_wts.py -w yolov5s.pt 

Copy the generated [yolov5s.wts] file to the tensorrtx_yolov5_jetson directory, and compile tensorrtx in this directory

xxxxxxxxxx
mkdir build && cd build && cmake .. 

Change CLASS_NUM in yololayer.h to yours. Because the official data set is coco, the default is 80.

Execute makeFile. (make once every time it is modified to CLASS_NUM)

xxxxxxxxxx
make -j4 

5.2.2 Generate .engine file

Generate .engine file(I use yolov5s, so end with s)

xxxxxxxxxx
sudo ./yolov5 -s ../yolov5s.wts yolov5s.engine s 

If you customize depth_multiple and width_multiple during training, just write:

xxxxxxxxxx
sudo ./yolov5 -s ../yolov5.wts yolov5.engine c 0.33 0.5 

The P6 model of yolov5 was also updated in tensorrtx 5.0

xxxxxxxxxx
sudo ./yolov5 -s ../yolov5.wts yolov5.engine s6 

5.2.3 Test

Test it with the pictures that come with it(there are two pictures in the samples)

xxxxxxxxxx
sudo ./yolov5 -d yolov5s.engine ../samples 

You can test it with a python file, you need to create a yaml file.

For example: coco.yaml

xxxxxxxxxx
PLUGIN_LIBRARY : libmyplugins.so              # plugin library 
engine_file_path : yolov5s.engine             # engine file path 
CONF_THRESH : 0.5                             # CONF threshold 
IOU_THRESHOLD : 0.4                           # IOU threshold 
categories : [ "person", "bicycle", ... ...] # Identify categories 

test

xxxxxxxxxx
cd .. 
python3 yolov5.py 

5.3 ROS deployment

Copy the generated [yolov5s.engine] and [libmyplugins.so] files to the [yahboomcar_yolov5] function package [param/nano4G] folder, for example:

xxxxxxxxxx
yahboomcar_yolov5 
    ├──  CMakeLists.txt 
    ├──  launch 
    │    └──  yolodetect.launch 
    ├──  package.xml 
    ├──  param 
    │    ├──  coco.yaml 
    │    ├──  nano4G 
    │    │    ├──  libmyplugins.so 
    │    │    └──  yolov5s.engine 
    │    └──  nx 
    │        ├──  libmyplugins.so 
    │        └──  yolov5s.engine 
    └──  scripts 
        └──  yolov5.py 

When using, follow the operation steps of [5.4].

write yaml file

For example: coco.yaml

xxxxxxxxxx
PLUGIN_LIBRARY : libmyplugins.so              # plugin library 
engine_file_path : yolov5s.engine             # engine file path 
CONF_THRESH : 0.5                             # CONF threshold 
IOU_THRESHOLD : 0.4                           # IOU threshold 
categories : [ "person", "bicycle", ... ...] # Identify categories 

If the file name changes, you need to modify the [yolov5.py] file and open it in the file path

xxxxxxxxxx
sudo vim ~/yahboomcar_ws/src/yahboomcar_yolov5/scripts/yolov5.py 

As follows

xxxxxxxxxx
class  YoloDetect : 
     def __init__(self): 
        rospy.on_shutdown(self.cancel) 
        rospy.init_node("YoloDetect", anonymous = False) 
        self.pTime  =  self.cTime  =  0 
        device  =  rospy.get_param("~device", "nano4G") 
        param_  =  rospkg.RosPack(). get_path("yahboomcar_yolov5")  +  '/param/'  
        file_yaml  =  param_  +  'coco.yaml' 
        PLUGIN_LIBRARY  =  param_  +  device  +  "/libmyplugins.so" 
        engine_file_path  =  param_  +  device  +  "/yolov5s.engine" 
        self.yolov5_wrapper  =  YoLov5TRT(file_yaml, PLUGIN_LIBRARY, engine_file_path) 
        self.pub_image  =  rospy.Publisher('Detect/image_msg', Image_Msg, queue_size = 10) 
        self.pub_msg  =  rospy.Publisher('DetectMsg', TargetArray, queue_size = 10) 

The parameters of [file_yaml], [PLUGIN_LIBRARY], and [engine_file_path] should correspond one-to-one with the used names.

5.4 Use

xxxxxxxxxx
roslaunch  yahboomcar_yolov5  yolodetect.launch  device:=nano4G  display:=true 
  • [device] parameter: the main control device of the robot, for example: nano4G, nx, etc.
  • [display] parameter: whether to enable the visual interface.

Support real-time monitoring of web pages, such as:

xxxxxxxxxx
# Query the webpage IP and port based on the information prompted after running the ROS node
# It is usually the local IP, and the default is 0.0.0.0:8080 if the IP is not found
192.168.2.89:8080 

img2023-04-07 16-59-57

View node information

xxxxxxxxxx
rqt_graph 

1353

Print detection information

xxxxxxxxxx
rostopic echo/DetectMsg 

print as follows

xxxxxxxxxx
data :  
  -  
    frame_id :  "tv" 
    stamp :  
      secs :  1646123012 
      nsecs :  116803169 
    scores :  0.754247903824 
    ptx :  106.302101135 
    pty :  121.952651978 
    distw : 144.548706055 
    disth : 90.0989227295 
    centerx :  72.2743530273 
    centery :  45.0494613647 
  • frame_id: Identifying name.
  • scores: Identify scores.
  • ptx, pty: the coordinates of the upper left corner of the recognition box.
  • distw, disth: The width and height of the recognition box.
  • centerx, centery: Identify the center.
yolov5 model training(jetson)
yolov4-tiny

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文