octree generative net 向最新版caffe移植過程

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沒錯就好了。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章