MaskRCNN RPN网络分析

MaskRCNN RPN网络分析在每个锚生成5种大小和3种形状的候选框(每层特征对应一种大小,每个锚点对应3种形状)。并进行两层卷积后,做前景与背景的分类,与候选框的偏移量回归。与目标重叠>=0.7则为前景,与目标重叠<=0.3则为背景,其余框去掉。#############################################################RegionPropos…

大家好,又见面了,我是你们的朋友全栈君。

è¿éåå¾çæè¿°

在每个锚生成5种大小和3种形状的候选框(每层特征对应一种大小,每个锚点对应3种形状)。并进行两层卷积后,做前景与背景的分类,与候选框的偏移量回归。与目标重叠> = 0.7则为前景,与目标重叠<= 0.3则为背景,其余框去掉。

############################################################
#  Region Proposal Network (RPN)
############################################################

def rpn_graph(feature_map, anchors_per_location, anchor_stride):
    """Builds the computation graph of Region Proposal Network.

    feature_map: backbone features [batch, height, width, depth]
    anchors_per_location: number of anchors per pixel in the feature map
    anchor_stride: Controls the density of anchors. Typically 1 (anchors for
                   every pixel in the feature map), or 2 (every other pixel).

    Returns:
        rpn_class_logits: [batch, H * W * anchors_per_location, 2] Anchor classifier logits (before softmax)
        rpn_probs: [batch, H * W * anchors_per_location, 2] Anchor classifier probabilities.
        rpn_bbox: [batch, H * W * anchors_per_location, (dy, dx, log(dh), log(dw))] Deltas to be
                  applied to anchors.
    """
    # TODO: check if stride of 2 causes alignment issues if the feature map
    # is not even.
    # Shared convolutional base of the RPN
    # 对特征图做一个(3, 3)卷积,结果大小[batch, height, width, depth]
    shared = KL.Conv2D(512, (3, 3), padding='same', activation='relu',
                       strides=anchor_stride,
                       name='rpn_conv_shared')(feature_map)

    # Anchor Score. [batch, height, width, anchors per location * 2].
    # anchors_per_location=3,3种锚点比例
    x = KL.Conv2D(2 * anchors_per_location, (1, 1), padding='valid',
                  activation='linear', name='rpn_class_raw')(shared)

    # Reshape to [batch, anchors, 2]
    # 背景和前景做分类
    rpn_class_logits = KL.Lambda(
        lambda t: tf.reshape(t, [tf.shape(t)[0], -1, 2]))(x)

    # Softmax on last dimension of BG/FG.
    # 分类 背景和前景,做softmax处理
    rpn_probs = KL.Activation(
        "softmax", name="rpn_class_xxx")(rpn_class_logits)

    # Bounding box refinement. [batch, H, W, anchors per location * depth]
    # where depth is [x, y, log(w), log(h)]
    # 边框优化,activation='linear'线性激活函数
    x = KL.Conv2D(anchors_per_location * 4, (1, 1), padding="valid",
                  activation='linear', name='rpn_bbox_pred')(shared)

    # Reshape to [batch, anchors, 4]
    # 4个框坐标
    rpn_bbox = KL.Lambda(lambda t: tf.reshape(t, [tf.shape(t)[0], -1, 4]))(x)

    return [rpn_class_logits, rpn_probs, rpn_bbox]


def build_rpn_model(anchor_stride, anchors_per_location, depth):
    """Builds a Keras model of the Region Proposal Network.
    It wraps the RPN graph so it can be used multiple times with shared
    weights.

    anchors_per_location: number of anchors per pixel in the feature map
    anchor_stride: Controls the density of anchors. Typically 1 (anchors for
                   every pixel in the feature map), or 2 (every other pixel).
    depth: Depth of the backbone feature map.

    Returns a Keras Model object. The model outputs, when called, are:
    rpn_class_logits: [batch, H * W * anchors_per_location, 2] Anchor classifier logits (before softmax)
    rpn_probs: [batch, H * W * anchors_per_location, 2] Anchor classifier probabilities.
    rpn_bbox: [batch, H * W * anchors_per_location, (dy, dx, log(dh), log(dw))] Deltas to be
                applied to anchors.
    """
    input_feature_map = KL.Input(shape=[None, None, depth],
                                 name="input_rpn_feature_map")
    outputs = rpn_graph(input_feature_map, anchors_per_location, anchor_stride)
    return KM.Model([input_feature_map], outputs, name="rpn_model")

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/152323.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • jmeter正则提取器用法_jmeter字符串截取

    jmeter正则提取器用法_jmeter字符串截取JMeter正则表达式提取器 转自:http://desert3.iteye.com/blog/1394934//提取HTML中隐藏域的值^(.*)$ //提取整个response返回提取MyLabel关联的input的值MyLabel”(.+:create:.+?)”  //提取下面link的href的值JSESSIONI

    2022年9月10日
    0
  • n皇后问题-回溯法求解[通俗易懂]

    n皇后问题-回溯法求解[通俗易懂]n皇后问题-回溯法求解1.算法描述在n×n格的国际象棋上摆放n个皇后,使其不能互相攻击,即任意两个皇后都不能处于同一行、同一列或同一斜线上,问有多少种摆法。n皇后是由八皇后问题演变而来的。该问题是国际西洋棋棋手马克斯·贝瑟尔于1848年提出:在8×8格的国际象棋上摆放八个皇后,使其不能互相攻击,即任意两个皇后都不能处于同一行、同一列或同一斜线上,问有多少种摆法。高斯认为有76…

    2022年9月30日
    0
  • JWT的权限控制与Shiro入门

    JWT的权限控制与Shiro入门

    2021年11月12日
    45
  • 芯片行业未来_为什么中国没有自己的芯片架构

    芯片行业未来_为什么中国没有自己的芯片架构【CSDN编者按】随着设备扩展带来的效益越来越少,人们开始设计内置AI的系统,以在本地处理更多数据。芯片制造商正在研究一种新的结构,这种结构能够显著增加每能耗和每个时钟周…

    2022年9月7日
    0
  • Android UI设计

    Android UI设计UI概述1、在Android应用中,UI(UserInterface)界面是人与手机之间数据传递、交互信息的重要媒介和对话接中。2、Android程序开发最重要的一个环节就是界面处理,界面的美观度直接影响用户的第一印象,因此,开发一个整齐、美观的界面是至关重要的。3、Android应用的界面是由View和ViewGroup对象构建而成的。View类是Android系统平台上用户界面表示的基本单元,View的一些子类被统称为Widgets(工具),它们提供了诸如文本输入框和按钮之类的UI对象

    2022年6月29日
    24
  • 根文件系统使用登录模式「建议收藏」

    根文件系统使用登录模式

    2022年1月30日
    47

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号