This project is a high-performance C++ implementation for real-time object detection using RF DETR. It leverages TensorRT for optimized inference and CUDA for accelerated processing, enabling efficient detection on both images and videos. Designed for maximum speed and accuracy, this implementation ensures seamless integration with RF-DETR model, making it suitable for deployment in research, production, and real-time applications.
Google Colab Support: To make GPU-based inference more accessible, a fully configured Google Colab notebook is provided. This notebook allows users to run the entire project from start to finish using a Google Colab T4 GPU, including compiling and executing C++ code directly in Colab. This is especially helpful for those who struggle with local GPU availability.
Note: The Google Colab notebook is not meant for performance testing, as the performance will be poor. It is intended for learning how to integrate C++, TensorRT, and CUDA.
- TensorRT Integration: Optimized deep learning inference using NVIDIA TensorRT, ensuring high-speed execution on GPU.
- Efficient Memory Management: Uses CUDA buffers and TensorRT engine caching for improved performance.
- Real-Time Inference: Supports image and video processing, allowing smooth detection across frames.
- Custom Preprocessing & Postprocessing: Handles image normalization, tensor conversion, and result decoding directly in CUDA for minimal overhead.
- High-Performance Video Processing: Efficiently processes video streams using OpenCV while maintaining low-latency inference with TensorRT.
- Google Colab Support: A ready-to-use Google Colab Notebook is provided to run the project in Google Colab, enabling easy setup and execution without requiring a local GPU.
Before building the project, ensure that the following dependencies are installed on your system:
- C++ Compiler: Compatible with C++17 or higher.
- CMake: Version 3.12 or higher.
- CUDA: Version 12.4 .
- TensorRT: Tested with TensorRT 10.8.0 for high-performance inference.
- OpenCV: Version 4.5.4 or higher for image and video processing.
Generate the onnx version of the RF-DETR model, You can use the same way defined in the official repo RF-DETR.
Clone the repository to your local machine:
git https://github.com/mohamedsamirx/RF-DETR-TensorRT-CPP.git
cd RF-DETR-TensorRT-CPP
Ensure that OpenCV and TensorRT are installed. Set the correct paths for these libraries in the CMakeLists.txt
file.
mkdir build && cd build
cmake ..
cmake --build . --config Release
Convert the ONNX model to a TensorRT engine:
./rfdetr-tensorrt rfdetr.onnx ""
Perform object detection on an image:
./rfdetr-tensorrt rfdetr.engine "zidane.jpg"
Perform object detection on a video:
./rfdetr-tensorrt rfdetr.engine "road.mp4"
This project is licensed under the Apache 2.0 license. See the LICENSE file for details.