Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ IndentWidth: 2
# 连续的空行保留几行
MaxEmptyLinesToKeep: 1
# 圆括号的换行方式
BreakBeforeBraces: Custom
BreakBeforeBraces: Custom
# 是否允许短方法单行
AllowShortFunctionsOnASingleLine: false
# 支持一行的if
Expand Down Expand Up @@ -81,4 +81,4 @@ BraceWrapping:
# 分离空语句
SplitEmptyRecord: false
# 分离空命名空间
SplitEmptyNamespace: false
SplitEmptyNamespace: false
17 changes: 11 additions & 6 deletions .github/workflows/Compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@ jobs:
name: 'NvidiaGpuTensorRT'
runs-on: ubuntu-latest
container:
image: ghcr.io/teddywesside1/easy_deploy_base_dev:nvidia_gpu_tensorrt_u2204
image: ghcr.io/zz990099/easy_deploy_tool:nvidia_gpu_trt10_u2204
options:
--privileged
--ipc host
-v ${{ github.workspace }}:/workspace
-w /workspace
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Compile Codes
run:
cd /workspace &&
mkdir build && cd build &&
cmake .. -DBUILD_TESTING=ON -DENABLE_TENSORRT=ON -DENABLE_ORT=ON &&
cd /workspace &&
mkdir build && cd build &&
cmake .. -DBUILD_TESTING=ON -DENABLE_TENSORRT=ON -DENABLE_ORT=ON &&
make -j

rk3588:
Expand All @@ -33,10 +36,12 @@ jobs:
permissions:
contents: read
packages: read # 访问容器镜像仓库的权限

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive

# 启用 QEMU 虚拟化支持
- name: Set up QEMU
Expand All @@ -62,7 +67,7 @@ jobs:
--name easy_deploy_container \
--platform linux/arm64 \
-v "$PWD:/workspace" \
ghcr.io/teddywesside1/easy_deploy_base_dev:rknn_u2204 \
ghcr.io/zz990099/easy_deploy_tool:rknn_230_u2204 \
tail -f /dev/null

# ========== 编译执行阶段 ==========
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/Lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: pre-commit Checks

on:
pull_request: # 在 PR 时触发
push: # 在推送代码到 main/master 分支时触发
branches: [main, master]

jobs:
pre-commit:
name: Run pre-commit checks
runs-on: ubuntu-latest # 使用 Ubuntu 环境

steps:
- name: Checkout code
uses: actions/checkout@v4 # 检出代码

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10" # 指定 Python 版本

- name: Install pre-commit
run: pip install pre-commit # 安装 pre-commit

- name: Run pre-commit checks
run: pre-commit run --all-files # 运行所有检查
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "easy_deploy_tool"]
path = easy_deploy_tool
url = git@github.com:zz990099/EasyDeployTool.git
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
repos:
# 官方仓库中的基础钩子
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-xml
- id: check-yaml
args: ["--allow-multiple-documents"]
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
exclude_types: [rst]
- id: fix-byte-order-marker

# 运行 Uncrustify 格式化 C/C++ 代码
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: "v20.1.0" # 指定 clang-format 版本
hooks:
- id: clang-format
name: clang-format (check)
args: [--style=file, --dry-run, --Werror] # 检查模式
types: [c, c++]
15 changes: 4 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,11 @@ cmake_minimum_required(VERSION 3.8)
project(easy_deployment)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

add_subdirectory(deploy_core)
add_subdirectory(deploy_utils)

if (BUILD_TESTING)
enable_testing()
endif()

add_subdirectory(inference_core)
add_subdirectory(easy_deploy_tool)
add_subdirectory(detection_2d)

add_subdirectory(sam)

if (BUILD_TESTING)
add_subdirectory(simple_tests)
endif()
150 changes: 69 additions & 81 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,20 @@
# EasyDeploy
<!-- PROJECT LOGO -->
<br />
<div align="center">
<a href="https://github.com/zz990099/EasyDeploy">
<img src="assets/logo.gif" alt="Logo" width="240" height="160" style="animation: play 5s infinite;">
</a>

<h3 align="center">EasyDeploy</h3>

<p align="center">
Provides a easy way to deploy algorithms based on deep learning!
<br />
<a href="https://github.com/zz990099/EasyDeploy/issues/new">Report Bug or Request Feature</a>
</p>
</div>

## About The Project

