diff options
-rw-r--r-- | data/cat.jpg | bin | 28238 -> 642416 bytes | |||
-rw-r--r-- | src/caffe/layers/input_layer.cpp | 11 | ||||
-rw-r--r-- | src/caffe/proto/caffe.proto | 5 |
3 files changed, 12 insertions, 4 deletions
diff --git a/data/cat.jpg b/data/cat.jpg Binary files differindex 3a2550bd..5303803b 100644 --- a/data/cat.jpg +++ b/data/cat.jpg diff --git a/src/caffe/layers/input_layer.cpp b/src/caffe/layers/input_layer.cpp index d8ed74a0..db3d634c 100644 --- a/src/caffe/layers/input_layer.cpp +++ b/src/caffe/layers/input_layer.cpp @@ -31,6 +31,7 @@ void* InputLayerPrefetch(void* layer_pointer) { const int batchsize = layer->layer_param_.batchsize(); const int cropsize = layer->layer_param_.cropsize(); const bool mirror = layer->layer_param_.mirror(); + const int resize_image = layer->layer_param_.resize_image(); if (mirror && cropsize == 0) { LOG(FATAL) << "Current implementation requires mirror and cropsize to be " @@ -46,8 +47,8 @@ void* InputLayerPrefetch(void* layer_pointer) { for (int itemid = 0; itemid < batchsize; ++itemid) { // get a blob CHECK_GT(lines_size,layer->lines_id_); - if (!ReadImageToDatum(layer->lines_[layer->lines_id_].first, - layer->lines_[layer->lines_id_].second, &datum)) { + if (!ReadImageToDatum(layer->lines_[layer->lines_id_].first, layer->lines_[layer->lines_id_].second, + resize_image, resize_image, &datum)) { continue; }; const string& data = datum.data(); @@ -114,6 +115,9 @@ void* InputLayerPrefetch(void* layer_pointer) { // We have reached the end. Restart from the first. DLOG(INFO) << "Restarting data prefetching from start."; layer->lines_id_=0; + if (layer->layer_param_.shuffle_data()) { + std::random_shuffle(layer->lines_.begin(), layer->lines_.end()); + } } } @@ -157,8 +161,9 @@ void InputLayer<Dtype>::SetUp(const vector<Blob<Dtype>*>& bottom, } // Read a data point, and use it to initialize the top blob. Datum datum; + const int resize_image = this->layer_param_.resize_image(); CHECK(ReadImageToDatum(lines_[lines_id_].first, lines_[lines_id_].second, - &datum)); + resize_image,resize_image,&datum)); // image int cropsize = this->layer_param_.cropsize(); if (cropsize > 0) { diff --git a/src/caffe/proto/caffe.proto b/src/caffe/proto/caffe.proto index 98942240..dd09b731 100644 --- a/src/caffe/proto/caffe.proto +++ b/src/caffe/proto/caffe.proto @@ -92,7 +92,10 @@ message LayerParameter { // be larger than the number of keys in the leveldb. optional uint32 rand_skip = 53 [ default = 0 ]; - optional bool shuffle_data = 61 [default = true]; + // Used by Input_layer to shuffle the list of files at every epoch + optional bool shuffle_data = 61 [default = false]; + // If >0 then it will resize input images to size given by resize_image using cv::resize + optional int32 resize_image = 62 [default = 0 ]; } message LayerConnection { |