Jelajahi Sumber

change chinese comments to english comments

FlyingQianMM 5 tahun lalu
induk
melakukan
764e89824d

+ 4 - 4
deploy/cpp/demo/classifier.cpp

@@ -51,7 +51,7 @@ int main(int argc, char** argv) {
     return -1;
   }
 
-  // 加载模型
+  // Load model
   PaddleX::Model model;
   model.Init(FLAGS_model_dir,
              FLAGS_use_gpu,
@@ -59,7 +59,7 @@ int main(int argc, char** argv) {
              FLAGS_gpu_id,
              FLAGS_key);
 
-  // 进行预测
+  // Predict
   int imgs = 1;
   if (FLAGS_image_list != "") {
     std::ifstream inf(FLAGS_image_list);
@@ -67,7 +67,7 @@ int main(int argc, char** argv) {
       std::cerr << "Fail to open file " << FLAGS_image_list << std::endl;
       return -1;
     }
-    // 多batch预测
+    // Mini-batch predict
     std::string image_path;
     std::vector<std::string> image_paths;
     while (getline(inf, image_path)) {
@@ -75,7 +75,7 @@ int main(int argc, char** argv) {
     }
     imgs = image_paths.size();
     for (int i = 0; i < image_paths.size(); i += FLAGS_batch_size) {
-      // 读图像
+      // Read image
       int im_vec_size =
           std::min(static_cast<int>(image_paths.size()), i + FLAGS_batch_size);
       std::vector<cv::Mat> im_vec(im_vec_size - i);

+ 7 - 7
deploy/cpp/demo/detector.cpp

@@ -45,7 +45,7 @@ DEFINE_int32(thread_num,
              "Number of preprocessing threads");
 
 int main(int argc, char** argv) {
-  // 解析命令行参数
+  // Parsing command-line
   google::ParseCommandLineFlags(&argc, &argv, true);
 
   if (FLAGS_model_dir == "") {
@@ -56,7 +56,7 @@ int main(int argc, char** argv) {
     std::cerr << "--image or --image_list need to be defined" << std::endl;
     return -1;
   }
-  // 加载模型
+  // Load model
   PaddleX::Model model;
   model.Init(FLAGS_model_dir,
              FLAGS_use_gpu,
@@ -65,7 +65,7 @@ int main(int argc, char** argv) {
              FLAGS_key);
   int imgs = 1;
   std::string save_dir = "output";
-  // 进行预测
+  // Predict
   if (FLAGS_image_list != "") {
     std::ifstream inf(FLAGS_image_list);
     if (!inf) {
@@ -90,7 +90,7 @@ int main(int argc, char** argv) {
         im_vec[j - i] = std::move(cv::imread(image_paths[j], 1));
       }
       model.predict(im_vec, &results, thread_num);
-      // 输出结果目标框
+      // Output predicted bounding boxes
       for (int j = 0; j < im_vec_size - i; ++j) {
         for (int k = 0; k < results[j].boxes.size(); ++k) {
           std::cout << "image file: " << image_paths[i + j] << ", ";
@@ -104,7 +104,7 @@ int main(int argc, char** argv) {
                     << results[j].boxes[k].coordinate[3] << ")" << std::endl;
         }
       }
-      // 可视化
+      // Visualize results
       for (int j = 0; j < im_vec_size - i; ++j) {
         cv::Mat vis_img = PaddleX::Visualize(
             im_vec[j], results[j], model.labels, FLAGS_threshold);
@@ -118,7 +118,7 @@ int main(int argc, char** argv) {
     PaddleX::DetResult result;
     cv::Mat im = cv::imread(FLAGS_image, 1);
     model.predict(im, &result);
-    // 输出结果目标框
+    // Output predicted bounding boxes
     for (int i = 0; i < result.boxes.size(); ++i) {
       std::cout << "image file: " << FLAGS_image << std::endl;
       std::cout << ", predict label: " << result.boxes[i].category
@@ -130,7 +130,7 @@ int main(int argc, char** argv) {
                 << result.boxes[i].coordinate[3] << ")" << std::endl;
     }
 
-    // 可视化
+    // Visualize results
     cv::Mat vis_img =
         PaddleX::Visualize(im, result, model.labels, FLAGS_threshold);
     std::string save_path =

+ 5 - 5
deploy/cpp/demo/segmenter.cpp

@@ -41,7 +41,7 @@ DEFINE_int32(thread_num,
              "Number of preprocessing threads");
 
 int main(int argc, char** argv) {
-  // 解析命令行参数
+  // Parsing command-line
   google::ParseCommandLineFlags(&argc, &argv, true);
 
   if (FLAGS_model_dir == "") {
@@ -53,7 +53,7 @@ int main(int argc, char** argv) {
     return -1;
   }
 
-  // 加载模型
+  // Load model
   PaddleX::Model model;
   model.Init(FLAGS_model_dir,
              FLAGS_use_gpu,
@@ -61,7 +61,7 @@ int main(int argc, char** argv) {
              FLAGS_gpu_id,
              FLAGS_key);
   int imgs = 1;
-  // 进行预测
+  // Predict
   if (FLAGS_image_list != "") {
     std::ifstream inf(FLAGS_image_list);
     if (!inf) {
@@ -86,7 +86,7 @@ int main(int argc, char** argv) {
         im_vec[j - i] = std::move(cv::imread(image_paths[j], 1));
       }
       model.predict(im_vec, &results, thread_num);
-      // 可视化
+      // Visualize results
       for (int j = 0; j < im_vec_size - i; ++j) {
         cv::Mat vis_img =
             PaddleX::Visualize(im_vec[j], results[j], model.labels);
@@ -100,7 +100,7 @@ int main(int argc, char** argv) {
     PaddleX::SegResult result;
     cv::Mat im = cv::imread(FLAGS_image, 1);
     model.predict(im, &result);
-    // 可视化
+    // Visualize results
     cv::Mat vis_img = PaddleX::Visualize(im, result, model.labels);
     std::string save_path =
         PaddleX::generate_save_path(FLAGS_save_dir, FLAGS_image);

+ 7 - 7
deploy/cpp/demo/video_classifier.cpp

@@ -57,7 +57,7 @@ int main(int argc, char** argv) {
     return -1;
   }
 
-  // 加载模型
+  // Load model
   PaddleX::Model model;
   model.Init(FLAGS_model_dir,
              FLAGS_use_gpu,
@@ -65,7 +65,7 @@ int main(int argc, char** argv) {
              FLAGS_gpu_id,
              FLAGS_key);
 
-  // 打开视频流
+  // Open video
   cv::VideoCapture capture;
   if (FLAGS_use_camera) {
     capture.open(FLAGS_camera_id);
@@ -85,11 +85,11 @@ int main(int argc, char** argv) {
     }
   }
 
-  // 创建VideoWriter
+  // Create a VideoWriter
   cv::VideoWriter video_out;
   std::string video_out_path;
   if (FLAGS_save_result) {
-    // 获取视频流信息: 分辨率, 帧率
+    // Get video information: resolution, fps
     int video_width = static_cast<int>(capture.get(CV_CAP_PROP_FRAME_WIDTH));
     int video_height = static_cast<int>(capture.get(CV_CAP_PROP_FRAME_HEIGHT));
     int video_fps = static_cast<int>(capture.get(CV_CAP_PROP_FPS));
@@ -126,16 +126,16 @@ int main(int argc, char** argv) {
   while (capture.read(frame)) {
     if (FLAGS_show_result || FLAGS_use_camera) {
      key = cv::waitKey(1);
-     // 按下ESC退出整个程序,保存视频文件到磁盘
+     // When pressing `ESC`, then exit program and result video is saved
      if (key == 27) {
        break;
      }
     } else if (frame.empty()) {
       break;
     }
-    // 开始预测
+    // Begin to predict
     model.predict(frame, &result);
-    // 可视化
+    // Visualize results
     cv::Mat vis_img = frame.clone();
     auto colormap = PaddleX::GenerateColorMap(model.labels.size());
     int c1 = colormap[3 * result.category_id + 0];

+ 8 - 7
deploy/cpp/demo/video_detector.cpp

@@ -48,7 +48,7 @@ DEFINE_double(threshold,
               "The minimum scores of target boxes which are shown");
 
 int main(int argc, char** argv) {
-  // 解析命令行参数
+  // Parsing command-line
   google::ParseCommandLineFlags(&argc, &argv, true);
 
   if (FLAGS_model_dir == "") {
@@ -59,14 +59,14 @@ int main(int argc, char** argv) {
     std::cerr << "--video_path or --use_camera need to be defined" << std::endl;
     return -1;
   }
-  // 加载模型
+  // Load model
   PaddleX::Model model;
   model.Init(FLAGS_model_dir,
              FLAGS_use_gpu,
              FLAGS_use_trt,
              FLAGS_gpu_id,
              FLAGS_key);
-  // 打开视频流
+  // Open video
   cv::VideoCapture capture;
   if (FLAGS_use_camera) {
     capture.open(FLAGS_camera_id);
@@ -86,11 +86,11 @@ int main(int argc, char** argv) {
     }
   }
 
-  // 创建VideoWriter
+  // Create a VideoWriter
   cv::VideoWriter video_out;
   std::string video_out_path;
   if (FLAGS_save_result) {
-    // 获取视频流信息: 分辨率, 帧率
+    // Get video information: resolution, fps
     int video_width = static_cast<int>(capture.get(CV_CAP_PROP_FRAME_WIDTH));
     int video_height = static_cast<int>(capture.get(CV_CAP_PROP_FRAME_HEIGHT));
     int video_fps = static_cast<int>(capture.get(CV_CAP_PROP_FPS));
@@ -127,15 +127,16 @@ int main(int argc, char** argv) {
   while (capture.read(frame)) {
     if (FLAGS_show_result || FLAGS_use_camera) {
      key = cv::waitKey(1);
-     // 按下ESC退出整个程序,保存视频文件到磁盘
+     // When pressing `ESC`, then exit program and result video is saved
      if (key == 27) {
        break;
      }
     } else if (frame.empty()) {
       break;
     }
+    // Begin to predict
     model.predict(frame, &result);
-    // 可视化
+    // Visualize results
     cv::Mat vis_img =
         PaddleX::Visualize(frame, result, model.labels, FLAGS_threshold);
     if (FLAGS_show_result || FLAGS_use_camera) {

+ 8 - 8
deploy/cpp/demo/video_segmenter.cpp

@@ -45,7 +45,7 @@ DEFINE_bool(save_result, true, "save the result of each frame to a video");
 DEFINE_string(save_dir, "output", "Path to save visualized image");
 
 int main(int argc, char** argv) {
-  // 解析命令行参数
+  // Parsing command-line
   google::ParseCommandLineFlags(&argc, &argv, true);
 
   if (FLAGS_model_dir == "") {
@@ -57,14 +57,14 @@ int main(int argc, char** argv) {
     return -1;
   }
 
-  // 加载模型
+  // Load model
   PaddleX::Model model;
   model.Init(FLAGS_model_dir,
              FLAGS_use_gpu,
              FLAGS_use_trt,
              FLAGS_gpu_id,
              FLAGS_key);
-  // 打开视频流
+  // Open video
   cv::VideoCapture capture;
   if (FLAGS_use_camera) {
     capture.open(FLAGS_camera_id);
@@ -85,11 +85,11 @@ int main(int argc, char** argv) {
   }
 
 
-  // 创建VideoWriter
+  // Create a VideoWriter
   cv::VideoWriter video_out;
   std::string video_out_path;
   if (FLAGS_save_result) {
-    // 获取视频流信息: 分辨率, 帧率
+    // Get video information: resolution, fps
     int video_width = static_cast<int>(capture.get(CV_CAP_PROP_FRAME_WIDTH));
     int video_height = static_cast<int>(capture.get(CV_CAP_PROP_FRAME_HEIGHT));
     int video_fps = static_cast<int>(capture.get(CV_CAP_PROP_FPS));
@@ -126,16 +126,16 @@ int main(int argc, char** argv) {
   while (capture.read(frame)) {
     if (FLAGS_show_result || FLAGS_use_camera) {
      key = cv::waitKey(1);
-     // 按下ESC退出整个程序,保存视频文件到磁盘
+     // When pressing `ESC`, then exit program and result video is saved
      if (key == 27) {
        break;
      }
     } else if (frame.empty()) {
       break;
     }
-    // 开始预测
+    // Begin to predict
     model.predict(frame, &result);
-    // 可视化
+    // Visualize results
     cv::Mat vis_img = PaddleX::Visualize(frame, result, model.labels);
     if (FLAGS_show_result || FLAGS_use_camera) {
       cv::imshow("video_segmenter", vis_img);

+ 9 - 9
examples/human_segmentation/deploy/cpp/human_segmenter.cpp

@@ -46,7 +46,7 @@ DEFINE_bool(save_result, true, "save the result of each frame to a video");
 DEFINE_string(save_dir, "output", "Path to save visualized image");
 
 int main(int argc, char** argv) {
-  // 解析命令行参数
+  // Parsing command-line
   google::ParseCommandLineFlags(&argc, &argv, true);
 
   if (FLAGS_model_dir == "") {
@@ -60,7 +60,7 @@ int main(int argc, char** argv) {
     return -1;
   }
 
-  // 加载模型
+  // Load model
   PaddleX::Model model;
   model.Init(FLAGS_model_dir,
              FLAGS_use_gpu,
@@ -68,7 +68,7 @@ int main(int argc, char** argv) {
              FLAGS_gpu_id,
              FLAGS_key);
   if (FLAGS_use_camera || FLAGS_video_path != "") {
-    // 打开视频流
+    // Open video
     cv::VideoCapture capture;
     if (FLAGS_use_camera) {
       capture.open(FLAGS_camera_id);
@@ -88,11 +88,11 @@ int main(int argc, char** argv) {
       }
     }
 
-    // 创建VideoWriter
+    // Create a VideoWriter
     cv::VideoWriter video_out;
     std::string video_out_path;
     if (FLAGS_save_result) {
-      // 获取视频流信息: 分辨率, 帧率
+      // Get video information: resolution, fps
       int video_width = static_cast<int>(capture.get(CV_CAP_PROP_FRAME_WIDTH));
       int video_height =
         static_cast<int>(capture.get(CV_CAP_PROP_FRAME_HEIGHT));
@@ -129,16 +129,16 @@ int main(int argc, char** argv) {
     while (capture.read(frame)) {
       if (FLAGS_show_result || FLAGS_use_camera) {
        key = cv::waitKey(1);
-       // 按下ESC退出整个程序,保存视频文件到磁盘
+       // When pressing `ESC`, then exit program and result video is saved
        if (key == 27) {
          break;
        }
       } else if (frame.empty()) {
         break;
       }
-      // 开始预测
+      // Begin to predict
       model.predict(frame, &result);
-      // 可视化
+      // Visualize results
       std::vector<uint8_t> label_map(result.label_map.data.begin(),
                                      result.label_map.data.end());
       cv::Mat mask(result.label_map.shape[0],
@@ -178,7 +178,7 @@ int main(int argc, char** argv) {
     PaddleX::SegResult result;
     cv::Mat im = cv::imread(FLAGS_image, 1);
     model.predict(im, &result);
-    // 可视化
+    // Visualize results
     std::vector<uint8_t> label_map(result.label_map.data.begin(),
                                    result.label_map.data.end());
     cv::Mat mask(result.label_map.shape[0],

+ 3 - 2
examples/meter_reader/deploy/cpp/meter_reader/meter_reader.cpp

@@ -51,7 +51,8 @@ DEFINE_string(seg_key, "", "Segmenter model 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");
-DEFINE_double(score_threshold, 0.5, "Detected bbox whose score is lower than this threshlod is filtered");
+DEFINE_double(score_threshold, 0.5,
+  "Detected bbox whose score is lower than this threshlod is filtered");
 
 void predict(const cv::Mat &input_image, PaddleX::Model *det_model,
              PaddleX::Model *seg_model, const std::string save_dir,
@@ -207,7 +208,7 @@ int main(int argc, char **argv) {
     return -1;
   }
 
-  // 加载模型
+  // Load model
   PaddleX::Model det_model;
   det_model.Init(FLAGS_det_model_dir, FLAGS_use_gpu, FLAGS_use_trt,
                  FLAGS_gpu_id, FLAGS_det_key);