The engineering deployment of deep learning algorithms relies on various inference frameworks, which often differ significantly from one another. These differences lead to low deployment and migration efficiency, especially when there is a need to support multiple hardware platforms.
This project implements several common detection and segmentation algorithms using the [EasyDeployTool](https://github.com/zz990099/EasyDeployTool) library, supporting `TensorRT`, `OnnxRuntime`, and `RKNN` inference frameworks.

The `EasyDeploy` project aims to address these challenges in two key ways:
### Models and Inference Frameworks Supported

1. **Abstracting inference framework functionalities**: By decoupling the pre-processing and post-processing procedures of algorithms from the inference process of deep learning models, `EasyDeploy` enables rapid deployment and migration of algorithms across multiple inference frameworks and hardware platforms.

2. **Asynchronous inference pipeline**: The project implements an asynchronous inference workflow, which significantly improves model inference throughput on platforms that support multi-core parallel inference.

### Features

1. Abstracting inference framework (hardware platform) characteristics to enable efficient algorithm deployment and migration.

2. Asynchronous inference pipeline to improve workflow throughput.

3. Supporting segmented and distributed model inference, enabling asynchronous inference across devices such as CPU, GPU and NPU.

### Models and Inference Frameworks Supported

- **Deployed Inference Frameworks**:
1. TensorRT
2. ONNX-Runtime
- **Deployed Inference Frameworks**:
1. TensorRT
2. ONNX-Runtime
3. RKNN

- **Deployed Algorithms**:
1. YOLOv8
2. RT-DETR
3. MobileSAM
- **Deployed Algorithms**:
1. YOLOv8
2. RT-DETR
3. MobileSAM
4. NanoSAM

## Demo test Results
Expand Down Expand Up @@ -105,46 +76,63 @@ The following test results showcase the visualized reasoning outcomes of the alg

## Getting Started

### Dependency

- The `EasyDeploy` project is entirely written in C++ and built using the CMake tool. It relies on the following dependencies:
- **OpenCV**
- **CMake**
- **glog**
- **GoogleTest**
- Specific dependencies for each **inference framework**

### Environment Build
- Follow [EnvironmentSetup](doc/EnviromentSetup.md) to setup enviroment with scripts quickly.

## What You Could Do With This Project

EasyDeploy aims to minimize the impact of inference framework-specific characteristics on the deployment of deep learning algorithms. To achieve this, we have developed an abstract base class named BaseInferCore and created specialized base classes for certain types of algorithms, such as 2D detection and instance segmentation.

Additionally, EasyDeploy provides an asynchronous inference pipeline to further enhance deployment efficiency.

With these features, EasyDeploy offers the following capabilities:

- **Direct use of pre-implemented algorithms**:
- If you need to directly use algorithms such as YOLOv8, RT-DETR, MobileSAM or NanoSAM, EasyDeploy has already implemented and optimized their deployment.
- [QuickStart](doc/QuickStart.md) may help.

- **Deploying a new algorithm efficiently**:
- If you need to deploy a new algorithm without worrying about the specific implementation details of inference frameworks, or if you want to easily migrate your algorithm to other inference frameworks, the BaseInferCore abstract base class can help you quickly implement and migrate the algorithm.
- [HowToDeployModels](doc/HowToDeployModels.md) may help.

- **Migrating algorithms to a new inference framework**:
- If you want to migrate algorithms based on BaseInferCore to a new inference framework, implementing a subclass of BaseInferCore will allow you to migrate all algorithms to the new framework with ease.
- [HowToDeployModels](doc/HowToDeployModels.md) may help.

- **Improving inference throughput**:
- If you need to increase the throughput of algorithm inference, EasyDeploy provides an asynchronous inference pipeline. For certain algorithm types (e.g., 2D detection, SAM), asynchronous base classes are already available, enabling you to boost the throughput of your models with minimal effort.

- **Segmented distributed asynchronous inference**:
- If you need to implement simple segmented, distributed, asynchronous inference for algorithms, the abstract base classes and asynchronous pipeline features provided in EasyDeploy make it easy to achieve this functionality.

## Todo

- [ ] Use `rga` library on rk3588 to do image pre-process.
- [x] Update ONNX-Runtime inference core code and test it out.
- [x] Test TensorRT inference framework on jetson platform.
### Download Project

Clone the git repository:
```bash
git clone git@github.com:zz990099/EasyDeploy.git
cd EasyDeploy
git submodule init && git submodule update
```

### Build Enviroment

Set up the working environment using Docker:
```bash
cd EasyDeploy
bash easy_deploy_tool/docker/easy_deploy_startup.sh
# Select `jetson` -> `trt10_u2204`/`trt8_u2204`
bash easy_deploy_tool/docker/into_docker.sh
```

### Compile Codes

Inside the Docker container, compile the project. Use the `-DENABLE_*` flags to enable specific inference frameworks. Available options: `-DENABLE_TENSORRT=ON`, `-DENABLE_ORT=ON`, `-DENABLE_RKNN=ON` (compatible with each other).
```bash
cd /workspace
mdkir build && cd build
cmake .. -DBUILD_TESTING=ON -DENABLE_TENSORRT=ON # -DENABLE_RKNN=ON
make -j
```

### Convert Model

1. Download models from [Google Drive](https://drive.google.com/drive/folders/1yVEOzo59aob_1uXwv343oeh0dTKuHT58?usp=drive_link) and place them in `/workspace/models/`.

2. Inside the Docker container, run the model conversion script:
```bash
cd /workspace
bash tools/cvt_onnx2trt.sh
# bash tools/cvt_onnx2rknn_all.sh
```

### Run Test Cases

1. Execute test cases (refer to the code for details):
```bash
cd /workspace/build
# List available test cases
ctest -N
# List available test cases
ctest
```

## References

- [ultralytics](https://github.com/ultralytics/ultralytics)
- [ultralytics-rknn](https://github.com/airockchip/ultralytics_yolov8/blob/main/RKOPT_README.md)
- [rt-detr](https://github.com/lyuwenyu/RT-DETR)
- [sam](https://github.com/facebookresearch/segment-anything)
- [mobilesam](https://github.com/ChaoningZhang/MobileSAM)
- [nanosam](https://github.com/NVIDIA-AI-IOT/nanosam)
- [EasyDeployTool](https://github.com/zz990099/EasyDeployTool)
33 changes: 0 additions & 33 deletions deploy_core/CMakeLists.txt

This file was deleted.

Loading