maskrcnn_benchmark理解记录——modeling\roi_heads\box_head\roi_box_feature_extractors.py

本文详细解析了Mask R-CNN中模型的ROI Heads部分,特别是box_head的roi_box_feature_extractors.py模块。内容涉及POOLER_SCALES如何根据backbone的strides确定,以及在ResNet基础上的Faster R-CNN和Mask R-CNN中不同阶段的特征图尺寸变化。文中还讨论了RoIAlign算法的作用和在不同Head(RCNN, Mask, Keypoints)中的应用,以及最终的average pooling操作。" 115235668,1368632,PHP无限极分类实现与原理解析,"['PHP', '数据库设计', '递归算法']
摘要由CSDN通过智能技术生成

 摘取config记录如下

MODEL:
  META_ARCHITECTURE: "GeneralizedRCNN"
  WEIGHT: "catalog://ImageNetPretrained/MSRA/R-50"
  BACKBONE:
    CONV_BODY: "R-50-FPN"
  RESNETS:
    BACKBONE_OUT_CHANNELS: 256
  ROI_HEADS:
    USE_FPN: True
  ROI_BOX_HEAD:
    POOLER_RESOLUTION: 7
    POOLER_SCALES: (0.25, 0.125, 0.0625, 0.03125)
    POOLER_SAMPLING_RATIO: 2
    FEATURE_EXTRACTOR: "FPN2MLPFeatureExtractor"
    PREDICTOR: "FPNPredictor"
    NUM_CLASSES: 2
MODEL.ROI_BOX_HEAD:
    POOLER_RESOLUTION: 7
    POOLER_SCALES: (0.25, 0.125, 0.0625, 0.03125)
    POOLER_SAMPLING_RATIO: 2
    FEATURE_EXTRACTOR: "FPN2MLPFeatureExtractor"

1.关于POOLER_SCALES: (0.25, 0.125, 0.0625, 0.03125)和POOLER_SAMPLING_RATIO: 2

_C.MODEL.ROI_BOX_HEAD.POOLER_SCALES = (0.25, 0.125, 0.0625, 0.03125)

_C.MODEL.ROI_BOX_HEAD.POOLER_SAMPLING_RATIO = 2

POOLER_SCALES是由于backbone(Resnet或Resnext架构)的strides生成的不同的缩小比例,(因为后四层作RPN的,所以这里是四层# conv2_x →conv5_x 作为特征提取层 那么对应POOLER_SCALES: (0.25, 0.125, 0.0625, 0.03125) 其实是第2到5层的池化 1/4;1/8;1/16;1/32。BTW, you should understand well the ResNet and ResNeXt architectures to better understand this explanation.resnet【链接】【链接】a

例如,假设您在输入图像中找到了坐标[0,0,64,64]的RoI。 再次假设您希望从所有backbone的层pool its features (这个其实还挺好玩,常叫pool为池化,但其实是pool its features,汇集其特征。那其实pool就是一步步地聚集、提取特征)

So, since there is a stride of 2 in the conv1 layer and another stride of 2 at the end of the first block, it results in a feature-map 4x smaller than the original image, thus, a scale of 0.25(这里 是到conv2_x). Since, there is a stride of 2 between all the convolution blocks of the backbone, the scale gets divided by 2

在服务器中安装maskrcnn_benchmark通常遵循以下步骤: 1. **系统环境检查**: 确保服务器操作系统为Linux,maskrcnn_benchmark通常在Linux环境下开发和运行。 2. **安装依赖库**: maskrcnn_benchmark依赖于多个库,包括但不限于Python 3, PyTorch, torchvision, CMake等。可以通过以下命令安装: ```bash sudo apt-get update sudo apt-get install -y python3 python3-pip pip3 install torch torchvision sudo apt-get install -y libturbojpeg sudo apt-get install -y cmake ``` 3. **编译**: maskrcnn_benchmark可能需要编译某些依赖库(如Caffe2),根据其官方文档中的指南进行编译。 4. **安装maskrcnn_benchmark**: 你可以使用Python包管理工具pip来安装,或者直接从GitHub下载源代码后安装。 - 使用pip安装(如果可用): ```bash pip3 install maskrcnn_benchmark ``` - 从源代码安装: ```bash git clone https://github.com/facebookresearch/maskrcnn-benchmark.git cd maskrcnn-benchmark python setup.py build develop ``` 5. **配置环境变量**: 根据maskrcnn_benchmark的安装说明,可能还需要设置环境变量,比如设置`PYTHONPATH`环境变量指向maskrcnn_benchmark的安装路径。 ```bash export PYTHONPATH=/path/to/maskrcnn_benchmark:$PYTHONPATH ``` 6. **验证安装**: 安装完成后,可以通过运行maskrcnn_benchmark中的测试用例来验证安装是否成功。 ```bash python -m maskrcnn_benchmark.configs.vg_attr_config --test-only ``` 请注意,maskrcnn_benchmark可能依赖于一些特定版本的依赖库,因此在安装时需要严格按照其官方文档的指示操作,以确保所有依赖都是兼容的。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值