Git Product home page Git Product logo

rangenettrt8's Introduction

本工程旨将rangenet工程部署到TensorRT8,ubuntu20.04中

Attention

  • 最近正在进行大幅度地改动,本仓库暂时不能很稳定地使用~
  • 由于使用了较新的API,本工程只适用于TensorRT8.2.3,但可自行查文档修改相应的API
  • 使用过conda环境的torch,然后发现速度会相对较慢(6ms->30ms)

Feature

更新的依赖和API

  • 将代码部署环境提升到TensorRT8, ubuntu20.04
  • 提供docker环境
  • 移除boost
  • 使用智能指针管理tensorrt对象和GPU显存的内存回收
  • 提供ros例程

更快的运行速度

  • 修正了使用FP16,分割精度降低的问题issue#9。使模型在保有精度的同时,预测速度大大提升
  • 使用cuda编程对数据进行预处理
  • 使用libtorch对数据进行knn后处理(参考代码here)

image-20220227223539620

TODO

  • 去掉0均值1方差的数据预处理,重新训练模型(毕竟已经有BN层了)
  • fix: 每次运行的结果不一样...(就很迷)

文件树

├── build
├── devel
├── logs
└── src
 └── RangeNetTrt8
  ├── CMakeLists.txt
  ├── CMakeLists_v2.txt
  ├── darknet53
  ├── docker
  ├── example
  ├── include
  ├── launch
  ├── LICENSE
  ├── ops
  ├── package.xml
  ├── pics
  ├── README.md
  ├── rosbag
  ├── script
  ├── src
  └── utils

方法一:docker(改进ing)

依赖

$ git clone https://github.com/Natsu-Akatsuki/RangeNetTrt8 ~/docker_ws/RangeNetTrt8/src
  • 下载onnx模型
$ wget -c https://www.ipb.uni-bonn.de/html/projects/semantic_suma/darknet53.tar.gz -O ~/docker_ws/RangeNetTrt8/src/darknet53.tar.gz
$ cd ~/docker_ws/RangeNetTrt8/src && tar -xzvf darknet53.tar.gz

安装

  • 拉取镜像(镜像大小约为20G,需预留足够的空间)
$ docker pull registry.cn-hangzhou.aliyuncs.com/gdut-iidcc/rangenet:1.0
  • 创建容器
$ cd ~/docker_ws/RanageNetTrt8/src
$ bash script/build_container_rangenet.sh

# 编译和执行
(container root) $ cd /docker_ws/RanageNetTrt8
# 编译前需加CMakelists_v2.txt改名字为CMakelists.txt
(container root) $ catkin_build
(container root) $ source devel/setup.bash

# dem01:
(container root) $ roslaunch rangenet_plusplus rangenet.launch
# 播放包(该模型仅适用于kitti数据集,需自行下载包文件和修改该launch文档)
(container root) $ roslaunch rangenet_plusplus rosbag.launch

# demo2:
# need modify the example/infer.yaml first
(container root) $ ./devel/lib/rangenet_plusplus/infer

NOTE

首次运行生成TensorRT模型运行需要一段时间

image-20220330012729619

方法二:native PC

依赖

  • ros1

  • nvidia driver

  • TensorRT 8.2.3(tar包下载), cuda_11.4.r11.4, cudnn 8.2.4

  • apt package and python package

$ sudo apt install build-essential python3-dev python3-pip apt-utils git cmake libboost-all-dev libyaml-cpp-dev libopencv-dev python3-empy
$ pip install catkin_tools trollius numpy
  • 创建工作空间
$ git clone https://github.com/Natsu-Akatsuki/RangeNetTrt8 ~/RangeNetTrt8/src
  • 下载onnx模型
$ wget -c https://www.ipb.uni-bonn.de/html/projects/semantic_suma/darknet53.tar.gz -O ~/RangeNetTrt8/src/darknet53.tar.gz
$ cd ~/RangeNetTrt8/src && tar -xzvf darknet53.tar.gz
  • 下载libtorch
$ wget -c https://download.pytorch.org/libtorch/cu113/libtorch-cxx11-abi-shared-with-deps-1.10.2%2Bcu113.zip -O libtorch.zip
$ unzip libtorch.zip

TIP: 需导入各种环境变量到~/.bashrc

# example
export PATH="/home/helios/.local/bin:$PATH"
CUDA_PATH=/usr/local/cuda/bin
TENSORRT_PATH=${HOME}/application/TensorRT-8.2.3.0/bin
CUDA_LIB_PATH=/usr/local/cuda/lib64
TENSORRT_LIB_PATH=${HOME}/application/TensorRT-8.2.3.0/lib
PYTORCH_LIB_PATH=${HOME}/application/libtorch/lib
export PATH=${PATH}:${CUDA_PATH}:${TENSORRT_PATH}
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${CUDA_LIB_PATH}:${TENSORRT_LIB_PATH}:${PYTORCH_LIB_PATH}

安装

  • 修改CMakeLists:修改其中的TensorRT, libtorch等依赖库的路径
  • 编译和执行
# 编译和执行
$ cd ~/RanageNetTrt8
$ catkin_build
$ source devel/setup.bash

# dem01:
$ roslaunch rangenet_plusplus rangenet.launch
# 播放包(该模型仅适用于kitti数据集,需自行下载包文件和修改该launch文档)
$ roslaunch rangenet_plusplus rosbag.launch

# demo2:
# need modify the example/infer.yaml first
$ ./devel/lib/rangenet_plusplus/infer

img

NOTE

首次运行生成TensorRT模型运行需要一段时间

Q&A

  • 模型解析出问题(查看是否下载的onnx模型是否完整,是否在解压缩时broken了)

[libprotobuf ERROR google/protobuf/text_format.cc:298] Error parsing text-format onnx2trt_onnx.ModelProto: 1:1: Invalid control characters encountered in text. [libprotobuf ERROR google/protobuf/text_format.cc:298] Error parsing text-format onnx2trt_onnx.ModelProto: 1:14: Message type "onnx2trt_onnx.ModelProto" has no field named "pytorch". Message type "onnx2trt_onnx.ModelProto" has no field named "pytorch"

Citations

If you use this library for any academic work, please cite the original paper.

@inproceedings{milioto2019iros,
  author    = {A. Milioto and I. Vizzo and J. Behley and C. Stachniss},
  title     = {{RangeNet++: Fast and Accurate LiDAR Semantic Segmentation}},
  booktitle = {IEEE/RSJ Intl.~Conf.~on Intelligent Robots and Systems (IROS)},
  year      = 2019,
  codeurl   = {https://github.com/PRBonn/lidar-bonnetal},
  videourl  = {https://youtu.be/wuokg7MFZyU},
}

If you use SuMa++, please cite the corresponding paper:

@inproceedings{chen2019iros, 
  author    = {X. Chen and A. Milioto and E. Palazzolo and P. Giguère and J. Behley and C. Stachniss},
  title     = {{SuMa++: Efficient LiDAR-based Semantic SLAM}},
  booktitle = {Proceedings of the IEEE/RSJ Int. Conf. on Intelligent Robots and Systems (IROS)},
  year      = {2019},
  codeurl   = {https://github.com/PRBonn/semantic_suma/},
  videourl  = {https://youtu.be/uo3ZuLuFAzk},
}

License

Copyright 2019, Xieyuanli Chen, Andres Milioto, Jens Behley, Cyrill Stachniss, University of Bonn.

This project is free software made available under the MIT License. For details see the LICENSE file.

rangenettrt8's People

Contributors

chen-xieyuanli avatar jbehley avatar kosmastsk avatar natsu-akatsuki avatar tano297 avatar

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.