diff --git a/deploy/cpp/docs/linux_build.md b/deploy/cpp/docs/linux_build.md index 321ec564569e8eb491f842439c222726bb32e30c..1ff2e158c8c1a374e1a142db70aad4799a592249 100644 --- a/deploy/cpp/docs/linux_build.md +++ b/deploy/cpp/docs/linux_build.md @@ -1,7 +1,7 @@ # Linux平台编译指南 ## 说明 -本文档在 `Linux`平台使用`GCC 4.8.5` 和 `GCC 4.9.4`测试过,如果需要使用更高G++版本编译使用,则需要重新编译Paddle预测库,请参考: [从源码编译Paddle预测库](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/advanced_guide/inference_deployment/inference/build_and_install_lib_cn.html)。 +本文档在 `Linux`平台使用`GCC 4.8.5` 和 `GCC 4.9.4`测试过,如果需要使用更高G++版本编译使用,则需要重新编译Paddle预测库,请参考: [从源码编译Paddle预测库](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/advanced_guide/inference_deployment/inference/build_and_install_lib_cn.html)。本文档使用的预置的opencv库是在ubuntu 16.04上用gcc4.8编译的,如果需要在ubuntu 16.04以外的系统环境编译,那么需自行编译opencv库。 ## 前置条件 * G++ 4.8.2 ~ 4.9.4 diff --git a/deploy/cpp/src/main.cc b/deploy/cpp/src/main.cc index 2926dfa3f55a5b1f6321404fba2c5d12ead0fce6..94e74022a347cef6c1547ea47e8c135d72f97691 100644 --- a/deploy/cpp/src/main.cc +++ b/deploy/cpp/src/main.cc @@ -94,7 +94,7 @@ void PredictImage(const std::string& image_path, std::vector result; det->Predict(im, &result); for (const auto& item : result) { - printf("class=%d confidence=%.2f rect=[%d %d %d %d]\n", + printf("class=%d confidence=%.4f rect=[%d %d %d %d]\n", item.class_id, item.confidence, item.rect[0], diff --git a/deploy/cpp/src/object_detector.cc b/deploy/cpp/src/object_detector.cc index c8aaedeb4dafa104a4227c24e46cc9d9d9176091..bffd5cc55857d61c3f1bf4aee5b76a6f8ede748a 100644 --- a/deploy/cpp/src/object_detector.cc +++ b/deploy/cpp/src/object_detector.cc @@ -11,8 +11,10 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - -# include "include/object_detector.h" +#include +// for setprecision +#include +#include "include/object_detector.h" namespace PaddleDetection { @@ -48,7 +50,7 @@ void ObjectDetector::LoadModel(const std::string& model_dir, precision, false, false); - } + } } else { config.DisableGpu(); } @@ -71,13 +73,15 @@ cv::Mat VisualizeResult(const cv::Mat& img, cv::Rect roi = cv::Rect(results[i].rect[0], results[i].rect[2], w, h); // Configure color and text size - std::string text = lable_list[results[i].class_id]; + std::ostringstream oss; + oss << std::setiosflags(std::ios::fixed) << std::setprecision(4); + oss << lable_list[results[i].class_id] << " "; + oss << results[i].confidence; + std::string text = oss.str(); int c1 = colormap[3 * results[i].class_id + 0]; int c2 = colormap[3 * results[i].class_id + 1]; int c3 = colormap[3 * results[i].class_id + 2]; cv::Scalar roi_color = cv::Scalar(c1, c2, c3); - text += " "; - text += std::to_string(static_cast(results[i].confidence * 100)) + "%"; int font_face = cv::FONT_HERSHEY_COMPLEX_SMALL; double font_scale = 0.5f; float thickness = 0.5; diff --git a/deploy/python/infer.py b/deploy/python/infer.py index 0003acd44b6a46333dc370c9c1e52edb90285ef4..0b2d5bdff276f760af98263a8a130474c8b30893 100644 --- a/deploy/python/infer.py +++ b/deploy/python/infer.py @@ -456,7 +456,7 @@ class Detector(): expect_boxes = (np_boxes[:, 1] > threshold) & (np_boxes[:, 0] > -1) np_boxes = np_boxes[expect_boxes, :] for box in np_boxes: - print('class_id:{:d}, confidence:{:.2f},' + print('class_id:{:d}, confidence:{:.4f},' 'left_top:[{:.2f},{:.2f}],' ' right_bottom:[{:.2f},{:.2f}]'.format( int(box[0]), box[1], box[2], box[3], box[4], box[5])) diff --git a/deploy/python/visualize.py b/deploy/python/visualize.py index 075a3619f5407d7e584317b716b1d7aca87bdd63..e4d5f6ac7666e824f3278d1cf9b0a42835d78c8c 100644 --- a/deploy/python/visualize.py +++ b/deploy/python/visualize.py @@ -180,7 +180,7 @@ def draw_box(im, np_boxes, labels): fill=color) # draw label - text = "{} {:.2f}".format(labels[clsid], score) + text = "{} {:.4f}".format(labels[clsid], score) tw, th = draw.textsize(text) draw.rectangle( [(xmin + 1, ymin - th), (xmin + tw + 1, ymin)], fill=color)