object_detection and instance segmentation with tensorflow mask rcnn network

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 文件

  1. 配置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
  1. 安装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
  1. 修改 /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
    )
  1. 下载Mster-RCNN 资源,并export to PYTHONPATH.

    git clone https://github.com/matterport/Mask_RCNN.git
    export PYTHONPATH=$PYTHONPATH:$PWD/Mask_RCNN
    
  2. 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 -
    
  3. 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.

  4. 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
    
  5. 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值