Skip to content

efahnjoe/pfld-pytorch-rocm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PFLD Pytorch ROCM

Implementation of PFLD A Practical Facial Landmark Detector by pytorch-rocm.

Install requirements

uv pip install -r requirements.txt

Datasets

  • 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.

  1. WFLW Training and Testing images [Google Drive] [Baidu Drive]
  2. WFLW Face Annotations
  3. Unzip above two packages and put them on ./data/
cd data 
uv run ./src/SetPreparation.py

Training & Testing

training :

uv run ./src/train.py

# or

uv run ./src/train.py --resume ./checkpoint/snapshot/checkpoint_best_nme.pth.tar

use tensorboard, open a new terminal

tensorboard  --logdir=./checkpoint/tensorboard/

testing:

uv run ./src/test.py

Results:

Results Example

pytorch -> onnx -> ncnn

Pytorch -> onnx

uv run ./src/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);

Reference

PFLD: A Practical Facial Landmark Detector https://arxiv.org/pdf/1902.10859.pdf

PFLD-Pytorch: https://github.com/polarisZhao/PFLD-pytorch

Tensorflow Implementation: https://github.com/guoqiangqi/PFLD

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%