Skip to content

Commit

Permalink
Merge pull request BVLC#1955 from philkr/reshaping_encoded
Browse files Browse the repository at this point in the history
Decoding the datum before feeding it into the reshaping data layer
  • Loading branch information
shelhamer committed Feb 26, 2015
2 parents b9aa166 + 2cf5089 commit a677076
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/caffe/layers/data_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,17 @@ void DataLayer<Dtype>::InternalThreadEntry() {
// Reshape on single input batches for inputs of varying dimension.
const int batch_size = this->layer_param_.data_param().batch_size();
const int crop_size = this->layer_param_.transform_param().crop_size();
bool force_color = this->layer_param_.data_param().force_encoded_color();
if (batch_size == 1 && crop_size == 0) {
Datum datum;
datum.ParseFromString(cursor_->value());
if (datum.encoded()) {
if (force_color) {
DecodeDatum(&datum, true);
} else {
DecodeDatumNative(&datum);
}
}
this->prefetch_data_.Reshape(1, datum.channels(),
datum.height(), datum.width());
this->transformed_data_.Reshape(1, datum.channels(),
Expand All @@ -104,7 +112,6 @@ void DataLayer<Dtype>::InternalThreadEntry() {
if (this->output_labels_) {
top_label = this->prefetch_label_.mutable_cpu_data();
}
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
Expand Down

0 comments on commit a677076

Please sign in to comment.