Skip to content

Commit d9e2cbc

Browse files
SsisyphusTaochandler
andauthored
add centernet dla34 ctdet task. (wang-xinyu#558)
* add centernet dla34 ctdet task. * update readme. * update readme and fix a bug in sample. Co-authored-by: chandler <[email protected]>
1 parent 1457e6f commit d9e2cbc

File tree

9 files changed

+1808
-0
lines changed

9 files changed

+1808
-0
lines changed

centernet/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# CenterNet
2+
3+
This is the trt implementation of detection model [ctdet_coco_dla_2x](https://drive.google.com/open?id=1pl_-ael8wERdUREEnaIfqOV_VF2bEVRT) from [xingyizhou/CenterNet](https://github.com/xingyizhou/CenterNet) official work.
4+
5+
## How to Run
6+
7+
1. Follow [NVIDIA/TensorRT](https://github.com/NVIDIA/TensorRT) tutorial to build TensorRT7
8+
9+
2. Copy folder `dcnv2Plugin` to `TensorRT/plugin` and edit `InferPlugin.cpp` and `CMakeLists.txt`
10+
11+
3. Rebuild to install custom plugin
12+
13+
4. Use `tensorrt-7.2.3.4-cp36-none-linux_x86_64.whl` in TensorRT OSS to update your python-tensorrt
14+
15+
5. Run `python centernet.py -m ${PTH_PATH} -s` to create trt engine
16+
17+
## Sample
18+
19+
```
20+
// Download ctdet_coco_dla_2x.pth and transfer it into trt engine first
21+
// Download the test img from https://raw.githubusercontent.com/tensorflow/models/master/research/deeplab/g3doc/img/image2.jpg or choose your own one
22+
cd sample
23+
python test.py ${ENGINE_PATH} ${IMG_PATH}
24+
```
25+
![trt_out](https://user-images.githubusercontent.com/47047345/119128637-7a878900-ba68-11eb-91ff-5dcc10f01b77.jpg)
26+
27+
## TODO
28+
29+
Integrate the post process with trt engine to make it more easier to use.

centernet/centernet.py

Lines changed: 333 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
file(GLOB SRCS *.cpp)
17+
set(PLUGIN_SOURCES ${PLUGIN_SOURCES} ${SRCS})
18+
set(PLUGIN_SOURCES ${PLUGIN_SOURCES} PARENT_SCOPE)
19+
file(GLOB CU_SRCS *.cu)
20+
set(PLUGIN_CU_SOURCES ${PLUGIN_CU_SOURCES} ${CU_SRCS})
21+
set(PLUGIN_CU_SOURCES ${PLUGIN_CU_SOURCES} PARENT_SCOPE)

centernet/dcnv2Plugin/dcn_v2_im2col_cuda.cu

Lines changed: 399 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*!
2+
******************* BEGIN Caffe Copyright Notice and Disclaimer ****************
3+
*
4+
* COPYRIGHT
5+
*
6+
* All contributions by the University of California:
7+
* Copyright (c) 2014-2017 The Regents of the University of California (Regents)
8+
* All rights reserved.
9+
*
10+
* All other contributions:
11+
* Copyright (c) 2014-2017, the respective contributors
12+
* All rights reserved.
13+
*
14+
* Caffe uses a shared copyright model: each contributor holds copyright over
15+
* their contributions to Caffe. The project versioning records all such
16+
* contribution and copyright details. If a contributor wants to further mark
17+
* their specific copyright on a particular contribution, they should indicate
18+
* their copyright solely in the commit message of the change when it is
19+
* committed.
20+
*
21+
* LICENSE
22+
*
23+
* Redistribution and use in source and binary forms, with or without
24+
* modification, are permitted provided that the following conditions are met:
25+
*
26+
* 1. Redistributions of source code must retain the above copyright notice, this
27+
* list of conditions and the following disclaimer.
28+
* 2. Redistributions in binary form must reproduce the above copyright notice,
29+
* this list of conditions and the following disclaimer in the documentation
30+
* and/or other materials provided with the distribution.
31+
*
32+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
36+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
39+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42+
*
43+
* CONTRIBUTION AGREEMENT
44+
*
45+
* By contributing to the BVLC/caffe repository through pull-request, comment,
46+
* or otherwise, the contributor releases their content to the
47+
* license and copyright terms herein.
48+
*
49+
***************** END Caffe Copyright Notice and Disclaimer ********************
50+
*
51+
* Copyright (c) 2018 Microsoft
52+
* Licensed under The MIT License [see LICENSE for details]
53+
* \file modulated_deformable_im2col.h
54+
* \brief Function definitions of converting an image to
55+
* column matrix based on kernel, padding, dilation, and offset.
56+
* These functions are mainly used in deformable convolution operators.
57+
* \ref: https://arxiv.org/abs/1811.11168
58+
* \author Yuwen Xiong, Haozhi Qi, Jifeng Dai, Xizhou Zhu, Han Hu
59+
*/
60+
61+
/***************** Adapted by Charles Shang *********************/
62+
63+
#ifndef DCN_V2_IM2COL_CUDA
64+
#define DCN_V2_IM2COL_CUDA
65+
66+
// #ifdef __cplusplus
67+
// extern "C"
68+
// {
69+
// #endif
70+
71+
void modulated_deformable_im2col_cuda(cudaStream_t stream,
72+
const float *data_im, const float *data_offset, const float *data_mask,
73+
const int batch_size, const int channels, const int height_im, const int width_im,
74+
const int height_col, const int width_col, const int kernel_h, const int kenerl_w,
75+
const int pad_h, const int pad_w, const int stride_h, const int stride_w,
76+
const int dilation_h, const int dilation_w,
77+
const int deformable_group, float *data_col);
78+
79+
void modulated_deformable_col2im_cuda(cudaStream_t stream,
80+
const float *data_col, const float *data_offset, const float *data_mask,
81+
const int batch_size, const int channels, const int height_im, const int width_im,
82+
const int height_col, const int width_col, const int kernel_h, const int kenerl_w,
83+
const int pad_h, const int pad_w, const int stride_h, const int stride_w,
84+
const int dilation_h, const int dilation_w,
85+
const int deformable_group, float *grad_im);
86+
87+
void modulated_deformable_col2im_coord_cuda(cudaStream_t stream,
88+
const float *data_col, const float *data_im, const float *data_offset, const float *data_mask,
89+
const int batch_size, const int channels, const int height_im, const int width_im,
90+
const int height_col, const int width_col, const int kernel_h, const int kenerl_w,
91+
const int pad_h, const int pad_w, const int stride_h, const int stride_w,
92+
const int dilation_h, const int dilation_w,
93+
const int deformable_group,
94+
float *grad_offset, float *grad_mask);
95+
96+
// #ifdef __cplusplus
97+
// }
98+
// #endif
99+
100+
#endif

0 commit comments

Comments
 (0)