All Projects → grimoire → Mmdetection To Tensorrt

grimoire / Mmdetection To Tensorrt

Licence: apache-2.0
convert mmdetection model to tensorrt, support fp16, int8, batch input, dynamic shape etc.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Mmdetection To Tensorrt

Paddledetection
Object Detection toolkit based on PaddlePaddle. It supports object detection, instance segmentation, multiple object tracking and real-time multi-person keypoint detection.
Stars: ✭ 5,799 (+2113.36%)
Mutual labels:  object-detection, ssd, yolov3, faster-rcnn
Fastmot
High-performance multiple object tracking based on YOLO, Deep SORT, and optical flow
Stars: ✭ 284 (+8.4%)
Mutual labels:  object-detection, ssd, yolov3
Pytorchnethub
项目注释+论文复现+算法竞赛
Stars: ✭ 341 (+30.15%)
Mutual labels:  ssd, yolov3, faster-rcnn
Bmw Yolov4 Inference Api Cpu
This is a repository for an nocode object detection inference API using the Yolov4 and Yolov3 Opencv.
Stars: ✭ 180 (-31.3%)
Mutual labels:  object-detection, yolov3, inference
Traffic Sign Detection
Traffic Sign Detection. Code for the paper entitled "Evaluation of deep neural networks for traffic sign detection systems".
Stars: ✭ 200 (-23.66%)
Mutual labels:  object-detection, ssd, faster-rcnn
Rectlabel Support
RectLabel - An image annotation tool to label images for bounding box object detection and segmentation.
Stars: ✭ 338 (+29.01%)
Mutual labels:  object-detection, ssd, faster-rcnn
Object Detection Api
Yolov3 Object Detection implemented as APIs, using TensorFlow and Flask
Stars: ✭ 177 (-32.44%)
Mutual labels:  object-detection, yolov3, inference
Tf Object Detection
Simpler app for tensorflow object detection API
Stars: ✭ 91 (-65.27%)
Mutual labels:  object-detection, ssd, faster-rcnn
Tensornets
High level network definitions with pre-trained weights in TensorFlow
Stars: ✭ 982 (+274.81%)
Mutual labels:  object-detection, yolov3, faster-rcnn
Trainyourownyolo
Train a state-of-the-art yolov3 object detector from scratch!
Stars: ✭ 399 (+52.29%)
Mutual labels:  object-detection, yolov3, inference
Bmw Labeltool Lite
This repository provides you with a easy to use labeling tool for State-of-the-art Deep Learning training purposes.
Stars: ✭ 145 (-44.66%)
Mutual labels:  object-detection, yolov3, inference
Mmdetection
OpenMMLab Detection Toolbox and Benchmark
Stars: ✭ 17,646 (+6635.11%)
Mutual labels:  object-detection, ssd, faster-rcnn
Yolov3 Object Detection With Opencv
This project implements a real-time image and video object detection classifier using pretrained yolov3 models.
Stars: ✭ 191 (-27.1%)
Mutual labels:  object-detection, yolov3
Frcnn
Faster R-CNN / R-FCN 💡 C++ version based on Caffe
Stars: ✭ 183 (-30.15%)
Mutual labels:  object-detection, yolov3
Py R Fcn Multigpu
Code for training py-faster-rcnn and py-R-FCN on multiple GPUs in caffe
Stars: ✭ 192 (-26.72%)
Mutual labels:  object-detection, faster-rcnn
Yolov3 Tf2
YoloV3 Implemented in Tensorflow 2.0
Stars: ✭ 2,327 (+788.17%)
Mutual labels:  object-detection, yolov3
Pine
🌲 Aimbot powered by real-time object detection with neural networks, GPU accelerated with Nvidia. Optimized for use with CS:GO.
Stars: ✭ 202 (-22.9%)
Mutual labels:  object-detection, yolov3
Yolov4 Custom Functions
A Wide Range of Custom Functions for YOLOv4, YOLOv4-tiny, YOLOv3, and YOLOv3-tiny Implemented in TensorFlow, TFLite, and TensorRT.
Stars: ✭ 199 (-24.05%)
Mutual labels:  object-detection, yolov3
Yolodet Pytorch
reproduce the YOLO series of papers in pytorch, including YOLOv4, PP-YOLO, YOLOv5,YOLOv3, etc.
Stars: ✭ 206 (-21.37%)
Mutual labels:  object-detection, yolov3
Luminoth
Deep Learning toolkit for Computer Vision.
Stars: ✭ 2,386 (+810.69%)
Mutual labels:  object-detection, faster-rcnn

