From 587eeabe16a72f9e5e9d5b203c370ffe407f3efb Mon Sep 17 00:00:00 2001 From: sguada Date: Mon, 17 Feb 2014 10:26:11 -0800 Subject: [PATCH] Enforce that new_height and new_width are both 0 or both > 0 --- src/caffe/layers/images_layer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/caffe/layers/images_layer.cpp b/src/caffe/layers/images_layer.cpp index 75ed643f4..ab3f8b0f8 100644 --- a/src/caffe/layers/images_layer.cpp +++ b/src/caffe/layers/images_layer.cpp @@ -136,6 +136,10 @@ void ImagesLayer::SetUp(const vector*>& bottom, vector*>* top) { CHECK_EQ(bottom.size(), 0) << "Input Layer takes no input blobs."; CHECK_EQ(top->size(), 2) << "Input Layer takes two blobs as output."; + const int new_height = this->layer_param_.new_height(); + const int new_width = this->layer_param_.new_height(); + CHECK((new_height==0 && new_width==0)||(new_height>0 && new_width > 0)) << + "Current implementation requires new_height and new_width to be set at the same time."; // Read the file with filenames and labels LOG(INFO) << "Opening file " << this->layer_param_.source(); std::ifstream infile(this->layer_param_.source().c_str()); @@ -162,8 +166,6 @@ void ImagesLayer::SetUp(const vector*>& bottom, } // Read a data point, and use it to initialize the top blob. Datum datum; - const int new_height = this->layer_param_.new_height(); - const int new_width = this->layer_param_.new_height(); CHECK(ReadImageToDatum(lines_[lines_id_].first, lines_[lines_id_].second, new_height,new_width,&datum)); // image