diff --git a/contrib/RealTimeHumanSeg/CMakeLists.txt b/contrib/RealTimeHumanSeg/cpp/CMakeLists.txt similarity index 100% rename from contrib/RealTimeHumanSeg/CMakeLists.txt rename to contrib/RealTimeHumanSeg/cpp/CMakeLists.txt diff --git a/contrib/RealTimeHumanSeg/CMakeSettings.json b/contrib/RealTimeHumanSeg/cpp/CMakeSettings.json similarity index 100% rename from contrib/RealTimeHumanSeg/CMakeSettings.json rename to contrib/RealTimeHumanSeg/cpp/CMakeSettings.json diff --git a/contrib/RealTimeHumanSeg/README.md b/contrib/RealTimeHumanSeg/cpp/README.md similarity index 100% rename from contrib/RealTimeHumanSeg/README.md rename to contrib/RealTimeHumanSeg/cpp/README.md diff --git a/contrib/RealTimeHumanSeg/docs/linux_build.md b/contrib/RealTimeHumanSeg/cpp/docs/linux_build.md similarity index 100% rename from contrib/RealTimeHumanSeg/docs/linux_build.md rename to contrib/RealTimeHumanSeg/cpp/docs/linux_build.md diff --git a/contrib/RealTimeHumanSeg/docs/windows_build.md b/contrib/RealTimeHumanSeg/cpp/docs/windows_build.md similarity index 100% rename from contrib/RealTimeHumanSeg/docs/windows_build.md rename to contrib/RealTimeHumanSeg/cpp/docs/windows_build.md diff --git a/contrib/RealTimeHumanSeg/humanseg.cc b/contrib/RealTimeHumanSeg/cpp/humanseg.cc similarity index 94% rename from contrib/RealTimeHumanSeg/humanseg.cc rename to contrib/RealTimeHumanSeg/cpp/humanseg.cc index 988742bee10f67f696283d5a63d5223ccc14449d..b81c81200064f6191e18cdb39fc8d6414aa5fe9d 100644 --- a/contrib/RealTimeHumanSeg/humanseg.cc +++ b/contrib/RealTimeHumanSeg/cpp/humanseg.cc @@ -44,7 +44,9 @@ void LoadModel( std::unique_ptr* predictor) { // Config the model info paddle::AnalysisConfig config; - config.SetModel(model_dir); + auto prog_file = model_dir + "/__model__"; + auto params_file = model_dir + "/__params__"; + config.SetModel(prog_file, params_file); if (use_gpu) { config.EnableUseGpu(100, 0); } else { @@ -60,7 +62,8 @@ void LoadModel( void HumanSeg::Preprocess(const cv::Mat& image_mat) { // Clone the image : keep the original mat for postprocess cv::Mat im = image_mat.clone(); - cv::resize(im, im, cv::Size(192, 192), 0.f, 0.f, cv::INTER_LINEAR); + auto eval_wh = cv::Size(eval_size_[0], eval_size_[1]); + cv::resize(im, im, eval_wh, 0.f, 0.f, cv::INTER_LINEAR); im.convertTo(im, CV_32FC3, 1.0); int rc = im.channels(); diff --git a/contrib/RealTimeHumanSeg/humanseg.h b/contrib/RealTimeHumanSeg/cpp/humanseg.h similarity index 92% rename from contrib/RealTimeHumanSeg/humanseg.h rename to contrib/RealTimeHumanSeg/cpp/humanseg.h index 9a4223460a71ceed70e25acf31636cd9b89f7dce..edaf825f713847a3b2c8bf5bae3a36de6ec03395 100644 --- a/contrib/RealTimeHumanSeg/humanseg.h +++ b/contrib/RealTimeHumanSeg/cpp/humanseg.h @@ -37,9 +37,11 @@ class HumanSeg { explicit HumanSeg(const std::string& model_dir, const std::vector& mean, const std::vector& scale, + const std::vector& eval_size, bool use_gpu = false) : mean_(mean), - scale_(scale) { + scale_(scale), + eval_size_(eval_size) { LoadModel(model_dir, use_gpu, &predictor_); } @@ -60,4 +62,5 @@ class HumanSeg { std::vector segout_data_; std::vector mean_; std::vector scale_; + std::vector eval_size_; }; diff --git a/contrib/RealTimeHumanSeg/humanseg_postprocess.cc b/contrib/RealTimeHumanSeg/cpp/humanseg_postprocess.cc similarity index 100% rename from contrib/RealTimeHumanSeg/humanseg_postprocess.cc rename to contrib/RealTimeHumanSeg/cpp/humanseg_postprocess.cc diff --git a/contrib/RealTimeHumanSeg/humanseg_postprocess.h b/contrib/RealTimeHumanSeg/cpp/humanseg_postprocess.h similarity index 100% rename from contrib/RealTimeHumanSeg/humanseg_postprocess.h rename to contrib/RealTimeHumanSeg/cpp/humanseg_postprocess.h diff --git a/contrib/RealTimeHumanSeg/linux_build.sh b/contrib/RealTimeHumanSeg/cpp/linux_build.sh similarity index 100% rename from contrib/RealTimeHumanSeg/linux_build.sh rename to contrib/RealTimeHumanSeg/cpp/linux_build.sh diff --git a/contrib/RealTimeHumanSeg/main.cc b/contrib/RealTimeHumanSeg/cpp/main.cc similarity index 96% rename from contrib/RealTimeHumanSeg/main.cc rename to contrib/RealTimeHumanSeg/cpp/main.cc index fea3a548dd1ef556066d5985c114226f6da6dca5..303051f051b885a83b0ef608fe2ab1319f97294e 100644 --- a/contrib/RealTimeHumanSeg/main.cc +++ b/contrib/RealTimeHumanSeg/cpp/main.cc @@ -78,7 +78,8 @@ int main(int argc, char* argv[]) { // Init Model std::vector means = {104.008, 116.669, 122.675}; std::vector scale = {1.000, 1.000, 1.000}; - HumanSeg seg(model_dir, means, scale, use_gpu); + std::vector eval_sz = {192, 192}; + HumanSeg seg(model_dir, means, scale, eval_sz, use_gpu); // Call ImagePredict while input_path is a image file path // The output will be saved as result.jpeg