Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
convert mmdetection model to tensorrt, support fp16, int8, batch input, dynamic shape etc.
| Date | Stars |
|---|---|
| 2026-07-24 | 597 |
| 2026-07-25 | 597 |
| 2026-07-28 | 597 |
| 2026-07-30 | 597 |
| 2026-08-06 | 597 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# MMDet to TensorRT
> [!NOTE]
>
> The main branch is used to support model conversion of MMDetection>=3.0.
> If you want to convert model on older MMDetection, Please switch to branch:
> - [mmdet2trt=v0.5.0](https://github.com/grimoire/mmdetection-to-tensorrt/tree/v0.5.0)
> - [torch2trt_dynamic=v0.5.0](https://github.com/grimoire/torch2trt_dynamic/tree/v0.5.0)
> - [amirstan_plugin=v0.5.0](https://github.com/grimoire/amirstan_plugin/tree/v0.5.0).
## News
- 2024.02: Support MMDetection>=3.0
## Introduction
This project aims to support End2End deployment of models in MMDetection with TensorRT.
Mask support is **experiment**.
Features:
- fp16
- int8(experiment)
- batched input
- dynamic input shape
- combination of different modules
- DeepStream
## Requirement
- install MMDetection:
```bash
pip install openmim
mim install mmdet==3.3.0
```
- install [torch2trt_dynamic](https://github.com/grimoire/torch2trt_dynamic):
```bash
git clone https://github.com/grimoire/torch2trt_dynamic.git torch2trt_dynamic
cd torch2trt_dynamic
pip install -e .
```
- install [amirstan_plugin](https://github.com/grimoire/amirstan_plugin):
- Install tensorrt: [TensorRT](https://developer.nvidia.com/tensorrt)
- clone repo and build plugin
```bash
git clone --depth=1 https://github.com/grimoire/amirstan_plugin.git
cd amirstan_plugin
git submodule update --init --progress --depth=1
mkdir build
cd build
cmake -DTENSORRT_DIR=${TENSORRT_DIR} ..
make -j10
```
> [!NOTE]
>
> **DON'T FORGET** setting the environment variable(in `~/.bashrc`):
>
> ```bash
> export AMIRSTAN_LIBRARY_PATH=${amirstan_plugin_root}/build/lib
> ```
## Installation
### Host
```bash
git clone https://github.com/grimoire/mmdetection-to-tensorrt.git
cd mmdetection-to-tensorrt
pip install -e .
```
### Docker
Build docker image
```bash
sudo docker build -t mmdet2trt_docker:v1.0 docker/
```
Run (will show the help for the CLI entrypoint)
```bash
sudo docker run --gpus all -it --rm -v ${your_data_path}:${bind_path} mmdet2trt_docker:v1.0
```
Or if you want to open a terminal inside de container:
```bash
sudo docker run --gpus all -it --rm -v ${your_data_path}:${bind_path} --entrypoint bash mmdet2trt_docker:v1.0
```
Example conversion:
```bash
sudo docker run --gpus all -it --rm -v ${your_data_path}:${bind_path} mmdet2trt_docker:v1.0 ${bind_path}/config.py ${bind_path}/checkpoint.pth ${bind_path}/output.trt
```
## Usage
Create a TensorRT model from mmdet model.
detail can be found in [getting_started.md](./docs/getting_started.md)
### CLI
```bash
# conversion might take few minutes.
mmdet2trt ${CONFIG_PATH} ${CHECKPOINT_PATH} ${OUTPUT_PATH}
```
Run mmdet2trt -h for help on optional arguments.
### Python
```python
shape_ranges=dict(
x=dict(
min=[1,3,320,320],
opt=[1,3,800,1344],
max=[1,3,1344,1344],
)
)
trt_model = mmdet2trt(cfg_path,
weight_path,
shape_ranges=shape_ranges,
fp16_mode=True)
# save converted model
torch.save(trt_model.state_dict(), save_model_path)
# save engine if you want to use it in c++ api
with open(save_engine_path, mode='wb') as f:
f.write(trt_model.state_dict()['engine'])
```
> [!NOTE]
>
> The input of the engine is the tensor **after preprocess**.
> The output of the engine is `num_dets, bboxes, scores, class_ids`. if you enable the `enable_mask` flag, there will be another output `mask`.
> The bboxes output of the engine did not divided by `scale_factor`.
how to perform inference with the converted model.
```python
from mmdet.apis import inference_detector
from mmdet2trt.apis import create_wrap_detector
# create wrap detector
trt_detector = create_wrap_detector(trt_model, cfg_path, device_id)
# result share same format as mmdetection
result = inference_detector(trt_detector, image_path)
```
Try demo in `demo/inference.py`, or `demo/Excerpt of 5,411 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:cafe1e76412149b2, topic:inference, topic:tensorrt
matched fp:cafe1e76412149b2, topic:object-detection