1、加载网络模型,model_file是网络文件(*.prototext), weights_file是权值文件(*.caffemodel),初始化net_。

追踪caffemodel的读取

2、查找CopyTrainedLayersFrom函数,在net.cpp中,明显caffemodel是二进制文件,会执行CopyTrainedLayersFromBinaryProto函数。

追踪caffemodel的读取

3、查找CopyTrainedLayersFromBinaryProto函数,就在CopyTrainedLayersFrom函数下面。明显这里要查看ReadNetParamsFromBinaryFileOrDie函数,会返回param(NetParameter是Message的继承类,Message是Google Protobuf的数据结构)。

追踪caffemodel的读取

4、查找ReadNetParamsFromBinaryFileOrDie函数,在upgrade_proto.cpp中,里面重要的是ReadProtoFromBinaryFile函数。

追踪caffemodel的读取

5、查找ReadProtoFromBinaryFile函数,在io.hpp,是个内联函数,可以继续追踪ReadProtoFromBinaryFile函数。

追踪caffemodel的读取

6、继续追踪ReadProtoFromBinaryFile函数,在io.cpp中。

filename是caffemodel文件名,fd是文件描述符,ZeroCopyInputStream是Protobuf的类,是为了减小内存的拷贝,再转为CodedInputStream,下面就是最后的ParseFromCodedStream,这是Protobuf的分析函数,有兴趣可以去分析Protobuf的底层源码,但是注释不多。

追踪caffemodel的读取

相关文章:

  • 2021-08-10
  • 2021-05-04
  • 2021-07-18
  • 2022-01-21
  • 2021-10-31
猜你喜欢
  • 2021-06-20
  • 2021-07-13
  • 2022-12-23
  • 2021-09-12
  • 2021-04-27
  • 2021-12-17
  • 2021-06-09
相关资源
相似解决方案