diff --git a/deploy/cpp/include/paddlex/paddlex.h b/deploy/cpp/include/paddlex/paddlex.h index e4d34ba47041b2ba74c21a95925198e2378f3bae..327058e4bd3251f41be82309f154b41eae11027c 100644 --- a/deploy/cpp/include/paddlex/paddlex.h +++ b/deploy/cpp/include/paddlex/paddlex.h @@ -233,6 +233,6 @@ class Model { // a predictor which run the model predicting std::unique_ptr predictor_; // input channel - int input_channel; + int input_channel_; }; } // namespace PaddleX diff --git a/deploy/cpp/src/paddlex.cpp b/deploy/cpp/src/paddlex.cpp index a018ffd0f94911b18dd4d59cad1fbe2f3ff391b5..5d33ae0e60285f41a2c24cca0ce96f51b54478bf 100644 --- a/deploy/cpp/src/paddlex.cpp +++ b/deploy/cpp/src/paddlex.cpp @@ -135,9 +135,9 @@ bool Model::load_config(const std::string& yaml_input) { labels[index] = item.as(); } if (config["_init_params"]["input_channel"].IsDefined()) { - input_channel = config["_init_params"]["input_channel"].as(); + input_channel_ = config["_init_params"]["input_channel"].as(); } else { - input_channel = 3; + input_channel_ = 3; } return true; } @@ -184,7 +184,7 @@ bool Model::predict(const cv::Mat& im, ClsResult* result) { auto in_tensor = predictor_->GetInputTensor("image"); int h = inputs_.new_im_size_[0]; int w = inputs_.new_im_size_[1]; - in_tensor->Reshape({1, input_channel, h, w}); + in_tensor->Reshape({1, input_channel_, h, w}); in_tensor->copy_from_cpu(inputs_.im_data_.data()); predictor_->ZeroCopyRun(); // get result @@ -231,12 +231,12 @@ bool Model::predict(const std::vector& im_batch, auto in_tensor = predictor_->GetInputTensor("image"); int h = inputs_batch_[0].new_im_size_[0]; int w = inputs_batch_[0].new_im_size_[1]; - in_tensor->Reshape({batch_size, input_channel, h, w}); - std::vector inputs_data(batch_size * input_channel * h * w); + in_tensor->Reshape({batch_size, input_channel_, h, w}); + std::vector inputs_data(batch_size * input_channel_ * h * w); for (int i = 0; i < batch_size; ++i) { std::copy(inputs_batch_[i].im_data_.begin(), inputs_batch_[i].im_data_.end(), - inputs_data.begin() + i * input_channel * h * w); + inputs_data.begin() + i * input_channel_ * h * w); } in_tensor->copy_from_cpu(inputs_data.data()); // in_tensor->copy_from_cpu(inputs_.im_data_.data()); @@ -290,7 +290,7 @@ bool Model::predict(const cv::Mat& im, DetResult* result) { int h = inputs_.new_im_size_[0]; int w = inputs_.new_im_size_[1]; auto im_tensor = predictor_->GetInputTensor("image"); - im_tensor->Reshape({1, input_channel, h, w}); + im_tensor->Reshape({1, input_channel_, h, w}); im_tensor->copy_from_cpu(inputs_.im_data_.data()); if (name == "YOLOv3" || name == "PPYOLO") { @@ -444,12 +444,12 @@ bool Model::predict(const std::vector& im_batch, int h = inputs_batch_[0].new_im_size_[0]; int w = inputs_batch_[0].new_im_size_[1]; auto im_tensor = predictor_->GetInputTensor("image"); - im_tensor->Reshape({batch_size, input_channel, h, w}); - std::vector inputs_data(batch_size * input_channel * h * w); + im_tensor->Reshape({batch_size, input_channel_, h, w}); + std::vector inputs_data(batch_size * input_channel_ * h * w); for (int i = 0; i < batch_size; ++i) { std::copy(inputs_batch_[i].im_data_.begin(), inputs_batch_[i].im_data_.end(), - inputs_data.begin() + i * input_channel * h * w); + inputs_data.begin() + i * input_channel_ * h * w); } im_tensor->copy_from_cpu(inputs_data.data()); if (name == "YOLOv3" || name == "PPYOLO") { @@ -589,7 +589,7 @@ bool Model::predict(const cv::Mat& im, SegResult* result) { int h = inputs_.new_im_size_[0]; int w = inputs_.new_im_size_[1]; auto im_tensor = predictor_->GetInputTensor("image"); - im_tensor->Reshape({1, input_channel, h, w}); + im_tensor->Reshape({1, input_channel_, h, w}); im_tensor->copy_from_cpu(inputs_.im_data_.data()); // predict @@ -703,12 +703,12 @@ bool Model::predict(const std::vector& im_batch, int h = inputs_batch_[0].new_im_size_[0]; int w = inputs_batch_[0].new_im_size_[1]; auto im_tensor = predictor_->GetInputTensor("image"); - im_tensor->Reshape({batch_size, input_channel, h, w}); - std::vector inputs_data(batch_size * input_channel * h * w); + im_tensor->Reshape({batch_size, input_channel_, h, w}); + std::vector inputs_data(batch_size * input_channel_ * h * w); for (int i = 0; i < batch_size; ++i) { std::copy(inputs_batch_[i].im_data_.begin(), inputs_batch_[i].im_data_.end(), - inputs_data.begin() + i * input_channel * h * w); + inputs_data.begin() + i * input_channel_ * h * w); } im_tensor->copy_from_cpu(inputs_data.data()); // im_tensor->copy_from_cpu(inputs_.im_data_.data());