Hi3559AV100 NNIE開發(3)RuyiStudio軟體 .wk文件生成過程-mobilefacenet.cfg的參數配置
- 2021 年 3 月 10 日
- 筆記
- .cfg, .wk, hi3559, Hi35xx項目開發, mobilefacenet, RuyiStudio
之後隨筆將更多筆墨著重於NNIE開發系列,下文是關於Hi3559AV100 NNIE開發(3)RuyiStudio軟體 .wk文件生成過程-mobilefacenet.cfg的參數配置,目前項目需要對mobilefacenet網路進行.wk的開發,通過RuyiStudio創建工程(關於軟體RuyiStudio的安裝與配置看後期是否有時間,有時間就會出一篇隨筆供大家參考),在工程下配置mobilefacenet.cfg文件,載入訓練好的mobilefacenet.caffemodel與mobilefacenet.prototxt並進行mobilefacenet.wk的生成,其中重要的一環為mobilefacenet.cfg參數的配置,下面隨筆將給出具體操作,首先給出整體需要配置的參數表:
1 [prototxt_file] 2 [caffemodel_file] 3 [batch_num] 4 [net_type] 5 [sparse_rate] 6 [compile_mode] 7 [is_simulation] 8 [log_level] 9 [instruction_name] 10 [RGB_order] 11 [data_scale] 12 [internal_stride] 13 [image_list] 14 [image_type] 15 [mean_file] 16 [norm_type]
下面給出一一說明:
(1)prototxt_file
1 layer { 2 name: "conv5 " 3 type: "Convolution" 4 bottom: "conv4" 5 top: "conv5_report" 6 convolution_param { 7 num_output: 256 8 kernel_size: 3 9 pad: 1 10 stride: 1 11 } 12 }
1 layer { 2 name: "conv5_hp" 3 type: "Convolution" 4 bottom: "conv4" 5 top: "conv5" 6 convolution_param { 7 num_output: 256 8 kernel_size: 3 9 pad: 1 10 stride: 1 11 } 12 }
1 layer { 2 bottom: "rpn_cls_score" 3 top: "rpn_cls_score_reshape" 4 name: "rpn_cls_score_reshape_cpu" 5 type: "Reshape" 6 reshape_param { 7 shape { 8 dim: 0 9 dim: 2 10 dim: -1 11 dim: 0 12 } 13 } 14 }
(2)caffemodel_file:
網路模型數據文件。
(3)[batch_num]
(4) [net_type]:
網路的類型。
(5) [sparse_rate] —>(取值0到1,默認0)
NNIE引擎採用了參數壓縮技術以減少頻寬佔用,為了提高壓縮率,可通對FC參數進稀疏處理。
用戶通過sparse_rate數值指定多少比例的FC參數稀疏為0,例如配0.5,則FC參數有50%將被稀疏為0,由於數據變的稀疏,壓縮模組會獲得更好的壓縮率。稀疏值越高,計算FC時所需參數頻寬越低,但精度會有所下降。
(6) [compile_mode]
(7) [is_simulation]
(8) [log_level]
(9) [instruction_name]
(10) [RGB_order] —>取值範圍:{RGB,BGR} default:BGR
(11) [data_scale]
(12) [internal_stride]
(13) [image_list]
NNIE mapper 用於數據量化的參考影像 list 文件或feature map 文件。該配置跟 image_type 相關。如果網路的數據輸入是灰度或者 RGB 影像輸入,即image_type 配置不為 0,image_list 配置為所參考圖片的list,內容示意圖如下圖圖示,圖片的格式支援以下幾種:
(14) [image_type]
表示網路實際執行時輸入給網路的數據類型,該配置跟 image list 相關。
0∶表示網路數據輸入為 SVP BLOB_TYPE_S32(參考《HiSVP API參考》)或者向量的類型(VEC_S32和 SEQ S32);此時要求 image list 配 置為 feature map 文件;
1∶ 表示網路數據輸入為 SVP BLOB TYPE U8(普通的灰度圖和 RGB 圖)類型; 此時要求 image_list 配置是 RGB 圖或者灰度圖片的 list 文件;
3∶ 網路數據輸入為 SVP_ BLOB_TYPE YUV420SP類型;
5∶ 網路數據輸入為SVP_BLOB_TYPE YUV422SP類型;
當配置為3或者5時,image_list配置為 RGB圖片的 list 文件。
(15) [mean_file]
(16)[norm_type]
表示對網路數據輸入的預處理方法。注意image_type配置為0時,norm_type只能配置為0;image_type配置為3或者5時,網路輸入數據為YUV影像,但是NNIE硬體會根據RGB_order配置項自動轉為RGB或者BGR影像,此時norm_type配置方法跟image_type為1時一致。
1 [prototxt_file] ./mark_prototxt/mobilefacenet_mark_nnie_20210205133124.prototxt 2 [caffemodel_file] ./data/mobilefacenet.prototxt.caffemodel 3 [batch_num] 256 4 [net_type] 0 5 [sparse_rate] 0 6 [compile_mode] 0 7 [is_simulation] 1 8 [log_level] 3 9 [instruction_name] ./mobileface_func 10 [RGB_order] BGR 11 [data_scale] 0.0078125 12 [internal_stride] 16 13 [image_list] ./data/images/imageList.txt 14 [image_type] 1 15 [mean_file] ./data/pixel_mean.txt 16 [norm_type] 5
後面隨筆將給出mobilefacenet網路的NNIE實現具體過程。