diff --git a/examples/vision/segmentation/paddleseg/cpp/infer.cc b/examples/vision/segmentation/paddleseg/cpp/infer.cc index d3c4627043..28bb560091 100644 --- a/examples/vision/segmentation/paddleseg/cpp/infer.cc +++ b/examples/vision/segmentation/paddleseg/cpp/infer.cc @@ -37,7 +37,7 @@ void CpuInfer(const std::string& model_dir, const std::string& image_file) { auto im = cv::imread(image_file); fastdeploy::vision::SegmentationResult res; - if (!model.Predict(&im, &res)) { + if (!model.Predict(im, &res)) { std::cerr << "Failed to predict." << std::endl; return; } @@ -66,7 +66,7 @@ void GpuInfer(const std::string& model_dir, const std::string& image_file) { auto im = cv::imread(image_file); fastdeploy::vision::SegmentationResult res; - if (!model.Predict(&im, &res)) { + if (!model.Predict(im, &res)) { std::cerr << "Failed to predict." << std::endl; return; } @@ -96,7 +96,7 @@ void TrtInfer(const std::string& model_dir, const std::string& image_file) { auto im = cv::imread(image_file); fastdeploy::vision::SegmentationResult res; - if (!model.Predict(&im, &res)) { + if (!model.Predict(im, &res)) { std::cerr << "Failed to predict." << std::endl; return; } diff --git a/examples/vision/segmentation/paddleseg/quantize/cpp/infer.cc b/examples/vision/segmentation/paddleseg/quantize/cpp/infer.cc index 2611e2456a..158a302636 100644 --- a/examples/vision/segmentation/paddleseg/quantize/cpp/infer.cc +++ b/examples/vision/segmentation/paddleseg/quantize/cpp/infer.cc @@ -34,7 +34,7 @@ void InitAndInfer(const std::string& model_dir, const std::string& image_file, auto im_bak = im.clone(); fastdeploy::vision::SegmentationResult res; - if (!model.Predict(&im, &res)) { + if (!model.Predict(im, &res)) { std::cerr << "Failed to predict." << std::endl; return; } diff --git a/examples/vision/segmentation/paddleseg/rknpu2/cpp/infer.cc b/examples/vision/segmentation/paddleseg/rknpu2/cpp/infer.cc index 9004828b77..bfc108d058 100644 --- a/examples/vision/segmentation/paddleseg/rknpu2/cpp/infer.cc +++ b/examples/vision/segmentation/paddleseg/rknpu2/cpp/infer.cc @@ -74,12 +74,12 @@ void InferHumanPPHumansegv2Lite(const std::string& device) { auto im = cv::imread(image_file); if (device == "npu") { - model.DisableNormalizeAndPermute(); + model.GetPreprocessor().DisableNormalizeAndPermute(); } fastdeploy::vision::SegmentationResult res; clock_t start = clock(); - if (!model.Predict(&im, &res)) { + if (!model.Predict(im, &res)) { std::cerr << "Failed to predict." << std::endl; return; } diff --git a/fastdeploy/vision/segmentation/ppseg/postprocessor.cc b/fastdeploy/vision/segmentation/ppseg/postprocessor.cc index a2acb8ef7a..953cf2c687 100644 --- a/fastdeploy/vision/segmentation/ppseg/postprocessor.cc +++ b/fastdeploy/vision/segmentation/ppseg/postprocessor.cc @@ -280,13 +280,17 @@ bool PaddleSegPostprocessor::Run( FDMat mat; std::vector uint8_result_buffer; + // Resize interpration + int interpolation = cv::INTER_LINEAR; if (is_resized) { if (infer_results_dtype == FDDataType::INT64 || infer_results_dtype == FDDataType::INT32 ){ - FDTensorCast2Uint8(&infer_result, infer_chw, &uint8_result_buffer); - } + FDTensorCast2Uint8(&infer_result, infer_chw, &uint8_result_buffer); + // label map resize with nearest interpolation + interpolation = cv::INTER_NEAREST; + } mat = std::move(Mat::Create(infer_result, ProcLib::OPENCV)); - Resize::Run(&mat, input_width, input_height, -1.0f, -1.0f, 1, false, ProcLib::OPENCV); + Resize::Run(&mat, input_width, input_height, -1.0f, -1.0f, interpolation, false, ProcLib::OPENCV); mat.ShareWithTensor(&infer_result); } result->shape = infer_result.shape;