#include "caffe/dataset_factory.hpp"
#include "caffe/layer.hpp"
#include "caffe/proto/caffe.pb.h"
+#include "caffe/util/benchmark.hpp"
#include "caffe/util/io.hpp"
#include "caffe/util/math_functions.hpp"
#include "caffe/util/rng.hpp"
CHECK(iter_ != dataset_->end());
const Datum& datum = iter_->value;
+ if (DecodeDatum(datum)) {
+ LOG(INFO) << "Decoding Datum";
+ }
// image
int crop_size = this->layer_param_.transform_param().crop_size();
if (crop_size > 0) {
// This function is used to create a thread that prefetches the data.
template <typename Dtype>
void DataLayer<Dtype>::InternalThreadEntry() {
+ Timer batch_timer;
+ batch_timer.Start();
CHECK(this->prefetch_data_.count());
CHECK(this->transformed_data_.count());
Dtype* top_data = this->prefetch_data_.mutable_cpu_data();
top_label = this->prefetch_label_.mutable_cpu_data();
}
const int batch_size = this->layer_param_.data_param().batch_size();
-
+ float read_time = 0;
+ float trans_time = 0;
+ Timer timer;
for (int item_id = 0; item_id < batch_size; ++item_id) {
+ timer.Start();
+ // get a blob
CHECK(iter_ != dataset_->end());
const Datum& datum = iter_->value;
+ cv::Mat cv_img = DecodeDatumToCVMat(datum);
+ read_time += timer.MilliSeconds();
+ timer.Start();
// Apply data transformations (mirror, scale, crop...)
int offset = this->prefetch_data_.offset(item_id);
this->transformed_data_.set_cpu_data(top_data + offset);
- this->data_transformer_.Transform(datum, &(this->transformed_data_));
+ this->data_transformer_.Transform(cv_img, &(this->transformed_data_));
if (this->output_labels_) {
top_label[item_id] = datum.label();
}
-
+ trans_time += timer.MilliSeconds();
// go to the next iter
++iter_;
if (iter_ == dataset_->end()) {
iter_ = dataset_->begin();
}
}
+ DLOG(INFO) << "Prefetch batch: " << batch_timer.MilliSeconds() << "ms.";
+ DLOG(INFO) << "Read time: " << read_time << "ms.";
+ DLOG(INFO) << "Transform time: " << trans_time << "ms.";
}
INSTANTIATE_CLASS(DataLayer);
#include "caffe/data_layers.hpp"
#include "caffe/layer.hpp"
+#include "caffe/util/benchmark.hpp"
#include "caffe/util/io.hpp"
#include "caffe/util/math_functions.hpp"
#include "caffe/util/rng.hpp"
// This function is used to create a thread that prefetches the data.
template <typename Dtype>
void ImageDataLayer<Dtype>::InternalThreadEntry() {
+ Timer batch_timer;
+ batch_timer.Start();
CHECK(this->prefetch_data_.count());
CHECK(this->transformed_data_.count());
Dtype* top_data = this->prefetch_data_.mutable_cpu_data();
// datum scales
const int lines_size = lines_.size();
+ float read_time = 0;
+ float trans_time = 0;
+ Timer timer;
for (int item_id = 0; item_id < batch_size; ++item_id) {
// get a blob
+ timer.Start();
CHECK_GT(lines_size, lines_id_);
cv::Mat cv_img = ReadImageToCVMat(lines_[lines_id_].first,
new_height, new_width, is_color);
if (!cv_img.data) {
continue;
}
+ read_time += timer.MilliSeconds();
+ timer.Start();
// Apply transformations (mirror, crop...) to the image
int offset = this->prefetch_data_.offset(item_id);
this->transformed_data_.set_cpu_data(top_data + offset);
this->data_transformer_.Transform(cv_img, &(this->transformed_data_));
+ trans_time += timer.MilliSeconds();
top_label[item_id] = lines_[lines_id_].second;
// go to the next iter
}
}
}
+ DLOG(INFO) << "Prefetch batch: " << batch_timer.MilliSeconds() << "ms.";
+ DLOG(INFO) << "Read time: " << read_time << "ms.";
+ DLOG(INFO) << "Transform time: " << trans_time << "ms.";
}
INSTANTIATE_CLASS(ImageDataLayer);
#include "caffe/common.hpp"
#include "caffe/data_layers.hpp"
#include "caffe/layer.hpp"
+#include "caffe/util/benchmark.hpp"
#include "caffe/util/io.hpp"
#include "caffe/util/math_functions.hpp"
#include "caffe/util/rng.hpp"
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
-
+ Timer batch_timer;
+ batch_timer.Start();
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();
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
+ timer.Start();
const unsigned int rand_index = PrefetchRand();
vector<float> window = (is_fg) ?
fg_windows_[rand_index % fg_windows_.size()] :
bg_windows_[rand_index % bg_windows_.size()];
- bool do_mirror = false;
- if (mirror && PrefetchRand() % 2) {
- do_mirror = true;
- }
+ bool do_mirror = mirror && PrefetchRand() % 2;
// load the image containing the window
pair<std::string, vector<int> > image =
LOG(ERROR) << "Could not open or find file " << image.first;
return;
}
+ read_time += timer.MilliSeconds();
+ timer.Start();
const int channels = cv_img.channels();
// crop window out of image and warp it
}
}
}
-
+ trans_time += timer.MilliSeconds();
// get window label
top_label[item_id] = window[WindowDataLayer<Dtype>::LABEL];
item_id++;
}
}
+ DLOG(INFO) << "Prefetch batch: " << batch_timer.MilliSeconds() << "ms.";
+ DLOG(INFO) << "Read time: " << read_time << "ms.";
+ DLOG(INFO) << "Transform time: " << trans_time << "ms.";
}
INSTANTIATE_CLASS(WindowDataLayer);
#include "caffe/layer.hpp"
#include "caffe/net.hpp"
#include "caffe/proto/caffe.pb.h"
+#include "caffe/util/benchmark.hpp"
#include "caffe/util/insert_splits.hpp"
#include "caffe/util/io.hpp"
#include "caffe/util/math_functions.hpp"
template <typename Dtype>
Dtype Net<Dtype>::ForwardFromTo(int start, int end) {
+ Timer timer;
+ timer.Start();
CHECK_GE(start, 0);
CHECK_LT(end, layers_.size());
Dtype loss = 0;
loss += layer_loss;
if (debug_info_) { ForwardDebugInfo(i); }
}
+ LOG(INFO) << "Forward time: " << timer.MilliSeconds() << "ms.";
return loss;
}
template <typename Dtype>
void Net<Dtype>::BackwardFromTo(int start, int end) {
+ Timer timer;
+ timer.Start();
CHECK_GE(end, 0);
CHECK_LT(start, layers_.size());
for (int i = start; i >= end; --i) {
if (debug_info_) { BackwardDebugInfo(i); }
}
}
+ LOG(INFO) << "Backward time: " << timer.MilliSeconds() << "ms.";
}
template <typename Dtype>