问题
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:
- What changes between files? (hint: the point data)
- 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:
- 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)
- Place all the images & the training_with_face_landmarks.xml in a common folder (Ex: Folder name "train").
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)
- Set command line argument as ./train
- Run the project
- It will generate sp.dat of size approx 178 MB (took 2 hours approx in my laptop)
- Use this sp.dat file in face_landmark_detection_ex project Command line Ex: sp.dat Example_image.jpg
- 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