MCPcopy Create free account
hub / github.com/BVLC/caffe / DataLayerSetUp

Method DataLayerSetUp

src/caffe/layers/window_data_layer.cpp:36–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35template <typename Dtype>
36void WindowDataLayer<Dtype>::DataLayerSetUp(const vector<Blob<Dtype>*>& bottom,
37 const vector<Blob<Dtype>*>& top) {
38 // LayerSetUp runs through the window_file and creates two structures
39 // that hold windows: one for foreground (object) windows and one
40 // for background (non-object) windows. We use an overlap threshold
41 // to decide which is which.
42
43 // window_file format
44 // repeated:
45 // # image_index
46 // img_path (abs path)
47 // channels
48 // height
49 // width
50 // num_windows
51 // class_index overlap x1 y1 x2 y2
52
53 LOG(INFO) << "Window data layer:" << std::endl
54 << " foreground (object) overlap threshold: "
55 << this->layer_param_.window_data_param().fg_threshold() << std::endl
56 << " background (non-object) overlap threshold: "
57 << this->layer_param_.window_data_param().bg_threshold() << std::endl
58 << " foreground sampling fraction: "
59 << this->layer_param_.window_data_param().fg_fraction() << std::endl
60 << " cache_images: "
61 << this->layer_param_.window_data_param().cache_images() << std::endl
62 << " root_folder: "
63 << this->layer_param_.window_data_param().root_folder();
64
65 cache_images_ = this->layer_param_.window_data_param().cache_images();
66 string root_folder = this->layer_param_.window_data_param().root_folder();
67
68 const bool prefetch_needs_rand =
69 this->transform_param_.mirror() ||
70 this->transform_param_.crop_size();
71 if (prefetch_needs_rand) {
72 const unsigned int prefetch_rng_seed = caffe_rng_rand();
73 prefetch_rng_.reset(new Caffe::RNG(prefetch_rng_seed));
74 } else {
75 prefetch_rng_.reset();
76 }
77
78 std::ifstream infile(this->layer_param_.window_data_param().source().c_str());
79 CHECK(infile.good()) << "Failed to open window file "
80 << this->layer_param_.window_data_param().source() << std::endl;
81
82 map<int, int> label_hist;
83 label_hist.insert(std::make_pair(0, 0));
84
85 string hashtag;
86 int image_index, channels;
87 if (!(infile >> hashtag >> image_index)) {
88 LOG(FATAL) << "Window file is empty";
89 }
90 do {
91 CHECK_EQ(hashtag, "#");
92 // read image path
93 string image_path;

Callers

nothing calls this directly

Calls 14

caffe_rng_randFunction · 0.85
batch_sizeMethod · 0.80
numMethod · 0.80
FromProtoMethod · 0.80
ReadFileToDatumFunction · 0.50
resetMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
ReshapeMethod · 0.45
sizeMethod · 0.45
channelsMethod · 0.45

Tested by

no test coverage detected