1 参数
message DenseImageDataParameter {
// Specify the data source file.
optional string source = 1;
// Specify the batch size.
optional uint32 batch_size = 2;
// The rand_skip variable is for the data layer to skip a few data points
// to avoid all asynchronous sgd clients to start at the same point. The skip
// point would be set as rand_skip * rand(0,1). Note that rand_skip should not
// be larger than the number of keys in the database.
optional uint32 rand_skip = 3 [default = 0];
// Whether or not ImageLayer should shuffle the list of files at every epoch.
optional bool shuffle = 4 [default = false];
// It will also resize images if new_height or new_width are not zero.
optional uint32 new_height = 5 [default = 0];
optional uint32 new_width = 6 [default = 0];
// Label gets divided by this factor, to train the encoder architecture of ENet.
optional uint32 label_divide_factor = 13 [default = 1];
// Specify if the images are color or gray
optional bool is_color = 7 [default = true];
optional string mean_file = 8;
optional string root_folder = 9 [default = ""];
optional bool mirror = 10 [default = false];
optional uint32 crop_width = 11 [default = 0];
optional uint32 crop_height = 12 [default = 0];
}
参数:
2 label_divide_factor对应源码层次修改
//直接设定读图大小
cv::Mat cv_lab = ReadImageToCVMat(root_folder + lines_[lines_id_].second,
new_height/label_divide_factor, new_width/label_divide_factor, false, true);
//设定top[1]大小
top[1]->Reshape(batch_size, 1, height/label_divide_factor, width/label_divide_factor);
this->prefetch_label_.Reshape(batch_size, 1, height/label_divide_factor, width/label_divide_factor);
this->transformed_label_.Reshape(1, 1, height/label_divide_factor, width/label_divide_factor);
#ifdef USE_OPENCV
cv::Mat ReadImageToCVMat(const string& filename,
const int height, const int width, const bool is_color,
const bool nearest_neighbour_interp) {
cv::Mat cv_img;
int cv_read_flag = (is_color ? CV_LOAD_IMAGE_COLOR :
CV_LOAD_IMAGE_GRAYSCALE);
cv::Mat cv_img_origin = cv::imread(filename, cv_read_flag);
if (!cv_img_origin.data) {
LOG(ERROR) << "Could not open or find file " << filename;
return cv_img_origin;
}
if (height > 0 && width > 0) {
int cv_interp_flag = nearest_neighbour_interp ? CV_INTER_NN :
CV_INTER_LINEAR;
cv::resize(cv_img_origin, cv_img, cv::Size(width, height), 0, 0,
cv_interp_flag);
} else {
cv_img = cv_img_origin;
}
return cv_img;
}
cv::Mat ReadImageToCVMat(const string& filename,
const int height, const int width, const bool is_color) {
return ReadImageToCVMat(filename, height, width, is_color, false);
}
cv::Mat ReadImageToCVMat(const string& filename,
const int height, const int width) {
return ReadImageToCVMat(filename, height, width, true);
}
cv::Mat ReadImageToCVMat(const string& filename,
const bool is_color) {
return ReadImageToCVMat(filename, 0, 0, is_color);
}
cv::Mat ReadImageToCVMat(const string& filename) {
return ReadImageToCVMat(filename, 0, 0, true);
}