From 6e5eecd7f926a7a050caf25b57f992ebbc1c0c75 Mon Sep 17 00:00:00 2001 From: FlyingQianMM <245467267@qq.com> Date: Wed, 16 Sep 2020 09:08:11 +0000 Subject: [PATCH] rename input_channel to input_channel_ --- deploy/cpp/include/paddlex/paddlex.h | 2 +- deploy/cpp/src/paddlex.cpp | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/deploy/cpp/include/paddlex/paddlex.h b/deploy/cpp/include/paddlex/paddlex.h index e4d34ba..327058e 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 a018ffd..5d33ae0 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()); -- GitLab