zoukankan      html  css  js  c++  java
  • mask-rcnn代码解读(四):rpn_feature_maps数据的处理

    此处模拟 rpn_feature_maps数据的处理,最终得到rpn_class_logits, rpn_class, rpn_bbox。

    代码如下:

    import numpy as np
    '''
    层与层之间主要是中间变量H与W不一致,则此处模拟2层,分别改为8与4
    '''
    # 模拟某层,如p3
    a1=np.ones((3,8,2)) # rpn_class_logits
    b1=np.ones((3,8,2)) # rpn_class
    c1=np.ones((3,8,4)) # rpn_bbox
    # 模拟某层,如p4
    a2=np.ones((3,4,2)) # rpn_class_logits
    b2=np.ones((3,4,2)) #rpn_class
    c2=np.ones((3,4,4)) #rpn_bbox
    layer_outputs = []
    '''
    以下模拟此处代码,得到layer_outputs:
    for p in rpn_feature_maps:
    layer_outputs.append(rpn([p]))
    '''
    d1=[a1,b1,c1]
    d2=[a2,b2,c2]
    layer_outputs.append(d1)
    layer_outputs.append(d2)
    '''
    outputs = list(zip(*layer_outputs))
    '''
    output_names = ["rpn_class_logits", "rpn_class", "rpn_bbox"] # 可跳过
    outputs = list(zip(*layer_outputs))
    print('outputs',outputs)
    '''
    此处模拟以下代码,最终得到rpn_class_logits, rpn_class, rpn_bbox值
    outputs = [KL.Concatenate(axis=1, name=n)(list(o)) for o, n in zip(outputs, output_names)]
    '''
    rpn_class_logits = np.concatenate((list(outputs[0])[0],list( outputs[0])[1]),axis=1)
    print('rpn_class_logits=',rpn_class_logits)
    rpn_class = np.concatenate((list(outputs[1])[0],list( outputs[1])[1]),axis=1)
    print('rpn_class=',rpn_class)
    rpn_bbox=np.concatenate((list(outputs[2])[0],list( outputs[2])[1]),axis=1)
    print('rpn_bbox=',rpn_bbox)


    结果如下:

    outputs [(array([[[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]],

    [[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]],

    [[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]]]), array([[[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]],

    [[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]],

    [[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]]])), (array([[[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]],

    [[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]],

    [[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]]]), array([[[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]],

    [[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]],

    [[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]]])), (array([[[1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.]],

    [[1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.]],

    [[1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.]]]), array([[[1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.]],

    [[1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.]],

    [[1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.]]]))]
    rpn_class_logits= (array([[[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]],

    [[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]],

    [[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]]]), array([[[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]],

    [[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]],

    [[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]]]))
    rpn_class= (array([[[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]],

    [[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]],

    [[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]]]), array([[[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]],

    [[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]],

    [[1., 1.],
    [1., 1.],
    [1., 1.],
    [1., 1.]]]))
    rpn_bbox= (array([[[1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.]],

    [[1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.]],

    [[1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.]]]), array([[[1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.]],

    [[1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.]],

    [[1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.],
    [1., 1., 1., 1.]]]))
    rpn_bbox= [[[1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]]

    [[1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]]

    [[1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]
    [1. 1. 1. 1.]]]





  • 相关阅读:
    组合数学——cf893E
    前缀和+贪心+线段树——cf893D
    期望线性性+线段树双tag标记——cf895E
    状压dp+数论——cf895C好题!
    官方资料&一些好的博客与技术点
    批处理小技巧总结
    使用 SP_OAXXX 创建文件夹,注意区别于 xp_cmdshell --mkdir xxx
    第一次使用并配置Hibernate
    做一个有心人
    强说愁
  • 原文地址:https://www.cnblogs.com/tangjunjun/p/11966802.html
Copyright © 2011-2022 走看看