Merge pull request #1910 from philkr/encoded
authorEvan Shelhamer <shelhamer@imaginarynumber.net>
Fri, 20 Feb 2015 02:01:13 +0000 (18:01 -0800)
committerEvan Shelhamer <shelhamer@imaginarynumber.net>
Fri, 20 Feb 2015 02:01:13 +0000 (18:01 -0800)
  add force_encoded_color flag to the data layer and warn about
  mixed encoding

1  2 
src/caffe/layers/data_layer.cpp
src/caffe/layers/window_data_layer.cpp
src/caffe/proto/caffe.proto

@@@ -102,6 -91,8 +104,7 @@@ void DataLayer<Dtype>::InternalThreadEn
    if (this->output_labels_) {
      top_label = this->prefetch_label_.mutable_cpu_data();
    }
 -  const int batch_size = this->layer_param_.data_param().batch_size();
+   bool force_color = this->layer_param_.data_param().force_encoded_color();
    for (int item_id = 0; item_id < batch_size; ++item_id) {
      timer.Start();
      // get a blob
  
      cv::Mat cv_img;
      if (datum.encoded()) {
-        cv_img = DecodeDatumToCVMatNative(datum);
 -      if (force_color)
++      if (force_color) {
+         cv_img = DecodeDatumToCVMat(datum, true);
 -      else
++      } else {
+         cv_img = DecodeDatumToCVMatNative(datum);
 -      if (cv_img.channels() != this->transformed_data_.channels())
++      }
++      if (cv_img.channels() != this->transformed_data_.channels()) {
+         LOG(WARNING) << "Your dataset contains encoded images with mixed "
+         << "channel sizes. Consider adding a 'force_color' flag to the "
+         << "model definition, or rebuild your dataset using "
+         << "convert_imageset.";
++      }
      }
      read_time += timer.MicroSeconds();
      timer.Start();
Simple merge