【问题标题】:get feature vector from Fast-RCNN从 Fast-RCNN 获取特征向量
【发布时间】:2018-10-25 15:27:38
【问题描述】:

我正在尝试识别和分组相似的图像,我按照本教程进行操作:https://douglasduhaime.com/posts/identifying-similar-images-with-tensorflow.html

问题是我使用的是faster_rcnn_resnet_101,我发现fast-rcnn中的特征向量在SecondStageBoxPredictor之后被丢弃了。我使用https://gist.github.com/markdtw/02ece6b90e75832bd44787c03a664e8d 在被丢弃之前获取向量。

feat_avg = graph.get_tensor_by_name('SecondStageBoxPredictor/AvgPool:0')

np.savetxt('output1/' + "test" + '.npz',feat_vector,delimiter=',')

但是,当我尝试保存矢量时出现错误:

ValueError: Expected 1D or 2D array, got 4D array instead

我打印了提取的特征向量看看结果:

    Tensor("SecondStageFeatureExtractor/resnet_v1_101/block4/unit_3/bottleneck_v1/Relu:0", shape=(?, 7, 7, 2048), dtype=float32) 
 [[[[0.         0.         0.         ... 0.         0.
    0.        ]
   [0.         0.         0.         ... 0.         0.
    0.        ]
   [0.         0.         0.         ... 0.         0.
    0.        ]
   ...
   [2.9170244  0.         0.33220196 ... 0.         0.
    0.        ]
   [0.         0.         0.         ... 0.         0.
    0.        ]
   [0.         0.         0.         ... 0.         0.
    0.        ]].....

我是 TensorFlow 和 CV 的新手,我想做的是提取特征向量,然后使用 TSNE 聚类。 我提取的特征向量到底有什么问题

【问题讨论】:

    标签: tensorflow object-detection object-detection-api tensorflow-slim


    【解决方案1】:

    特征向量是 4D 传感器:[Batch, Height, Width, Channels]。 np.savetxt 等待一维或二维数组。您可以将特征向量切片为 2D 数组或使用其他一些功能将其保存为 4D。

    【讨论】:

      猜你喜欢
      • 2017-12-26
      • 1970-01-01
      • 2022-01-05
      • 2015-11-01
      • 1970-01-01
      • 2017-09-27
      • 2017-04-30
      • 1970-01-01
      • 2019-04-02
      相关资源
      最近更新 更多