From 970befc1c69cae3c7595bcc1a7e7b271dd3b0635 Mon Sep 17 00:00:00 2001 From: joey12300 <136876878@qq.com> Date: Wed, 23 Oct 2019 17:18:38 +0800 Subject: [PATCH] merge the visualize.py --- inference/tools/visualize.py | 9 ++++----- serving/seg-serving/op/reader_op.cpp | 26 ++++++++------------------ 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/inference/tools/visualize.py b/inference/tools/visualize.py index 87373e91..93b8410d 100644 --- a/inference/tools/visualize.py +++ b/inference/tools/visualize.py @@ -9,12 +9,11 @@ color_map = [[128, 64, 128], [244, 35, 231], [69, 69, 69], [102, 102, 156], [0, 0, 230], [119, 10, 32]] im = cv2.imread(sys.argv[1]) - -# Please note (224, 224) just for daheng model +shape = im.shape print("visualizing...") -for i in range(0, 224): - for j in range(0, 224): +for i in range(0, shape[0]): + for j in range(0, shape[1]): im[i, j] = color_map[im[i, j, 0]] -cv2.imwrite(sys.argv[1], im) +cv2.imwrite(sys.argv[2], im) print("visualizing done!") diff --git a/serving/seg-serving/op/reader_op.cpp b/serving/seg-serving/op/reader_op.cpp index b825d81b..47ec7345 100644 --- a/serving/seg-serving/op/reader_op.cpp +++ b/serving/seg-serving/op/reader_op.cpp @@ -123,31 +123,21 @@ int ReaderOp::inference() { const int HH = _image_8u_tmp.rows; const int WW = _image_8u_tmp.cols; const int CC = _image_8u_tmp.channels(); + //HH: cols WW:rows in_width_vec->push_back(HH); in_height_vec->push_back(WW); - // resize/crop + // resize if (_image_8u_tmp.cols != resize.width || _image_8u_tmp.rows != resize.height) { -// int short_egde = std::min(_image_8u_tmp.cols, _image_8u_tmp.rows); -// int yy = static_cast((_image_8u_tmp.rows - short_egde) / 2); -// int xx = static_cast((_image_8u_tmp.cols - short_egde) / 2); -// _image_8u_tmp = -// cv::Mat(_image_8u_tmp, cv::Rect(xx, yy, short_egde, short_egde)); -// if (_image_8u_tmp.cols != resize.width || -// _image_8u_tmp.rows != resize.height) { cv::Mat resize_image; -// cv::resize(_image_8u_tmp, resize_image, resize); -// _image_8u_tmp = resize_image; -// } -// - cv::resize(_image_8u_tmp, resize_image, resize); - _image_8u_tmp = resize_image; - LOG(INFO) << "Succ crop one image[CHW=" << _image_8u_tmp.channels() - << ", " << _image_8u_tmp.cols << ", " << _image_8u_tmp.rows - << "]" - << " from image[CHW=" << CC << ", " << HH << ", " << WW << "]"; + cv::resize(_image_8u_tmp, resize_image, resize); + _image_8u_tmp = resize_image; + LOG(INFO) << "Succ crop one image[CHW=" << _image_8u_tmp.channels() + << ", " << _image_8u_tmp.cols << ", " << _image_8u_tmp.rows + << "]" + << " from image[CHW=" << CC << ", " << HH << ", " << WW << "]"; } // BGR->RGB transformer -- GitLab