Browse Source

fix ImageBlob clear bug

jack 5 years ago
parent
commit
e0dea23d2f
2 changed files with 5 additions and 2 deletions
  1. 0 2
      deploy/cpp/include/paddlex/transforms.h
  2. 5 0
      deploy/cpp/src/paddlex.cpp

+ 0 - 2
deploy/cpp/include/paddlex/transforms.h

@@ -45,8 +45,6 @@ class ImageBlob {
   std::vector<float> im_data_;
   std::vector<float> im_data_;
 
 
   void clear() {
   void clear() {
-    ori_im_size_.clear();
-    new_im_size_.clear();
     im_size_before_resize_.clear();
     im_size_before_resize_.clear();
     reshape_order_.clear();
     reshape_order_.clear();
     im_data_.clear();
     im_data_.clear();

+ 5 - 0
deploy/cpp/src/paddlex.cpp

@@ -128,6 +128,7 @@ bool Model::preprocess(const std::vector<cv::Mat> &input_im_batch, std::vector<I
 
 
 bool Model::predict(const cv::Mat& im, ClsResult* result) {
 bool Model::predict(const cv::Mat& im, ClsResult* result) {
   inputs_.clear();
   inputs_.clear();
+  result->clear();
   if (type == "detector") {
   if (type == "detector") {
     std::cerr << "Loading model is a 'detector', DetResult should be passed to "
     std::cerr << "Loading model is a 'detector', DetResult should be passed to "
                  "function predict()!"
                  "function predict()!"
@@ -224,6 +225,7 @@ bool Model::predict(const std::vector<cv::Mat> &im_batch, std::vector<ClsResult>
 }
 }
 
 
 bool Model::predict(const cv::Mat& im, DetResult* result) {
 bool Model::predict(const cv::Mat& im, DetResult* result) {
+  inputs_.clear();
   result->clear();
   result->clear();
   if (type == "classifier") {
   if (type == "classifier") {
     std::cerr << "Loading model is a 'classifier', ClsResult should be passed "
     std::cerr << "Loading model is a 'classifier', ClsResult should be passed "
@@ -328,6 +330,9 @@ bool Model::predict(const cv::Mat& im, DetResult* result) {
 }
 }
 
 
 bool Model::predict(const std::vector<cv::Mat> &im_batch, std::vector<DetResult> &result, int thread_num) {
 bool Model::predict(const std::vector<cv::Mat> &im_batch, std::vector<DetResult> &result, int thread_num) {
+  for(auto &inputs: inputs_batch_) {
+    inputs.clear();
+  }
   if (type == "classifier") {
   if (type == "classifier") {
     std::cerr << "Loading model is a 'classifier', ClsResult should be passed "
     std::cerr << "Loading model is a 'classifier', ClsResult should be passed "
                  "to function predict()!"
                  "to function predict()!"