1 main component
- ResizeNearset: nearest neighbor interpolation for resizing features. 适用于(FPN-功能金字塔)模块
- ProposalLayer:根据RPN(region proposal network)输出[scores, bbox_deltas] 和anchors生成first stage’s proposals。
- PyramidROIAlign:从相应的feature layer 中裁剪并调整ROI要素(first stage’s propsals) 的大小
- DetectionLayer:优化第一阶段的proposals,并生成最终检测结果
- SpecialSlice:一个变通(workaround)插件,用于将检测输出[y1,x1,y2,x2,class_id,score]切片到[y1,x1,y2,x2],用于多个索引维度的数据 (batch_idx, proposal_idx, detections(y1, x1, y2, x2)).
2 生成uff 文件
- 配置19.10-py3 tensorflow container
docker run --rm -it --gpus all -v $TRT_SOURCE:/workspace/TensorRT -v $TRT_RELEASE:/tensorrt nvcr.io/nvidia/tensorflow:19.10-py3 /bin/bash
- 安装requirements和uff toolkit, graphSurgeon
cd /workspace/TensorRT/samples/opensource/sampleUffMaskRCNN/converted/
pip3 install -r requirements.txt
pip3 install /tensorrt/uff/uff-*-py2.py3-none-any.whl
pip3 install /tensorrt/graphsurgeon/graphsurgeon-*-py2.py3-none-any.whl
- 修改
/usr/lib/python3.6/dist-packages/uff/converters/tensorflow/converter_functions.py
中的conv2d_transpose
方程
uff_graph.conv_transpose(
inputs[0], inputs[2], inputs[1],
strides, padding,
dilation=None, number_groups=number_groups,
left_format=lhs_fmt, right_format=rhs_fmt,
name=name, fields=fields
)
-
下载Mster-RCNN 资源,并export to
PYTHONPATH
.git clone https://github.com/matterport/Mask_RCNN.git export PYTHONPATH=$PYTHONPATH:$PWD/Mask_RCNN
-
Apply the patch into Mask R-CNN repo to update the model from NHWC to NCHW.
cd Mask_RCNN git checkout 3deaec5 patch -p1 < ../0001-Update-the-Mask_RCNN-model-from-NHWC-to-NCHW.patch cd -
-
Download the pre-trained Keras model
wget https://github.com/matterport/Mask_RCNN/releases/download/v2.0/mask_rcnn_coco.h5
Note: The md5sum of model file is e98aaff6f99e307b5e2a8a3ff741a518.
-
Convert the h5 model to the UFF model and copy it to your data folder
python3 mrcnn_to_trt_single.py -w mask_rcnn_coco.h5 -o mrcnn_nchw.uff -p ./config.py
-
Populate your
/data
folder with the following test images./usr/src/tensorrt/data/faster-rcnn/001763.ppm /usr/src/tensorrt/data/faster-rcnn/004545.ppm
3 run and coding
make and run