summaryrefslogtreecommitdiff
path: root/src/caffe/layers/window_data_layer.cpp
diff options
context:
space:
mode:
authorSergio <sguada@gmail.com>2014-10-07 11:19:16 -0700
committerSergio <sguada@gmail.com>2014-10-15 17:03:07 -0700
commite9d6e5a0b22a9f4768b8c04c9031ee8adb822ece (patch)
treea83e8b231cf92cc9e3ed9bf40870f70fd6946091 /src/caffe/layers/window_data_layer.cpp
parentd337b044c25abf30f94dd9fb7d25aca940eda7c0 (diff)
downloadcaffeonacl-e9d6e5a0b22a9f4768b8c04c9031ee8adb822ece.tar.gz
caffeonacl-e9d6e5a0b22a9f4768b8c04c9031ee8adb822ece.tar.bz2
caffeonacl-e9d6e5a0b22a9f4768b8c04c9031ee8adb822ece.zip
Add root_folder to ImageDataLayer
Diffstat (limited to 'src/caffe/layers/window_data_layer.cpp')
-rw-r--r--src/caffe/layers/window_data_layer.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/caffe/layers/window_data_layer.cpp b/src/caffe/layers/window_data_layer.cpp
index 47e0fb2a..8e656155 100644
--- a/src/caffe/layers/window_data_layer.cpp
+++ b/src/caffe/layers/window_data_layer.cpp
@@ -13,7 +13,9 @@
#include "caffe/common.hpp"
#include "caffe/data_layers.hpp"
#include "caffe/layer.hpp"
+#ifdef TIMING
#include "caffe/util/benchmark.hpp"
+#endif
#include "caffe/util/io.hpp"
#include "caffe/util/math_functions.hpp"
#include "caffe/util/rng.hpp"
@@ -193,8 +195,13 @@ template <typename Dtype>
void WindowDataLayer<Dtype>::InternalThreadEntry() {
// At each iteration, sample N windows where N*p are foreground (object)
// windows and N*(1-p) are background (non-object) windows
+ #ifdef TIMING
Timer batch_timer;
batch_timer.Start();
+ float read_time = 0;
+ float trans_time = 0;
+ Timer timer;
+ #endif
Dtype* top_data = this->prefetch_data_.mutable_cpu_data();
Dtype* top_label = this->prefetch_label_.mutable_cpu_data();
const Dtype scale = this->layer_param_.window_data_param().scale();
@@ -221,14 +228,13 @@ void WindowDataLayer<Dtype>::InternalThreadEntry() {
const int num_samples[2] = { batch_size - num_fg, num_fg };
int item_id = 0;
- float read_time = 0;
- float trans_time = 0;
- Timer timer;
// sample from bg set then fg set
for (int is_fg = 0; is_fg < 2; ++is_fg) {
for (int dummy = 0; dummy < num_samples[is_fg]; ++dummy) {
// sample a window
+ #ifdef TIMING
timer.Start();
+ #endif
const unsigned int rand_index = PrefetchRand();
vector<float> window = (is_fg) ?
fg_windows_[rand_index % fg_windows_.size()] :
@@ -245,8 +251,10 @@ void WindowDataLayer<Dtype>::InternalThreadEntry() {
LOG(ERROR) << "Could not open or find file " << image.first;
return;
}
+ #ifdef TIMING
read_time += timer.MilliSeconds();
timer.Start();
+ #endif
const int channels = cv_img.channels();
// crop window out of image and warp it
@@ -364,7 +372,9 @@ void WindowDataLayer<Dtype>::InternalThreadEntry() {
}
}
}
+ #ifdef TIMING
trans_time += timer.MilliSeconds();
+ #endif
// get window label
top_label[item_id] = window[WindowDataLayer<Dtype>::LABEL];
@@ -404,9 +414,11 @@ void WindowDataLayer<Dtype>::InternalThreadEntry() {
item_id++;
}
}
- DLOG(INFO) << "Prefetch batch: " << batch_timer.MilliSeconds() << "ms.";
- DLOG(INFO) << "Read time: " << read_time << "ms.";
- DLOG(INFO) << "Transform time: " << trans_time << "ms.";
+ #ifdef TIMING
+ LOG(INFO) << "Prefetch batch: " << batch_timer.MilliSeconds() << "ms.";
+ LOG(INFO) << "Read time: " << read_time << "ms.";
+ LOG(INFO) << "Transform time: " << trans_time << "ms.";
+ #endif
}
INSTANTIATE_CLASS(WindowDataLayer);