Skip to content

Commit 35140c2

Browse files
committed
update: add ncnn inference
1 parent 64c5b0e commit 35140c2

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

README.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,41 @@ $ python3 test.py
4242

4343
![](./results/example.png)
4444

45+
#### pytorch -> onnx -> ncnn
46+
47+
**Pytorch -> onnx**
48+
49+
~~~~shell
50+
python3 pytorch2onnx.py
51+
~~~~
52+
53+
**onnx -> ncnn**
54+
55+
how to build :https://github.com/Tencent/ncnn/wiki/how-to-build
56+
57+
~~~shell
58+
cd ncnn/build/tools/onnx
59+
./onnx2ncnn pfld-sim.onnx pfld-sim.param pfld-sim.bin
60+
~~~
61+
62+
Now you can use **pfld-sim.param** and **pfld-sim.bin** in ncnn:
63+
64+
~~~cpp
65+
ncnn::Net pfld;
66+
pfld.load_param("path/to/pfld-sim.param");
67+
pfld.load_model("path/to/pfld-sim.bin");
68+
69+
cv::Mat img = cv::imread(imagepath, 1);
70+
ncnn::Mat in = ncnn::Mat::from_pixels_resize(img.data, ncnn::Mat::PIXEL_BGR, img.cols, img.rows, 112, 112);
71+
const float norm_vals[3] = {1/255.f, 1/255.f, 1/255.f};
72+
in.substract_mean_normalize(0, norm_vals);
73+
74+
ncnn::Extractor ex = pfld.create_extractor();
75+
ex.input("input_1", in);
76+
ncnn::Mat out;
77+
ex.extract("415", out);
78+
~~~
79+
4580
#### reference:
4681
4782
PFLD: A Practical Facial Landmark Detector https://arxiv.org/pdf/1902.10859.pdf
@@ -50,9 +85,9 @@ Tensorflow Implementation: https://github.com/guoqiangqi/PFLD
5085
5186
#### TODO:
5287
53-
- [ ] fix bugs
54-
55-
- [ ] ncnn inference
88+
- [x] Train on CPU and GPU
5689
90+
- [x] ncnn inference
5791
- [ ] retrain on datasets AFLW and 300W
92+
- [ ] fix bugs
5893

0 commit comments

Comments
 (0)