图书馆:train_shape_predictor_ex.cpp

DLib : train_shape_predictor_ex.cpp

我正在尝试通过执行 train_dlib_shape_predictor_ex.cpp on helen dataset 来训练 Dlib 的形状预测器,如代码中所述,我将测试图像放在形状预测器当前目录的人脸文件夹中。但是当我 运行 它抛出以下异常的代码时:

C:\train_shape_predictor_ex\Release>train_shape_predictor_ex test

exception thrown!
ERROR: unable to open test/training_with_face_landmarks.xml for reading.

因为在以下页面的海伦数据集中没有 training_with_face_landmarks.xmltesting_with_face_landmarks.xml 文件可用:link

有一个名为 annotation 的文件夹,其中包含一个文本文件,其中包含数据集中每张图像的 194 个地标点位置。如何将此文件转换为 training_with_face_landmarks.xml.

打开'training_with_face_landmarks.xml'文件并观察其结构。

现在,问问自己:

  1. 文件之间有什么变化? (提示:点数据)
  2. 什么保持不变? (提示:通用 'boiler plate' 顶部和尾部)

打开 HELEN 数据 - 再问一遍...

您现在的任务是将 HELEN 集中的数据解析为临时 data-structure/variable,然后将其写入具有所有必需的顶部和尾部的文件。在循环内循环等中编写循环会很麻烦,而且可能很烦人,但你会做到的。

'c++ i/o streams' 作为搜索字符串将帮助您入门。

我为 helen 训练图像(第 1、2、3 和 4 部分)创建了 training_with_face_landmarks.xml,共有 2000 张图像。

下载Link:https://www.dropbox.com/s/jk98moqm8vopp5b/training_with_face_landmarks_2000.zip?dl=0

步骤:

  1. http://www.ifp.illinois.edu/~vuongle2/helen/ 下载训练图像 - 第 1 部分、训练图像 - 第 2 部分、训练图像 - 第 3 部分和训练图像 - 第 4 部分。 (每个部分有500张图片,所以总共有2000张图片)
  2. 将所有图像和 training_with_face_landmarks.xml 放在一个公共文件夹中(例如:文件夹名称 "train")。
  3. 项目train_shape_predictor_ex.cpp中,注释掉这些sections/lines

    一个。参考 testing_with_face_landmarks.xml 及其用法 b.培训师 set_oversampling_amount(100) C。培训师 set_nu(0.05) d.教练 set_tree_depth(3)

  4. 设置命令行参数为./train
  5. 运行项目
  6. 它将生成 sp.dat 大小约为 178 MB(在我的笔记本电脑上大约需要 2 小时)
  7. 在 face_landmark_detection_ex 项目中使用此 sp.dat 文件 命令行示例:sp.dat Example_image.jpg
  8. 在face_landmark_detection_ex.cpp中, 一种。在194的循环中,调用draw_solid_circle函数 b.使用 save_png 函数将地标输出保存为文件。

尽情享受吧:)

问候 果皮。 J