DLib : train_shape_predictor_ex.cpp

时光毁灭记忆、已成空白 提交于 2019-12-04 02:06:10

问题


I am trying to train the shape predictor of Dlib by executing train_dlib_shape_predictor_ex.cpp on helen dataset as described in the code, I place test images in a face folder in current directory of shape predictor. But when I run the code it throws following exception:

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.

as no training_with_face_landmarks.xml and testing_with_face_landmarks.xml files are available in helen dataset on the following page : link

There is a folder named annotation which contains one text file containing the 194 landmark points location for each and every image in the dataset. How to convert this file into training_with_face_landmarks.xml.


回答1:


Open up the 'training_with_face_landmarks.xml' file and observe its structure.

Now, ask yourself:

  1. What changes between files? (hint: the point data)
  2. What stays the same? (hint: generic 'boiler plate' top and tail)

Open up the HELEN data - ask the same again...

Your task now is to parse the data from the HELEN set into a temporary data-structure/variable and then write it to file with all the required top and tail. It'll be a kludge and likely annoying to write with loops inside loops inside loops etc. but you'll get there.

'c++ i/o streams' as a search string will get you started.




回答2:


I created the training_with_face_landmarks.xml for helen training images (part 1, 2, 3, & 4) of total 2000 images.

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

Steps:

  1. Download Train images - part 1, Train images - part 2, Train images - part 3 & Train images - part 4 from http://www.ifp.illinois.edu/~vuongle2/helen/. (each part has 500 images, so total of 2000 images)
  2. Place all the images & the training_with_face_landmarks.xml in a common folder (Ex: Folder name "train").
  3. In the project train_shape_predictor_ex.cpp, comment out these sections/lines

    a. Reference to testing_with_face_landmarks.xml and its usage b. trainer set_oversampling_amount(100) c. trainer set_nu(0.05) d. trainer set_tree_depth(3)

  4. Set command line argument as ./train
  5. Run the project
  6. It will generate sp.dat of size approx 178 MB (took 2 hours approx in my laptop)
  7. Use this sp.dat file in face_landmark_detection_ex project Command line Ex: sp.dat Example_image.jpg
  8. In face_landmark_detection_ex.cpp, a. In a loop of 194, call draw_solid_circle function b. using save_png function save the landmark output as a file.

Enjoy :)

Regards Gopi. J



来源:https://stackoverflow.com/questions/36711905/dlib-train-shape-predictor-ex-cpp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!