MMDet to tensorrt

This project aims to convert the mmdetection model to tensorrt model end2end.
Focus on object detection for now.
Mask support is experiment.

support:

  • fp16
  • int8(experiment)
  • batched input
  • dynamic input shape
  • combination of different modules
  • deepstream support

Any advices, bug reports and stars are welcome.

License

This project is released under the Apache 2.0 license.

Requirement

Important!

Set the envoirment variable(in ~/.bashrc):

export AMIRSTAN_LIBRARY_PATH=${amirstan_plugin_root}/build/lib

Installation

Host

git clone https://github.com/grimoire/mmdetection-to-tensorrt.git
cd mmdetection-to-tensorrt
python setup.py develop

Docker

Build docker image(Note that TensorRT7.0 might have memory leak, better to upgrade to 7.1+)

# cuda10.2 tensorrt7.0 pytorch1.6
sudo docker build -t mmdet2trt_docker:v1.0 docker/

Run (will show the help for the CLI entrypoint)

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:

sudo docker run --gpus all -it --rm -v ${your_data_path}:${bind_path} --entrypoint bash mmdet2trt_docker:v1.0

Example conversion:

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

how to create a tensorrt model from mmdet model (converting might take few minutes)(Might have some warning when converting.)
detail can be found in getting_started.md

CLI

mmdet2trt ${CONFIG_PATH} ${CHECKPOINT_PATH} ${OUTPUT_PATH}

Run mmdet2trt -h for help on optional arguments.

Python

opt_shape_param=[
    [
        [1,3,320,320],      # min shape
        [1,3,800,1344],     # optimize shape
        [1,3,1344,1344],    # max shape
    ]
]
max_workspace_size=1<<30    # some module and tactic need large workspace.
trt_model = mmdet2trt(cfg_path, weight_path, opt_shape_param=opt_shape_param, fp16_mode=True, max_workspace_size=max_workspace_size)
torch.save(trt_model.state_dict(), save_path)

how to use the converted model

trt_model = init_detector(save_path)
num_detections, trt_bbox, trt_score, trt_cls = inference_detector(trt_model, image_path, cfg_path, "cuda:0")

how to save the tensorrt engine

with open(engine_path, mode='wb') as f:
    f.write(model_trt.state_dict()['engine'])

note that the bbox inference result did not divided by scale factor, divided by you self if needed.

play demo in demo/inference.py

getting_started.md for more detail

How does it works?

Most other project use pytorch=>ONNX=>tensorRT route, This repo convert pytorch=>tensorRT directly, avoid unnecessary ONNX IR. read https://github.com/NVIDIA-AI-IOT/torch2trt#how-does-it-work for detail.

Support Model/Module

  • [x] Faster R-CNN
  • [x] Cascade R-CNN
  • [x] Double-Head R-CNN
  • [x] Group Normalization
  • [x] Weight Standardization
  • [x] DCN
  • [x] SSD
  • [x] RetinaNet
  • [x] Libra R-CNN
  • [x] FCOS
  • [x] Fovea
  • [x] CARAFE
  • [x] FreeAnchor
  • [x] RepPoints
  • [x] NAS-FPN
  • [x] ATSS
  • [x] PAFPN
  • [x] FSAF
  • [x] GCNet
  • [x] Guided Anchoring
  • [x] Generalized Attention
  • [x] Dynamic R-CNN
  • [x] Hybrid Task Cascade
  • [x] DetectoRS
  • [x] Side-Aware Boundary Localization
  • [x] YOLOv3
  • [x] PAA
  • [ ] CornerNet(WIP)
  • [x] Generalized Focal Loss
  • [x] Grid RCNN
  • [x] VFNet
  • [x] GROIE
  • [x] Mask R-CNN(experiment)
  • [x] Cascade Mask R-CNN(experiment)
  • [x] Cascade RPN
  • [x] DETR

Tested on:

  • torch=1.6.0
  • tensorrt=7.1.3.4
  • mmdetection=2.10.0
  • cuda=10.2
  • cudnn=8.0.2.39

If you find any error, please report in the issue.

FAQ

read this page if you meet any problem.

Contact

This repo is maintained by @grimoire

Discuss group: QQ:1107959378

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].