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.]]]





  • 相关阅读:
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    白盒,单元测试
    向数据库添加100W 条数据 性能测试
    软件测试
    软件需求工程-产品经理该如何更好地记录反馈、捕捉需求?
    Spring,Spring MVC,MyBatis,Hibernate总结
    Java基础总结
    Java8新特性_四大内置核心函数式接口
    Lambda表达式及相关练习
    Java 8新特性(Lambda,Stream API)
  • 原文地址:https://www.cnblogs.com/tangjunjun/p/11966802.html
Copyright © 2011-2022 走看看