参考博客:

http://blog.csdn.net/abc8730866/article/details/52522843

http://blog.csdn.net/lijiancheng0614/article/details/48180331

 

编译出extract_features.exe模块

caffe提取每一层中的特征,在matlab或python查看

在×64、Release模式下编译生成extract_features.exe

 

将某一层的特征向量生成lmdb文件

在caffe工程的examples下新建一个文件夹,命名为_temp

caffe提取每一层中的特征,在matlab或python查看

 

 将examplesimages下的图片写成一个文本文档,命名为file_list.txt,放在_temp文件夹下

caffe提取每一层中的特征,在matlab或python查看

将examples/eature_extraction/imagenet_val.prototxt复制到之前新建的_temp文件夹。

 打开imagenet_val.prototxt,修改以下file_list.txt的路径,对应准确即可:

 caffe提取每一层中的特征,在matlab或python查看

在modelsbvlc_reference_caffenet目录中,下载bvlc_reference_caffenet.caffemodel文件

 

在caffe根目录下,新建bat脚本,

Buildx64Releaseextract_features.exe models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel examples/_temp/imagenet_val.prototxt fc7 examples/_temp/features 10 lmdb
pause

可以在examples/_temp/features中生成提取的lmdb文件

caffe提取每一层中的特征,在matlab或python查看

 

将lmdb文件转化为mat文件

feat_helper_pb2.py

# Generated by the protocol buffer compiler.  DO NOT EDIT!


from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import descriptor_pb2

# @@protoc_insertion_point(imports)



DESCRIPTOR = descriptor.FileDescriptor(
  name='datum.proto',
  package='feat_extract',
  serialized_pb='nx0bx64x61tum.protox12x0cx66x65x61t_extract"inx05x44x61tumx12x10nx08x63hannelsx18x01 x01(x05x12x0enx06heightx18x02 x01(x05x12rnx05widthx18x03 x01(x05x12x0cnx04x64x61tax18x04 x01(x0cx12rnx05labelx18x05 x01(x05x12x12nnfloat_datax18x06 x03(x02')


_DATUM = descriptor.Descriptor(
  name='Datum',
  full_name='feat_extract.Datum',
  filename=None,
  file=DESCRIPTOR,
  containing_type=None,
  fields=[
    descriptor.FieldDescriptor(
      name='channels', full_name='feat_extract.Datum.channels', index=0,
      number=1, type=5, cpp_type=1, label=1,
      has_default_value=False, default_value=0,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      options=None),
    descriptor.FieldDescriptor(
      name='height', full_name='feat_extract.Datum.height', index=1,
      number=2, type=5, cpp_type=1, label=1,
      has_default_value=False, default_value=0,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      options=None),
    descriptor.FieldDescriptor(
      name='width', full_name='feat_extract.Datum.width', index=2,
      number=3, type=5, cpp_type=1, label=1,
      has_default_value=False, default_value=0,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      options=None),
    descriptor.FieldDescriptor(
      name='data', full_name='feat_extract.Datum.data', index=3,
      number=4, type=12, cpp_type=9, label=1,
      has_default_value=False, default_value="",
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      options=None),
    descriptor.FieldDescriptor(
      name='label', full_name='feat_extract.Datum.label', index=4,
      number=5, type=5, cpp_type=1, label=1,
      has_default_value=False, default_value=0,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      options=None),
    descriptor.FieldDescriptor(
      name='float_data', full_name='feat_extract.Datum.float_data', index=5,
      number=6, type=2, cpp_type=6, label=3,
      has_default_value=False, default_value=[],
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      options=None),
  ],
  extensions=[
  ],
  nested_types=[],
  enum_types=[
  ],
  options=None,
  is_extendable=False,
  extension_ranges=[],
  serialized_start=29,
  serialized_end=134,
)

DESCRIPTOR.message_types_by_name['Datum'] = _DATUM

class Datum(message.Message):
  __metaclass__ = reflection.GeneratedProtocolMessageType
  DESCRIPTOR = _DATUM

  # @@protoc_insertion_point(class_scope:feat_extract.Datum)


# @@protoc_insertion_point(module_scope)

View Code