1.先将caffe/src/caffe/layers 中cpp文件和 caffe/include/caffe/layers 中hpp文件中所有有关于OGN的层复制到最新版caffe的对应位置,除了ogn开头的文件外,还有caffe/src/caffe/layers/label_to_onehot_layer.cpp和其对应hpp文件。
此外,将caffe/include/image_tree_tools文件夹也考到对应位置。
2.修改caffe/src/caffe/proto/caffe.proto
首先在message LayerParameter { 大括号里最后加入
optional LabelToOnehotParameter label_to_onehot_param = 999;
optional OGNDataParameter ogn_data_param = 1000;
optional OGNLossPrepParameter ogn_loss_prep_param = 1001;
optional OGNConvParameter ogn_conv_param = 1002;
optional OGNPropParameter ogn_prop_param = 1003;
optional OGNOutputParameter ogn_output_param = 1004;
再将每层定义加在文件最后面:
message LabelToOnehotParameter{
optional uint32 num_output = 1;
}
message OGNDataParameter{
optional uint32 batch_size = 1;
optional string source = 2;
optional bool preload_data = 3 [default = true];
}
message OGNLossPrepParameter {
optional string gt_key_layer = 1;
optional string pr_key_layer = 2;
optional bool use_voxel_grid = 3 [default = false];
}
message OGNConvParameter {
optional bool is_deconv = 1;
optional uint32 filter_size = 2;
optional uint32 output_channels = 3;
optional FillerParameter weight_filler = 4;
optional FillerParameter bias_filler = 5;
optional string key_layer = 6;
}
message OGNPropParameter {
enum PropagationMode {
PROP_PRED = 0;
PROP_KNOWN = 1;
}
optional string key_layer = 1;
optional PropagationMode prop_mode = 2;
}
message OGNOutputParameter {
optional string output_path = 1;
repeated string key_layer = 2;}
3.修改caffe/include/caffe/layer.hpp
首先,在开头namespace caffe {后面直接加上
template<typename Dtype> class Net;
结果是这样的:
namespace caffe {
template<typename Dtype> class Net;
/**
* @brief An interface for the units of computation which can be composed into a
* Net.
然后,在这:
inline void set_param_propagate_down(const int param_id, const bool value) {
if (param_propagate_down_.size() <= param_id) {
param_propagate_down_.resize(param_id + 1, true);
}
param_propagate_down_[param_id] = value;
}
之后加入
/**
* @brief get the pointer to the parent network that holds this layer
* (needed by apply_deformation_layer)
*/
inline const Net<Dtype>* parent_net() const {
CHECK_NOTNULL( parent_net_);
return parent_net_;
}
/**
* @brief set the pointer to the parent network that holds this layer
* (needed by apply_deformation_layer)
*/
inline void set_parent_net( const Net<Dtype>* net) {
parent_net_ = net;
}
在接下来:
protected:
/** The protobuf that stores the layer parameters */
LayerParameter layer_param_;
/** The phase: TRAIN or TEST */
Phase phase_;
/** The vector that stores the learnable parameters as a set of blobs. */
vector<shared_ptr<Blob<Dtype> > > blobs_;
/** Vector indicating whether to compute the diff of each param blob. */
vector<bool> param_propagate_down_;
后面加入:
const Net<Dtype>* parent_net_;
4.修改caffe/src/caffe/layers/ogn_output_layer.cpp和/home/sunyu/caffe/src/caffe/layers/ogn_prop_layer.cpp
因为在layer.hpp加了未完成的Net类模板,所以要在上述两文件开头
加上#include "caffe/net.hpp"
5.此外,还有一些文件复制:
ogn/python/rendering 文件夹
ogn/tools/文件夹中的:ogn_converter.cpp ogn_eval.cpp train_net.cpp test_net.cpp finetune_net.cpp net_speed_benchmark.cpp device_query.cpp
最后,make all -j4没错就好了。