I'm reading the paper of PFLD and do some experiment on it. Basing on PFLD offical codes(https://github.com/polarisZhao/PFLD-pytorch),I try to change some of the structure of the code to experiment.
In offical codes, PFLD just calls MTCNN as face detector. I add yolov5 and pyramidbox so that we can choose face detector from these three.
Additionally, I'm testing to replace the backbone of PFLD.
You can use your own yolo models to have a better effient. The models are placed in ./FaceDetector/yolov5/weights/
pip3 install -r requirements.txt
- WFLW Dataset Download
Wider Facial Landmarks in-the-wild (WFLW) is a new proposed face dataset. It contains 10000 faces (7500 for training and 2500 for testing) with 98 fully manual annotated landmarks.
- WFLW Training and Testing images [Google Drive] [Baidu Drive]
- WFLW Face Annotations
- Unzip above two packages and put them on
./data/WFLW/
- move
Mirror98.txt
toWFLW/WFLW_annotations
$ cd data
$ python3 SetPreparation.py
training :
$ python3 train.py
use tensorboard, open a new terminal
$ tensorboard --logdir=./checkpoint/tensorboard/
testing:
$ python3 test.py
Pytorch -> onnx
python3 pytorch2onnx.py
onnx -> ncnn
how to build :https://github.com/Tencent/ncnn/wiki/how-to-build
cd ncnn/build/tools/onnx
./onnx2ncnn pfld-sim.onnx pfld-sim.param pfld-sim.bin
Now you can use pfld-sim.param and pfld-sim.bin in ncnn:
ncnn::Net pfld;
pfld.load_param("path/to/pfld-sim.param");
pfld.load_model("path/to/pfld-sim.bin");
cv::Mat img = cv::imread(imagepath, 1);
ncnn::Mat in = ncnn::Mat::from_pixels_resize(img.data, ncnn::Mat::PIXEL_BGR, img.cols, img.rows, 112, 112);
const float norm_vals[3] = {1/255.f, 1/255.f, 1/255.f};
in.substract_mean_normalize(0, norm_vals);
ncnn::Extractor ex = pfld.create_extractor();
ex.input("input_1", in);
ncnn::Mat out;
ex.extract("415", out);