Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DLib : train_shape_predictor_ex.cpp

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 Answers

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

like image 117
gopi jayaraman Avatar answered Feb 28 '26 17:02

gopi jayaraman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!