From 8c652e277c9846433a562efe6e9938b335fc835a Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng Date: Fri, 8 Nov 2024 12:45:32 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- configs/LZ-ArcFace.yaml | 24 +++++++++++++----------- configs/LZ-MobileNetV3.yaml | 24 +++++++++++++----------- configs/LZ-Picodet.yaml | 24 +++++++++++++----------- configs/LZ-Picodet_fp32.yaml | 24 +++++++++++++----------- configs/LZ-RetinaFace.yaml | 24 +++++++++++++----------- 5 files changed, 65 insertions(+), 55 deletions(-) diff --git a/configs/LZ-ArcFace.yaml b/configs/LZ-ArcFace.yaml index 789cdb1..b29cbe3 100644 --- a/configs/LZ-ArcFace.yaml +++ b/configs/LZ-ArcFace.yaml @@ -1,14 +1,4 @@ -config: - # RGB - mean: - - 0.485 - - 0.456 - - 0.406 - std: - - 0.229 - - 0.224 - - 0.225 - type: "fp32" +backend: "rknn" load_onnx: inputs: @@ -22,6 +12,18 @@ load_onnx: outputs: - save_infer_model/scale_0.tmp_1 +config: + # RGB + mean: + - 0.485 + - 0.456 + - 0.406 + std: + - 0.229 + - 0.224 + - 0.225 + type: "fp32" + build: do_quantization: True dataset: ./dataset.txt \ No newline at end of file diff --git a/configs/LZ-MobileNetV3.yaml b/configs/LZ-MobileNetV3.yaml index 3020477..2e7f2d9 100644 --- a/configs/LZ-MobileNetV3.yaml +++ b/configs/LZ-MobileNetV3.yaml @@ -1,14 +1,4 @@ -config: - # BGR - mean: - - 0.406 - - 0.456 - - 0.485 - std: - - 0.225 - - 0.224 - - 0.229 - type: "fp32" +backend: "rknn" load_onnx: inputs: @@ -22,6 +12,18 @@ load_onnx: outputs: - DequantizeLinear.881 +config: + # BGR + mean: + - 0.406 + - 0.456 + - 0.485 + std: + - 0.225 + - 0.224 + - 0.229 + type: "fp32" + build: do_quantization: false dataset: \ No newline at end of file diff --git a/configs/LZ-Picodet.yaml b/configs/LZ-Picodet.yaml index ce39f0e..f0f189c 100644 --- a/configs/LZ-Picodet.yaml +++ b/configs/LZ-Picodet.yaml @@ -1,14 +1,4 @@ -config: - # BGR - mean: - - 0.406 - - 0.456 - - 0.485 - std: - - 0.225 - - 0.224 - - 0.229 - type: "fp32" +backend: "rknn" load_onnx: inputs: @@ -29,6 +19,18 @@ load_onnx: - DequantizeLinear.1445 - DequantizeLinear.1447 +config: + # BGR + mean: + - 0.406 + - 0.456 + - 0.485 + std: + - 0.225 + - 0.224 + - 0.229 + type: "fp32" + build: do_quantization: false dataset: \ No newline at end of file diff --git a/configs/LZ-Picodet_fp32.yaml b/configs/LZ-Picodet_fp32.yaml index 8071fd3..5076688 100644 --- a/configs/LZ-Picodet_fp32.yaml +++ b/configs/LZ-Picodet_fp32.yaml @@ -1,14 +1,4 @@ -config: - # BGR - mean: - - 0.406 - - 0.456 - - 0.485 - std: - - 0.225 - - 0.224 - - 0.229 - type: "fp32" +backend: "rknn" load_onnx: inputs: @@ -29,6 +19,18 @@ load_onnx: - sigmoid_3.tmp_0 - split_3.tmp_1 +config: + # BGR + mean: + - 0.406 + - 0.456 + - 0.485 + std: + - 0.225 + - 0.224 + - 0.229 + type: "fp32" + build: do_quantization: True dataset: ./dataset.txt \ No newline at end of file diff --git a/configs/LZ-RetinaFace.yaml b/configs/LZ-RetinaFace.yaml index e51314c..a68103e 100644 --- a/configs/LZ-RetinaFace.yaml +++ b/configs/LZ-RetinaFace.yaml @@ -1,14 +1,4 @@ -config: - # RGB - mean: - - -104 - - -117 - - -123 - std: - - 1 - - 1 - - 1 - type: "int8" +backend: "rknn" load_onnx: inputs: @@ -24,6 +14,18 @@ load_onnx: - classifications - 571 +config: + # RGB + mean: + - -104 + - -117 + - -123 + std: + - 1 + - 1 + - 1 + type: "int8" + build: do_quantization: True dataset: ./dataset.txt \ No newline at end of file -- Gitee From 65eabc85ef520064c5927a31ef9ee9281a9bf1a0 Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng Date: Fri, 8 Nov 2024 15:51:57 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=9B=9E=E5=A4=8DRKNN=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- configs/LZ-ArcFace.yaml | 2 -- configs/LZ-LPRNet.yaml | 27 +++++++++++++++++++++++++++ configs/LZ-MobileNetV3.yaml | 2 -- configs/LZ-Picodet.yaml | 2 -- configs/LZ-Picodet_fp32.yaml | 2 -- configs/LZ-RetinaFace.yaml | 2 -- docs/models/lprnet.md | 13 +++++++++++++ utils/export.py | 24 +++++++++++------------- 8 files changed, 51 insertions(+), 23 deletions(-) create mode 100644 configs/LZ-LPRNet.yaml create mode 100644 docs/models/lprnet.md diff --git a/configs/LZ-ArcFace.yaml b/configs/LZ-ArcFace.yaml index b29cbe3..a1bdec9 100644 --- a/configs/LZ-ArcFace.yaml +++ b/configs/LZ-ArcFace.yaml @@ -1,5 +1,3 @@ -backend: "rknn" - load_onnx: inputs: - x diff --git a/configs/LZ-LPRNet.yaml b/configs/LZ-LPRNet.yaml new file mode 100644 index 0000000..5a4a954 --- /dev/null +++ b/configs/LZ-LPRNet.yaml @@ -0,0 +1,27 @@ +load_onnx: + inputs: + - input + input_size_list: + - + - 1 + - 3 + - 24 + - 94 + outputs: + - output + +config: + # RGB + mean: + - 0.5 + - 0.5 + - 0.5 + std: + - 0.5 + - 0.5 + - 0.5 + type: "fp32" + +build: + do_quantization: True + dataset: ./dataset.txt \ No newline at end of file diff --git a/configs/LZ-MobileNetV3.yaml b/configs/LZ-MobileNetV3.yaml index 2e7f2d9..563dca5 100644 --- a/configs/LZ-MobileNetV3.yaml +++ b/configs/LZ-MobileNetV3.yaml @@ -1,5 +1,3 @@ -backend: "rknn" - load_onnx: inputs: - x diff --git a/configs/LZ-Picodet.yaml b/configs/LZ-Picodet.yaml index f0f189c..e7ac15f 100644 --- a/configs/LZ-Picodet.yaml +++ b/configs/LZ-Picodet.yaml @@ -1,5 +1,3 @@ -backend: "rknn" - load_onnx: inputs: - image diff --git a/configs/LZ-Picodet_fp32.yaml b/configs/LZ-Picodet_fp32.yaml index 5076688..4cd21d4 100644 --- a/configs/LZ-Picodet_fp32.yaml +++ b/configs/LZ-Picodet_fp32.yaml @@ -1,5 +1,3 @@ -backend: "rknn" - load_onnx: inputs: - image diff --git a/configs/LZ-RetinaFace.yaml b/configs/LZ-RetinaFace.yaml index a68103e..e8b9a23 100644 --- a/configs/LZ-RetinaFace.yaml +++ b/configs/LZ-RetinaFace.yaml @@ -1,5 +1,3 @@ -backend: "rknn" - load_onnx: inputs: - input0 diff --git a/docs/models/lprnet.md b/docs/models/lprnet.md new file mode 100644 index 0000000..0e93dee --- /dev/null +++ b/docs/models/lprnet.md @@ -0,0 +1,13 @@ +```bash +cd /path/to/LockzhinerVisionModule + +rm lprnet.onnx +wget https://ftrg.zbox.filez.com/v2/delivery/data/95f00b0fc900458ba134f8b180b3f7a1/examples/LPRNet/lprnet.onnx + +rm LZ-LPRNet.onnx +mv lprnet.onnx LZ-LPRNet.onnx + +python utils/export.py \ + --config_path=./configs/LZ-LPRNet.yaml \ + --model_load_path=./LZ-LPRNet.onnx +``` \ No newline at end of file diff --git a/utils/export.py b/utils/export.py index c826f09..c990f0f 100644 --- a/utils/export.py +++ b/utils/export.py @@ -9,20 +9,14 @@ import onnx def get_config(): parser = argparse.ArgumentParser() parser.add_argument("--verbose", default="Debug", help="rknntoolkit verbose") - parser.add_argument( - "--config_path", required=True, help="The path of model config file" - ) - parser.add_argument( - "--model_load_path", required=True, help="The path of onnx model file" - ) - parser.add_argument("--target_platform", required=True, help="The target platform") - parser.add_argument( - "--model_save_path", required=True, help="The path of rknn model save" + parser.add_argument("--config_path", required=True, help="The path of model config file") + parser.add_argument("--model_load_path", required=True, help="The path of onnx model file") + parser.add_argument("--target_platform", required=False, help="The target platform") + parser.add_argument("--model_save_path", required=False, help="The path of rknn model save" ) args = parser.parse_args() return args - if __name__ == "__main__": config = get_config() with open(config.config_path) as file: @@ -30,9 +24,13 @@ if __name__ == "__main__": yaml_config = yaml.safe_load(file_data) print(yaml_config) - config_inputs = [str(input_name) for input_name in yaml_config["load_onnx"]["inputs"]] + config_inputs = [ + str(input_name) for input_name in yaml_config["load_onnx"]["inputs"] + ] config_input_size_list = yaml_config["load_onnx"]["input_size_list"] - config_outputs = [str(output_name) for output_name in yaml_config["load_onnx"]["outputs"]] + config_outputs = [ + str(output_name) for output_name in yaml_config["load_onnx"]["outputs"] + ] # Prune ONNX Model print("--> Prune ONNX Model") @@ -98,4 +96,4 @@ if __name__ == "__main__": model_save_path = config.model_save_path ret = model.export_rknn(model_save_path) assert ret == 0, "Export rknn model failed!" - print("Export OK!") + print("Export OK!") \ No newline at end of file -- Gitee From e1fec54a533921701e2d307a8ae2e26f64b7eb62 Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng Date: Fri, 8 Nov 2024 16:02:45 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AF=BC=E5=87=BA=20LPRN?= =?UTF-8?q?et=20NCNN=20=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 7 +++++++ docs/models/lprnet.md | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index b33e012..e94becb 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,13 @@ dataset.txt *.pdmodel *.onnx *.rknn +debug* +*.ncnn.bin +*.ncnn.param +*.pnnx.bin +*.pnnx.param +LZ-*.py + # Picture *.jpg diff --git a/docs/models/lprnet.md b/docs/models/lprnet.md index 0e93dee..6b42488 100644 --- a/docs/models/lprnet.md +++ b/docs/models/lprnet.md @@ -7,7 +7,17 @@ wget https://ftrg.zbox.filez.com/v2/delivery/data/95f00b0fc900458ba134f8b180b3f7 rm LZ-LPRNet.onnx mv lprnet.onnx LZ-LPRNet.onnx -python utils/export.py \ - --config_path=./configs/LZ-LPRNet.yaml \ - --model_load_path=./LZ-LPRNet.onnx +export EXPORT_MODEL_NAME=LZ-LPRNet +mkdir -p ${EXPORT_MODEL_NAME} +pnnx ${EXPORT_MODEL_NAME}.onnx \ + pnnxparam=${EXPORT_MODEL_NAME}/${EXPORT_MODEL_NAME}.pnnx.param \ + pnnxbin=${EXPORT_MODEL_NAME}/${EXPORT_MODEL_NAME}.pnnx.bin \ + pnnxpy=${EXPORT_MODEL_NAME}/${EXPORT_MODEL_NAME}.py \ + pnnxonnx=${EXPORT_MODEL_NAME}/${EXPORT_MODEL_NAME}.pnnx.onnx \ + ncnnparam=${EXPORT_MODEL_NAME}/${EXPORT_MODEL_NAME}.ncnn.param \ + ncnnbin=${EXPORT_MODEL_NAME}/${EXPORT_MODEL_NAME}.ncnn.bin \ + ncnnpy=${EXPORT_MODEL_NAME}/${EXPORT_MODEL_NAME}.py \ + inputshape=[1,3,24,94] + +zip -r -9 ${EXPORT_MODEL_NAME}.zip ${EXPORT_MODEL_NAME} ``` \ No newline at end of file -- Gitee From 04a39503f0c133ca33fe5cc3d434064b9c298adb Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng Date: Sun, 10 Nov 2024 12:31:52 +0000 Subject: [PATCH 4/6] update example/vision/classification/README.md. Signed-off-by: Zheng-Bicheng --- example/vision/classification/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/vision/classification/README.md b/example/vision/classification/README.md index 34a794a..9b27de0 100644 --- a/example/vision/classification/README.md +++ b/example/vision/classification/README.md @@ -51,7 +51,7 @@ Labelme 是一个 python 语言编写,带有图形界面的图像标注软件 ### 2.2 标注前的准备 -首先,请参考 [摄像头使用指南](./example/periphery/capture) 利用 **Lockzhiner Vision Module 图片获取助手** 拍摄你需要进行标注的图片,如下图所示: +首先,请参考 [摄像头使用指南](../../../periphery/capture) 利用 **Lockzhiner Vision Module 图片获取助手** 拍摄你需要进行标注的图片,如下图所示: ![](images/capture_images.png) -- Gitee From 9ae54f916d4a605f36a1641b29db7cdd86a04980 Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng Date: Sun, 10 Nov 2024 12:32:37 +0000 Subject: [PATCH 5/6] update example/vision/classification/README.md. Signed-off-by: Zheng-Bicheng --- example/vision/classification/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/vision/classification/README.md b/example/vision/classification/README.md index 9b27de0..554f019 100644 --- a/example/vision/classification/README.md +++ b/example/vision/classification/README.md @@ -51,7 +51,7 @@ Labelme 是一个 python 语言编写,带有图形界面的图像标注软件 ### 2.2 标注前的准备 -首先,请参考 [摄像头使用指南](../../../periphery/capture) 利用 **Lockzhiner Vision Module 图片获取助手** 拍摄你需要进行标注的图片,如下图所示: +首先,请参考 [摄像头使用指南](../../periphery/capture) 利用 **Lockzhiner Vision Module 图片获取助手** 拍摄你需要进行标注的图片,如下图所示: ![](images/capture_images.png) -- Gitee From 21f459dbef78dc8d8da9896746bffbd1b2fe45f8 Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng Date: Sun, 10 Nov 2024 12:33:15 +0000 Subject: [PATCH 6/6] update example/vision/detetcion/README.md. Signed-off-by: Zheng-Bicheng --- example/vision/detetcion/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/vision/detetcion/README.md b/example/vision/detetcion/README.md index d2c2a4c..db16b50 100644 --- a/example/vision/detetcion/README.md +++ b/example/vision/detetcion/README.md @@ -53,7 +53,7 @@ Labelme 是一个 python 语言编写,带有图形界面的图像标注软件 ### 2.2 标注前的准备 -首先,请参考 [摄像头使用指南](./example/periphery/capture) 利用 **Lockzhiner Vision Module 图片获取助手** 拍摄你需要进行标注的图片,如下图所示: +首先,请参考 [摄像头使用指南](../../periphery/capture) 利用 **Lockzhiner Vision Module 图片获取助手** 拍摄你需要进行标注的图片,如下图所示: ![](images/capture_images.png) -- Gitee