Channingss 5 년 전
부모
커밋
248fb5a472
4개의 변경된 파일27개의 추가작업 그리고 13개의 파일을 삭제
  1. 1 1
      .pre-commit-config.yaml
  2. 2 1
      deploy/cpp/include/paddlex/results.h
  3. 8 8
      deploy/lite/export_lite.py
  4. 16 3
      docs/tutorials/deploy/deploy_lite.md

+ 1 - 1
.pre-commit-config.yaml

@@ -35,6 +35,6 @@
     -   id: cpplint-cpp-source
         name: cpplint
         description: Check C++ code style using cpplint.py.
-        entry: bash cpplint_pre_commit.hook
+        entry: bash ./tools/codestyle/cpplint_pre_commit.hook
         language: system
         files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx)$

+ 2 - 1
deploy/cpp/include/paddlex/results.h

@@ -63,9 +63,10 @@ class SegResult : public BaseResult {
  public:
   Mask<int64_t> label_map;
   Mask<float> score_map;
+  std::string type = "seg";
   void clear() {
     label_map.clear();
     score_map.clear();
   }
 };
-}  // namespce of PaddleX
+}  // namespace PaddleX

+ 8 - 8
deploy/lite/export_lite.py

@@ -19,30 +19,30 @@ import argparse
 
 def export_lite():
     opt = lite.Opt()
-    model_file = os.path.join(FLAGS.model_path, '__model__')
-    params_file = os.path.join(FLAGS.model_path, '__params__')
-    opt.run_optimize("", model_file, params_file, FLAGS.place, FLAGS.save_dir)
+    model_file = os.path.join(FLAGS.model_dir, '__model__')
+    params_file = os.path.join(FLAGS.model_dir, '__params__')
+    opt.run_optimize("", model_file, params_file, FLAGS.place, FLAGS.save_file)
 
 
 if __name__ == '__main__':
     parser = argparse.ArgumentParser(description=__doc__)
     parser.add_argument(
-        "--model_path",
+        "--model_dir",
         type=str,
         default="",
-        help="model path.",
+        help="path of '__model__' and '__params__'.",
         required=True)
     parser.add_argument(
         "--place",
         type=str,
         default="arm",
-        help="preprocess config path.",
+        help="run place: 'arm|opencl|x86|npu|xpu|rknpu|apu'.",
         required=True)
     parser.add_argument(
-        "--save_dir",
+        "--save_file",
         type=str,
         default="paddlex.onnx",
-        help="Directory for storing the output visualization files.",
+        help="file name for storing the output files.",
         required=True)
     FLAGS = parser.parse_args()
     export_lite()

+ 16 - 3
docs/tutorials/deploy/deploy_lite.md

@@ -1,5 +1,12 @@
 # 移动端部署
 
+PaddleX的移动端部署由PaddleLite实现,部署的流程如下,首先将训练好的模型导出为inference model,然后使用PaddleLite的python接口对模型进行优化,最后使用PaddleLite的预测库进行部署,
+PaddleLite的详细介绍和使用可参考:[PaddleLite文档](https://paddle-lite.readthedocs.io/zh/latest/)
+
+> PaddleX --> Inference Model --> PaddleLite Opt --> PaddleLite Inference
+
+以下介绍如何将PaddleX导出为inference model,然后使用PaddleLite的OPT模块对模型进行优化:
+
 step 1: 安装PaddleLite
 
 ```
@@ -9,15 +16,21 @@ pip install paddlelite
 step 2: 将PaddleX模型导出为inference模型
 
 参考[导出inference模型](deploy_server/deploy_python.html#inference)将模型导出为inference格式模型。
-**注意:由于PaddleX代码的持续更新,版本低于1.0.0的模型暂时无法直接用于预测部署,参考[模型版本升级](../upgrade_version.md)对模型版本进行升级。**
+**注意:由于PaddleX代码的持续更新,版本低于1.0.0的模型暂时无法直接用于预测部署,参考[模型版本升级](./upgrade_version.md)对模型版本进行升级。**
 
 step 3: 将inference模型转换成PaddleLite模型
 
 ```
-python /path/to/PaddleX/deploy/lite/export_lite.py --model_path /path/to/inference_model --save_dir /path/to/onnx_model
+python /path/to/PaddleX/deploy/lite/export_lite.py --model_dir /path/to/inference_model --save_file /path/to/onnx_model --place place/to/run
+
 ```
 
-`--model_path`用于指定inference模型的路径,`--save_dir`用于指定Lite模型的保存路径。
+|  参数   | 说明  |
+|  ----  | ----  |
+| model_dir  | 预测模型所在路径,包含"__model__", "__params__"文件 |
+| save_file  | 模型输出的名称,默认为"paddlex.nb" |
+| place  | 运行的平台,可选:arm|opencl|x86|npu|xpu|rknpu|apu |
+
 
 step 4: 预测