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6l>dNR@90rcRxoSooY{r2VF<@AZ;<$l!DkekN-DVh7zvhNP7yNPNcyeOvm{~8glSony5tVPk>(J
zd0WbYG|)9bOFeP);7f80Ykvt`9Fm<1t&$0EsP>D}-cTp)kk$SwnEcvOy`d}>o>c(O9_=M3gAtZV_T%IAF_oy|`yBqAG!
zvn%LXC$dBEGK`AsXvCjg3m=L=q_QpycLW(x9jpsPv;7_5>e~V0G3zar3U@*6wQIFp
z?S>d>)giW{O2g5B;TvoAT(z_?y=I=Y2dSmCK?iC@r}}&H4hj|~_ED@$Rd^`i{QwWY
zxZ_?2B;O`5@vbTxv>)gO?6>gUkZCwvhcTdI
zf#ZPGAy3Y!Pu#8WUPanaw9Tkj>WKQJZmBowlzl>biQgl%8`%zim(bRO|DN~~@NA$9
zNZS!UEFu$VL$U_gw>ETN4OsR2FZ=hur{@^5s{ifZ|90>Gw}1cJz5Cz({qO17|GL&Z
zQzU3=yxGsLt^xb^f5vb8_#H%DbhqFC@wCtO|1-^UoL88kZT@*Y#YhIVtR_dA-r6SL
zl<{POys%G!l;*Z@25FI=lK(_rOOC&Gfcza&``tr2xp$7qwWR%Rg)n_l
z+<~qzx`+;Pr_y)tozq_l
+
+#include
+#include
+#include
+#include
+
+#include "include/paddlex/paddlex.h"
+
+DEFINE_string(model_dir, "", "Path of inference model");
+DEFINE_bool(use_gpu, false, "Infering with GPU or CPU");
+DEFINE_bool(use_trt, false, "Infering with TensorRT");
+DEFINE_int32(gpu_id, 0, "GPU card id");
+DEFINE_string(key, "", "key of encryption");
+DEFINE_string(image, "", "Path of test image file");
+DEFINE_string(image_list, "", "Path of test image list file");
+
+int main(int argc, char** argv) {
+ // Parsing command-line
+ google::ParseCommandLineFlags(&argc, &argv, true);
+
+ if (FLAGS_model_dir == "") {
+ std::cerr << "--model_dir need to be defined" << std::endl;
+ return -1;
+ }
+ if (FLAGS_image == "" & FLAGS_image_list == "") {
+ std::cerr << "--image or --image_list need to be defined" << std::endl;
+ return -1;
+ }
+
+ // 加载模型
+ PaddleX::Model model;
+ model.Init(FLAGS_model_dir, FLAGS_use_gpu, FLAGS_use_trt, FLAGS_gpu_id, FLAGS_key);
+
+ // 进行预测
+ if (FLAGS_image_list != "") {
+ std::ifstream inf(FLAGS_image_list);
+ if (!inf) {
+ std::cerr << "Fail to open file " << FLAGS_image_list << std::endl;
+ return -1;
+ }
+ std::string image_path;
+ while (getline(inf, image_path)) {
+ PaddleX::ClsResult result;
+ cv::Mat im = cv::imread(image_path, 1);
+ model.predict(im, &result);
+ std::cout << "Predict label: " << result.category
+ << ", label_id:" << result.category_id
+ << ", score: " << result.score << std::endl;
+ }
+ } else {
+ PaddleX::ClsResult result;
+ cv::Mat im = cv::imread(FLAGS_image, 1);
+ model.predict(im, &result);
+ std::cout << "Predict label: " << result.category
+ << ", label_id:" << result.category_id
+ << ", score: " << result.score << std::endl;
+ }
+
+ return 0;
+}
diff --git a/deploy/cpp_dll/demo/detector.cpp b/deploy/cpp_dll/demo/detector.cpp
new file mode 100644
index 0000000..c3fe617
--- /dev/null
+++ b/deploy/cpp_dll/demo/detector.cpp
@@ -0,0 +1,79 @@
+// Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// 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
+#include
+#include
+#include
+
+#include "include/paddlex/paddlex.h"
+#include "include/paddlex/visualize.h"
+
+namespace PaddleX {
+std::string image;
+void PredictImage(std::string image, PaddleX::DetResult result);
+
+void Loadmodel() {
+ std::string model_dir = "E:\\0608\\inference_model";
+ std::string key = "";
+ std::string image_list = "";
+ std::string save_dir = "output";
+ int gpu_id = 0;
+ bool use_trt = 0;
+ bool use_gpu = 1;
+
+ // Load model and create a object detector
+
+ PaddleX::DetResult result;
+ PredictImage(image, result);
+}
+
+void PredictImage(std::string image, PaddleX::DetResult result) {
+ image = "E:\\0608\\pic\\test.jpg";
+ cv::Mat im = cv::imread(image, 1);
+
+ // PaddleX::DetResult* result;
+ std::string model_dir = "E:\\0608\\inference_model";
+ std::string key = "";
+ std::string image_list = "";
+
+ int gpu_id = 0;
+ bool use_trt = 0;
+ bool use_gpu = 1;
+ PaddleX::Model model;
+ model.Init(model_dir, use_gpu, use_trt, gpu_id, key);
+ model.predict(im, &result);
+ for (int i = 0; i < result.boxes.size(); ++i) {
+ std::cout << ", predict label: " << result.boxes[i].category
+ << ", label_id:" << result.boxes[i].category_id
+ << ", score: " << result.boxes[i].score
+ << ", box(xmin, ymin, w, h):(" << result.boxes[i].coordinate[0]
+ << ", " << result.boxes[i].coordinate[1] << ", "
+ << result.boxes[i].coordinate[2] << ", "
+ << result.boxes[i].coordinate[3] << ")" << std::endl;
+ }
+
+ // 可视化
+ auto colormap = PaddleX::GenerateColorMap(model.labels.size());
+ cv::Mat vis_img = PaddleX::Visualize(im, result, model.labels, colormap, 0.5);
+ std::string save_dir = "output";
+ std::string save_path = PaddleX::generate_save_path(save_dir, image);
+
+ cv::imwrite(save_path, vis_img);
+ // result->clear();
+ std::cout << "Visualized output saved as " << save_path << std::endl;
+}
+} // namespace PaddleX
\ No newline at end of file
diff --git a/deploy/cpp_dll/demo/segmenter.cpp b/deploy/cpp_dll/demo/segmenter.cpp
new file mode 100644
index 0000000..687bb40
--- /dev/null
+++ b/deploy/cpp_dll/demo/segmenter.cpp
@@ -0,0 +1,87 @@
+// Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// 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
+#include
+#include
+#include
+
+#include "include/paddlex/paddlex.h"
+#include "include/paddlex/visualize.h"
+
+DEFINE_string(model_dir, "", "Path of inference model");
+DEFINE_bool(use_gpu, false, "Infering with GPU or CPU");
+DEFINE_bool(use_trt, false, "Infering with TensorRT");
+DEFINE_int32(gpu_id, 0, "GPU card id");
+DEFINE_string(key, "", "key of encryption");
+DEFINE_string(image, "", "Path of test image file");
+DEFINE_string(image_list, "", "Path of test image list file");
+DEFINE_string(save_dir, "output", "Path to save visualized image");
+
+int main(int argc, char** argv) {
+ // 解析命令行参数
+ google::ParseCommandLineFlags(&argc, &argv, true);
+
+ if (FLAGS_model_dir == "") {
+ std::cerr << "--model_dir need to be defined" << std::endl;
+ return -1;
+ }
+ if (FLAGS_image == "" & FLAGS_image_list == "") {
+ std::cerr << "--image or --image_list need to be defined" << std::endl;
+ return -1;
+ }
+
+ // 加载模型
+ PaddleX::Model model;
+ model.Init(FLAGS_model_dir, FLAGS_use_gpu, FLAGS_use_trt, FLAGS_gpu_id, FLAGS_key);
+
+ auto colormap = PaddleX::GenerateColorMap(model.labels.size());
+ // 进行预测
+ if (FLAGS_image_list != "") {
+ std::ifstream inf(FLAGS_image_list);
+ if (!inf) {
+ std::cerr << "Fail to open file " << FLAGS_image_list << std::endl;
+ return -1;
+ }
+ std::string image_path;
+ while (getline(inf, image_path)) {
+ PaddleX::SegResult result;
+ cv::Mat im = cv::imread(image_path, 1);
+ model.predict(im, &result);
+ // 可视化
+ cv::Mat vis_img =
+ PaddleX::Visualize(im, result, model.labels, colormap);
+ std::string save_path =
+ PaddleX::generate_save_path(FLAGS_save_dir, image_path);
+ cv::imwrite(save_path, vis_img);
+ result.clear();
+ std::cout << "Visualized output saved as " << save_path << std::endl;
+ }
+ } else {
+ PaddleX::SegResult result;
+ cv::Mat im = cv::imread(FLAGS_image, 1);
+ model.predict(im, &result);
+ // 可视化
+ cv::Mat vis_img = PaddleX::Visualize(im, result, model.labels, colormap);
+ std::string save_path =
+ PaddleX::generate_save_path(FLAGS_save_dir, FLAGS_image);
+ cv::imwrite(save_path, vis_img);
+ result.clear();
+ std::cout << "Visualized output saved as " << save_path << std::endl;
+ }
+
+ return 0;
+}
diff --git a/deploy/cpp_dll/include/paddlex/config_parser.h b/deploy/cpp_dll/include/paddlex/config_parser.h
new file mode 100644
index 0000000..7262945
--- /dev/null
+++ b/deploy/cpp_dll/include/paddlex/config_parser.h
@@ -0,0 +1,57 @@
+// Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// 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.
+
+#pragma once
+
+#include
+#include