輕量級人臉檢測模型

輕量級的人臉檢測模型

簡介

人臉檢測現在已經被做壞了,各種算法,輕重都有,總有一款適合你,今天我們做一個輕量級的,模型大小隻有580kb。

github
注意是tf2 分支

出發點

人臉檢測是一類檢測算法,而且目前主流的算法都是基於ssd的結構。
想要模型快,小就兩點,模型參數量,模型的計算複雜度。

基於此,可以大致定下需要的模型結構

  1. one sage
  2. 輕backbone
  3. 輸入尺寸320x320 或更小
  4. 輸出feature不宜過大,層數不宜過多,一般3層,按需來
  5. 適當的提升性能的手段,例如fpn,inception等的結構
    等。。。。

具體的結構見代碼

於是有了 lightnet , 算是改的DSFD吧,但是更像retinanetface

github
注意是tf2 分支

模型和性能

Lightnet_0.5 including tflite model,
(time cost: mac [email protected], tf2.0 15ms+, tflite 8ms±,input shape 320x320)
model input_size fddb model size
Lightnet_0.75 640x640 0.960 800k±
Lightnet_0.5 640x640 0.953 560k±
Lightnet_0.5 416x416 0.953 560k±
Lightnet_0.5 320x320 0.936 560k±
model input_size wider easy wider medium wider hard
Lightnet_0.75 640x640 0.867 0.806 0.440
Lightnet_0.5 640x640 0.858 0.796 0.430
Lightnet_0.5 multiscale 0.861 0.837 0.726

ps the time cost not including nms, and flip test is used

訓練

  1. 首先clone下代碼,git clone https://github.com/610265158/DSFD-tensorflow.git
  2. 下載數據集widerface
    把 WIDER_train, WIDER_val and wider_face_split 放到新建的WIDER 下面,
  3. 然後運行,python prepare_wider_data.py, 然後會產生train.txt 和val.txt

其中 內容每一行是這個樣子:./WIDER/WIDER_val/images/0–Parade/0_Parade_Parade_0_913.jpg| 238,146,450,392,1 612,192,818,426,1 28,100,104,214,1。

也就是如果 你要訓練你自己的數據就這樣: imgpath| xmin,ymin,xmax,ymax,1 …

  1. 默認的config文件是一個很輕量級的模型, 直接運行  
    python train.py

  2. 模型轉換 python tools/convert_to_tflite.py 會轉換爲tflite 模型

如果訓練完了,想看一下demo,

python vis.py --model ./model/detector.tflite or
python vis.py --model ./model/detector

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章