====== Instructions for KSNN conversion tool ====== Introduction and guide on how to use the KSNN conversion tool. ===== Get the conversion tool ===== The conversion tool is integrated in the NPU SDK. ```shell $ git clone --recursive https://github.com/khadas/aml_npu_sdk.git ``` The KSNN conversion tool is under ''acuity-toolkit/python'', ```shell $ cd aml_npu_sdk/acuity-toolkit/python && ls $ convert data outputs ``` ===== Conversion example ===== Choose tensorflow MobileNet SSD as an example. 1. Get the frozen model, ```shell $ cd aml_npu_sdk/acuity-toolkit/python $ wget https://github.com/yan-wyb/models-zoo/raw/master/tensorflow/mobilenet_ssd/ssd_mobilenet_v1_coco_2017_11_17.pb ``` 2. Convert, ```shell # uint8 $ ./convert --model-name mobilenet_ssd \ > --platform tensorflow \ > --model /home/yan/yan/Yan/models-zoo/tensorflow/mobilenet_ssd/ssd_mobilenet_v1_coco_2017_11_17.pb \ > --input-size-list '300,300,3' \ > --inputs FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/BatchNorm/batchnorm/mul_1 \ > --outputs "'concat concat_1'" \ > --mean-values '127.5 127.5 127.5 0.007843137' \ > --quantized-dtype asymmetric_affine \ > --source-files ./data/dataset/dataset0.txt \ > --kboard VIM3 --print-level 0 # int8 $ ./convert --model-name mobilenet_ssd \ > --platform tensorflow \ > --model /home/yan/yan/Yan/models-zoo/tensorflow/mobilenet_ssd/ssd_mobilenet_v1_coco_2017_11_17.pb \ > --input-size-list '300,300,3' \ > --inputs FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/BatchNorm/batchnorm/mul_1 \ > --outputs "'concat concat_1'" \ > --mean-values '127.5 127.5 127.5 0.007843137' \ > --quantized-dtype dynamic_fixed_point \ > --qtype int8 \ > --source-files ./data/dataset/dataset0.txt \ > --kboard VIM3 --print-level 0 # int16 $ ./convert --model-name mobilenet_ssd \ > --platform tensorflow \ > --model /home/yan/yan/Yan/models-zoo/tensorflow/mobilenet_ssd/ssd_mobilenet_v1_coco_2017_11_17.pb \ > --input-size-list '300,300,3' \ > --inputs FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/BatchNorm/batchnorm/mul_1 \ > --outputs "'concat concat_1'" \ > --mean-values '127.5 127.5 127.5 0.007843137' \ > --quantized-dtype dynamic_fixed_point \ > --qtype int16 \ > --source-files ./data/dataset/dataset0.txt \ > --kboard VIM3 --print-level 0 ``` During conversion, if you need to view detailed information, you can modify ''--print-level 0'' to ''--print-level 1''. 3. Model file generated after conversion. ```shell $ cd aml_npu_sdk/acuity-toolkit/python $ ls outputs/mobilenet_ssd/ mobilenet_ssd.nb libnn_mobilenet_ssd.so ``` ===== More ===== - [[ksnn-usage|KSNN Usage]] - [[ksnn-api|KSNN API Documentation]]