diff --git a/.gitignore b/.gitignore index 3aac9ad8..40286f14 100644 --- a/.gitignore +++ b/.gitignore @@ -20,9 +20,31 @@ matlab_runners/Feature Point Experiments/yt_features/ matlab_runners/Feature Point Experiments/yt_features_clm/ matlab_runners/Gaze Experiments/mpii_out/ build/ -Debug/ Release/AU_predictors/ Release/ +exe/Recording/recording/ ipch/ +exe/FeatureExtraction/out_bp4d/ +matlab_runners/Action Unit Experiments/out_bp4d/ +matlab_runners/Action Unit Experiments/out_SEMAINE/ +x64/Debug/ +matlab_runners/Action Unit Experiments/out_unbc/ +matlab_runners/Action Unit Experiments/out_bosph/ +matlab_runners/Action Unit Experiments/out_DISFA/ +matlab_runners/Action Unit Experiments/out_fera/ matlab_runners/Demos/output_features_seq/ matlab_runners/Demos/output_features_vid/ +exe/FaceLandmarkImg/Debug/ +exe/FaceLandmarkVid/Debug/ +exe/FaceLandmarkVidMulti/Debug/ +exe/FeatureExtraction/Debug/ +exe/Recording/Debug/ +gui/OpenFaceOffline/bin/ +gui/OpenFaceOffline/obj/ +lib/3rdParty/dlib/Debug/ +lib/local/CamCom/Debug/ +lib/local/CamCom/x64/ +lib/local/CppInerop/Debug/ +lib/local/CppInerop/x64/Debug/ +lib/local/FaceAnalyser/Debug/ +lib/local/LandmarkDetector/Debug/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..6b0918d5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,71 @@ +language: cpp + +branches: + only: + - master + - develop + - /^feature-.*$/ +compiler: + - gcc + - clang + +os: + - osx + - linux + +before_install: + # g++4.8.1 + - if [ "$CXX" == "g++" ]; then + if [[ ${TRAVIS_OS_NAME} = linux ]]; then + sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test; + fi + fi + + # clang 3.4 + - if [ "$CXX" == "clang++" ]; then + if [[ ${TRAVIS_OS_NAME} = linux ]]; then + sudo add-apt-repository -y ppa:h-rayflood/llvm; + fi + fi + + - if [[ ${TRAVIS_OS_NAME} = linux ]]; then sudo apt-get update -qq; fi + +install: + - if [ "$CXX" == "g++" ]; then if [[ ${TRAVIS_OS_NAME} = linux ]]; then sudo apt-get install -qq g++-4.8; fi fi + - if [ "$CXX" == "g++" ]; then if [[ ${TRAVIS_OS_NAME} = linux ]]; then export CXX="g++-4.8"; fi fi + - if [ "$CXX" == "clang++" ]; then if [[ ${TRAVIS_OS_NAME} = linux ]]; then sudo apt-get install -qq clang-3.4; fi fi + - if [ "$CXX" == "clang++" ]; then if [[ ${TRAVIS_OS_NAME} = linux ]]; then export CXX="clang++-3.4"; fi fi + + - if [[ ${TRAVIS_OS_NAME} = linux ]]; then sudo apt-get install git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev; fi + - if [[ ${TRAVIS_OS_NAME} = linux ]]; then sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev checkinstall; fi + + # Getting newest boost + - if [[ ${TRAVIS_OS_NAME} = linux ]]; then sudo add-apt-repository -y ppa:boost-latest/ppa; fi + - if [[ ${TRAVIS_OS_NAME} = linux ]]; then sudo apt-get update; fi + - if [[ ${TRAVIS_OS_NAME} = linux ]]; then sudo apt-get install libboost1.55-all-dev; fi + + - if [[ ${TRAVIS_OS_NAME} = osx ]]; then brew update; fi + - if [[ ${TRAVIS_OS_NAME} = osx ]]; then brew tap homebrew/science; fi + - if [[ ${TRAVIS_OS_NAME} = osx ]]; then brew install tbb opencv3; fi + +before_script: + - git clone https://github.com/Itseez/opencv.git + - cd opencv + - mkdir build + - cd build + - cmake .. + - make -j2 + - sudo make -j2 install + - cd ../.. + +script: + - $CXX --version + - mkdir build + - cd build + - cmake -D CMAKE_BUILD_TYPE=RELEASE .. + - make -j2 + - ../build/bin/FaceLandmarkImg -fdir "../videos/" -ofdir "./demo_img/" -oidir "./demo_img/" -wild -q + - ../build/bin/FaceLandmarkImg -inroot ../videos -f Obama.jpg -outroot data -of obama.txt -op obama.3d -oi obama.bmp -multi_view 1 -wild -q + - ../build/bin/FaceLandmarkVidMulti -inroot ../videos -f multi_face.avi -outroot output -ov multi_face.avi -q + - ../build/bin/FeatureExtraction -f "../videos/1815_01_008_tony_blair.avi" -outroot output_features -ov blair.avi -of "1815_01_008_tony_blair.txt" -simalign aligned -ov feat_test.avi -hogalign hog_test.dat -q + - ../build/bin/FaceLandmarkVid -inroot ../videos -f 1815_01_008_tony_blair.avi -f 0188_03_021_al_pacino.avi -f 0217_03_006_alanis_morissette.avi -outroot output_data -ov 1.avi -ov 2.avi -ov 3.avi -q \ No newline at end of file diff --git a/README.md b/README.md index 3ff88d9d..015fc4e3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # OpenFace: an open source facial behavior analysis toolkit +[![Build Status](https://travis-ci.org/TadasBaltrusaitis/OpenFace.svg?branch=master)](https://travis-ci.org/TadasBaltrusaitis/OpenFace) +[![Build status](https://ci.appveyor.com/api/projects/status/8msiklxfbhlnsmxp/branch/master?svg=true)](https://ci.appveyor.com/project/TadasBaltrusaitis/openface/branch/master) + Over the past few years, there has been an increased interest in automatic facial behavior analysis and understanding. We present OpenFace – an open source tool intended for computer vision and machine learning researchers, affective computing community and people interested in building interactive applications based on facial behavior analysis. OpenFace is the first open source tool capable of facial landmark detection, head pose estimation, facial action unit recognition, and eye-gaze estimation. The computer vision algorithms which represent the core of OpenFace demonstrate state-of-the-art results in all of the above mentioned tasks. Furthermore, our tool is capable of real-time performance and is able to run from a simple webcam without any specialist hardware. The code was written mainly by Tadas Baltrusaitis during his time at the Language Technologies Institute at the Carnegie Mellon University; Computer Laboratory, University of Cambridge; and Institute for Creative Technologies, University of Southern California. @@ -73,3 +76,4 @@ I did my best to make sure that the code runs out of the box but there are alway Copyright can be found in the Copyright.txt You have to respect boost, TBB, dlib, and OpenCV licenses. + diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..dcba59bf --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,28 @@ +version: 1.0.{build} +branches: + only: + - develop + - master + - /^feature-.*$/ +max_jobs: 4 +configuration: +- Debug +- Release +platform: +- x64 +- Win32 +build: + project: OpenFace.sln + verbosity: minimal +test_script: +# C++ + - cmd: dir + - cmd: if exist x64 (cd x64) + - cmd: if exist Debug (cd Debug) + - cmd: if exist Release (cd Release) + - cmd: dir + - cmd: if exist "../videos" (FaceLandmarkImg.exe -fdir "../videos/" -ofdir "./demo_img/" -oidir "./demo_img/" -wild -q) else (FaceLandmarkImg.exe -fdir "../../videos/" -ofdir "./demo_img/" -oidir "./demo_img/" -wild -q) + - cmd: if exist "../videos" (FaceLandmarkImg.exe -inroot ../videos -f obama.jpg -outroot out_data -of obama.pts -op obama.3d -oi obama.bmp -q) else (FaceLandmarkImg.exe -inroot ../../videos -f obama.jpg -outroot out_data -of obama.pts -op obama.3d -oi obama.bmp -q) + - cmd: if exist "../videos" (FaceLandmarkVidMulti.exe -inroot ../videos -f multi_face.avi -ov multi_face.avi -q) else (FaceLandmarkVidMulti.exe -inroot ../../videos -f multi_face.avi -ov multi_face.avi -q) + - cmd: if exist "../videos" (FeatureExtraction.exe -f "../videos/1815_01_008_tony_blair.avi" -outroot output_features -of "1815_01_008_tony_blair.txt" -simalign aligned -ov feat_track.avi -hogalign hog_test.dat -q) else (FeatureExtraction.exe -f "../../videos/1815_01_008_tony_blair.avi" -outroot output_features -of "1815_01_008_tony_blair.txt" -simalign aligned -ov feat_track.avi -hogalign hog_test.dat -q) + - cmd: if exist "../videos" (FaceLandmarkVid.exe -f "../videos/1815_01_008_tony_blair.avi" -ov track.avi -q) else (FaceLandmarkVid.exe -f "../../videos/1815_01_008_tony_blair.avi" -ov track.avi -q) diff --git a/exe/FaceLandmarkImg/CMakeLists.txt b/exe/FaceLandmarkImg/CMakeLists.txt index 9df24400..65097c9b 100644 --- a/exe/FaceLandmarkImg/CMakeLists.txt +++ b/exe/FaceLandmarkImg/CMakeLists.txt @@ -1,3 +1,6 @@ +#TBB library +include_directories(${TBB_ROOT_DIR}/include) + # Local libraries include_directories(${LandmarkDetector_SOURCE_DIR}/include) @@ -11,4 +14,4 @@ target_link_libraries(FaceLandmarkImg dlib) target_link_libraries(FaceLandmarkImg ${OpenCV_LIBS} ${Boost_LIBRARIES} ${TBB_LIBRARIES}) -install (TARGETS FaceLandmarkImg DESTINATION ${CMAKE_BINARY_DIR}/bin) +install (TARGETS FaceLandmarkImg DESTINATION bin) diff --git a/exe/FaceLandmarkImg/FaceLandmarkImg.cpp b/exe/FaceLandmarkImg/FaceLandmarkImg.cpp index e45f9b92..718d3eca 100644 --- a/exe/FaceLandmarkImg/FaceLandmarkImg.cpp +++ b/exe/FaceLandmarkImg/FaceLandmarkImg.cpp @@ -188,26 +188,64 @@ void write_out_pose_landmarks(const string& outfeatures, const cv::Mat_& } } -void write_out_landmarks(const string& outfeatures, const LandmarkDetector::CLNF& clnf_model) +void write_out_landmarks(const string& outfeatures, const LandmarkDetector::CLNF& clnf_model, const cv::Vec6d& pose, const cv::Point3f& gaze0, const cv::Point3f& gaze1, std::vector> au_intensities, std::vector> au_occurences) { create_directory_from_file(outfeatures); std::ofstream featuresFile; - featuresFile.open(outfeatures); + featuresFile.open(outfeatures); - if(featuresFile.is_open()) - { + if (featuresFile.is_open()) + { int n = clnf_model.patch_experts.visibilities[0][0].rows; featuresFile << "version: 1" << endl; featuresFile << "npoints: " << n << endl; featuresFile << "{" << endl; - - for (int i = 0; i < n; ++ i) + + for (int i = 0; i < n; ++i) { // Use matlab format, so + 1 - featuresFile << clnf_model.detected_landmarks.at(i) + 1 << " " << clnf_model.detected_landmarks.at(i+n) + 1 << endl; + featuresFile << clnf_model.detected_landmarks.at(i) + 1 << " " << clnf_model.detected_landmarks.at(i + n) + 1 << endl; } - featuresFile << "}" << endl; + featuresFile << "}" << endl; + // Do the pose and eye gaze if present as well + featuresFile << "pose: eul_x, eul_y, eul_z: " << endl; + featuresFile << "{" << endl; + featuresFile << pose[3] << " " << pose[4] << " " << pose[5] << endl; + featuresFile << "}" << endl; + + // Do the pose and eye gaze if present as well + featuresFile << "gaze: dir_x_1, dir_y_1, dir_z_1, dir_x_2, dir_y_2, dir_z_2: " << endl; + featuresFile << "{" << endl; + featuresFile << gaze0.x << " " << gaze0.y << " " << gaze0.z << " " << gaze1.x << " " << gaze1.y << " " << gaze1.z << endl; + featuresFile << "}" << endl; + + // Do the au intensities + featuresFile << "au intensities: " << au_intensities.size() << endl; + featuresFile << "{" << endl; + + for (size_t i = 0; i < au_intensities.size(); ++i) + { + // Use matlab format, so + 1 + featuresFile << au_intensities[i].first << " " << au_intensities[i].second << endl; + } + + featuresFile << "}" << endl; + + // Do the au occurences + featuresFile << "au occurences: " << au_occurences.size() << endl; + featuresFile << "{" << endl; + + for (size_t i = 0; i < au_occurences.size(); ++i) + { + // Use matlab format, so + 1 + featuresFile << au_occurences[i].first << " " << au_occurences[i].second << endl; + } + + featuresFile << "}" << endl; + + + featuresFile.close(); } } @@ -315,6 +353,45 @@ int main (int argc, char **argv) cv::CascadeClassifier classifier(det_parameters.face_detector_location); dlib::frontal_face_detector face_detector_hog = dlib::get_frontal_face_detector(); + // Loading the AU prediction models + string au_loc = "AU_predictors/AU_all_static.txt"; + + if (!boost::filesystem::exists(boost::filesystem::path(au_loc))) + { + boost::filesystem::path loc = boost::filesystem::path(arguments[0]).parent_path() / au_loc; + + if (boost::filesystem::exists(loc)) + { + au_loc = loc.string(); + } + else + { + cout << "Can't find AU prediction files, exiting" << endl; + return 1; + } + } + + // Used for image masking for AUs + string tri_loc; + if (boost::filesystem::exists(boost::filesystem::path("model/tris_68_full.txt"))) + { + std::ifstream triangulation_file("model/tris_68_full.txt"); + tri_loc = "model/tris_68_full.txt"; + } + else + { + boost::filesystem::path loc = boost::filesystem::path(arguments[0]).parent_path() / "model/tris_68_full.txt"; + tri_loc = loc.string(); + + if (!exists(loc)) + { + cout << "Can't find triangulation files, exiting" << endl; + return 1; + } + } + + FaceAnalysis::FaceAnalyser face_analyser(vector(), 0.7, 112, 112, au_loc, tri_loc); + bool visualise = !det_parameters.quiet_mode; // Do some image loading @@ -325,6 +402,12 @@ int main (int argc, char **argv) // Loading image cv::Mat read_image = cv::imread(file, -1); + if (read_image.empty()) + { + cout << "Could not read the input image" << endl; + return 1; + } + // Loading depth file if exists (optional) cv::Mat_ depth_image; @@ -396,6 +479,8 @@ int main (int argc, char **argv) } + auto ActionUnits = face_analyser.PredictStaticAUs(read_image, clnf_model, false); + // Writing out the detected landmarks (in an OS independent manner) if(!output_landmark_locations.empty()) { @@ -412,7 +497,7 @@ int main (int argc, char **argv) boost::filesystem::path fname = out_feat_path.filename().replace_extension(""); boost::filesystem::path ext = out_feat_path.extension(); string outfeatures = dir.string() + preferredSlash + fname.string() + string(name) + ext.string(); - write_out_landmarks(outfeatures, clnf_model); + write_out_landmarks(outfeatures, clnf_model, headPose, gazeDirection0, gazeDirection1, ActionUnits.first, ActionUnits.second); } if (!output_pose_locations.empty()) @@ -472,8 +557,14 @@ int main (int argc, char **argv) boost::filesystem::path ext = out_feat_path.extension(); outimage = dir.string() + preferredSlash + fname.string() + string(name) + ext.string(); create_directory_from_file(outimage); - imwrite(outimage, display_image); + bool write_success = cv::imwrite(outimage, display_image); + if (!write_success) + { + cout << "Could not output a processed image" << endl; + return 1; + } + } } @@ -503,11 +594,13 @@ int main (int argc, char **argv) FaceAnalysis::EstimateGaze(clnf_model, gazeDirection1, fx, fy, cx, cy, false); } + auto ActionUnits = face_analyser.PredictStaticAUs(read_image, clnf_model, false); + // Writing out the detected landmarks if(!output_landmark_locations.empty()) { string outfeatures = output_landmark_locations.at(i); - write_out_landmarks(outfeatures, clnf_model); + write_out_landmarks(outfeatures, clnf_model, headPose, gazeDirection0, gazeDirection1, ActionUnits.first, ActionUnits.second); } // Writing out the detected landmarks @@ -543,7 +636,13 @@ int main (int argc, char **argv) if(!outimage.empty()) { create_directory_from_file(outimage); - imwrite(outimage, display_image); + bool write_success = imwrite(outimage, display_image); + + if (!write_success) + { + cout << "Could not output a processed image" << endl; + return 1; + } } } } diff --git a/exe/FaceLandmarkImg/FaceLandmarkImg.vcxproj b/exe/FaceLandmarkImg/FaceLandmarkImg.vcxproj index c92c3dfd..d9358b29 100644 --- a/exe/FaceLandmarkImg/FaceLandmarkImg.vcxproj +++ b/exe/FaceLandmarkImg/FaceLandmarkImg.vcxproj @@ -110,6 +110,7 @@ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) $(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\FaceAnalyser\include;%(AdditionalIncludeDirectories) StreamingSIMDExtensions2 + true Console @@ -123,7 +124,8 @@ Disabled WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) $(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\FaceAnalyser\include;%(AdditionalIncludeDirectories) - AdvancedVectorExtensions2 + AdvancedVectorExtensions + true Console @@ -141,6 +143,7 @@ $(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\FaceAnalyser\include;%(AdditionalIncludeDirectories) false StreamingSIMDExtensions2 + true Console @@ -159,7 +162,8 @@ WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) $(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\FaceAnalyser\include;%(AdditionalIncludeDirectories) false - AdvancedVectorExtensions2 + AdvancedVectorExtensions + true Console diff --git a/exe/FaceLandmarkVid/CMakeLists.txt b/exe/FaceLandmarkVid/CMakeLists.txt index 7274ddef..5c5587fd 100644 --- a/exe/FaceLandmarkVid/CMakeLists.txt +++ b/exe/FaceLandmarkVid/CMakeLists.txt @@ -1,3 +1,6 @@ +#TBB library +include_directories(${TBB_ROOT_DIR}/include) + add_executable(FaceLandmarkVid FaceLandmarkVid.cpp) # Local libraries @@ -13,4 +16,4 @@ target_link_libraries(FaceLandmarkVid dlib) target_link_libraries(FaceLandmarkVid ${OpenCV_LIBS} ${Boost_LIBRARIES} ${TBB_LIBRARIES}) -install (TARGETS FaceLandmarkVid DESTINATION ${CMAKE_BINARY_DIR}/bin) +install (TARGETS FaceLandmarkVid DESTINATION bin) diff --git a/exe/FaceLandmarkVid/FaceLandmarkVid.cpp b/exe/FaceLandmarkVid/FaceLandmarkVid.cpp index c2fc0237..5846e533 100644 --- a/exe/FaceLandmarkVid/FaceLandmarkVid.cpp +++ b/exe/FaceLandmarkVid/FaceLandmarkVid.cpp @@ -193,7 +193,8 @@ int main (int argc, char **argv) // Indicates that rotation should be with respect to world or camera coordinates bool u; - LandmarkDetector::get_video_input_output_params(files, depth_directories, out_dummy, output_video_files, u, arguments); + string output_codec; + LandmarkDetector::get_video_input_output_params(files, depth_directories, out_dummy, output_video_files, u, output_codec, arguments); // The modules that are being used for tracking LandmarkDetector::CLNF clnf_model(det_parameters.model_location); @@ -247,6 +248,7 @@ int main (int argc, char **argv) if (!boost::filesystem::exists(current_file)) { FATAL_STREAM("File does not exist"); + return 1; } current_file = boost::filesystem::path(current_file).generic_string(); @@ -264,7 +266,11 @@ int main (int argc, char **argv) video_capture >> captured_image; } - if( !video_capture.isOpened() ) FATAL_STREAM( "Failed to open video source" ); + if (!video_capture.isOpened()) + { + FATAL_STREAM("Failed to open video source"); + return 1; + } else INFO_STREAM( "Device or file opened"); cv::Mat captured_image; @@ -292,7 +298,14 @@ int main (int argc, char **argv) cv::VideoWriter writerFace; if (!output_video_files.empty()) { - writerFace = cv::VideoWriter(output_video_files[f_n], CV_FOURCC('D', 'I', 'V', 'X'), 30, captured_image.size(), true); + try + { + writerFace = cv::VideoWriter(output_video_files[f_n], CV_FOURCC(output_codec[0], output_codec[1], output_codec[2], output_codec[3]), 30, captured_image.size(), true); + } + catch(cv::Exception e) + { + WARN_STREAM( "Could not open VideoWriter, OUTPUT FILE WILL NOT BE WRITTEN. Currently using codec " << output_codec << ", try using an other one (-oc option)"); + } } // Use for timestamping if using a webcam diff --git a/exe/FaceLandmarkVid/FaceLandmarkVid.vcxproj b/exe/FaceLandmarkVid/FaceLandmarkVid.vcxproj index 50848d0d..71666c99 100644 --- a/exe/FaceLandmarkVid/FaceLandmarkVid.vcxproj +++ b/exe/FaceLandmarkVid/FaceLandmarkVid.vcxproj @@ -86,7 +86,7 @@ true - FaceTrackingVid + FaceLandmarkVid $(ProjectDir)$(Configuration)\ @@ -95,7 +95,7 @@ false - FaceTrackingVid + FaceLandmarkVid $(ProjectDir)$(Configuration)\ @@ -111,6 +111,7 @@ $(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\FaceAnalyser\include;%(AdditionalIncludeDirectories) false StreamingSIMDExtensions2 + true Console @@ -125,7 +126,8 @@ WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) $(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\FaceAnalyser\include;%(AdditionalIncludeDirectories) false - AdvancedVectorExtensions2 + AdvancedVectorExtensions + true Console @@ -145,6 +147,7 @@ false Speed StreamingSIMDExtensions2 + true Console @@ -165,7 +168,8 @@ $(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\FaceAnalyser\include;%(AdditionalIncludeDirectories) false Speed - AdvancedVectorExtensions2 + AdvancedVectorExtensions + true Console diff --git a/exe/FaceLandmarkVidMulti/CMakeLists.txt b/exe/FaceLandmarkVidMulti/CMakeLists.txt index 161b33be..181db54d 100644 --- a/exe/FaceLandmarkVidMulti/CMakeLists.txt +++ b/exe/FaceLandmarkVidMulti/CMakeLists.txt @@ -1,3 +1,6 @@ +#TBB library +include_directories(${TBB_ROOT_DIR}/include) + # Local libraries include_directories(${LandmarkDetector_SOURCE_DIR}/include) @@ -9,4 +12,4 @@ target_link_libraries(FaceLandmarkVidMulti dlib) target_link_libraries(FaceLandmarkVidMulti ${OpenCV_LIBS} ${Boost_LIBRARIES} ${TBB_LIBRARIES}) -install (TARGETS FaceLandmarkVidMulti DESTINATION ${CMAKE_BINARY_DIR}/bin) +install (TARGETS FaceLandmarkVidMulti DESTINATION bin) diff --git a/exe/FaceLandmarkVidMulti/FaceLandmarkVidMulti.cpp b/exe/FaceLandmarkVidMulti/FaceLandmarkVidMulti.cpp index 063f89bd..66b231e1 100644 --- a/exe/FaceLandmarkVidMulti/FaceLandmarkVidMulti.cpp +++ b/exe/FaceLandmarkVidMulti/FaceLandmarkVidMulti.cpp @@ -151,7 +151,8 @@ int main (int argc, char **argv) // Get the input output file parameters bool u; - LandmarkDetector::get_video_input_output_params(files, depth_directories, dummy_out, tracked_videos_output, u, arguments); + string output_codec; + LandmarkDetector::get_video_input_output_params(files, depth_directories, dummy_out, tracked_videos_output, u, output_codec, arguments); // Get camera parameters LandmarkDetector::get_camera_params(device, fx, fy, cx, cy, arguments); @@ -219,7 +220,11 @@ int main (int argc, char **argv) video_capture >> captured_image; } - if( !video_capture.isOpened() ) FATAL_STREAM( "Failed to open video source" ); + if (!video_capture.isOpened()) + { + FATAL_STREAM("Failed to open video source"); + return 1; + } else INFO_STREAM( "Device or file opened"); cv::Mat captured_image; @@ -239,7 +244,14 @@ int main (int argc, char **argv) cv::VideoWriter writerFace; if(!tracked_videos_output.empty()) { - writerFace = cv::VideoWriter(tracked_videos_output[f_n], CV_FOURCC('D','I','V','X'), 30, captured_image.size(), true); + try + { + writerFace = cv::VideoWriter(tracked_videos_output[f_n], CV_FOURCC(output_codec[0],output_codec[1],output_codec[2],output_codec[3]), 30, captured_image.size(), true); + } + catch(cv::Exception e) + { + WARN_STREAM( "Could not open VideoWriter, OUTPUT FILE WILL NOT BE WRITTEN. Currently using codec " << output_codec << ", try using an other one (-oc option)"); + } } // For measuring the timings @@ -412,7 +424,7 @@ int main (int argc, char **argv) sprintf(fpsC, "%d", (int)fps); string fpsSt("FPS:"); fpsSt += fpsC; - cv::putText(disp_image, fpsSt, cv::Point(10,20), CV_FONT_HERSHEY_SIMPLEX, 0.5, CV_RGB(255,0,0)); + cv::putText(disp_image, fpsSt, cv::Point(10,20), CV_FONT_HERSHEY_SIMPLEX, 0.5, CV_RGB(255,0,0), 1, CV_AA); int num_active_models = 0; @@ -428,7 +440,7 @@ int main (int argc, char **argv) sprintf(active_m_C, "%d", num_active_models); string active_models_st("Active models:"); active_models_st += active_m_C; - cv::putText(disp_image, active_models_st, cv::Point(10,60), CV_FONT_HERSHEY_SIMPLEX, 0.5, CV_RGB(255,0,0)); + cv::putText(disp_image, active_models_st, cv::Point(10,60), CV_FONT_HERSHEY_SIMPLEX, 0.5, CV_RGB(255,0,0), 1, CV_AA); if(!det_parameters[0].quiet_mode) { diff --git a/exe/FaceLandmarkVidMulti/FaceLandmarkVidMulti.vcxproj b/exe/FaceLandmarkVidMulti/FaceLandmarkVidMulti.vcxproj index e2ab430d..802cb25c 100644 --- a/exe/FaceLandmarkVidMulti/FaceLandmarkVidMulti.vcxproj +++ b/exe/FaceLandmarkVidMulti/FaceLandmarkVidMulti.vcxproj @@ -84,14 +84,14 @@ - FaceTrackingVidMulti + FaceLandmarkVidMulti $(ProjectDir)$(Configuration)\ FaceLandmarkVidMulti - FaceTrackingVidMulti + FaceLandmarkVidMulti $(ProjectDir)$(Configuration)\ @@ -103,6 +103,7 @@ Disabled $(SolutionDir)\lib\local\LandmarkDetector\include;%(AdditionalIncludeDirectories) StreamingSIMDExtensions2 + true true @@ -113,7 +114,8 @@ Level3 Disabled $(SolutionDir)\lib\local\LandmarkDetector\include;%(AdditionalIncludeDirectories) - AdvancedVectorExtensions2 + AdvancedVectorExtensions + true true @@ -128,6 +130,7 @@ $(SolutionDir)\lib\local\LandmarkDetector\include;%(AdditionalIncludeDirectories) StreamingSIMDExtensions2 MultiThreadedDLL + true true @@ -142,8 +145,9 @@ true true $(SolutionDir)\lib\local\LandmarkDetector\include;%(AdditionalIncludeDirectories) - AdvancedVectorExtensions2 + AdvancedVectorExtensions MultiThreadedDLL + true true diff --git a/exe/FeatureExtraction/CMakeLists.txt b/exe/FeatureExtraction/CMakeLists.txt index 5839c04f..3c561493 100644 --- a/exe/FeatureExtraction/CMakeLists.txt +++ b/exe/FeatureExtraction/CMakeLists.txt @@ -1,3 +1,6 @@ +#TBB library +include_directories(${TBB_ROOT_DIR}/include) + add_executable(FeatureExtraction FeatureExtraction.cpp) # Local libraries diff --git a/exe/FeatureExtraction/FeatureExtraction.cpp b/exe/FeatureExtraction/FeatureExtraction.cpp index cb67fcb3..2deebb99 100644 --- a/exe/FeatureExtraction/FeatureExtraction.cpp +++ b/exe/FeatureExtraction/FeatureExtraction.cpp @@ -152,231 +152,13 @@ void create_directory(string output_path) } } -void get_output_feature_params(vector &output_similarity_aligned, vector &output_hog_aligned_files, double &similarity_scale, - int &similarity_size, bool &grayscale, bool &rigid, bool& verbose, - bool &output_2D_landmarks, bool &output_3D_landmarks, bool &output_model_params, bool &output_pose, bool &output_AUs, bool &output_gaze, - vector &arguments) -{ - output_similarity_aligned.clear(); - output_hog_aligned_files.clear(); +void get_output_feature_params(vector &output_similarity_aligned, vector &output_hog_aligned_files, double &similarity_scale, + int &similarity_size, bool &grayscale, bool& verbose, bool& dynamic, bool &output_2D_landmarks, bool &output_3D_landmarks, + bool &output_model_params, bool &output_pose, bool &output_AUs, bool &output_gaze, vector &arguments); - bool* valid = new bool[arguments.size()]; +void get_image_input_output_params_feats(vector > &input_image_files, bool& as_video, vector &arguments); - for (size_t i = 0; i < arguments.size(); ++i) - { - valid[i] = true; - } - - string input_root = ""; - string output_root = ""; - - // First check if there is a root argument (so that videos and outputs could be defined more easilly) - for (size_t i = 0; i < arguments.size(); ++i) - { - if (arguments[i].compare("-root") == 0) - { - input_root = arguments[i + 1]; - output_root = arguments[i + 1]; - i++; - } - if (arguments[i].compare("-inroot") == 0) - { - input_root = arguments[i + 1]; - i++; - } - if (arguments[i].compare("-outroot") == 0) - { - output_root = arguments[i + 1]; - i++; - } - } - - for (size_t i = 0; i < arguments.size(); ++i) - { - if (arguments[i].compare("-simalign") == 0) - { - output_similarity_aligned.push_back(output_root + arguments[i + 1]); - create_directory(output_root + arguments[i + 1]); - valid[i] = false; - valid[i + 1] = false; - i++; - } - else if (arguments[i].compare("-hogalign") == 0) - { - output_hog_aligned_files.push_back(output_root + arguments[i + 1]); - create_directory_from_file(output_root + arguments[i + 1]); - valid[i] = false; - valid[i + 1] = false; - i++; - } - else if (arguments[i].compare("-verbose") == 0) - { - verbose = true; - } - else if (arguments[i].compare("-rigid") == 0) - { - rigid = true; - } - else if (arguments[i].compare("-g") == 0) - { - grayscale = true; - valid[i] = false; - } - else if (arguments[i].compare("-simscale") == 0) - { - similarity_scale = stod(arguments[i + 1]); - valid[i] = false; - valid[i + 1] = false; - i++; - } - else if (arguments[i].compare("-simsize") == 0) - { - similarity_size = stoi(arguments[i + 1]); - valid[i] = false; - valid[i + 1] = false; - i++; - } - else if (arguments[i].compare("-no2Dfp") == 0) - { - output_2D_landmarks = false; - valid[i] = false; - } - else if (arguments[i].compare("-no3Dfp") == 0) - { - output_3D_landmarks = false; - valid[i] = false; - } - else if (arguments[i].compare("-noMparams") == 0) - { - output_model_params = false; - valid[i] = false; - } - else if (arguments[i].compare("-noPose") == 0) - { - output_pose = false; - valid[i] = false; - } - else if (arguments[i].compare("-noAUs") == 0) - { - output_AUs = false; - valid[i] = false; - } - else if (arguments[i].compare("-noGaze") == 0) - { - output_gaze = false; - valid[i] = false; - } - } - - for (int i = arguments.size() - 1; i >= 0; --i) - { - if (!valid[i]) - { - arguments.erase(arguments.begin() + i); - } - } - -} -// Can process images via directories creating a separate output file per directory -void get_image_input_output_params_feats(vector > &input_image_files, bool& as_video, vector &arguments) -{ - bool* valid = new bool[arguments.size()]; - - for(size_t i = 0; i < arguments.size(); ++i) - { - valid[i] = true; - if (arguments[i].compare("-fdir") == 0) - { - - // parse the -fdir directory by reading in all of the .png and .jpg files in it - path image_directory (arguments[i+1]); - - try - { - // does the file exist and is it a directory - if (exists(image_directory) && is_directory(image_directory)) - { - - vector file_in_directory; - copy(directory_iterator(image_directory), directory_iterator(), back_inserter(file_in_directory)); - - // Sort the images in the directory first - sort(file_in_directory.begin(), file_in_directory.end()); - - vector curr_dir_files; - - for (vector::const_iterator file_iterator (file_in_directory.begin()); file_iterator != file_in_directory.end(); ++file_iterator) - { - // Possible image extension .jpg and .png - if(file_iterator->extension().string().compare(".jpg") == 0 || file_iterator->extension().string().compare(".png") == 0) - { - curr_dir_files.push_back(file_iterator->string()); - } - } - - input_image_files.push_back(curr_dir_files); - } - } - catch (const filesystem_error& ex) - { - cout << ex.what() << '\n'; - } - - valid[i] = false; - valid[i+1] = false; - i++; - } - else if (arguments[i].compare("-asvid") == 0) - { - as_video = true; - } - } - - // Clear up the argument list - for(int i=arguments.size()-1; i >= 0; --i) - { - if(!valid[i]) - { - arguments.erase(arguments.begin()+i); - } - } - -} - -void output_HOG_frame(std::ofstream* hog_file, bool good_frame, const cv::Mat_& hog_descriptor, int num_rows, int num_cols) -{ - - // Using FHOGs, hence 31 channels - int num_channels = 31; - - hog_file->write((char*)(&num_cols), 4); - hog_file->write((char*)(&num_rows), 4); - hog_file->write((char*)(&num_channels), 4); - - // Not the best way to store a bool, but will be much easier to read it - float good_frame_float; - if(good_frame) - good_frame_float = 1; - else - good_frame_float = -1; - - hog_file->write((char*)(&good_frame_float), 4); - - cv::MatConstIterator_ descriptor_it = hog_descriptor.begin(); - - for(int y = 0; y < num_cols; ++y) - { - for(int x = 0; x < num_rows; ++x) - { - for(unsigned int o = 0; o < 31; ++o) - { - - float hog_data = (float)(*descriptor_it++); - hog_file->write ((char*)&hog_data, 4); - } - } - } -} +void output_HOG_frame(std::ofstream* hog_file, bool good_frame, const cv::Mat_& hog_descriptor, int num_rows, int num_cols); // Some globals for tracking timing information for visualisation double fps_tracker = -1.0; @@ -432,7 +214,7 @@ void visualise_tracking(cv::Mat& captured_image, const LandmarkDetector::CLNF& f std::sprintf(fpsC, "%d", (int)fps_tracker); string fpsSt("FPS:"); fpsSt += fpsC; - cv::putText(captured_image, fpsSt, cv::Point(10, 20), CV_FONT_HERSHEY_SIMPLEX, 0.5, CV_RGB(255, 0, 0)); + cv::putText(captured_image, fpsSt, cv::Point(10, 20), CV_FONT_HERSHEY_SIMPLEX, 0.5, CV_RGB(255, 0, 0), 1, CV_AA); if (!det_parameters.quiet_mode) { @@ -443,195 +225,16 @@ void visualise_tracking(cv::Mat& captured_image, const LandmarkDetector::CLNF& f void prepareOutputFile(std::ofstream* output_file, bool output_2D_landmarks, bool output_3D_landmarks, bool output_model_params, bool output_pose, bool output_AUs, bool output_gaze, - int num_landmarks, int num_model_modes, vector au_names_class, vector au_names_reg) -{ - - *output_file << "frame, timestamp, confidence, success"; - - if (output_gaze) - { - *output_file << ", gaze_0_x, gaze_0_y, gaze_0_z, gaze_1_x, gaze_1_y, gaze_2_z"; - } - - if (output_pose) - { - *output_file << ", pose_Tx, pose_Ty, pose_Tz, pose_Rx, pose_Ry, pose_Rz"; - } - - if (output_2D_landmarks) - { - for (int i = 0; i < num_landmarks; ++i) - { - *output_file << ", x_" << i; - } - for (int i = 0; i < num_landmarks; ++i) - { - *output_file << ", y_" << i; - } - } - - if (output_3D_landmarks) - { - for (int i = 0; i < num_landmarks; ++i) - { - *output_file << ", X_" << i; - } - for (int i = 0; i < num_landmarks; ++i) - { - *output_file << ", Y_" << i; - } - for (int i = 0; i < num_landmarks; ++i) - { - *output_file << ", Z_" << i; - } - } - - // Outputting model parameters (rigid and non-rigid), the first parameters are the 6 rigid shape parameters, they are followed by the non rigid shape parameters - if (output_model_params) - { - *output_file << ", p_scale, p_rx, p_ry, p_rz, p_tx, p_ty"; - for (int i = 0; i < num_model_modes; ++i) - { - *output_file << ", p_" << i; - } - } - - if (output_AUs) - { - std::sort(au_names_reg.begin(), au_names_reg.end()); - for (string reg_name : au_names_reg) - { - *output_file << ", " << reg_name << "_r"; - } - - std::sort(au_names_class.begin(), au_names_class.end()); - for (string class_name : au_names_class) - { - *output_file << ", " << class_name << "_c"; - } - } - - *output_file << endl; - -} + int num_landmarks, int num_model_modes, vector au_names_class, vector au_names_reg); // Output all of the information into one file in one go (quite a few parameters, but simplifies the flow) void outputAllFeatures(std::ofstream* output_file, bool output_2D_landmarks, bool output_3D_landmarks, bool output_model_params, bool output_pose, bool output_AUs, bool output_gaze, const LandmarkDetector::CLNF& face_model, int frame_count, double time_stamp, bool detection_success, cv::Point3f gazeDirection0, cv::Point3f gazeDirection1, const cv::Vec6d& pose_estimate, double fx, double fy, double cx, double cy, - const FaceAnalysis::FaceAnalyser& face_analyser) -{ + const FaceAnalysis::FaceAnalyser& face_analyser); - double confidence = 0.5 * (1 - face_model.detection_certainty); - - *output_file << frame_count + 1 << ", " << time_stamp << ", " << confidence << ", " << detection_success; - - // Output the estimated gaze - if (output_gaze) - { - *output_file << ", " << gazeDirection0.x << ", " << gazeDirection0.y << ", " << gazeDirection0.z - << ", " << gazeDirection1.x << ", " << gazeDirection1.y << ", " << gazeDirection1.z; - } - - // Output the estimated head pose - if (output_pose) - { - *output_file << ", " << pose_estimate[0] << ", " << pose_estimate[1] << ", " << pose_estimate[2] - << ", " << pose_estimate[3] << ", " << pose_estimate[4] << ", " << pose_estimate[5]; - } - - // Output the detected 2D facial landmarks - if (output_2D_landmarks) - { - for (int i = 0; i < face_model.pdm.NumberOfPoints() * 2; ++i) - { - *output_file << ", " << face_model.detected_landmarks.at(i); - } - } - - // Output the detected 3D facial landmarks - if (output_3D_landmarks) - { - cv::Mat_ shape_3D = face_model.GetShape(fx, fy, cx, cy); - for (int i = 0; i < face_model.pdm.NumberOfPoints() * 3; ++i) - { - *output_file << ", " << shape_3D.at(i); - } - } - - if (output_model_params) - { - for (int i = 0; i < 6; ++i) - { - *output_file << ", " << face_model.params_global[i]; - } - for (int i = 0; i < face_model.pdm.NumberOfModes(); ++i) - { - *output_file << ", " << face_model.params_local.at(i, 0); - } - } - - - - if (output_AUs) - { - auto aus_reg = face_analyser.GetCurrentAUsReg(); - - vector au_reg_names = face_analyser.GetAURegNames(); - std::sort(au_reg_names.begin(), au_reg_names.end()); - - // write out ar the correct index - for (string au_name : au_reg_names) - { - for (auto au_reg : aus_reg) - { - if (au_name.compare(au_reg.first) == 0) - { - *output_file << ", " << au_reg.second; - break; - } - } - } - - if (aus_reg.size() == 0) - { - for (size_t p = 0; p < face_analyser.GetAURegNames().size(); ++p) - { - *output_file << ", 0"; - } - } - - auto aus_class = face_analyser.GetCurrentAUsClass(); - - vector au_class_names = face_analyser.GetAUClassNames(); - std::sort(au_class_names.begin(), au_class_names.end()); - - // write out ar the correct index - for (string au_name : au_class_names) - { - for (auto au_class: aus_class) - { - if (au_name.compare(au_class.first) == 0) - { - *output_file << ", " << au_class.second; - break; - } - } - } - - if (aus_class.size() == 0) - { - for (size_t p = 0; p < face_analyser.GetAUClassNames().size(); ++p) - { - *output_file << ", 0"; - } - } - } - *output_file << endl; -} - -void post_process_output_file(FaceAnalysis::FaceAnalyser& face_analyser, string output_file); +void post_process_output_file(FaceAnalysis::FaceAnalyser& face_analyser, string output_file, bool dynamic); int main (int argc, char **argv) @@ -650,7 +253,8 @@ int main (int argc, char **argv) // Indicates that rotation should be with respect to camera or world coordinates bool use_world_coordinates; - LandmarkDetector::get_video_input_output_params(input_files, depth_directories, output_files, tracked_videos_output, use_world_coordinates, arguments); + string output_codec; //not used but should + LandmarkDetector::get_video_input_output_params(input_files, depth_directories, output_files, tracked_videos_output, use_world_coordinates, output_codec, arguments); bool video_input = true; bool verbose = true; @@ -701,7 +305,7 @@ int main (int argc, char **argv) int sim_size = 112; bool grayscale = false; bool video_output = false; - bool rigid = false; + bool dynamic = true; // Indicates if a dynamic AU model should be used (dynamic is useful if the video is long enough to include neutral expressions) int num_hog_rows; int num_hog_cols; @@ -714,17 +318,14 @@ int main (int argc, char **argv) bool output_AUs = true; bool output_gaze = true; - get_output_feature_params(output_similarity_align, output_hog_align_files, sim_scale, sim_size, grayscale, rigid, verbose, + get_output_feature_params(output_similarity_align, output_hog_align_files, sim_scale, sim_size, grayscale, verbose, dynamic, output_2D_landmarks, output_3D_landmarks, output_model_params, output_pose, output_AUs, output_gaze, arguments); // Used for image masking - cv::Mat_ triangulation; string tri_loc; if(boost::filesystem::exists(path("model/tris_68_full.txt"))) { - std::ifstream triangulation_file("model/tris_68_full.txt"); - LandmarkDetector::ReadMat(triangulation_file, triangulation); tri_loc = "model/tris_68_full.txt"; } else @@ -732,15 +333,10 @@ int main (int argc, char **argv) path loc = path(arguments[0]).parent_path() / "model/tris_68_full.txt"; tri_loc = loc.string(); - if(exists(loc)) - { - std::ifstream triangulation_file(loc.string()); - LandmarkDetector::ReadMat(triangulation_file, triangulation); - } - else + if(!exists(loc)) { cout << "Can't find triangulation files, exiting" << endl; - return 0; + return 1; } } @@ -755,13 +351,24 @@ int main (int argc, char **argv) int curr_img = -1; string au_loc; - if(boost::filesystem::exists(path("AU_predictors/AU_all_best.txt"))) + + string au_loc_local; + if (dynamic) { - au_loc = "AU_predictors/AU_all_best.txt"; + au_loc_local = "AU_predictors/AU_all_best.txt"; } else { - path loc = path(arguments[0]).parent_path() / "AU_predictors/AU_all_best.txt"; + au_loc_local = "AU_predictors/AU_all_static.txt"; + } + + if(boost::filesystem::exists(path(au_loc_local))) + { + au_loc = au_loc_local; + } + else + { + path loc = path(arguments[0]).parent_path() / au_loc_local; if(exists(loc)) { @@ -770,7 +377,7 @@ int main (int argc, char **argv) else { cout << "Can't find AU prediction files, exiting" << endl; - return 0; + return 1; } } @@ -884,7 +491,16 @@ int main (int argc, char **argv) cv::VideoWriter writerFace; if(!tracked_videos_output.empty()) { - writerFace = cv::VideoWriter(tracked_videos_output[f_n], CV_FOURCC('D', 'I', 'V', 'X'), fps_vid_in, captured_image.size(), true); + try + { + writerFace = cv::VideoWriter(tracked_videos_output[f_n], CV_FOURCC(output_codec[0],output_codec[1],output_codec[2],output_codec[3]), fps_vid_in, captured_image.size(), true); + } + catch(cv::Exception e) + { + WARN_STREAM( "Could not open VideoWriter, OUTPUT FILE WILL NOT BE WRITTEN. Currently using codec " << output_codec << ", try using an other one (-oc option)"); + } + + } int frame_count = 0; @@ -1007,7 +623,7 @@ int main (int argc, char **argv) char name[100]; // output the frame number - std::sprintf(name, "frame_det_%06d.png", frame_count); + std::sprintf(name, "frame_det_%06d.bmp", frame_count); // Construct the output filename boost::filesystem::path slash("/"); @@ -1015,8 +631,13 @@ int main (int argc, char **argv) std::string preferredSlash = slash.make_preferred().string(); string out_file = output_similarity_align[f_n] + preferredSlash + string(name); - imwrite(out_file, sim_warped_img); - + bool write_success = imwrite(out_file, sim_warped_img); + + if (!write_success) + { + cout << "Could not output similarity aligned image image" << endl; + return 1; + } } // Visualising the tracker @@ -1080,14 +701,10 @@ int main (int argc, char **argv) output_file.close(); - if(output_files.size() > 0) + if(output_files.size() > 0 && output_AUs) { - - // If the video is long enough post-process it for AUs - if (output_AUs && frame_count > 100) - { - post_process_output_file(face_analyser, output_files[f_n]); - } + cout << "Postprocessing the Action Unit predictions" << endl; + post_process_output_file(face_analyser, output_files[f_n], dynamic); } // Reset the models for the next video face_analyser.Reset(); @@ -1102,7 +719,7 @@ int main (int argc, char **argv) } // break out of the loop if done with all the files (or using a webcam) - if(f_n == input_files.size() -1 || input_files.empty()) + if((video_input && f_n == input_files.size() -1) || (!video_input && f_n == input_image_files.size() - 1)) { done = true; } @@ -1112,7 +729,7 @@ int main (int argc, char **argv) } // Allows for post processing of the AU signal -void post_process_output_file(FaceAnalysis::FaceAnalyser& face_analyser, string output_file) +void post_process_output_file(FaceAnalysis::FaceAnalyser& face_analyser, string output_file, bool dynamic) { vector certainties; @@ -1122,8 +739,8 @@ void post_process_output_file(FaceAnalysis::FaceAnalyser& face_analyser, string vector>> predictions_class; // Construct the new values to overwrite the output file with - face_analyser.ExtractAllPredictionsOfflineReg(predictions_reg, certainties, successes, timestamps); - face_analyser.ExtractAllPredictionsOfflineClass(predictions_class, certainties, successes, timestamps); + face_analyser.ExtractAllPredictionsOfflineReg(predictions_reg, certainties, successes, timestamps, dynamic); + face_analyser.ExtractAllPredictionsOfflineClass(predictions_class, certainties, successes, timestamps, dynamic); int num_class = predictions_class.size(); int num_reg = predictions_reg.size(); @@ -1179,7 +796,7 @@ void post_process_output_file(FaceAnalysis::FaceAnalyser& face_analyser, string int begin_ind = -1; - for (int i = 0; i < tokens.size(); ++i) + for (size_t i = 0; i < tokens.size(); ++i) { if (tokens[i].find("AU") != string::npos && begin_ind == -1) { @@ -1195,33 +812,484 @@ void post_process_output_file(FaceAnalysis::FaceAnalyser& face_analyser, string outfile << output_file_contents[0].c_str() << endl; // Write the contents - for (int i = 1; i < output_file_contents.size(); ++i) + for (int i = 1; i < (int)output_file_contents.size(); ++i) { std::vector tokens; boost::split(tokens, output_file_contents[i], boost::is_any_of(",")); outfile << tokens[0]; - for (int t = 1; t < tokens.size(); ++t) + for (int t = 1; t < (int)tokens.size(); ++t) { if (t >= begin_ind && t < end_ind) { if(t - begin_ind < num_reg) { - outfile << "," << predictions_reg[inds_reg[t - begin_ind]].second[i - 1]; + outfile << ", " << predictions_reg[inds_reg[t - begin_ind]].second[i - 1]; } else { - outfile << "," << predictions_class[inds_class[t - begin_ind - num_reg]].second[i - 1]; + outfile << ", " << predictions_class[inds_class[t - begin_ind - num_reg]].second[i - 1]; } } else { - outfile << "," << tokens[t]; + outfile << ", " << tokens[t]; } } outfile << endl; } -} \ No newline at end of file +} + +void prepareOutputFile(std::ofstream* output_file, bool output_2D_landmarks, bool output_3D_landmarks, + bool output_model_params, bool output_pose, bool output_AUs, bool output_gaze, + int num_landmarks, int num_model_modes, vector au_names_class, vector au_names_reg) +{ + + *output_file << "frame, timestamp, confidence, success"; + + if (output_gaze) + { + *output_file << ", gaze_0_x, gaze_0_y, gaze_0_z, gaze_1_x, gaze_1_y, gaze_2_z"; + } + + if (output_pose) + { + *output_file << ", pose_Tx, pose_Ty, pose_Tz, pose_Rx, pose_Ry, pose_Rz"; + } + + if (output_2D_landmarks) + { + for (int i = 0; i < num_landmarks; ++i) + { + *output_file << ", x_" << i; + } + for (int i = 0; i < num_landmarks; ++i) + { + *output_file << ", y_" << i; + } + } + + if (output_3D_landmarks) + { + for (int i = 0; i < num_landmarks; ++i) + { + *output_file << ", X_" << i; + } + for (int i = 0; i < num_landmarks; ++i) + { + *output_file << ", Y_" << i; + } + for (int i = 0; i < num_landmarks; ++i) + { + *output_file << ", Z_" << i; + } + } + + // Outputting model parameters (rigid and non-rigid), the first parameters are the 6 rigid shape parameters, they are followed by the non rigid shape parameters + if (output_model_params) + { + *output_file << ", p_scale, p_rx, p_ry, p_rz, p_tx, p_ty"; + for (int i = 0; i < num_model_modes; ++i) + { + *output_file << ", p_" << i; + } + } + + if (output_AUs) + { + std::sort(au_names_reg.begin(), au_names_reg.end()); + for (string reg_name : au_names_reg) + { + *output_file << ", " << reg_name << "_r"; + } + + std::sort(au_names_class.begin(), au_names_class.end()); + for (string class_name : au_names_class) + { + *output_file << ", " << class_name << "_c"; + } + } + + *output_file << endl; + +} + +// Output all of the information into one file in one go (quite a few parameters, but simplifies the flow) +void outputAllFeatures(std::ofstream* output_file, bool output_2D_landmarks, bool output_3D_landmarks, + bool output_model_params, bool output_pose, bool output_AUs, bool output_gaze, + const LandmarkDetector::CLNF& face_model, int frame_count, double time_stamp, bool detection_success, + cv::Point3f gazeDirection0, cv::Point3f gazeDirection1, const cv::Vec6d& pose_estimate, double fx, double fy, double cx, double cy, + const FaceAnalysis::FaceAnalyser& face_analyser) +{ + + double confidence = 0.5 * (1 - face_model.detection_certainty); + + *output_file << frame_count + 1 << ", " << time_stamp << ", " << confidence << ", " << detection_success; + + // Output the estimated gaze + if (output_gaze) + { + *output_file << ", " << gazeDirection0.x << ", " << gazeDirection0.y << ", " << gazeDirection0.z + << ", " << gazeDirection1.x << ", " << gazeDirection1.y << ", " << gazeDirection1.z; + } + + // Output the estimated head pose + if (output_pose) + { + if(face_model.tracking_initialised) + { + *output_file << ", " << pose_estimate[0] << ", " << pose_estimate[1] << ", " << pose_estimate[2] + << ", " << pose_estimate[3] << ", " << pose_estimate[4] << ", " << pose_estimate[5]; + } + else + { + *output_file << ", 0, 0, 0, 0, 0, 0"; + } + } + + // Output the detected 2D facial landmarks + if (output_2D_landmarks) + { + for (int i = 0; i < face_model.pdm.NumberOfPoints() * 2; ++i) + { + if(face_model.tracking_initialised) + { + *output_file << ", " << face_model.detected_landmarks.at(i); + } + else + { + *output_file << ", 0"; + } + } + } + + // Output the detected 3D facial landmarks + if (output_3D_landmarks) + { + cv::Mat_ shape_3D = face_model.GetShape(fx, fy, cx, cy); + for (int i = 0; i < face_model.pdm.NumberOfPoints() * 3; ++i) + { + if (face_model.tracking_initialised) + { + *output_file << ", " << shape_3D.at(i); + } + else + { + *output_file << ", 0"; + } + } + } + + if (output_model_params) + { + for (int i = 0; i < 6; ++i) + { + if (face_model.tracking_initialised) + { + *output_file << ", " << face_model.params_global[i]; + } + else + { + *output_file << ", 0"; + } + } + for (int i = 0; i < face_model.pdm.NumberOfModes(); ++i) + { + if(face_model.tracking_initialised) + { + *output_file << ", " << face_model.params_local.at(i, 0); + } + else + { + *output_file << ", 0"; + } + } + } + + + + if (output_AUs) + { + auto aus_reg = face_analyser.GetCurrentAUsReg(); + + vector au_reg_names = face_analyser.GetAURegNames(); + std::sort(au_reg_names.begin(), au_reg_names.end()); + + // write out ar the correct index + for (string au_name : au_reg_names) + { + for (auto au_reg : aus_reg) + { + if (au_name.compare(au_reg.first) == 0) + { + *output_file << ", " << au_reg.second; + break; + } + } + } + + if (aus_reg.size() == 0) + { + for (size_t p = 0; p < face_analyser.GetAURegNames().size(); ++p) + { + *output_file << ", 0"; + } + } + + auto aus_class = face_analyser.GetCurrentAUsClass(); + + vector au_class_names = face_analyser.GetAUClassNames(); + std::sort(au_class_names.begin(), au_class_names.end()); + + // write out ar the correct index + for (string au_name : au_class_names) + { + for (auto au_class : aus_class) + { + if (au_name.compare(au_class.first) == 0) + { + *output_file << ", " << au_class.second; + break; + } + } + } + + if (aus_class.size() == 0) + { + for (size_t p = 0; p < face_analyser.GetAUClassNames().size(); ++p) + { + *output_file << ", 0"; + } + } + } + *output_file << endl; +} + + +void get_output_feature_params(vector &output_similarity_aligned, vector &output_hog_aligned_files, double &similarity_scale, + int &similarity_size, bool &grayscale, bool& verbose, bool& dynamic, + bool &output_2D_landmarks, bool &output_3D_landmarks, bool &output_model_params, bool &output_pose, bool &output_AUs, bool &output_gaze, + vector &arguments) +{ + output_similarity_aligned.clear(); + output_hog_aligned_files.clear(); + + bool* valid = new bool[arguments.size()]; + + for (size_t i = 0; i < arguments.size(); ++i) + { + valid[i] = true; + } + + string output_root = ""; + + // By default the model is dynamic + dynamic = true; + + string separator = string(1, boost::filesystem::path::preferred_separator); + + // First check if there is a root argument (so that videos and outputs could be defined more easilly) + for (size_t i = 0; i < arguments.size(); ++i) + { + if (arguments[i].compare("-root") == 0) + { + output_root = arguments[i + 1] + separator; + i++; + } + if (arguments[i].compare("-outroot") == 0) + { + output_root = arguments[i + 1] + separator; + i++; + } + } + + for (size_t i = 0; i < arguments.size(); ++i) + { + if (arguments[i].compare("-simalign") == 0) + { + output_similarity_aligned.push_back(output_root + arguments[i + 1]); + create_directory(output_root + arguments[i + 1]); + valid[i] = false; + valid[i + 1] = false; + i++; + } + else if (arguments[i].compare("-hogalign") == 0) + { + output_hog_aligned_files.push_back(output_root + arguments[i + 1]); + create_directory_from_file(output_root + arguments[i + 1]); + valid[i] = false; + valid[i + 1] = false; + i++; + } + else if (arguments[i].compare("-verbose") == 0) + { + verbose = true; + } + else if (arguments[i].compare("-au_static") == 0) + { + dynamic = false; + } + else if (arguments[i].compare("-g") == 0) + { + grayscale = true; + valid[i] = false; + } + else if (arguments[i].compare("-simscale") == 0) + { + similarity_scale = stod(arguments[i + 1]); + valid[i] = false; + valid[i + 1] = false; + i++; + } + else if (arguments[i].compare("-simsize") == 0) + { + similarity_size = stoi(arguments[i + 1]); + valid[i] = false; + valid[i + 1] = false; + i++; + } + else if (arguments[i].compare("-no2Dfp") == 0) + { + output_2D_landmarks = false; + valid[i] = false; + } + else if (arguments[i].compare("-no3Dfp") == 0) + { + output_3D_landmarks = false; + valid[i] = false; + } + else if (arguments[i].compare("-noMparams") == 0) + { + output_model_params = false; + valid[i] = false; + } + else if (arguments[i].compare("-noPose") == 0) + { + output_pose = false; + valid[i] = false; + } + else if (arguments[i].compare("-noAUs") == 0) + { + output_AUs = false; + valid[i] = false; + } + else if (arguments[i].compare("-noGaze") == 0) + { + output_gaze = false; + valid[i] = false; + } + } + + for (int i = arguments.size() - 1; i >= 0; --i) + { + if (!valid[i]) + { + arguments.erase(arguments.begin() + i); + } + } + +} + +// Can process images via directories creating a separate output file per directory +void get_image_input_output_params_feats(vector > &input_image_files, bool& as_video, vector &arguments) +{ + bool* valid = new bool[arguments.size()]; + + for (size_t i = 0; i < arguments.size(); ++i) + { + valid[i] = true; + if (arguments[i].compare("-fdir") == 0) + { + + // parse the -fdir directory by reading in all of the .png and .jpg files in it + path image_directory(arguments[i + 1]); + + try + { + // does the file exist and is it a directory + if (exists(image_directory) && is_directory(image_directory)) + { + + vector file_in_directory; + copy(directory_iterator(image_directory), directory_iterator(), back_inserter(file_in_directory)); + + // Sort the images in the directory first + sort(file_in_directory.begin(), file_in_directory.end()); + + vector curr_dir_files; + + for (vector::const_iterator file_iterator(file_in_directory.begin()); file_iterator != file_in_directory.end(); ++file_iterator) + { + // Possible image extension .jpg and .png + if (file_iterator->extension().string().compare(".jpg") == 0 || file_iterator->extension().string().compare(".png") == 0) + { + curr_dir_files.push_back(file_iterator->string()); + } + } + + input_image_files.push_back(curr_dir_files); + } + } + catch (const filesystem_error& ex) + { + cout << ex.what() << '\n'; + } + + valid[i] = false; + valid[i + 1] = false; + i++; + } + else if (arguments[i].compare("-asvid") == 0) + { + as_video = true; + } + } + + // Clear up the argument list + for (int i = arguments.size() - 1; i >= 0; --i) + { + if (!valid[i]) + { + arguments.erase(arguments.begin() + i); + } + } + +} + +void output_HOG_frame(std::ofstream* hog_file, bool good_frame, const cv::Mat_& hog_descriptor, int num_rows, int num_cols) +{ + + // Using FHOGs, hence 31 channels + int num_channels = 31; + + hog_file->write((char*)(&num_cols), 4); + hog_file->write((char*)(&num_rows), 4); + hog_file->write((char*)(&num_channels), 4); + + // Not the best way to store a bool, but will be much easier to read it + float good_frame_float; + if (good_frame) + good_frame_float = 1; + else + good_frame_float = -1; + + hog_file->write((char*)(&good_frame_float), 4); + + cv::MatConstIterator_ descriptor_it = hog_descriptor.begin(); + + for (int y = 0; y < num_cols; ++y) + { + for (int x = 0; x < num_rows; ++x) + { + for (unsigned int o = 0; o < 31; ++o) + { + + float hog_data = (float)(*descriptor_it++); + hog_file->write((char*)&hog_data, 4); + } + } + } +} diff --git a/exe/FeatureExtraction/FeatureExtraction.vcxproj b/exe/FeatureExtraction/FeatureExtraction.vcxproj index 6ee28348..69fb3d1d 100644 --- a/exe/FeatureExtraction/FeatureExtraction.vcxproj +++ b/exe/FeatureExtraction/FeatureExtraction.vcxproj @@ -110,6 +110,7 @@ $(SolutionDir)\lib\local\FaceAnalyser\include;$(SolutionDir)\lib\local\LandmarkDetector\include;%(AdditionalIncludeDirectories) false StreamingSIMDExtensions2 + true Console @@ -124,7 +125,8 @@ WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) $(SolutionDir)\lib\local\FaceAnalyser\include;$(SolutionDir)\lib\local\LandmarkDetector\include;%(AdditionalIncludeDirectories) false - AdvancedVectorExtensions2 + AdvancedVectorExtensions + true Console @@ -144,6 +146,7 @@ Speed StreamingSIMDExtensions2 MultiThreadedDLL + true Console @@ -163,8 +166,9 @@ $(SolutionDir)\lib\local\FaceAnalyser\include;$(SolutionDir)\lib\local\LandmarkDetector\include;%(AdditionalIncludeDirectories) false Speed - AdvancedVectorExtensions2 + AdvancedVectorExtensions MultiThreadedDLL + true Console diff --git a/exe/Recording/Record.cpp b/exe/Recording/Record.cpp index dd19ddfc..ff4cc4c3 100644 --- a/exe/Recording/Record.cpp +++ b/exe/Recording/Record.cpp @@ -168,7 +168,10 @@ int main (int argc, char **argv) INFO_STREAM( "Attempting to capture from device: " << device ); vCap = cv::VideoCapture( device ); - if( !vCap.isOpened() ) FATAL_STREAM( "Failed to open video source" ); + if (!vCap.isOpened()) { + FATAL_STREAM("Failed to open video source"); + return 1; + } cv::Mat img; vCap >> img; diff --git a/exe/Recording/Recording.vcxproj b/exe/Recording/Recording.vcxproj index 57b2b8a0..5f04e4c3 100644 --- a/exe/Recording/Recording.vcxproj +++ b/exe/Recording/Recording.vcxproj @@ -85,6 +85,7 @@ Level3 Disabled + true true @@ -94,6 +95,7 @@ Level3 Disabled + true true @@ -107,6 +109,7 @@ true false Cdecl + true true @@ -124,6 +127,7 @@ true false Cdecl + true true diff --git a/lib/3rdParty/dlib/dlib.vcxproj b/lib/3rdParty/dlib/dlib.vcxproj index 51445a42..5203d2d5 100644 --- a/lib/3rdParty/dlib/dlib.vcxproj +++ b/lib/3rdParty/dlib/dlib.vcxproj @@ -107,6 +107,7 @@ Debug $(IntDir) $(IntDir)vc$(PlatformToolsetVersion).pdb + true true @@ -118,7 +119,7 @@ EnableFastChecks CompileAsCpp ProgramDatabase - AdvancedVectorExtensions2 + AdvancedVectorExtensions Sync Disabled Disabled @@ -130,6 +131,7 @@ Debug $(IntDir) $(IntDir)vc$(PlatformToolsetVersion).pdb + true true @@ -154,6 +156,7 @@ $(IntDir) $(IntDir)vc$(PlatformToolsetVersion).pdb Speed + true WIN32;_WINDOWS;DLIB_PNG_SUPPORT;DLIB_JPEG_SUPPORT;NDEBUG;DLIB_HAVE_SSE2;DLIB_HAVE_SSE3;DLIB_HAVE_SSE41;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions) @@ -175,7 +178,7 @@ $(SolutionDir)dlib/include/dlib/..;%(AdditionalIncludeDirectories) CompileAsCpp - AdvancedVectorExtensions2 + AdvancedVectorExtensions Sync AnySuitable Full @@ -190,6 +193,7 @@ $(IntDir) $(IntDir)vc$(PlatformToolsetVersion).pdb Speed + true WIN32;_WINDOWS;DLIB_PNG_SUPPORT;DLIB_JPEG_SUPPORT;NDEBUG;DLIB_HAVE_SSE2;DLIB_HAVE_SSE3;DLIB_HAVE_SSE41;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions) diff --git a/lib/3rdParty/dlib/include/dlib/general_hash/random_hashing.h b/lib/3rdParty/dlib/include/dlib/general_hash/random_hashing.h index 2be76f45..0a9e26ba 100644 --- a/lib/3rdParty/dlib/include/dlib/general_hash/random_hashing.h +++ b/lib/3rdParty/dlib/include/dlib/general_hash/random_hashing.h @@ -36,830 +36,830 @@ namespace dlib const static unsigned int max = 4096; const static float logvals[max] = { - 4.079, 3.905, 3.8, 3.723, 3.663, 3.613, 3.57, 3.532, 3.499, 3.468, - 3.441, 3.416, 3.392, 3.37, 3.35, 3.33, 3.312, 3.295, 3.278, 3.263, - 3.248, 3.233, 3.219, 3.206, 3.193, 3.181, 3.169, 3.158, 3.147, 3.136, - 3.125, 3.115, 3.105, 3.096, 3.086, 3.077, 3.068, 3.059, 3.051, 3.043, - 3.035, 3.027, 3.019, 3.011, 3.004, 2.996, 2.989, 2.982, 2.975, 2.968, - 2.962, 2.955, 2.949, 2.942, 2.936, 2.93, 2.924, 2.918, 2.912, 2.906, - 2.901, 2.895, 2.89, 2.884, 2.879, 2.873, 2.868, 2.863, 2.858, 2.853, - 2.848, 2.843, 2.838, 2.833, 2.829, 2.824, 2.819, 2.815, 2.81, 2.806, - 2.801, 2.797, 2.792, 2.788, 2.784, 2.78, 2.776, 2.771, 2.767, 2.763, - 2.759, 2.755, 2.751, 2.748, 2.744, 2.74, 2.736, 2.732, 2.729, 2.725, - 2.721, 2.718, 2.714, 2.71, 2.707, 2.703, 2.7, 2.697, 2.693, 2.69, - 2.686, 2.683, 2.68, 2.676, 2.673, 2.67, 2.667, 2.663, 2.66, 2.657, - 2.654, 2.651, 2.648, 2.645, 2.642, 2.639, 2.636, 2.633, 2.63, 2.627, - 2.624, 2.621, 2.618, 2.615, 2.612, 2.61, 2.607, 2.604, 2.601, 2.599, - 2.596, 2.593, 2.59, 2.588, 2.585, 2.582, 2.58, 2.577, 2.574, 2.572, - 2.569, 2.567, 2.564, 2.562, 2.559, 2.557, 2.554, 2.552, 2.549, 2.547, - 2.544, 2.542, 2.539, 2.537, 2.534, 2.532, 2.53, 2.527, 2.525, 2.523, - 2.52, 2.518, 2.516, 2.513, 2.511, 2.509, 2.507, 2.504, 2.502, 2.5, - 2.498, 2.495, 2.493, 2.491, 2.489, 2.487, 2.485, 2.482, 2.48, 2.478, - 2.476, 2.474, 2.472, 2.47, 2.468, 2.466, 2.464, 2.462, 2.459, 2.457, - 2.455, 2.453, 2.451, 2.449, 2.447, 2.445, 2.443, 2.441, 2.439, 2.437, - 2.436, 2.434, 2.432, 2.43, 2.428, 2.426, 2.424, 2.422, 2.42, 2.418, - 2.416, 2.415, 2.413, 2.411, 2.409, 2.407, 2.405, 2.404, 2.402, 2.4, - 2.398, 2.396, 2.394, 2.393, 2.391, 2.389, 2.387, 2.386, 2.384, 2.382, - 2.38, 2.379, 2.377, 2.375, 2.373, 2.372, 2.37, 2.368, 2.367, 2.365, - 2.363, 2.361, 2.36, 2.358, 2.356, 2.355, 2.353, 2.352, 2.35, 2.348, - 2.347, 2.345, 2.343, 2.342, 2.34, 2.338, 2.337, 2.335, 2.334, 2.332, - 2.331, 2.329, 2.327, 2.326, 2.324, 2.323, 2.321, 2.32, 2.318, 2.316, - 2.315, 2.313, 2.312, 2.31, 2.309, 2.307, 2.306, 2.304, 2.303, 2.301, - 2.3, 2.298, 2.297, 2.295, 2.294, 2.292, 2.291, 2.289, 2.288, 2.286, - 2.285, 2.284, 2.282, 2.281, 2.279, 2.278, 2.276, 2.275, 2.274, 2.272, - 2.271, 2.269, 2.268, 2.266, 2.265, 2.264, 2.262, 2.261, 2.259, 2.258, - 2.257, 2.255, 2.254, 2.253, 2.251, 2.25, 2.248, 2.247, 2.246, 2.244, - 2.243, 2.242, 2.24, 2.239, 2.238, 2.236, 2.235, 2.234, 2.232, 2.231, - 2.23, 2.228, 2.227, 2.226, 2.225, 2.223, 2.222, 2.221, 2.219, 2.218, - 2.217, 2.215, 2.214, 2.213, 2.212, 2.21, 2.209, 2.208, 2.207, 2.205, - 2.204, 2.203, 2.202, 2.2, 2.199, 2.198, 2.197, 2.195, 2.194, 2.193, - 2.192, 2.19, 2.189, 2.188, 2.187, 2.185, 2.184, 2.183, 2.182, 2.181, - 2.179, 2.178, 2.177, 2.176, 2.175, 2.173, 2.172, 2.171, 2.17, 2.169, - 2.168, 2.166, 2.165, 2.164, 2.163, 2.162, 2.16, 2.159, 2.158, 2.157, - 2.156, 2.155, 2.154, 2.152, 2.151, 2.15, 2.149, 2.148, 2.147, 2.146, - 2.144, 2.143, 2.142, 2.141, 2.14, 2.139, 2.138, 2.136, 2.135, 2.134, - 2.133, 2.132, 2.131, 2.13, 2.129, 2.128, 2.126, 2.125, 2.124, 2.123, - 2.122, 2.121, 2.12, 2.119, 2.118, 2.117, 2.116, 2.114, 2.113, 2.112, - 2.111, 2.11, 2.109, 2.108, 2.107, 2.106, 2.105, 2.104, 2.103, 2.102, - 2.101, 2.1, 2.099, 2.097, 2.096, 2.095, 2.094, 2.093, 2.092, 2.091, - 2.09, 2.089, 2.088, 2.087, 2.086, 2.085, 2.084, 2.083, 2.082, 2.081, - 2.08, 2.079, 2.078, 2.077, 2.076, 2.075, 2.074, 2.073, 2.072, 2.071, - 2.07, 2.069, 2.068, 2.067, 2.066, 2.065, 2.064, 2.063, 2.062, 2.061, - 2.06, 2.059, 2.058, 2.057, 2.056, 2.055, 2.054, 2.053, 2.052, 2.051, - 2.05, 2.049, 2.048, 2.047, 2.046, 2.045, 2.044, 2.043, 2.042, 2.041, - 2.04, 2.039, 2.038, 2.037, 2.036, 2.036, 2.035, 2.034, 2.033, 2.032, - 2.031, 2.03, 2.029, 2.028, 2.027, 2.026, 2.025, 2.024, 2.023, 2.022, - 2.021, 2.02, 2.02, 2.019, 2.018, 2.017, 2.016, 2.015, 2.014, 2.013, - 2.012, 2.011, 2.01, 2.009, 2.008, 2.008, 2.007, 2.006, 2.005, 2.004, - 2.003, 2.002, 2.001, 2, 1.999, 1.998, 1.998, 1.997, 1.996, 1.995, - 1.994, 1.993, 1.992, 1.991, 1.99, 1.99, 1.989, 1.988, 1.987, 1.986, - 1.985, 1.984, 1.983, 1.982, 1.982, 1.981, 1.98, 1.979, 1.978, 1.977, - 1.976, 1.975, 1.975, 1.974, 1.973, 1.972, 1.971, 1.97, 1.969, 1.969, - 1.968, 1.967, 1.966, 1.965, 1.964, 1.963, 1.963, 1.962, 1.961, 1.96, - 1.959, 1.958, 1.957, 1.957, 1.956, 1.955, 1.954, 1.953, 1.952, 1.952, - 1.951, 1.95, 1.949, 1.948, 1.947, 1.947, 1.946, 1.945, 1.944, 1.943, - 1.942, 1.942, 1.941, 1.94, 1.939, 1.938, 1.937, 1.937, 1.936, 1.935, - 1.934, 1.933, 1.933, 1.932, 1.931, 1.93, 1.929, 1.928, 1.928, 1.927, - 1.926, 1.925, 1.924, 1.924, 1.923, 1.922, 1.921, 1.92, 1.92, 1.919, - 1.918, 1.917, 1.916, 1.916, 1.915, 1.914, 1.913, 1.912, 1.912, 1.911, - 1.91, 1.909, 1.908, 1.908, 1.907, 1.906, 1.905, 1.904, 1.904, 1.903, - 1.902, 1.901, 1.901, 1.9, 1.899, 1.898, 1.897, 1.897, 1.896, 1.895, - 1.894, 1.894, 1.893, 1.892, 1.891, 1.89, 1.89, 1.889, 1.888, 1.887, - 1.887, 1.886, 1.885, 1.884, 1.884, 1.883, 1.882, 1.881, 1.88, 1.88, - 1.879, 1.878, 1.877, 1.877, 1.876, 1.875, 1.874, 1.874, 1.873, 1.872, - 1.871, 1.871, 1.87, 1.869, 1.868, 1.868, 1.867, 1.866, 1.865, 1.865, - 1.864, 1.863, 1.862, 1.862, 1.861, 1.86, 1.859, 1.859, 1.858, 1.857, - 1.857, 1.856, 1.855, 1.854, 1.854, 1.853, 1.852, 1.851, 1.851, 1.85, - 1.849, 1.848, 1.848, 1.847, 1.846, 1.846, 1.845, 1.844, 1.843, 1.843, - 1.842, 1.841, 1.84, 1.84, 1.839, 1.838, 1.838, 1.837, 1.836, 1.835, - 1.835, 1.834, 1.833, 1.833, 1.832, 1.831, 1.83, 1.83, 1.829, 1.828, - 1.828, 1.827, 1.826, 1.825, 1.825, 1.824, 1.823, 1.823, 1.822, 1.821, - 1.821, 1.82, 1.819, 1.818, 1.818, 1.817, 1.816, 1.816, 1.815, 1.814, - 1.814, 1.813, 1.812, 1.811, 1.811, 1.81, 1.809, 1.809, 1.808, 1.807, - 1.807, 1.806, 1.805, 1.805, 1.804, 1.803, 1.802, 1.802, 1.801, 1.8, - 1.8, 1.799, 1.798, 1.798, 1.797, 1.796, 1.796, 1.795, 1.794, 1.794, - 1.793, 1.792, 1.792, 1.791, 1.79, 1.79, 1.789, 1.788, 1.787, 1.787, - 1.786, 1.785, 1.785, 1.784, 1.783, 1.783, 1.782, 1.781, 1.781, 1.78, - 1.779, 1.779, 1.778, 1.777, 1.777, 1.776, 1.775, 1.775, 1.774, 1.773, - 1.773, 1.772, 1.771, 1.771, 1.77, 1.769, 1.769, 1.768, 1.767, 1.767, - 1.766, 1.766, 1.765, 1.764, 1.764, 1.763, 1.762, 1.762, 1.761, 1.76, - 1.76, 1.759, 1.758, 1.758, 1.757, 1.756, 1.756, 1.755, 1.754, 1.754, - 1.753, 1.752, 1.752, 1.751, 1.751, 1.75, 1.749, 1.749, 1.748, 1.747, - 1.747, 1.746, 1.745, 1.745, 1.744, 1.743, 1.743, 1.742, 1.742, 1.741, - 1.74, 1.74, 1.739, 1.738, 1.738, 1.737, 1.736, 1.736, 1.735, 1.735, - 1.734, 1.733, 1.733, 1.732, 1.731, 1.731, 1.73, 1.729, 1.729, 1.728, - 1.728, 1.727, 1.726, 1.726, 1.725, 1.724, 1.724, 1.723, 1.723, 1.722, - 1.721, 1.721, 1.72, 1.719, 1.719, 1.718, 1.718, 1.717, 1.716, 1.716, - 1.715, 1.715, 1.714, 1.713, 1.713, 1.712, 1.711, 1.711, 1.71, 1.71, - 1.709, 1.708, 1.708, 1.707, 1.706, 1.706, 1.705, 1.705, 1.704, 1.703, - 1.703, 1.702, 1.702, 1.701, 1.7, 1.7, 1.699, 1.699, 1.698, 1.697, - 1.697, 1.696, 1.696, 1.695, 1.694, 1.694, 1.693, 1.692, 1.692, 1.691, - 1.691, 1.69, 1.689, 1.689, 1.688, 1.688, 1.687, 1.686, 1.686, 1.685, - 1.685, 1.684, 1.683, 1.683, 1.682, 1.682, 1.681, 1.68, 1.68, 1.679, - 1.679, 1.678, 1.678, 1.677, 1.676, 1.676, 1.675, 1.675, 1.674, 1.673, - 1.673, 1.672, 1.672, 1.671, 1.67, 1.67, 1.669, 1.669, 1.668, 1.667, - 1.667, 1.666, 1.666, 1.665, 1.665, 1.664, 1.663, 1.663, 1.662, 1.662, - 1.661, 1.66, 1.66, 1.659, 1.659, 1.658, 1.658, 1.657, 1.656, 1.656, - 1.655, 1.655, 1.654, 1.653, 1.653, 1.652, 1.652, 1.651, 1.651, 1.65, - 1.649, 1.649, 1.648, 1.648, 1.647, 1.647, 1.646, 1.645, 1.645, 1.644, - 1.644, 1.643, 1.643, 1.642, 1.641, 1.641, 1.64, 1.64, 1.639, 1.639, - 1.638, 1.637, 1.637, 1.636, 1.636, 1.635, 1.635, 1.634, 1.633, 1.633, - 1.632, 1.632, 1.631, 1.631, 1.63, 1.629, 1.629, 1.628, 1.628, 1.627, - 1.627, 1.626, 1.625, 1.625, 1.624, 1.624, 1.623, 1.623, 1.622, 1.622, - 1.621, 1.62, 1.62, 1.619, 1.619, 1.618, 1.618, 1.617, 1.617, 1.616, - 1.615, 1.615, 1.614, 1.614, 1.613, 1.613, 1.612, 1.612, 1.611, 1.61, - 1.61, 1.609, 1.609, 1.608, 1.608, 1.607, 1.607, 1.606, 1.605, 1.605, - 1.604, 1.604, 1.603, 1.603, 1.602, 1.602, 1.601, 1.6, 1.6, 1.599, - 1.599, 1.598, 1.598, 1.597, 1.597, 1.596, 1.596, 1.595, 1.594, 1.594, - 1.593, 1.593, 1.592, 1.592, 1.591, 1.591, 1.59, 1.59, 1.589, 1.588, - 1.588, 1.587, 1.587, 1.586, 1.586, 1.585, 1.585, 1.584, 1.584, 1.583, - 1.582, 1.582, 1.581, 1.581, 1.58, 1.58, 1.579, 1.579, 1.578, 1.578, - 1.577, 1.577, 1.576, 1.576, 1.575, 1.574, 1.574, 1.573, 1.573, 1.572, - 1.572, 1.571, 1.571, 1.57, 1.57, 1.569, 1.569, 1.568, 1.567, 1.567, - 1.566, 1.566, 1.565, 1.565, 1.564, 1.564, 1.563, 1.563, 1.562, 1.562, - 1.561, 1.561, 1.56, 1.56, 1.559, 1.558, 1.558, 1.557, 1.557, 1.556, - 1.556, 1.555, 1.555, 1.554, 1.554, 1.553, 1.553, 1.552, 1.552, 1.551, - 1.551, 1.55, 1.55, 1.549, 1.549, 1.548, 1.547, 1.547, 1.546, 1.546, - 1.545, 1.545, 1.544, 1.544, 1.543, 1.543, 1.542, 1.542, 1.541, 1.541, - 1.54, 1.54, 1.539, 1.539, 1.538, 1.538, 1.537, 1.537, 1.536, 1.536, - 1.535, 1.534, 1.534, 1.533, 1.533, 1.532, 1.532, 1.531, 1.531, 1.53, - 1.53, 1.529, 1.529, 1.528, 1.528, 1.527, 1.527, 1.526, 1.526, 1.525, - 1.525, 1.524, 1.524, 1.523, 1.523, 1.522, 1.522, 1.521, 1.521, 1.52, - 1.52, 1.519, 1.519, 1.518, 1.518, 1.517, 1.517, 1.516, 1.516, 1.515, - 1.515, 1.514, 1.514, 1.513, 1.512, 1.512, 1.511, 1.511, 1.51, 1.51, - 1.509, 1.509, 1.508, 1.508, 1.507, 1.507, 1.506, 1.506, 1.505, 1.505, - 1.504, 1.504, 1.503, 1.503, 1.502, 1.502, 1.501, 1.501, 1.5, 1.5, - 1.499, 1.499, 1.498, 1.498, 1.497, 1.497, 1.496, 1.496, 1.495, 1.495, - 1.494, 1.494, 1.493, 1.493, 1.492, 1.492, 1.491, 1.491, 1.49, 1.49, - 1.489, 1.489, 1.488, 1.488, 1.487, 1.487, 1.486, 1.486, 1.485, 1.485, - 1.484, 1.484, 1.483, 1.483, 1.482, 1.482, 1.481, 1.481, 1.48, 1.48, - 1.48, 1.479, 1.479, 1.478, 1.478, 1.477, 1.477, 1.476, 1.476, 1.475, - 1.475, 1.474, 1.474, 1.473, 1.473, 1.472, 1.472, 1.471, 1.471, 1.47, - 1.47, 1.469, 1.469, 1.468, 1.468, 1.467, 1.467, 1.466, 1.466, 1.465, - 1.465, 1.464, 1.464, 1.463, 1.463, 1.462, 1.462, 1.461, 1.461, 1.46, - 1.46, 1.459, 1.459, 1.458, 1.458, 1.458, 1.457, 1.457, 1.456, 1.456, - 1.455, 1.455, 1.454, 1.454, 1.453, 1.453, 1.452, 1.452, 1.451, 1.451, - 1.45, 1.45, 1.449, 1.449, 1.448, 1.448, 1.447, 1.447, 1.446, 1.446, - 1.445, 1.445, 1.444, 1.444, 1.444, 1.443, 1.443, 1.442, 1.442, 1.441, - 1.441, 1.44, 1.44, 1.439, 1.439, 1.438, 1.438, 1.437, 1.437, 1.436, - 1.436, 1.435, 1.435, 1.434, 1.434, 1.434, 1.433, 1.433, 1.432, 1.432, - 1.431, 1.431, 1.43, 1.43, 1.429, 1.429, 1.428, 1.428, 1.427, 1.427, - 1.426, 1.426, 1.425, 1.425, 1.424, 1.424, 1.424, 1.423, 1.423, 1.422, - 1.422, 1.421, 1.421, 1.42, 1.42, 1.419, 1.419, 1.418, 1.418, 1.417, - 1.417, 1.416, 1.416, 1.416, 1.415, 1.415, 1.414, 1.414, 1.413, 1.413, - 1.412, 1.412, 1.411, 1.411, 1.41, 1.41, 1.409, 1.409, 1.409, 1.408, - 1.408, 1.407, 1.407, 1.406, 1.406, 1.405, 1.405, 1.404, 1.404, 1.403, - 1.403, 1.402, 1.402, 1.402, 1.401, 1.401, 1.4, 1.4, 1.399, 1.399, - 1.398, 1.398, 1.397, 1.397, 1.396, 1.396, 1.395, 1.395, 1.395, 1.394, - 1.394, 1.393, 1.393, 1.392, 1.392, 1.391, 1.391, 1.39, 1.39, 1.389, - 1.389, 1.389, 1.388, 1.388, 1.387, 1.387, 1.386, 1.386, 1.385, 1.385, - 1.384, 1.384, 1.383, 1.383, 1.383, 1.382, 1.382, 1.381, 1.381, 1.38, - 1.38, 1.379, 1.379, 1.378, 1.378, 1.378, 1.377, 1.377, 1.376, 1.376, - 1.375, 1.375, 1.374, 1.374, 1.373, 1.373, 1.373, 1.372, 1.372, 1.371, - 1.371, 1.37, 1.37, 1.369, 1.369, 1.368, 1.368, 1.367, 1.367, 1.367, - 1.366, 1.366, 1.365, 1.365, 1.364, 1.364, 1.363, 1.363, 1.362, 1.362, - 1.362, 1.361, 1.361, 1.36, 1.36, 1.359, 1.359, 1.358, 1.358, 1.358, - 1.357, 1.357, 1.356, 1.356, 1.355, 1.355, 1.354, 1.354, 1.353, 1.353, - 1.353, 1.352, 1.352, 1.351, 1.351, 1.35, 1.35, 1.349, 1.349, 1.349, - 1.348, 1.348, 1.347, 1.347, 1.346, 1.346, 1.345, 1.345, 1.344, 1.344, - 1.344, 1.343, 1.343, 1.342, 1.342, 1.341, 1.341, 1.34, 1.34, 1.34, - 1.339, 1.339, 1.338, 1.338, 1.337, 1.337, 1.336, 1.336, 1.336, 1.335, - 1.335, 1.334, 1.334, 1.333, 1.333, 1.332, 1.332, 1.332, 1.331, 1.331, - 1.33, 1.33, 1.329, 1.329, 1.328, 1.328, 1.328, 1.327, 1.327, 1.326, - 1.326, 1.325, 1.325, 1.324, 1.324, 1.324, 1.323, 1.323, 1.322, 1.322, - 1.321, 1.321, 1.32, 1.32, 1.32, 1.319, 1.319, 1.318, 1.318, 1.317, - 1.317, 1.316, 1.316, 1.316, 1.315, 1.315, 1.314, 1.314, 1.313, 1.313, - 1.312, 1.312, 1.312, 1.311, 1.311, 1.31, 1.31, 1.309, 1.309, 1.309, - 1.308, 1.308, 1.307, 1.307, 1.306, 1.306, 1.305, 1.305, 1.305, 1.304, - 1.304, 1.303, 1.303, 1.302, 1.302, 1.302, 1.301, 1.301, 1.3, 1.3, - 1.299, 1.299, 1.298, 1.298, 1.298, 1.297, 1.297, 1.296, 1.296, 1.295, - 1.295, 1.295, 1.294, 1.294, 1.293, 1.293, 1.292, 1.292, 1.291, 1.291, - 1.291, 1.29, 1.29, 1.289, 1.289, 1.288, 1.288, 1.288, 1.287, 1.287, - 1.286, 1.286, 1.285, 1.285, 1.285, 1.284, 1.284, 1.283, 1.283, 1.282, - 1.282, 1.281, 1.281, 1.281, 1.28, 1.28, 1.279, 1.279, 1.278, 1.278, - 1.278, 1.277, 1.277, 1.276, 1.276, 1.275, 1.275, 1.275, 1.274, 1.274, - 1.273, 1.273, 1.272, 1.272, 1.272, 1.271, 1.271, 1.27, 1.27, 1.269, - 1.269, 1.269, 1.268, 1.268, 1.267, 1.267, 1.266, 1.266, 1.266, 1.265, - 1.265, 1.264, 1.264, 1.263, 1.263, 1.263, 1.262, 1.262, 1.261, 1.261, - 1.26, 1.26, 1.26, 1.259, 1.259, 1.258, 1.258, 1.257, 1.257, 1.257, - 1.256, 1.256, 1.255, 1.255, 1.254, 1.254, 1.254, 1.253, 1.253, 1.252, - 1.252, 1.251, 1.251, 1.251, 1.25, 1.25, 1.249, 1.249, 1.248, 1.248, - 1.248, 1.247, 1.247, 1.246, 1.246, 1.245, 1.245, 1.245, 1.244, 1.244, - 1.243, 1.243, 1.242, 1.242, 1.242, 1.241, 1.241, 1.24, 1.24, 1.239, - 1.239, 1.239, 1.238, 1.238, 1.237, 1.237, 1.237, 1.236, 1.236, 1.235, - 1.235, 1.234, 1.234, 1.234, 1.233, 1.233, 1.232, 1.232, 1.231, 1.231, - 1.231, 1.23, 1.23, 1.229, 1.229, 1.228, 1.228, 1.228, 1.227, 1.227, - 1.226, 1.226, 1.226, 1.225, 1.225, 1.224, 1.224, 1.223, 1.223, 1.223, - 1.222, 1.222, 1.221, 1.221, 1.22, 1.22, 1.22, 1.219, 1.219, 1.218, - 1.218, 1.218, 1.217, 1.217, 1.216, 1.216, 1.215, 1.215, 1.215, 1.214, - 1.214, 1.213, 1.213, 1.212, 1.212, 1.212, 1.211, 1.211, 1.21, 1.21, - 1.21, 1.209, 1.209, 1.208, 1.208, 1.207, 1.207, 1.207, 1.206, 1.206, - 1.205, 1.205, 1.204, 1.204, 1.204, 1.203, 1.203, 1.202, 1.202, 1.202, - 1.201, 1.201, 1.2, 1.2, 1.199, 1.199, 1.199, 1.198, 1.198, 1.197, - 1.197, 1.197, 1.196, 1.196, 1.195, 1.195, 1.194, 1.194, 1.194, 1.193, - 1.193, 1.192, 1.192, 1.192, 1.191, 1.191, 1.19, 1.19, 1.189, 1.189, - 1.189, 1.188, 1.188, 1.187, 1.187, 1.187, 1.186, 1.186, 1.185, 1.185, - 1.184, 1.184, 1.184, 1.183, 1.183, 1.182, 1.182, 1.182, 1.181, 1.181, - 1.18, 1.18, 1.179, 1.179, 1.179, 1.178, 1.178, 1.177, 1.177, 1.177, - 1.176, 1.176, 1.175, 1.175, 1.175, 1.174, 1.174, 1.173, 1.173, 1.172, - 1.172, 1.172, 1.171, 1.171, 1.17, 1.17, 1.17, 1.169, 1.169, 1.168, - 1.168, 1.167, 1.167, 1.167, 1.166, 1.166, 1.165, 1.165, 1.165, 1.164, - 1.164, 1.163, 1.163, 1.163, 1.162, 1.162, 1.161, 1.161, 1.16, 1.16, - 1.16, 1.159, 1.159, 1.158, 1.158, 1.158, 1.157, 1.157, 1.156, 1.156, - 1.156, 1.155, 1.155, 1.154, 1.154, 1.153, 1.153, 1.153, 1.152, 1.152, - 1.151, 1.151, 1.151, 1.15, 1.15, 1.149, 1.149, 1.149, 1.148, 1.148, - 1.147, 1.147, 1.146, 1.146, 1.146, 1.145, 1.145, 1.144, 1.144, 1.144, - 1.143, 1.143, 1.142, 1.142, 1.142, 1.141, 1.141, 1.14, 1.14, 1.139, - 1.139, 1.139, 1.138, 1.138, 1.137, 1.137, 1.137, 1.136, 1.136, 1.135, - 1.135, 1.135, 1.134, 1.134, 1.133, 1.133, 1.133, 1.132, 1.132, 1.131, - 1.131, 1.13, 1.13, 1.13, 1.129, 1.129, 1.128, 1.128, 1.128, 1.127, - 1.127, 1.126, 1.126, 1.126, 1.125, 1.125, 1.124, 1.124, 1.124, 1.123, - 1.123, 1.122, 1.122, 1.121, 1.121, 1.121, 1.12, 1.12, 1.119, 1.119, - 1.119, 1.118, 1.118, 1.117, 1.117, 1.117, 1.116, 1.116, 1.115, 1.115, - 1.115, 1.114, 1.114, 1.113, 1.113, 1.113, 1.112, 1.112, 1.111, 1.111, - 1.11, 1.11, 1.11, 1.109, 1.109, 1.108, 1.108, 1.108, 1.107, 1.107, - 1.106, 1.106, 1.106, 1.105, 1.105, 1.104, 1.104, 1.104, 1.103, 1.103, - 1.102, 1.102, 1.102, 1.101, 1.101, 1.1, 1.1, 1.099, 1.099, 1.099, - 1.098, 1.098, 1.097, 1.097, 1.097, 1.096, 1.096, 1.095, 1.095, 1.095, - 1.094, 1.094, 1.093, 1.093, 1.093, 1.092, 1.092, 1.091, 1.091, 1.091, - 1.09, 1.09, 1.089, 1.089, 1.089, 1.088, 1.088, 1.087, 1.087, 1.086, - 1.086, 1.086, 1.085, 1.085, 1.084, 1.084, 1.084, 1.083, 1.083, 1.082, - 1.082, 1.082, 1.081, 1.081, 1.08, 1.08, 1.08, 1.079, 1.079, 1.078, - 1.078, 1.078, 1.077, 1.077, 1.076, 1.076, 1.076, 1.075, 1.075, 1.074, - 1.074, 1.074, 1.073, 1.073, 1.072, 1.072, 1.072, 1.071, 1.071, 1.07, - 1.07, 1.069, 1.069, 1.069, 1.068, 1.068, 1.067, 1.067, 1.067, 1.066, - 1.066, 1.065, 1.065, 1.065, 1.064, 1.064, 1.063, 1.063, 1.063, 1.062, - 1.062, 1.061, 1.061, 1.061, 1.06, 1.06, 1.059, 1.059, 1.059, 1.058, - 1.058, 1.057, 1.057, 1.057, 1.056, 1.056, 1.055, 1.055, 1.055, 1.054, - 1.054, 1.053, 1.053, 1.053, 1.052, 1.052, 1.051, 1.051, 1.05, 1.05, - 1.05, 1.049, 1.049, 1.048, 1.048, 1.048, 1.047, 1.047, 1.046, 1.046, - 1.046, 1.045, 1.045, 1.044, 1.044, 1.044, 1.043, 1.043, 1.042, 1.042, - 1.042, 1.041, 1.041, 1.04, 1.04, 1.04, 1.039, 1.039, 1.038, 1.038, - 1.038, 1.037, 1.037, 1.036, 1.036, 1.036, 1.035, 1.035, 1.034, 1.034, - 1.034, 1.033, 1.033, 1.032, 1.032, 1.032, 1.031, 1.031, 1.03, 1.03, - 1.03, 1.029, 1.029, 1.028, 1.028, 1.028, 1.027, 1.027, 1.026, 1.026, - 1.026, 1.025, 1.025, 1.024, 1.024, 1.023, 1.023, 1.023, 1.022, 1.022, - 1.021, 1.021, 1.021, 1.02, 1.02, 1.019, 1.019, 1.019, 1.018, 1.018, - 1.017, 1.017, 1.017, 1.016, 1.016, 1.015, 1.015, 1.015, 1.014, 1.014, - 1.013, 1.013, 1.013, 1.012, 1.012, 1.011, 1.011, 1.011, 1.01, 1.01, - 1.009, 1.009, 1.009, 1.008, 1.008, 1.007, 1.007, 1.007, 1.006, 1.006, - 1.005, 1.005, 1.005, 1.004, 1.004, 1.003, 1.003, 1.003, 1.002, 1.002, - 1.001, 1.001, 1.001, 1, 0.9997, 0.9993, 0.9989, 0.9985, 0.9981, 0.9977, - 0.9973, 0.9969, 0.9965, 0.9961, 0.9957, 0.9953, 0.9949, 0.9945, 0.9941, 0.9937, - 0.9933, 0.9929, 0.9925, 0.9921, 0.9917, 0.9913, 0.9909, 0.9905, 0.9901, 0.9897, - 0.9893, 0.9889, 0.9885, 0.9881, 0.9877, 0.9873, 0.9869, 0.9865, 0.9861, 0.9856, - 0.9852, 0.9848, 0.9844, 0.984, 0.9836, 0.9832, 0.9828, 0.9824, 0.982, 0.9816, - 0.9812, 0.9808, 0.9804, 0.98, 0.9796, 0.9792, 0.9788, 0.9784, 0.978, 0.9776, - 0.9772, 0.9768, 0.9764, 0.976, 0.9756, 0.9752, 0.9748, 0.9744, 0.974, 0.9736, - 0.9732, 0.9728, 0.9724, 0.972, 0.9716, 0.9712, 0.9707, 0.9703, 0.9699, 0.9695, - 0.9691, 0.9687, 0.9683, 0.9679, 0.9675, 0.9671, 0.9667, 0.9663, 0.9659, 0.9655, - 0.9651, 0.9647, 0.9643, 0.9639, 0.9635, 0.9631, 0.9627, 0.9623, 0.9619, 0.9615, - 0.9611, 0.9607, 0.9603, 0.9599, 0.9595, 0.9591, 0.9587, 0.9583, 0.9579, 0.9574, - 0.957, 0.9566, 0.9562, 0.9558, 0.9554, 0.955, 0.9546, 0.9542, 0.9538, 0.9534, - 0.953, 0.9526, 0.9522, 0.9518, 0.9514, 0.951, 0.9506, 0.9502, 0.9498, 0.9494, - 0.949, 0.9486, 0.9482, 0.9478, 0.9474, 0.947, 0.9466, 0.9462, 0.9457, 0.9453, - 0.9449, 0.9445, 0.9441, 0.9437, 0.9433, 0.9429, 0.9425, 0.9421, 0.9417, 0.9413, - 0.9409, 0.9405, 0.9401, 0.9397, 0.9393, 0.9389, 0.9385, 0.9381, 0.9377, 0.9373, - 0.9369, 0.9365, 0.9361, 0.9356, 0.9352, 0.9348, 0.9344, 0.934, 0.9336, 0.9332, - 0.9328, 0.9324, 0.932, 0.9316, 0.9312, 0.9308, 0.9304, 0.93, 0.9296, 0.9292, - 0.9288, 0.9284, 0.928, 0.9276, 0.9272, 0.9267, 0.9263, 0.9259, 0.9255, 0.9251, - 0.9247, 0.9243, 0.9239, 0.9235, 0.9231, 0.9227, 0.9223, 0.9219, 0.9215, 0.9211, - 0.9207, 0.9203, 0.9199, 0.9195, 0.9191, 0.9186, 0.9182, 0.9178, 0.9174, 0.917, - 0.9166, 0.9162, 0.9158, 0.9154, 0.915, 0.9146, 0.9142, 0.9138, 0.9134, 0.913, - 0.9126, 0.9122, 0.9118, 0.9113, 0.9109, 0.9105, 0.9101, 0.9097, 0.9093, 0.9089, - 0.9085, 0.9081, 0.9077, 0.9073, 0.9069, 0.9065, 0.9061, 0.9057, 0.9053, 0.9049, - 0.9044, 0.904, 0.9036, 0.9032, 0.9028, 0.9024, 0.902, 0.9016, 0.9012, 0.9008, - 0.9004, 0.9, 0.8996, 0.8992, 0.8988, 0.8983, 0.8979, 0.8975, 0.8971, 0.8967, - 0.8963, 0.8959, 0.8955, 0.8951, 0.8947, 0.8943, 0.8939, 0.8935, 0.8931, 0.8926, - 0.8922, 0.8918, 0.8914, 0.891, 0.8906, 0.8902, 0.8898, 0.8894, 0.889, 0.8886, - 0.8882, 0.8878, 0.8873, 0.8869, 0.8865, 0.8861, 0.8857, 0.8853, 0.8849, 0.8845, - 0.8841, 0.8837, 0.8833, 0.8829, 0.8825, 0.882, 0.8816, 0.8812, 0.8808, 0.8804, - 0.88, 0.8796, 0.8792, 0.8788, 0.8784, 0.878, 0.8775, 0.8771, 0.8767, 0.8763, - 0.8759, 0.8755, 0.8751, 0.8747, 0.8743, 0.8739, 0.8735, 0.873, 0.8726, 0.8722, - 0.8718, 0.8714, 0.871, 0.8706, 0.8702, 0.8698, 0.8694, 0.869, 0.8685, 0.8681, - 0.8677, 0.8673, 0.8669, 0.8665, 0.8661, 0.8657, 0.8653, 0.8649, 0.8644, 0.864, - 0.8636, 0.8632, 0.8628, 0.8624, 0.862, 0.8616, 0.8612, 0.8607, 0.8603, 0.8599, - 0.8595, 0.8591, 0.8587, 0.8583, 0.8579, 0.8575, 0.857, 0.8566, 0.8562, 0.8558, - 0.8554, 0.855, 0.8546, 0.8542, 0.8538, 0.8533, 0.8529, 0.8525, 0.8521, 0.8517, - 0.8513, 0.8509, 0.8505, 0.85, 0.8496, 0.8492, 0.8488, 0.8484, 0.848, 0.8476, - 0.8472, 0.8467, 0.8463, 0.8459, 0.8455, 0.8451, 0.8447, 0.8443, 0.8439, 0.8434, - 0.843, 0.8426, 0.8422, 0.8418, 0.8414, 0.841, 0.8406, 0.8401, 0.8397, 0.8393, - 0.8389, 0.8385, 0.8381, 0.8377, 0.8372, 0.8368, 0.8364, 0.836, 0.8356, 0.8352, - 0.8348, 0.8343, 0.8339, 0.8335, 0.8331, 0.8327, 0.8323, 0.8319, 0.8314, 0.831, - 0.8306, 0.8302, 0.8298, 0.8294, 0.8289, 0.8285, 0.8281, 0.8277, 0.8273, 0.8269, - 0.8265, 0.826, 0.8256, 0.8252, 0.8248, 0.8244, 0.824, 0.8235, 0.8231, 0.8227, - 0.8223, 0.8219, 0.8215, 0.821, 0.8206, 0.8202, 0.8198, 0.8194, 0.819, 0.8185, - 0.8181, 0.8177, 0.8173, 0.8169, 0.8165, 0.816, 0.8156, 0.8152, 0.8148, 0.8144, - 0.814, 0.8135, 0.8131, 0.8127, 0.8123, 0.8119, 0.8114, 0.811, 0.8106, 0.8102, - 0.8098, 0.8094, 0.8089, 0.8085, 0.8081, 0.8077, 0.8073, 0.8068, 0.8064, 0.806, - 0.8056, 0.8052, 0.8047, 0.8043, 0.8039, 0.8035, 0.8031, 0.8026, 0.8022, 0.8018, - 0.8014, 0.801, 0.8005, 0.8001, 0.7997, 0.7993, 0.7989, 0.7984, 0.798, 0.7976, - 0.7972, 0.7968, 0.7963, 0.7959, 0.7955, 0.7951, 0.7947, 0.7942, 0.7938, 0.7934, - 0.793, 0.7926, 0.7921, 0.7917, 0.7913, 0.7909, 0.7904, 0.79, 0.7896, 0.7892, - 0.7888, 0.7883, 0.7879, 0.7875, 0.7871, 0.7866, 0.7862, 0.7858, 0.7854, 0.7849, - 0.7845, 0.7841, 0.7837, 0.7833, 0.7828, 0.7824, 0.782, 0.7816, 0.7811, 0.7807, - 0.7803, 0.7799, 0.7794, 0.779, 0.7786, 0.7782, 0.7777, 0.7773, 0.7769, 0.7765, - 0.776, 0.7756, 0.7752, 0.7748, 0.7743, 0.7739, 0.7735, 0.7731, 0.7726, 0.7722, - 0.7718, 0.7714, 0.7709, 0.7705, 0.7701, 0.7697, 0.7692, 0.7688, 0.7684, 0.7679, - 0.7675, 0.7671, 0.7667, 0.7662, 0.7658, 0.7654, 0.765, 0.7645, 0.7641, 0.7637, - 0.7632, 0.7628, 0.7624, 0.762, 0.7615, 0.7611, 0.7607, 0.7602, 0.7598, 0.7594, - 0.759, 0.7585, 0.7581, 0.7577, 0.7572, 0.7568, 0.7564, 0.756, 0.7555, 0.7551, - 0.7547, 0.7542, 0.7538, 0.7534, 0.7529, 0.7525, 0.7521, 0.7516, 0.7512, 0.7508, - 0.7504, 0.7499, 0.7495, 0.7491, 0.7486, 0.7482, 0.7478, 0.7473, 0.7469, 0.7465, - 0.746, 0.7456, 0.7452, 0.7447, 0.7443, 0.7439, 0.7434, 0.743, 0.7426, 0.7421, - 0.7417, 0.7413, 0.7408, 0.7404, 0.74, 0.7395, 0.7391, 0.7387, 0.7382, 0.7378, - 0.7374, 0.7369, 0.7365, 0.7361, 0.7356, 0.7352, 0.7348, 0.7343, 0.7339, 0.7335, - 0.733, 0.7326, 0.7321, 0.7317, 0.7313, 0.7308, 0.7304, 0.73, 0.7295, 0.7291, - 0.7287, 0.7282, 0.7278, 0.7273, 0.7269, 0.7265, 0.726, 0.7256, 0.7252, 0.7247, - 0.7243, 0.7238, 0.7234, 0.723, 0.7225, 0.7221, 0.7216, 0.7212, 0.7208, 0.7203, - 0.7199, 0.7195, 0.719, 0.7186, 0.7181, 0.7177, 0.7173, 0.7168, 0.7164, 0.7159, - 0.7155, 0.7151, 0.7146, 0.7142, 0.7137, 0.7133, 0.7128, 0.7124, 0.712, 0.7115, - 0.7111, 0.7106, 0.7102, 0.7098, 0.7093, 0.7089, 0.7084, 0.708, 0.7075, 0.7071, - 0.7066, 0.7062, 0.7058, 0.7053, 0.7049, 0.7044, 0.704, 0.7035, 0.7031, 0.7027, - 0.7022, 0.7018, 0.7013, 0.7009, 0.7004, 0.7, 0.6995, 0.6991, 0.6986, 0.6982, - 0.6978, 0.6973, 0.6969, 0.6964, 0.696, 0.6955, 0.6951, 0.6946, 0.6942, 0.6937, - 0.6933, 0.6928, 0.6924, 0.6919, 0.6915, 0.691, 0.6906, 0.6901, 0.6897, 0.6892, - 0.6888, 0.6883, 0.6879, 0.6874, 0.687, 0.6865, 0.6861, 0.6856, 0.6852, 0.6847, - 0.6843, 0.6838, 0.6834, 0.6829, 0.6825, 0.682, 0.6816, 0.6811, 0.6807, 0.6802, - 0.6798, 0.6793, 0.6789, 0.6784, 0.678, 0.6775, 0.6771, 0.6766, 0.6762, 0.6757, - 0.6752, 0.6748, 0.6743, 0.6739, 0.6734, 0.673, 0.6725, 0.6721, 0.6716, 0.6711, - 0.6707, 0.6702, 0.6698, 0.6693, 0.6689, 0.6684, 0.668, 0.6675, 0.667, 0.6666, - 0.6661, 0.6657, 0.6652, 0.6648, 0.6643, 0.6638, 0.6634, 0.6629, 0.6625, 0.662, - 0.6615, 0.6611, 0.6606, 0.6602, 0.6597, 0.6592, 0.6588, 0.6583, 0.6579, 0.6574, - 0.6569, 0.6565, 0.656, 0.6556, 0.6551, 0.6546, 0.6542, 0.6537, 0.6532, 0.6528, - 0.6523, 0.6519, 0.6514, 0.6509, 0.6505, 0.65, 0.6495, 0.6491, 0.6486, 0.6481, - 0.6477, 0.6472, 0.6468, 0.6463, 0.6458, 0.6454, 0.6449, 0.6444, 0.644, 0.6435, - 0.643, 0.6426, 0.6421, 0.6416, 0.6412, 0.6407, 0.6402, 0.6397, 0.6393, 0.6388, - 0.6383, 0.6379, 0.6374, 0.6369, 0.6365, 0.636, 0.6355, 0.6351, 0.6346, 0.6341, - 0.6336, 0.6332, 0.6327, 0.6322, 0.6318, 0.6313, 0.6308, 0.6303, 0.6299, 0.6294, - 0.6289, 0.6285, 0.628, 0.6275, 0.627, 0.6266, 0.6261, 0.6256, 0.6251, 0.6247, - 0.6242, 0.6237, 0.6232, 0.6228, 0.6223, 0.6218, 0.6213, 0.6208, 0.6204, 0.6199, - 0.6194, 0.6189, 0.6185, 0.618, 0.6175, 0.617, 0.6165, 0.6161, 0.6156, 0.6151, - 0.6146, 0.6142, 0.6137, 0.6132, 0.6127, 0.6122, 0.6117, 0.6113, 0.6108, 0.6103, - 0.6098, 0.6093, 0.6089, 0.6084, 0.6079, 0.6074, 0.6069, 0.6064, 0.606, 0.6055, - 0.605, 0.6045, 0.604, 0.6035, 0.603, 0.6026, 0.6021, 0.6016, 0.6011, 0.6006, - 0.6001, 0.5996, 0.5992, 0.5987, 0.5982, 0.5977, 0.5972, 0.5967, 0.5962, 0.5957, - 0.5952, 0.5948, 0.5943, 0.5938, 0.5933, 0.5928, 0.5923, 0.5918, 0.5913, 0.5908, - 0.5903, 0.5898, 0.5894, 0.5889, 0.5884, 0.5879, 0.5874, 0.5869, 0.5864, 0.5859, - 0.5854, 0.5849, 0.5844, 0.5839, 0.5834, 0.5829, 0.5824, 0.5819, 0.5814, 0.5809, - 0.5804, 0.5799, 0.5794, 0.5789, 0.5784, 0.5779, 0.5774, 0.5769, 0.5764, 0.5759, - 0.5754, 0.5749, 0.5744, 0.5739, 0.5734, 0.5729, 0.5724, 0.5719, 0.5714, 0.5709, - 0.5704, 0.5699, 0.5694, 0.5689, 0.5684, 0.5679, 0.5674, 0.5669, 0.5664, 0.5659, - 0.5654, 0.5649, 0.5644, 0.5639, 0.5633, 0.5628, 0.5623, 0.5618, 0.5613, 0.5608, - 0.5603, 0.5598, 0.5593, 0.5588, 0.5582, 0.5577, 0.5572, 0.5567, 0.5562, 0.5557, - 0.5552, 0.5547, 0.5541, 0.5536, 0.5531, 0.5526, 0.5521, 0.5516, 0.5511, 0.5505, - 0.55, 0.5495, 0.549, 0.5485, 0.548, 0.5474, 0.5469, 0.5464, 0.5459, 0.5454, - 0.5448, 0.5443, 0.5438, 0.5433, 0.5428, 0.5422, 0.5417, 0.5412, 0.5407, 0.5402, - 0.5396, 0.5391, 0.5386, 0.5381, 0.5375, 0.537, 0.5365, 0.536, 0.5354, 0.5349, - 0.5344, 0.5339, 0.5333, 0.5328, 0.5323, 0.5317, 0.5312, 0.5307, 0.5302, 0.5296, - 0.5291, 0.5286, 0.528, 0.5275, 0.527, 0.5264, 0.5259, 0.5254, 0.5248, 0.5243, - 0.5238, 0.5232, 0.5227, 0.5222, 0.5216, 0.5211, 0.5206, 0.52, 0.5195, 0.5189, - 0.5184, 0.5179, 0.5173, 0.5168, 0.5162, 0.5157, 0.5152, 0.5146, 0.5141, 0.5135, - 0.513, 0.5124, 0.5119, 0.5114, 0.5108, 0.5103, 0.5097, 0.5092, 0.5086, 0.5081, - 0.5075, 0.507, 0.5064, 0.5059, 0.5053, 0.5048, 0.5043, 0.5037, 0.5032, 0.5026, - 0.502, 0.5015, 0.5009, 0.5004, 0.4998, 0.4993, 0.4987, 0.4982, 0.4976, 0.4971, - 0.4965, 0.496, 0.4954, 0.4948, 0.4943, 0.4937, 0.4932, 0.4926, 0.492, 0.4915, - 0.4909, 0.4904, 0.4898, 0.4892, 0.4887, 0.4881, 0.4875, 0.487, 0.4864, 0.4859, - 0.4853, 0.4847, 0.4842, 0.4836, 0.483, 0.4825, 0.4819, 0.4813, 0.4807, 0.4802, - 0.4796, 0.479, 0.4785, 0.4779, 0.4773, 0.4767, 0.4762, 0.4756, 0.475, 0.4744, - 0.4739, 0.4733, 0.4727, 0.4721, 0.4716, 0.471, 0.4704, 0.4698, 0.4692, 0.4687, - 0.4681, 0.4675, 0.4669, 0.4663, 0.4657, 0.4652, 0.4646, 0.464, 0.4634, 0.4628, - 0.4622, 0.4616, 0.461, 0.4605, 0.4599, 0.4593, 0.4587, 0.4581, 0.4575, 0.4569, - 0.4563, 0.4557, 0.4551, 0.4545, 0.4539, 0.4533, 0.4527, 0.4521, 0.4515, 0.451, - 0.4504, 0.4498, 0.4491, 0.4485, 0.4479, 0.4473, 0.4467, 0.4461, 0.4455, 0.4449, - 0.4443, 0.4437, 0.4431, 0.4425, 0.4419, 0.4413, 0.4407, 0.4401, 0.4394, 0.4388, - 0.4382, 0.4376, 0.437, 0.4364, 0.4358, 0.4351, 0.4345, 0.4339, 0.4333, 0.4327, - 0.4321, 0.4314, 0.4308, 0.4302, 0.4296, 0.4289, 0.4283, 0.4277, 0.4271, 0.4264, - 0.4258, 0.4252, 0.4246, 0.4239, 0.4233, 0.4227, 0.422, 0.4214, 0.4208, 0.4201, - 0.4195, 0.4189, 0.4182, 0.4176, 0.4169, 0.4163, 0.4157, 0.415, 0.4144, 0.4137, - 0.4131, 0.4125, 0.4118, 0.4112, 0.4105, 0.4099, 0.4092, 0.4086, 0.4079, 0.4073, - 0.4066, 0.406, 0.4053, 0.4047, 0.404, 0.4034, 0.4027, 0.402, 0.4014, 0.4007, - 0.4001, 0.3994, 0.3987, 0.3981, 0.3974, 0.3967, 0.3961, 0.3954, 0.3947, 0.3941, - 0.3934, 0.3927, 0.3921, 0.3914, 0.3907, 0.39, 0.3894, 0.3887, 0.388, 0.3873, - 0.3866, 0.386, 0.3853, 0.3846, 0.3839, 0.3832, 0.3825, 0.3819, 0.3812, 0.3805, - 0.3798, 0.3791, 0.3784, 0.3777, 0.377, 0.3763, 0.3756, 0.3749, 0.3742, 0.3735, - 0.3728, 0.3721, 0.3714, 0.3707, 0.37, 0.3693, 0.3686, 0.3679, 0.3672, 0.3665, - 0.3657, 0.365, 0.3643, 0.3636, 0.3629, 0.3622, 0.3614, 0.3607, 0.36, 0.3593, - 0.3585, 0.3578, 0.3571, 0.3564, 0.3556, 0.3549, 0.3542, 0.3534, 0.3527, 0.352, - 0.3512, 0.3505, 0.3497, 0.349, 0.3483, 0.3475, 0.3468, 0.346, 0.3453, 0.3445, - 0.3438, 0.343, 0.3422, 0.3415, 0.3407, 0.34, 0.3392, 0.3384, 0.3377, 0.3369, - 0.3361, 0.3354, 0.3346, 0.3338, 0.3331, 0.3323, 0.3315, 0.3307, 0.3299, 0.3292, - 0.3284, 0.3276, 0.3268, 0.326, 0.3252, 0.3244, 0.3236, 0.3228, 0.3221, 0.3213, - 0.3205, 0.3196, 0.3188, 0.318, 0.3172, 0.3164, 0.3156, 0.3148, 0.314, 0.3132, - 0.3123, 0.3115, 0.3107, 0.3099, 0.309, 0.3082, 0.3074, 0.3065, 0.3057, 0.3049, - 0.304, 0.3032, 0.3023, 0.3015, 0.3007, 0.2998, 0.2989, 0.2981, 0.2972, 0.2964, - 0.2955, 0.2946, 0.2938, 0.2929, 0.292, 0.2912, 0.2903, 0.2894, 0.2885, 0.2877, - 0.2868, 0.2859, 0.285, 0.2841, 0.2832, 0.2823, 0.2814, 0.2805, 0.2796, 0.2787, - 0.2778, 0.2768, 0.2759, 0.275, 0.2741, 0.2732, 0.2722, 0.2713, 0.2704, 0.2694, - 0.2685, 0.2675, 0.2666, 0.2656, 0.2647, 0.2637, 0.2628, 0.2618, 0.2608, 0.2599, - 0.2589, 0.2579, 0.2569, 0.256, 0.255, 0.254, 0.253, 0.252, 0.251, 0.25, - 0.249, 0.248, 0.2469, 0.2459, 0.2449, 0.2439, 0.2428, 0.2418, 0.2408, 0.2397, - 0.2387, 0.2376, 0.2365, 0.2355, 0.2344, 0.2333, 0.2323, 0.2312, 0.2301, 0.229, - 0.2279, 0.2268, 0.2257, 0.2246, 0.2235, 0.2223, 0.2212, 0.2201, 0.2189, 0.2178, - 0.2166, 0.2155, 0.2143, 0.2132, 0.212, 0.2108, 0.2096, 0.2084, 0.2072, 0.206, - 0.2048, 0.2036, 0.2023, 0.2011, 0.1999, 0.1986, 0.1974, 0.1961, 0.1948, 0.1935, - 0.1923, 0.191, 0.1896, 0.1883, 0.187, 0.1857, 0.1843, 0.183, 0.1816, 0.1802, - 0.1789, 0.1775, 0.1761, 0.1747, 0.1732, 0.1718, 0.1703, 0.1689, 0.1674, 0.1659, - 0.1644, 0.1629, 0.1614, 0.1599, 0.1583, 0.1567, 0.1551, 0.1535, 0.1519, 0.1503, - 0.1486, 0.147, 0.1453, 0.1436, 0.1418, 0.1401, 0.1383, 0.1365, 0.1347, 0.1329, - 0.131, 0.1291, 0.1272, 0.1252, 0.1233, 0.1213, 0.1192, 0.1171, 0.115, 0.1129, - 0.1107, 0.1084, 0.1061, 0.1038, 0.1014, 0.09894, 0.09643, 0.09385, 0.0912, 0.08847, - 0.08566, 0.08275, 0.07974, 0.0766, 0.07334, 0.06992, 0.06633, 0.06253, 0.05849, 0.05415, - 0.04943, 0.0442, 0.03828, 0.03125, 0.0221, -0}; + 4.079f, 3.905f, 3.8f, 3.723f, 3.663f, 3.613f, 3.57f, 3.532f, 3.499f, 3.468f, + 3.441f, 3.416f, 3.392f, 3.37f, 3.35f, 3.33f, 3.312f, 3.295f, 3.278f, 3.263f, + 3.248f, 3.233f, 3.219f, 3.206f, 3.193f, 3.181f, 3.169f, 3.158f, 3.147f, 3.136f, + 3.125f, 3.115f, 3.105f, 3.096f, 3.086f, 3.077f, 3.068f, 3.059f, 3.051f, 3.043f, + 3.035f, 3.027f, 3.019f, 3.011f, 3.004f, 2.996f, 2.989f, 2.982f, 2.975f, 2.968f, + 2.962f, 2.955f, 2.949f, 2.942f, 2.936f, 2.93f, 2.924f, 2.918f, 2.912f, 2.906f, + 2.901f, 2.895f, 2.89f, 2.884f, 2.879f, 2.873f, 2.868f, 2.863f, 2.858f, 2.853f, + 2.848f, 2.843f, 2.838f, 2.833f, 2.829f, 2.824f, 2.819f, 2.815f, 2.81f, 2.806f, + 2.801f, 2.797f, 2.792f, 2.788f, 2.784f, 2.78f, 2.776f, 2.771f, 2.767f, 2.763f, + 2.759f, 2.755f, 2.751f, 2.748f, 2.744f, 2.74f, 2.736f, 2.732f, 2.729f, 2.725f, + 2.721f, 2.718f, 2.714f, 2.71f, 2.707f, 2.703f, 2.7f, 2.697f, 2.693f, 2.69f, + 2.686f, 2.683f, 2.68f, 2.676f, 2.673f, 2.67f, 2.667f, 2.663f, 2.66f, 2.657f, + 2.654f, 2.651f, 2.648f, 2.645f, 2.642f, 2.639f, 2.636f, 2.633f, 2.63f, 2.627f, + 2.624f, 2.621f, 2.618f, 2.615f, 2.612f, 2.61f, 2.607f, 2.604f, 2.601f, 2.599f, + 2.596f, 2.593f, 2.59f, 2.588f, 2.585f, 2.582f, 2.58f, 2.577f, 2.574f, 2.572f, + 2.569f, 2.567f, 2.564f, 2.562f, 2.559f, 2.557f, 2.554f, 2.552f, 2.549f, 2.547f, + 2.544f, 2.542f, 2.539f, 2.537f, 2.534f, 2.532f, 2.53f, 2.527f, 2.525f, 2.523f, + 2.52f, 2.518f, 2.516f, 2.513f, 2.511f, 2.509f, 2.507f, 2.504f, 2.502f, 2.5f, + 2.498f, 2.495f, 2.493f, 2.491f, 2.489f, 2.487f, 2.485f, 2.482f, 2.48f, 2.478f, + 2.476f, 2.474f, 2.472f, 2.47f, 2.468f, 2.466f, 2.464f, 2.462f, 2.459f, 2.457f, + 2.455f, 2.453f, 2.451f, 2.449f, 2.447f, 2.445f, 2.443f, 2.441f, 2.439f, 2.437f, + 2.436f, 2.434f, 2.432f, 2.43f, 2.428f, 2.426f, 2.424f, 2.422f, 2.42f, 2.418f, + 2.416f, 2.415f, 2.413f, 2.411f, 2.409f, 2.407f, 2.405f, 2.404f, 2.402f, 2.4f, + 2.398f, 2.396f, 2.394f, 2.393f, 2.391f, 2.389f, 2.387f, 2.386f, 2.384f, 2.382f, + 2.38f, 2.379f, 2.377f, 2.375f, 2.373f, 2.372f, 2.37f, 2.368f, 2.367f, 2.365f, + 2.363f, 2.361f, 2.36f, 2.358f, 2.356f, 2.355f, 2.353f, 2.352f, 2.35f, 2.348f, + 2.347f, 2.345f, 2.343f, 2.342f, 2.34f, 2.338f, 2.337f, 2.335f, 2.334f, 2.332f, + 2.331f, 2.329f, 2.327f, 2.326f, 2.324f, 2.323f, 2.321f, 2.32f, 2.318f, 2.316f, + 2.315f, 2.313f, 2.312f, 2.31f, 2.309f, 2.307f, 2.306f, 2.304f, 2.303f, 2.301f, + 2.3f, 2.298f, 2.297f, 2.295f, 2.294f, 2.292f, 2.291f, 2.289f, 2.288f, 2.286f, + 2.285f, 2.284f, 2.282f, 2.281f, 2.279f, 2.278f, 2.276f, 2.275f, 2.274f, 2.272f, + 2.271f, 2.269f, 2.268f, 2.266f, 2.265f, 2.264f, 2.262f, 2.261f, 2.259f, 2.258f, + 2.257f, 2.255f, 2.254f, 2.253f, 2.251f, 2.25f, 2.248f, 2.247f, 2.246f, 2.244f, + 2.243f, 2.242f, 2.24f, 2.239f, 2.238f, 2.236f, 2.235f, 2.234f, 2.232f, 2.231f, + 2.23f, 2.228f, 2.227f, 2.226f, 2.225f, 2.223f, 2.222f, 2.221f, 2.219f, 2.218f, + 2.217f, 2.215f, 2.214f, 2.213f, 2.212f, 2.21f, 2.209f, 2.208f, 2.207f, 2.205f, + 2.204f, 2.203f, 2.202f, 2.2f, 2.199f, 2.198f, 2.197f, 2.195f, 2.194f, 2.193f, + 2.192f, 2.19f, 2.189f, 2.188f, 2.187f, 2.185f, 2.184f, 2.183f, 2.182f, 2.181f, + 2.179f, 2.178f, 2.177f, 2.176f, 2.175f, 2.173f, 2.172f, 2.171f, 2.17f, 2.169f, + 2.168f, 2.166f, 2.165f, 2.164f, 2.163f, 2.162f, 2.16f, 2.159f, 2.158f, 2.157f, + 2.156f, 2.155f, 2.154f, 2.152f, 2.151f, 2.15f, 2.149f, 2.148f, 2.147f, 2.146f, + 2.144f, 2.143f, 2.142f, 2.141f, 2.14f, 2.139f, 2.138f, 2.136f, 2.135f, 2.134f, + 2.133f, 2.132f, 2.131f, 2.13f, 2.129f, 2.128f, 2.126f, 2.125f, 2.124f, 2.123f, + 2.122f, 2.121f, 2.12f, 2.119f, 2.118f, 2.117f, 2.116f, 2.114f, 2.113f, 2.112f, + 2.111f, 2.11f, 2.109f, 2.108f, 2.107f, 2.106f, 2.105f, 2.104f, 2.103f, 2.102f, + 2.101f, 2.1f, 2.099f, 2.097f, 2.096f, 2.095f, 2.094f, 2.093f, 2.092f, 2.091f, + 2.09f, 2.089f, 2.088f, 2.087f, 2.086f, 2.085f, 2.084f, 2.083f, 2.082f, 2.081f, + 2.08f, 2.079f, 2.078f, 2.077f, 2.076f, 2.075f, 2.074f, 2.073f, 2.072f, 2.071f, + 2.07f, 2.069f, 2.068f, 2.067f, 2.066f, 2.065f, 2.064f, 2.063f, 2.062f, 2.061f, + 2.06f, 2.059f, 2.058f, 2.057f, 2.056f, 2.055f, 2.054f, 2.053f, 2.052f, 2.051f, + 2.05f, 2.049f, 2.048f, 2.047f, 2.046f, 2.045f, 2.044f, 2.043f, 2.042f, 2.041f, + 2.04f, 2.039f, 2.038f, 2.037f, 2.036f, 2.036f, 2.035f, 2.034f, 2.033f, 2.032f, + 2.031f, 2.03f, 2.029f, 2.028f, 2.027f, 2.026f, 2.025f, 2.024f, 2.023f, 2.022f, + 2.021f, 2.02f, 2.02f, 2.019f, 2.018f, 2.017f, 2.016f, 2.015f, 2.014f, 2.013f, + 2.012f, 2.011f, 2.01f, 2.009f, 2.008f, 2.008f, 2.007f, 2.006f, 2.005f, 2.004f, + 2.003f, 2.002f, 2.001f, 2.0f, 1.999f, 1.998f, 1.998f, 1.997f, 1.996f, 1.995f, + 1.994f, 1.993f, 1.992f, 1.991f, 1.99f, 1.99f, 1.989f, 1.988f, 1.987f, 1.986f, + 1.985f, 1.984f, 1.983f, 1.982f, 1.982f, 1.981f, 1.98f, 1.979f, 1.978f, 1.977f, + 1.976f, 1.975f, 1.975f, 1.974f, 1.973f, 1.972f, 1.971f, 1.97f, 1.969f, 1.969f, + 1.968f, 1.967f, 1.966f, 1.965f, 1.964f, 1.963f, 1.963f, 1.962f, 1.961f, 1.96f, + 1.959f, 1.958f, 1.957f, 1.957f, 1.956f, 1.955f, 1.954f, 1.953f, 1.952f, 1.952f, + 1.951f, 1.95f, 1.949f, 1.948f, 1.947f, 1.947f, 1.946f, 1.945f, 1.944f, 1.943f, + 1.942f, 1.942f, 1.941f, 1.94f, 1.939f, 1.938f, 1.937f, 1.937f, 1.936f, 1.935f, + 1.934f, 1.933f, 1.933f, 1.932f, 1.931f, 1.93f, 1.929f, 1.928f, 1.928f, 1.927f, + 1.926f, 1.925f, 1.924f, 1.924f, 1.923f, 1.922f, 1.921f, 1.92f, 1.92f, 1.919f, + 1.918f, 1.917f, 1.916f, 1.916f, 1.915f, 1.914f, 1.913f, 1.912f, 1.912f, 1.911f, + 1.91f, 1.909f, 1.908f, 1.908f, 1.907f, 1.906f, 1.905f, 1.904f, 1.904f, 1.903f, + 1.902f, 1.901f, 1.901f, 1.9f, 1.899f, 1.898f, 1.897f, 1.897f, 1.896f, 1.895f, + 1.894f, 1.894f, 1.893f, 1.892f, 1.891f, 1.89f, 1.89f, 1.889f, 1.888f, 1.887f, + 1.887f, 1.886f, 1.885f, 1.884f, 1.884f, 1.883f, 1.882f, 1.881f, 1.88f, 1.88f, + 1.879f, 1.878f, 1.877f, 1.877f, 1.876f, 1.875f, 1.874f, 1.874f, 1.873f, 1.872f, + 1.871f, 1.871f, 1.87f, 1.869f, 1.868f, 1.868f, 1.867f, 1.866f, 1.865f, 1.865f, + 1.864f, 1.863f, 1.862f, 1.862f, 1.861f, 1.86f, 1.859f, 1.859f, 1.858f, 1.857f, + 1.857f, 1.856f, 1.855f, 1.854f, 1.854f, 1.853f, 1.852f, 1.851f, 1.851f, 1.85f, + 1.849f, 1.848f, 1.848f, 1.847f, 1.846f, 1.846f, 1.845f, 1.844f, 1.843f, 1.843f, + 1.842f, 1.841f, 1.84f, 1.84f, 1.839f, 1.838f, 1.838f, 1.837f, 1.836f, 1.835f, + 1.835f, 1.834f, 1.833f, 1.833f, 1.832f, 1.831f, 1.83f, 1.83f, 1.829f, 1.828f, + 1.828f, 1.827f, 1.826f, 1.825f, 1.825f, 1.824f, 1.823f, 1.823f, 1.822f, 1.821f, + 1.821f, 1.82f, 1.819f, 1.818f, 1.818f, 1.817f, 1.816f, 1.816f, 1.815f, 1.814f, + 1.814f, 1.813f, 1.812f, 1.811f, 1.811f, 1.81f, 1.809f, 1.809f, 1.808f, 1.807f, + 1.807f, 1.806f, 1.805f, 1.805f, 1.804f, 1.803f, 1.802f, 1.802f, 1.801f, 1.8f, + 1.8f, 1.799f, 1.798f, 1.798f, 1.797f, 1.796f, 1.796f, 1.795f, 1.794f, 1.794f, + 1.793f, 1.792f, 1.792f, 1.791f, 1.79f, 1.79f, 1.789f, 1.788f, 1.787f, 1.787f, + 1.786f, 1.785f, 1.785f, 1.784f, 1.783f, 1.783f, 1.782f, 1.781f, 1.781f, 1.78f, + 1.779f, 1.779f, 1.778f, 1.777f, 1.777f, 1.776f, 1.775f, 1.775f, 1.774f, 1.773f, + 1.773f, 1.772f, 1.771f, 1.771f, 1.77f, 1.769f, 1.769f, 1.768f, 1.767f, 1.767f, + 1.766f, 1.766f, 1.765f, 1.764f, 1.764f, 1.763f, 1.762f, 1.762f, 1.761f, 1.76f, + 1.76f, 1.759f, 1.758f, 1.758f, 1.757f, 1.756f, 1.756f, 1.755f, 1.754f, 1.754f, + 1.753f, 1.752f, 1.752f, 1.751f, 1.751f, 1.75f, 1.749f, 1.749f, 1.748f, 1.747f, + 1.747f, 1.746f, 1.745f, 1.745f, 1.744f, 1.743f, 1.743f, 1.742f, 1.742f, 1.741f, + 1.74f, 1.74f, 1.739f, 1.738f, 1.738f, 1.737f, 1.736f, 1.736f, 1.735f, 1.735f, + 1.734f, 1.733f, 1.733f, 1.732f, 1.731f, 1.731f, 1.73f, 1.729f, 1.729f, 1.728f, + 1.728f, 1.727f, 1.726f, 1.726f, 1.725f, 1.724f, 1.724f, 1.723f, 1.723f, 1.722f, + 1.721f, 1.721f, 1.72f, 1.719f, 1.719f, 1.718f, 1.718f, 1.717f, 1.716f, 1.716f, + 1.715f, 1.715f, 1.714f, 1.713f, 1.713f, 1.712f, 1.711f, 1.711f, 1.71f, 1.71f, + 1.709f, 1.708f, 1.708f, 1.707f, 1.706f, 1.706f, 1.705f, 1.705f, 1.704f, 1.703f, + 1.703f, 1.702f, 1.702f, 1.701f, 1.7f, 1.7f, 1.699f, 1.699f, 1.698f, 1.697f, + 1.697f, 1.696f, 1.696f, 1.695f, 1.694f, 1.694f, 1.693f, 1.692f, 1.692f, 1.691f, + 1.691f, 1.69f, 1.689f, 1.689f, 1.688f, 1.688f, 1.687f, 1.686f, 1.686f, 1.685f, + 1.685f, 1.684f, 1.683f, 1.683f, 1.682f, 1.682f, 1.681f, 1.68f, 1.68f, 1.679f, + 1.679f, 1.678f, 1.678f, 1.677f, 1.676f, 1.676f, 1.675f, 1.675f, 1.674f, 1.673f, + 1.673f, 1.672f, 1.672f, 1.671f, 1.67f, 1.67f, 1.669f, 1.669f, 1.668f, 1.667f, + 1.667f, 1.666f, 1.666f, 1.665f, 1.665f, 1.664f, 1.663f, 1.663f, 1.662f, 1.662f, + 1.661f, 1.66f, 1.66f, 1.659f, 1.659f, 1.658f, 1.658f, 1.657f, 1.656f, 1.656f, + 1.655f, 1.655f, 1.654f, 1.653f, 1.653f, 1.652f, 1.652f, 1.651f, 1.651f, 1.65f, + 1.649f, 1.649f, 1.648f, 1.648f, 1.647f, 1.647f, 1.646f, 1.645f, 1.645f, 1.644f, + 1.644f, 1.643f, 1.643f, 1.642f, 1.641f, 1.641f, 1.64f, 1.64f, 1.639f, 1.639f, + 1.638f, 1.637f, 1.637f, 1.636f, 1.636f, 1.635f, 1.635f, 1.634f, 1.633f, 1.633f, + 1.632f, 1.632f, 1.631f, 1.631f, 1.63f, 1.629f, 1.629f, 1.628f, 1.628f, 1.627f, + 1.627f, 1.626f, 1.625f, 1.625f, 1.624f, 1.624f, 1.623f, 1.623f, 1.622f, 1.622f, + 1.621f, 1.62f, 1.62f, 1.619f, 1.619f, 1.618f, 1.618f, 1.617f, 1.617f, 1.616f, + 1.615f, 1.615f, 1.614f, 1.614f, 1.613f, 1.613f, 1.612f, 1.612f, 1.611f, 1.61f, + 1.61f, 1.609f, 1.609f, 1.608f, 1.608f, 1.607f, 1.607f, 1.606f, 1.605f, 1.605f, + 1.604f, 1.604f, 1.603f, 1.603f, 1.602f, 1.602f, 1.601f, 1.6f, 1.6f, 1.599f, + 1.599f, 1.598f, 1.598f, 1.597f, 1.597f, 1.596f, 1.596f, 1.595f, 1.594f, 1.594f, + 1.593f, 1.593f, 1.592f, 1.592f, 1.591f, 1.591f, 1.59f, 1.59f, 1.589f, 1.588f, + 1.588f, 1.587f, 1.587f, 1.586f, 1.586f, 1.585f, 1.585f, 1.584f, 1.584f, 1.583f, + 1.582f, 1.582f, 1.581f, 1.581f, 1.58f, 1.58f, 1.579f, 1.579f, 1.578f, 1.578f, + 1.577f, 1.577f, 1.576f, 1.576f, 1.575f, 1.574f, 1.574f, 1.573f, 1.573f, 1.572f, + 1.572f, 1.571f, 1.571f, 1.57f, 1.57f, 1.569f, 1.569f, 1.568f, 1.567f, 1.567f, + 1.566f, 1.566f, 1.565f, 1.565f, 1.564f, 1.564f, 1.563f, 1.563f, 1.562f, 1.562f, + 1.561f, 1.561f, 1.56f, 1.56f, 1.559f, 1.558f, 1.558f, 1.557f, 1.557f, 1.556f, + 1.556f, 1.555f, 1.555f, 1.554f, 1.554f, 1.553f, 1.553f, 1.552f, 1.552f, 1.551f, + 1.551f, 1.55f, 1.55f, 1.549f, 1.549f, 1.548f, 1.547f, 1.547f, 1.546f, 1.546f, + 1.545f, 1.545f, 1.544f, 1.544f, 1.543f, 1.543f, 1.542f, 1.542f, 1.541f, 1.541f, + 1.54f, 1.54f, 1.539f, 1.539f, 1.538f, 1.538f, 1.537f, 1.537f, 1.536f, 1.536f, + 1.535f, 1.534f, 1.534f, 1.533f, 1.533f, 1.532f, 1.532f, 1.531f, 1.531f, 1.53f, + 1.53f, 1.529f, 1.529f, 1.528f, 1.528f, 1.527f, 1.527f, 1.526f, 1.526f, 1.525f, + 1.525f, 1.524f, 1.524f, 1.523f, 1.523f, 1.522f, 1.522f, 1.521f, 1.521f, 1.52f, + 1.52f, 1.519f, 1.519f, 1.518f, 1.518f, 1.517f, 1.517f, 1.516f, 1.516f, 1.515f, + 1.515f, 1.514f, 1.514f, 1.513f, 1.512f, 1.512f, 1.511f, 1.511f, 1.51f, 1.51f, + 1.509f, 1.509f, 1.508f, 1.508f, 1.507f, 1.507f, 1.506f, 1.506f, 1.505f, 1.505f, + 1.504f, 1.504f, 1.503f, 1.503f, 1.502f, 1.502f, 1.501f, 1.501f, 1.5f, 1.5f, + 1.499f, 1.499f, 1.498f, 1.498f, 1.497f, 1.497f, 1.496f, 1.496f, 1.495f, 1.495f, + 1.494f, 1.494f, 1.493f, 1.493f, 1.492f, 1.492f, 1.491f, 1.491f, 1.49f, 1.49f, + 1.489f, 1.489f, 1.488f, 1.488f, 1.487f, 1.487f, 1.486f, 1.486f, 1.485f, 1.485f, + 1.484f, 1.484f, 1.483f, 1.483f, 1.482f, 1.482f, 1.481f, 1.481f, 1.48f, 1.48f, + 1.48f, 1.479f, 1.479f, 1.478f, 1.478f, 1.477f, 1.477f, 1.476f, 1.476f, 1.475f, + 1.475f, 1.474f, 1.474f, 1.473f, 1.473f, 1.472f, 1.472f, 1.471f, 1.471f, 1.47f, + 1.47f, 1.469f, 1.469f, 1.468f, 1.468f, 1.467f, 1.467f, 1.466f, 1.466f, 1.465f, + 1.465f, 1.464f, 1.464f, 1.463f, 1.463f, 1.462f, 1.462f, 1.461f, 1.461f, 1.46f, + 1.46f, 1.459f, 1.459f, 1.458f, 1.458f, 1.458f, 1.457f, 1.457f, 1.456f, 1.456f, + 1.455f, 1.455f, 1.454f, 1.454f, 1.453f, 1.453f, 1.452f, 1.452f, 1.451f, 1.451f, + 1.45f, 1.45f, 1.449f, 1.449f, 1.448f, 1.448f, 1.447f, 1.447f, 1.446f, 1.446f, + 1.445f, 1.445f, 1.444f, 1.444f, 1.444f, 1.443f, 1.443f, 1.442f, 1.442f, 1.441f, + 1.441f, 1.44f, 1.44f, 1.439f, 1.439f, 1.438f, 1.438f, 1.437f, 1.437f, 1.436f, + 1.436f, 1.435f, 1.435f, 1.434f, 1.434f, 1.434f, 1.433f, 1.433f, 1.432f, 1.432f, + 1.431f, 1.431f, 1.43f, 1.43f, 1.429f, 1.429f, 1.428f, 1.428f, 1.427f, 1.427f, + 1.426f, 1.426f, 1.425f, 1.425f, 1.424f, 1.424f, 1.424f, 1.423f, 1.423f, 1.422f, + 1.422f, 1.421f, 1.421f, 1.42f, 1.42f, 1.419f, 1.419f, 1.418f, 1.418f, 1.417f, + 1.417f, 1.416f, 1.416f, 1.416f, 1.415f, 1.415f, 1.414f, 1.414f, 1.413f, 1.413f, + 1.412f, 1.412f, 1.411f, 1.411f, 1.41f, 1.41f, 1.409f, 1.409f, 1.409f, 1.408f, + 1.408f, 1.407f, 1.407f, 1.406f, 1.406f, 1.405f, 1.405f, 1.404f, 1.404f, 1.403f, + 1.403f, 1.402f, 1.402f, 1.402f, 1.401f, 1.401f, 1.4f, 1.4f, 1.399f, 1.399f, + 1.398f, 1.398f, 1.397f, 1.397f, 1.396f, 1.396f, 1.395f, 1.395f, 1.395f, 1.394f, + 1.394f, 1.393f, 1.393f, 1.392f, 1.392f, 1.391f, 1.391f, 1.39f, 1.39f, 1.389f, + 1.389f, 1.389f, 1.388f, 1.388f, 1.387f, 1.387f, 1.386f, 1.386f, 1.385f, 1.385f, + 1.384f, 1.384f, 1.383f, 1.383f, 1.383f, 1.382f, 1.382f, 1.381f, 1.381f, 1.38f, + 1.38f, 1.379f, 1.379f, 1.378f, 1.378f, 1.378f, 1.377f, 1.377f, 1.376f, 1.376f, + 1.375f, 1.375f, 1.374f, 1.374f, 1.373f, 1.373f, 1.373f, 1.372f, 1.372f, 1.371f, + 1.371f, 1.37f, 1.37f, 1.369f, 1.369f, 1.368f, 1.368f, 1.367f, 1.367f, 1.367f, + 1.366f, 1.366f, 1.365f, 1.365f, 1.364f, 1.364f, 1.363f, 1.363f, 1.362f, 1.362f, + 1.362f, 1.361f, 1.361f, 1.36f, 1.36f, 1.359f, 1.359f, 1.358f, 1.358f, 1.358f, + 1.357f, 1.357f, 1.356f, 1.356f, 1.355f, 1.355f, 1.354f, 1.354f, 1.353f, 1.353f, + 1.353f, 1.352f, 1.352f, 1.351f, 1.351f, 1.35f, 1.35f, 1.349f, 1.349f, 1.349f, + 1.348f, 1.348f, 1.347f, 1.347f, 1.346f, 1.346f, 1.345f, 1.345f, 1.344f, 1.344f, + 1.344f, 1.343f, 1.343f, 1.342f, 1.342f, 1.341f, 1.341f, 1.34f, 1.34f, 1.34f, + 1.339f, 1.339f, 1.338f, 1.338f, 1.337f, 1.337f, 1.336f, 1.336f, 1.336f, 1.335f, + 1.335f, 1.334f, 1.334f, 1.333f, 1.333f, 1.332f, 1.332f, 1.332f, 1.331f, 1.331f, + 1.33f, 1.33f, 1.329f, 1.329f, 1.328f, 1.328f, 1.328f, 1.327f, 1.327f, 1.326f, + 1.326f, 1.325f, 1.325f, 1.324f, 1.324f, 1.324f, 1.323f, 1.323f, 1.322f, 1.322f, + 1.321f, 1.321f, 1.32f, 1.32f, 1.32f, 1.319f, 1.319f, 1.318f, 1.318f, 1.317f, + 1.317f, 1.316f, 1.316f, 1.316f, 1.315f, 1.315f, 1.314f, 1.314f, 1.313f, 1.313f, + 1.312f, 1.312f, 1.312f, 1.311f, 1.311f, 1.31f, 1.31f, 1.309f, 1.309f, 1.309f, + 1.308f, 1.308f, 1.307f, 1.307f, 1.306f, 1.306f, 1.305f, 1.305f, 1.305f, 1.304f, + 1.304f, 1.303f, 1.303f, 1.302f, 1.302f, 1.302f, 1.301f, 1.301f, 1.3f, 1.3f, + 1.299f, 1.299f, 1.298f, 1.298f, 1.298f, 1.297f, 1.297f, 1.296f, 1.296f, 1.295f, + 1.295f, 1.295f, 1.294f, 1.294f, 1.293f, 1.293f, 1.292f, 1.292f, 1.291f, 1.291f, + 1.291f, 1.29f, 1.29f, 1.289f, 1.289f, 1.288f, 1.288f, 1.288f, 1.287f, 1.287f, + 1.286f, 1.286f, 1.285f, 1.285f, 1.285f, 1.284f, 1.284f, 1.283f, 1.283f, 1.282f, + 1.282f, 1.281f, 1.281f, 1.281f, 1.28f, 1.28f, 1.279f, 1.279f, 1.278f, 1.278f, + 1.278f, 1.277f, 1.277f, 1.276f, 1.276f, 1.275f, 1.275f, 1.275f, 1.274f, 1.274f, + 1.273f, 1.273f, 1.272f, 1.272f, 1.272f, 1.271f, 1.271f, 1.27f, 1.27f, 1.269f, + 1.269f, 1.269f, 1.268f, 1.268f, 1.267f, 1.267f, 1.266f, 1.266f, 1.266f, 1.265f, + 1.265f, 1.264f, 1.264f, 1.263f, 1.263f, 1.263f, 1.262f, 1.262f, 1.261f, 1.261f, + 1.26f, 1.26f, 1.26f, 1.259f, 1.259f, 1.258f, 1.258f, 1.257f, 1.257f, 1.257f, + 1.256f, 1.256f, 1.255f, 1.255f, 1.254f, 1.254f, 1.254f, 1.253f, 1.253f, 1.252f, + 1.252f, 1.251f, 1.251f, 1.251f, 1.25f, 1.25f, 1.249f, 1.249f, 1.248f, 1.248f, + 1.248f, 1.247f, 1.247f, 1.246f, 1.246f, 1.245f, 1.245f, 1.245f, 1.244f, 1.244f, + 1.243f, 1.243f, 1.242f, 1.242f, 1.242f, 1.241f, 1.241f, 1.24f, 1.24f, 1.239f, + 1.239f, 1.239f, 1.238f, 1.238f, 1.237f, 1.237f, 1.237f, 1.236f, 1.236f, 1.235f, + 1.235f, 1.234f, 1.234f, 1.234f, 1.233f, 1.233f, 1.232f, 1.232f, 1.231f, 1.231f, + 1.231f, 1.23f, 1.23f, 1.229f, 1.229f, 1.228f, 1.228f, 1.228f, 1.227f, 1.227f, + 1.226f, 1.226f, 1.226f, 1.225f, 1.225f, 1.224f, 1.224f, 1.223f, 1.223f, 1.223f, + 1.222f, 1.222f, 1.221f, 1.221f, 1.22f, 1.22f, 1.22f, 1.219f, 1.219f, 1.218f, + 1.218f, 1.218f, 1.217f, 1.217f, 1.216f, 1.216f, 1.215f, 1.215f, 1.215f, 1.214f, + 1.214f, 1.213f, 1.213f, 1.212f, 1.212f, 1.212f, 1.211f, 1.211f, 1.21f, 1.21f, + 1.21f, 1.209f, 1.209f, 1.208f, 1.208f, 1.207f, 1.207f, 1.207f, 1.206f, 1.206f, + 1.205f, 1.205f, 1.204f, 1.204f, 1.204f, 1.203f, 1.203f, 1.202f, 1.202f, 1.202f, + 1.201f, 1.201f, 1.2f, 1.2f, 1.199f, 1.199f, 1.199f, 1.198f, 1.198f, 1.197f, + 1.197f, 1.197f, 1.196f, 1.196f, 1.195f, 1.195f, 1.194f, 1.194f, 1.194f, 1.193f, + 1.193f, 1.192f, 1.192f, 1.192f, 1.191f, 1.191f, 1.19f, 1.19f, 1.189f, 1.189f, + 1.189f, 1.188f, 1.188f, 1.187f, 1.187f, 1.187f, 1.186f, 1.186f, 1.185f, 1.185f, + 1.184f, 1.184f, 1.184f, 1.183f, 1.183f, 1.182f, 1.182f, 1.182f, 1.181f, 1.181f, + 1.18f, 1.18f, 1.179f, 1.179f, 1.179f, 1.178f, 1.178f, 1.177f, 1.177f, 1.177f, + 1.176f, 1.176f, 1.175f, 1.175f, 1.175f, 1.174f, 1.174f, 1.173f, 1.173f, 1.172f, + 1.172f, 1.172f, 1.171f, 1.171f, 1.17f, 1.17f, 1.17f, 1.169f, 1.169f, 1.168f, + 1.168f, 1.167f, 1.167f, 1.167f, 1.166f, 1.166f, 1.165f, 1.165f, 1.165f, 1.164f, + 1.164f, 1.163f, 1.163f, 1.163f, 1.162f, 1.162f, 1.161f, 1.161f, 1.16f, 1.16f, + 1.16f, 1.159f, 1.159f, 1.158f, 1.158f, 1.158f, 1.157f, 1.157f, 1.156f, 1.156f, + 1.156f, 1.155f, 1.155f, 1.154f, 1.154f, 1.153f, 1.153f, 1.153f, 1.152f, 1.152f, + 1.151f, 1.151f, 1.151f, 1.15f, 1.15f, 1.149f, 1.149f, 1.149f, 1.148f, 1.148f, + 1.147f, 1.147f, 1.146f, 1.146f, 1.146f, 1.145f, 1.145f, 1.144f, 1.144f, 1.144f, + 1.143f, 1.143f, 1.142f, 1.142f, 1.142f, 1.141f, 1.141f, 1.14f, 1.14f, 1.139f, + 1.139f, 1.139f, 1.138f, 1.138f, 1.137f, 1.137f, 1.137f, 1.136f, 1.136f, 1.135f, + 1.135f, 1.135f, 1.134f, 1.134f, 1.133f, 1.133f, 1.133f, 1.132f, 1.132f, 1.131f, + 1.131f, 1.13f, 1.13f, 1.13f, 1.129f, 1.129f, 1.128f, 1.128f, 1.128f, 1.127f, + 1.127f, 1.126f, 1.126f, 1.126f, 1.125f, 1.125f, 1.124f, 1.124f, 1.124f, 1.123f, + 1.123f, 1.122f, 1.122f, 1.121f, 1.121f, 1.121f, 1.12f, 1.12f, 1.119f, 1.119f, + 1.119f, 1.118f, 1.118f, 1.117f, 1.117f, 1.117f, 1.116f, 1.116f, 1.115f, 1.115f, + 1.115f, 1.114f, 1.114f, 1.113f, 1.113f, 1.113f, 1.112f, 1.112f, 1.111f, 1.111f, + 1.11f, 1.11f, 1.11f, 1.109f, 1.109f, 1.108f, 1.108f, 1.108f, 1.107f, 1.107f, + 1.106f, 1.106f, 1.106f, 1.105f, 1.105f, 1.104f, 1.104f, 1.104f, 1.103f, 1.103f, + 1.102f, 1.102f, 1.102f, 1.101f, 1.101f, 1.1f, 1.1f, 1.099f, 1.099f, 1.099f, + 1.098f, 1.098f, 1.097f, 1.097f, 1.097f, 1.096f, 1.096f, 1.095f, 1.095f, 1.095f, + 1.094f, 1.094f, 1.093f, 1.093f, 1.093f, 1.092f, 1.092f, 1.091f, 1.091f, 1.091f, + 1.09f, 1.09f, 1.089f, 1.089f, 1.089f, 1.088f, 1.088f, 1.087f, 1.087f, 1.086f, + 1.086f, 1.086f, 1.085f, 1.085f, 1.084f, 1.084f, 1.084f, 1.083f, 1.083f, 1.082f, + 1.082f, 1.082f, 1.081f, 1.081f, 1.08f, 1.08f, 1.08f, 1.079f, 1.079f, 1.078f, + 1.078f, 1.078f, 1.077f, 1.077f, 1.076f, 1.076f, 1.076f, 1.075f, 1.075f, 1.074f, + 1.074f, 1.074f, 1.073f, 1.073f, 1.072f, 1.072f, 1.072f, 1.071f, 1.071f, 1.07f, + 1.07f, 1.069f, 1.069f, 1.069f, 1.068f, 1.068f, 1.067f, 1.067f, 1.067f, 1.066f, + 1.066f, 1.065f, 1.065f, 1.065f, 1.064f, 1.064f, 1.063f, 1.063f, 1.063f, 1.062f, + 1.062f, 1.061f, 1.061f, 1.061f, 1.06f, 1.06f, 1.059f, 1.059f, 1.059f, 1.058f, + 1.058f, 1.057f, 1.057f, 1.057f, 1.056f, 1.056f, 1.055f, 1.055f, 1.055f, 1.054f, + 1.054f, 1.053f, 1.053f, 1.053f, 1.052f, 1.052f, 1.051f, 1.051f, 1.05f, 1.05f, + 1.05f, 1.049f, 1.049f, 1.048f, 1.048f, 1.048f, 1.047f, 1.047f, 1.046f, 1.046f, + 1.046f, 1.045f, 1.045f, 1.044f, 1.044f, 1.044f, 1.043f, 1.043f, 1.042f, 1.042f, + 1.042f, 1.041f, 1.041f, 1.04f, 1.04f, 1.04f, 1.039f, 1.039f, 1.038f, 1.038f, + 1.038f, 1.037f, 1.037f, 1.036f, 1.036f, 1.036f, 1.035f, 1.035f, 1.034f, 1.034f, + 1.034f, 1.033f, 1.033f, 1.032f, 1.032f, 1.032f, 1.031f, 1.031f, 1.03f, 1.03f, + 1.03f, 1.029f, 1.029f, 1.028f, 1.028f, 1.028f, 1.027f, 1.027f, 1.026f, 1.026f, + 1.026f, 1.025f, 1.025f, 1.024f, 1.024f, 1.023f, 1.023f, 1.023f, 1.022f, 1.022f, + 1.021f, 1.021f, 1.021f, 1.02f, 1.02f, 1.019f, 1.019f, 1.019f, 1.018f, 1.018f, + 1.017f, 1.017f, 1.017f, 1.016f, 1.016f, 1.015f, 1.015f, 1.015f, 1.014f, 1.014f, + 1.013f, 1.013f, 1.013f, 1.012f, 1.012f, 1.011f, 1.011f, 1.011f, 1.01f, 1.01f, + 1.009f, 1.009f, 1.009f, 1.008f, 1.008f, 1.007f, 1.007f, 1.007f, 1.006f, 1.006f, + 1.005f, 1.005f, 1.005f, 1.004f, 1.004f, 1.003f, 1.003f, 1.003f, 1.002f, 1.002f, + 1.001f, 1.001f, 1.001f, 1.0f, 0.9997f, 0.9993f, 0.9989f, 0.9985f, 0.9981f, 0.9977f, + 0.9973f, 0.9969f, 0.9965f, 0.9961f, 0.9957f, 0.9953f, 0.9949f, 0.9945f, 0.9941f, 0.9937f, + 0.9933f, 0.9929f, 0.9925f, 0.9921f, 0.9917f, 0.9913f, 0.9909f, 0.9905f, 0.9901f, 0.9897f, + 0.9893f, 0.9889f, 0.9885f, 0.9881f, 0.9877f, 0.9873f, 0.9869f, 0.9865f, 0.9861f, 0.9856f, + 0.9852f, 0.9848f, 0.9844f, 0.984f, 0.9836f, 0.9832f, 0.9828f, 0.9824f, 0.982f, 0.9816f, + 0.9812f, 0.9808f, 0.9804f, 0.98f, 0.9796f, 0.9792f, 0.9788f, 0.9784f, 0.978f, 0.9776f, + 0.9772f, 0.9768f, 0.9764f, 0.976f, 0.9756f, 0.9752f, 0.9748f, 0.9744f, 0.974f, 0.9736f, + 0.9732f, 0.9728f, 0.9724f, 0.972f, 0.9716f, 0.9712f, 0.9707f, 0.9703f, 0.9699f, 0.9695f, + 0.9691f, 0.9687f, 0.9683f, 0.9679f, 0.9675f, 0.9671f, 0.9667f, 0.9663f, 0.9659f, 0.9655f, + 0.9651f, 0.9647f, 0.9643f, 0.9639f, 0.9635f, 0.9631f, 0.9627f, 0.9623f, 0.9619f, 0.9615f, + 0.9611f, 0.9607f, 0.9603f, 0.9599f, 0.9595f, 0.9591f, 0.9587f, 0.9583f, 0.9579f, 0.9574f, + 0.957f, 0.9566f, 0.9562f, 0.9558f, 0.9554f, 0.955f, 0.9546f, 0.9542f, 0.9538f, 0.9534f, + 0.953f, 0.9526f, 0.9522f, 0.9518f, 0.9514f, 0.951f, 0.9506f, 0.9502f, 0.9498f, 0.9494f, + 0.949f, 0.9486f, 0.9482f, 0.9478f, 0.9474f, 0.947f, 0.9466f, 0.9462f, 0.9457f, 0.9453f, + 0.9449f, 0.9445f, 0.9441f, 0.9437f, 0.9433f, 0.9429f, 0.9425f, 0.9421f, 0.9417f, 0.9413f, + 0.9409f, 0.9405f, 0.9401f, 0.9397f, 0.9393f, 0.9389f, 0.9385f, 0.9381f, 0.9377f, 0.9373f, + 0.9369f, 0.9365f, 0.9361f, 0.9356f, 0.9352f, 0.9348f, 0.9344f, 0.934f, 0.9336f, 0.9332f, + 0.9328f, 0.9324f, 0.932f, 0.9316f, 0.9312f, 0.9308f, 0.9304f, 0.93f, 0.9296f, 0.9292f, + 0.9288f, 0.9284f, 0.928f, 0.9276f, 0.9272f, 0.9267f, 0.9263f, 0.9259f, 0.9255f, 0.9251f, + 0.9247f, 0.9243f, 0.9239f, 0.9235f, 0.9231f, 0.9227f, 0.9223f, 0.9219f, 0.9215f, 0.9211f, + 0.9207f, 0.9203f, 0.9199f, 0.9195f, 0.9191f, 0.9186f, 0.9182f, 0.9178f, 0.9174f, 0.917f, + 0.9166f, 0.9162f, 0.9158f, 0.9154f, 0.915f, 0.9146f, 0.9142f, 0.9138f, 0.9134f, 0.913f, + 0.9126f, 0.9122f, 0.9118f, 0.9113f, 0.9109f, 0.9105f, 0.9101f, 0.9097f, 0.9093f, 0.9089f, + 0.9085f, 0.9081f, 0.9077f, 0.9073f, 0.9069f, 0.9065f, 0.9061f, 0.9057f, 0.9053f, 0.9049f, + 0.9044f, 0.904f, 0.9036f, 0.9032f, 0.9028f, 0.9024f, 0.902f, 0.9016f, 0.9012f, 0.9008f, + 0.9004f, 0.9f, 0.8996f, 0.8992f, 0.8988f, 0.8983f, 0.8979f, 0.8975f, 0.8971f, 0.8967f, + 0.8963f, 0.8959f, 0.8955f, 0.8951f, 0.8947f, 0.8943f, 0.8939f, 0.8935f, 0.8931f, 0.8926f, + 0.8922f, 0.8918f, 0.8914f, 0.891f, 0.8906f, 0.8902f, 0.8898f, 0.8894f, 0.889f, 0.8886f, + 0.8882f, 0.8878f, 0.8873f, 0.8869f, 0.8865f, 0.8861f, 0.8857f, 0.8853f, 0.8849f, 0.8845f, + 0.8841f, 0.8837f, 0.8833f, 0.8829f, 0.8825f, 0.882f, 0.8816f, 0.8812f, 0.8808f, 0.8804f, + 0.88f, 0.8796f, 0.8792f, 0.8788f, 0.8784f, 0.878f, 0.8775f, 0.8771f, 0.8767f, 0.8763f, + 0.8759f, 0.8755f, 0.8751f, 0.8747f, 0.8743f, 0.8739f, 0.8735f, 0.873f, 0.8726f, 0.8722f, + 0.8718f, 0.8714f, 0.871f, 0.8706f, 0.8702f, 0.8698f, 0.8694f, 0.869f, 0.8685f, 0.8681f, + 0.8677f, 0.8673f, 0.8669f, 0.8665f, 0.8661f, 0.8657f, 0.8653f, 0.8649f, 0.8644f, 0.864f, + 0.8636f, 0.8632f, 0.8628f, 0.8624f, 0.862f, 0.8616f, 0.8612f, 0.8607f, 0.8603f, 0.8599f, + 0.8595f, 0.8591f, 0.8587f, 0.8583f, 0.8579f, 0.8575f, 0.857f, 0.8566f, 0.8562f, 0.8558f, + 0.8554f, 0.855f, 0.8546f, 0.8542f, 0.8538f, 0.8533f, 0.8529f, 0.8525f, 0.8521f, 0.8517f, + 0.8513f, 0.8509f, 0.8505f, 0.85f, 0.8496f, 0.8492f, 0.8488f, 0.8484f, 0.848f, 0.8476f, + 0.8472f, 0.8467f, 0.8463f, 0.8459f, 0.8455f, 0.8451f, 0.8447f, 0.8443f, 0.8439f, 0.8434f, + 0.843f, 0.8426f, 0.8422f, 0.8418f, 0.8414f, 0.841f, 0.8406f, 0.8401f, 0.8397f, 0.8393f, + 0.8389f, 0.8385f, 0.8381f, 0.8377f, 0.8372f, 0.8368f, 0.8364f, 0.836f, 0.8356f, 0.8352f, + 0.8348f, 0.8343f, 0.8339f, 0.8335f, 0.8331f, 0.8327f, 0.8323f, 0.8319f, 0.8314f, 0.831f, + 0.8306f, 0.8302f, 0.8298f, 0.8294f, 0.8289f, 0.8285f, 0.8281f, 0.8277f, 0.8273f, 0.8269f, + 0.8265f, 0.826f, 0.8256f, 0.8252f, 0.8248f, 0.8244f, 0.824f, 0.8235f, 0.8231f, 0.8227f, + 0.8223f, 0.8219f, 0.8215f, 0.821f, 0.8206f, 0.8202f, 0.8198f, 0.8194f, 0.819f, 0.8185f, + 0.8181f, 0.8177f, 0.8173f, 0.8169f, 0.8165f, 0.816f, 0.8156f, 0.8152f, 0.8148f, 0.8144f, + 0.814f, 0.8135f, 0.8131f, 0.8127f, 0.8123f, 0.8119f, 0.8114f, 0.811f, 0.8106f, 0.8102f, + 0.8098f, 0.8094f, 0.8089f, 0.8085f, 0.8081f, 0.8077f, 0.8073f, 0.8068f, 0.8064f, 0.806f, + 0.8056f, 0.8052f, 0.8047f, 0.8043f, 0.8039f, 0.8035f, 0.8031f, 0.8026f, 0.8022f, 0.8018f, + 0.8014f, 0.801f, 0.8005f, 0.8001f, 0.7997f, 0.7993f, 0.7989f, 0.7984f, 0.798f, 0.7976f, + 0.7972f, 0.7968f, 0.7963f, 0.7959f, 0.7955f, 0.7951f, 0.7947f, 0.7942f, 0.7938f, 0.7934f, + 0.793f, 0.7926f, 0.7921f, 0.7917f, 0.7913f, 0.7909f, 0.7904f, 0.79f, 0.7896f, 0.7892f, + 0.7888f, 0.7883f, 0.7879f, 0.7875f, 0.7871f, 0.7866f, 0.7862f, 0.7858f, 0.7854f, 0.7849f, + 0.7845f, 0.7841f, 0.7837f, 0.7833f, 0.7828f, 0.7824f, 0.782f, 0.7816f, 0.7811f, 0.7807f, + 0.7803f, 0.7799f, 0.7794f, 0.779f, 0.7786f, 0.7782f, 0.7777f, 0.7773f, 0.7769f, 0.7765f, + 0.776f, 0.7756f, 0.7752f, 0.7748f, 0.7743f, 0.7739f, 0.7735f, 0.7731f, 0.7726f, 0.7722f, + 0.7718f, 0.7714f, 0.7709f, 0.7705f, 0.7701f, 0.7697f, 0.7692f, 0.7688f, 0.7684f, 0.7679f, + 0.7675f, 0.7671f, 0.7667f, 0.7662f, 0.7658f, 0.7654f, 0.765f, 0.7645f, 0.7641f, 0.7637f, + 0.7632f, 0.7628f, 0.7624f, 0.762f, 0.7615f, 0.7611f, 0.7607f, 0.7602f, 0.7598f, 0.7594f, + 0.759f, 0.7585f, 0.7581f, 0.7577f, 0.7572f, 0.7568f, 0.7564f, 0.756f, 0.7555f, 0.7551f, + 0.7547f, 0.7542f, 0.7538f, 0.7534f, 0.7529f, 0.7525f, 0.7521f, 0.7516f, 0.7512f, 0.7508f, + 0.7504f, 0.7499f, 0.7495f, 0.7491f, 0.7486f, 0.7482f, 0.7478f, 0.7473f, 0.7469f, 0.7465f, + 0.746f, 0.7456f, 0.7452f, 0.7447f, 0.7443f, 0.7439f, 0.7434f, 0.743f, 0.7426f, 0.7421f, + 0.7417f, 0.7413f, 0.7408f, 0.7404f, 0.74f, 0.7395f, 0.7391f, 0.7387f, 0.7382f, 0.7378f, + 0.7374f, 0.7369f, 0.7365f, 0.7361f, 0.7356f, 0.7352f, 0.7348f, 0.7343f, 0.7339f, 0.7335f, + 0.733f, 0.7326f, 0.7321f, 0.7317f, 0.7313f, 0.7308f, 0.7304f, 0.73f, 0.7295f, 0.7291f, + 0.7287f, 0.7282f, 0.7278f, 0.7273f, 0.7269f, 0.7265f, 0.726f, 0.7256f, 0.7252f, 0.7247f, + 0.7243f, 0.7238f, 0.7234f, 0.723f, 0.7225f, 0.7221f, 0.7216f, 0.7212f, 0.7208f, 0.7203f, + 0.7199f, 0.7195f, 0.719f, 0.7186f, 0.7181f, 0.7177f, 0.7173f, 0.7168f, 0.7164f, 0.7159f, + 0.7155f, 0.7151f, 0.7146f, 0.7142f, 0.7137f, 0.7133f, 0.7128f, 0.7124f, 0.712f, 0.7115f, + 0.7111f, 0.7106f, 0.7102f, 0.7098f, 0.7093f, 0.7089f, 0.7084f, 0.708f, 0.7075f, 0.7071f, + 0.7066f, 0.7062f, 0.7058f, 0.7053f, 0.7049f, 0.7044f, 0.704f, 0.7035f, 0.7031f, 0.7027f, + 0.7022f, 0.7018f, 0.7013f, 0.7009f, 0.7004f, 0.7f, 0.6995f, 0.6991f, 0.6986f, 0.6982f, + 0.6978f, 0.6973f, 0.6969f, 0.6964f, 0.696f, 0.6955f, 0.6951f, 0.6946f, 0.6942f, 0.6937f, + 0.6933f, 0.6928f, 0.6924f, 0.6919f, 0.6915f, 0.691f, 0.6906f, 0.6901f, 0.6897f, 0.6892f, + 0.6888f, 0.6883f, 0.6879f, 0.6874f, 0.687f, 0.6865f, 0.6861f, 0.6856f, 0.6852f, 0.6847f, + 0.6843f, 0.6838f, 0.6834f, 0.6829f, 0.6825f, 0.682f, 0.6816f, 0.6811f, 0.6807f, 0.6802f, + 0.6798f, 0.6793f, 0.6789f, 0.6784f, 0.678f, 0.6775f, 0.6771f, 0.6766f, 0.6762f, 0.6757f, + 0.6752f, 0.6748f, 0.6743f, 0.6739f, 0.6734f, 0.673f, 0.6725f, 0.6721f, 0.6716f, 0.6711f, + 0.6707f, 0.6702f, 0.6698f, 0.6693f, 0.6689f, 0.6684f, 0.668f, 0.6675f, 0.667f, 0.6666f, + 0.6661f, 0.6657f, 0.6652f, 0.6648f, 0.6643f, 0.6638f, 0.6634f, 0.6629f, 0.6625f, 0.662f, + 0.6615f, 0.6611f, 0.6606f, 0.6602f, 0.6597f, 0.6592f, 0.6588f, 0.6583f, 0.6579f, 0.6574f, + 0.6569f, 0.6565f, 0.656f, 0.6556f, 0.6551f, 0.6546f, 0.6542f, 0.6537f, 0.6532f, 0.6528f, + 0.6523f, 0.6519f, 0.6514f, 0.6509f, 0.6505f, 0.65f, 0.6495f, 0.6491f, 0.6486f, 0.6481f, + 0.6477f, 0.6472f, 0.6468f, 0.6463f, 0.6458f, 0.6454f, 0.6449f, 0.6444f, 0.644f, 0.6435f, + 0.643f, 0.6426f, 0.6421f, 0.6416f, 0.6412f, 0.6407f, 0.6402f, 0.6397f, 0.6393f, 0.6388f, + 0.6383f, 0.6379f, 0.6374f, 0.6369f, 0.6365f, 0.636f, 0.6355f, 0.6351f, 0.6346f, 0.6341f, + 0.6336f, 0.6332f, 0.6327f, 0.6322f, 0.6318f, 0.6313f, 0.6308f, 0.6303f, 0.6299f, 0.6294f, + 0.6289f, 0.6285f, 0.628f, 0.6275f, 0.627f, 0.6266f, 0.6261f, 0.6256f, 0.6251f, 0.6247f, + 0.6242f, 0.6237f, 0.6232f, 0.6228f, 0.6223f, 0.6218f, 0.6213f, 0.6208f, 0.6204f, 0.6199f, + 0.6194f, 0.6189f, 0.6185f, 0.618f, 0.6175f, 0.617f, 0.6165f, 0.6161f, 0.6156f, 0.6151f, + 0.6146f, 0.6142f, 0.6137f, 0.6132f, 0.6127f, 0.6122f, 0.6117f, 0.6113f, 0.6108f, 0.6103f, + 0.6098f, 0.6093f, 0.6089f, 0.6084f, 0.6079f, 0.6074f, 0.6069f, 0.6064f, 0.606f, 0.6055f, + 0.605f, 0.6045f, 0.604f, 0.6035f, 0.603f, 0.6026f, 0.6021f, 0.6016f, 0.6011f, 0.6006f, + 0.6001f, 0.5996f, 0.5992f, 0.5987f, 0.5982f, 0.5977f, 0.5972f, 0.5967f, 0.5962f, 0.5957f, + 0.5952f, 0.5948f, 0.5943f, 0.5938f, 0.5933f, 0.5928f, 0.5923f, 0.5918f, 0.5913f, 0.5908f, + 0.5903f, 0.5898f, 0.5894f, 0.5889f, 0.5884f, 0.5879f, 0.5874f, 0.5869f, 0.5864f, 0.5859f, + 0.5854f, 0.5849f, 0.5844f, 0.5839f, 0.5834f, 0.5829f, 0.5824f, 0.5819f, 0.5814f, 0.5809f, + 0.5804f, 0.5799f, 0.5794f, 0.5789f, 0.5784f, 0.5779f, 0.5774f, 0.5769f, 0.5764f, 0.5759f, + 0.5754f, 0.5749f, 0.5744f, 0.5739f, 0.5734f, 0.5729f, 0.5724f, 0.5719f, 0.5714f, 0.5709f, + 0.5704f, 0.5699f, 0.5694f, 0.5689f, 0.5684f, 0.5679f, 0.5674f, 0.5669f, 0.5664f, 0.5659f, + 0.5654f, 0.5649f, 0.5644f, 0.5639f, 0.5633f, 0.5628f, 0.5623f, 0.5618f, 0.5613f, 0.5608f, + 0.5603f, 0.5598f, 0.5593f, 0.5588f, 0.5582f, 0.5577f, 0.5572f, 0.5567f, 0.5562f, 0.5557f, + 0.5552f, 0.5547f, 0.5541f, 0.5536f, 0.5531f, 0.5526f, 0.5521f, 0.5516f, 0.5511f, 0.5505f, + 0.55f, 0.5495f, 0.549f, 0.5485f, 0.548f, 0.5474f, 0.5469f, 0.5464f, 0.5459f, 0.5454f, + 0.5448f, 0.5443f, 0.5438f, 0.5433f, 0.5428f, 0.5422f, 0.5417f, 0.5412f, 0.5407f, 0.5402f, + 0.5396f, 0.5391f, 0.5386f, 0.5381f, 0.5375f, 0.537f, 0.5365f, 0.536f, 0.5354f, 0.5349f, + 0.5344f, 0.5339f, 0.5333f, 0.5328f, 0.5323f, 0.5317f, 0.5312f, 0.5307f, 0.5302f, 0.5296f, + 0.5291f, 0.5286f, 0.528f, 0.5275f, 0.527f, 0.5264f, 0.5259f, 0.5254f, 0.5248f, 0.5243f, + 0.5238f, 0.5232f, 0.5227f, 0.5222f, 0.5216f, 0.5211f, 0.5206f, 0.52f, 0.5195f, 0.5189f, + 0.5184f, 0.5179f, 0.5173f, 0.5168f, 0.5162f, 0.5157f, 0.5152f, 0.5146f, 0.5141f, 0.5135f, + 0.513f, 0.5124f, 0.5119f, 0.5114f, 0.5108f, 0.5103f, 0.5097f, 0.5092f, 0.5086f, 0.5081f, + 0.5075f, 0.507f, 0.5064f, 0.5059f, 0.5053f, 0.5048f, 0.5043f, 0.5037f, 0.5032f, 0.5026f, + 0.502f, 0.5015f, 0.5009f, 0.5004f, 0.4998f, 0.4993f, 0.4987f, 0.4982f, 0.4976f, 0.4971f, + 0.4965f, 0.496f, 0.4954f, 0.4948f, 0.4943f, 0.4937f, 0.4932f, 0.4926f, 0.492f, 0.4915f, + 0.4909f, 0.4904f, 0.4898f, 0.4892f, 0.4887f, 0.4881f, 0.4875f, 0.487f, 0.4864f, 0.4859f, + 0.4853f, 0.4847f, 0.4842f, 0.4836f, 0.483f, 0.4825f, 0.4819f, 0.4813f, 0.4807f, 0.4802f, + 0.4796f, 0.479f, 0.4785f, 0.4779f, 0.4773f, 0.4767f, 0.4762f, 0.4756f, 0.475f, 0.4744f, + 0.4739f, 0.4733f, 0.4727f, 0.4721f, 0.4716f, 0.471f, 0.4704f, 0.4698f, 0.4692f, 0.4687f, + 0.4681f, 0.4675f, 0.4669f, 0.4663f, 0.4657f, 0.4652f, 0.4646f, 0.464f, 0.4634f, 0.4628f, + 0.4622f, 0.4616f, 0.461f, 0.4605f, 0.4599f, 0.4593f, 0.4587f, 0.4581f, 0.4575f, 0.4569f, + 0.4563f, 0.4557f, 0.4551f, 0.4545f, 0.4539f, 0.4533f, 0.4527f, 0.4521f, 0.4515f, 0.451f, + 0.4504f, 0.4498f, 0.4491f, 0.4485f, 0.4479f, 0.4473f, 0.4467f, 0.4461f, 0.4455f, 0.4449f, + 0.4443f, 0.4437f, 0.4431f, 0.4425f, 0.4419f, 0.4413f, 0.4407f, 0.4401f, 0.4394f, 0.4388f, + 0.4382f, 0.4376f, 0.437f, 0.4364f, 0.4358f, 0.4351f, 0.4345f, 0.4339f, 0.4333f, 0.4327f, + 0.4321f, 0.4314f, 0.4308f, 0.4302f, 0.4296f, 0.4289f, 0.4283f, 0.4277f, 0.4271f, 0.4264f, + 0.4258f, 0.4252f, 0.4246f, 0.4239f, 0.4233f, 0.4227f, 0.422f, 0.4214f, 0.4208f, 0.4201f, + 0.4195f, 0.4189f, 0.4182f, 0.4176f, 0.4169f, 0.4163f, 0.4157f, 0.415f, 0.4144f, 0.4137f, + 0.4131f, 0.4125f, 0.4118f, 0.4112f, 0.4105f, 0.4099f, 0.4092f, 0.4086f, 0.4079f, 0.4073f, + 0.4066f, 0.406f, 0.4053f, 0.4047f, 0.404f, 0.4034f, 0.4027f, 0.402f, 0.4014f, 0.4007f, + 0.4001f, 0.3994f, 0.3987f, 0.3981f, 0.3974f, 0.3967f, 0.3961f, 0.3954f, 0.3947f, 0.3941f, + 0.3934f, 0.3927f, 0.3921f, 0.3914f, 0.3907f, 0.39f, 0.3894f, 0.3887f, 0.388f, 0.3873f, + 0.3866f, 0.386f, 0.3853f, 0.3846f, 0.3839f, 0.3832f, 0.3825f, 0.3819f, 0.3812f, 0.3805f, + 0.3798f, 0.3791f, 0.3784f, 0.3777f, 0.377f, 0.3763f, 0.3756f, 0.3749f, 0.3742f, 0.3735f, + 0.3728f, 0.3721f, 0.3714f, 0.3707f, 0.37f, 0.3693f, 0.3686f, 0.3679f, 0.3672f, 0.3665f, + 0.3657f, 0.365f, 0.3643f, 0.3636f, 0.3629f, 0.3622f, 0.3614f, 0.3607f, 0.36f, 0.3593f, + 0.3585f, 0.3578f, 0.3571f, 0.3564f, 0.3556f, 0.3549f, 0.3542f, 0.3534f, 0.3527f, 0.352f, + 0.3512f, 0.3505f, 0.3497f, 0.349f, 0.3483f, 0.3475f, 0.3468f, 0.346f, 0.3453f, 0.3445f, + 0.3438f, 0.343f, 0.3422f, 0.3415f, 0.3407f, 0.34f, 0.3392f, 0.3384f, 0.3377f, 0.3369f, + 0.3361f, 0.3354f, 0.3346f, 0.3338f, 0.3331f, 0.3323f, 0.3315f, 0.3307f, 0.3299f, 0.3292f, + 0.3284f, 0.3276f, 0.3268f, 0.326f, 0.3252f, 0.3244f, 0.3236f, 0.3228f, 0.3221f, 0.3213f, + 0.3205f, 0.3196f, 0.3188f, 0.318f, 0.3172f, 0.3164f, 0.3156f, 0.3148f, 0.314f, 0.3132f, + 0.3123f, 0.3115f, 0.3107f, 0.3099f, 0.309f, 0.3082f, 0.3074f, 0.3065f, 0.3057f, 0.3049f, + 0.304f, 0.3032f, 0.3023f, 0.3015f, 0.3007f, 0.2998f, 0.2989f, 0.2981f, 0.2972f, 0.2964f, + 0.2955f, 0.2946f, 0.2938f, 0.2929f, 0.292f, 0.2912f, 0.2903f, 0.2894f, 0.2885f, 0.2877f, + 0.2868f, 0.2859f, 0.285f, 0.2841f, 0.2832f, 0.2823f, 0.2814f, 0.2805f, 0.2796f, 0.2787f, + 0.2778f, 0.2768f, 0.2759f, 0.275f, 0.2741f, 0.2732f, 0.2722f, 0.2713f, 0.2704f, 0.2694f, + 0.2685f, 0.2675f, 0.2666f, 0.2656f, 0.2647f, 0.2637f, 0.2628f, 0.2618f, 0.2608f, 0.2599f, + 0.2589f, 0.2579f, 0.2569f, 0.256f, 0.255f, 0.254f, 0.253f, 0.252f, 0.251f, 0.25f, + 0.249f, 0.248f, 0.2469f, 0.2459f, 0.2449f, 0.2439f, 0.2428f, 0.2418f, 0.2408f, 0.2397f, + 0.2387f, 0.2376f, 0.2365f, 0.2355f, 0.2344f, 0.2333f, 0.2323f, 0.2312f, 0.2301f, 0.229f, + 0.2279f, 0.2268f, 0.2257f, 0.2246f, 0.2235f, 0.2223f, 0.2212f, 0.2201f, 0.2189f, 0.2178f, + 0.2166f, 0.2155f, 0.2143f, 0.2132f, 0.212f, 0.2108f, 0.2096f, 0.2084f, 0.2072f, 0.206f, + 0.2048f, 0.2036f, 0.2023f, 0.2011f, 0.1999f, 0.1986f, 0.1974f, 0.1961f, 0.1948f, 0.1935f, + 0.1923f, 0.191f, 0.1896f, 0.1883f, 0.187f, 0.1857f, 0.1843f, 0.183f, 0.1816f, 0.1802f, + 0.1789f, 0.1775f, 0.1761f, 0.1747f, 0.1732f, 0.1718f, 0.1703f, 0.1689f, 0.1674f, 0.1659f, + 0.1644f, 0.1629f, 0.1614f, 0.1599f, 0.1583f, 0.1567f, 0.1551f, 0.1535f, 0.1519f, 0.1503f, + 0.1486f, 0.147f, 0.1453f, 0.1436f, 0.1418f, 0.1401f, 0.1383f, 0.1365f, 0.1347f, 0.1329f, + 0.131f, 0.1291f, 0.1272f, 0.1252f, 0.1233f, 0.1213f, 0.1192f, 0.1171f, 0.115f, 0.1129f, + 0.1107f, 0.1084f, 0.1061f, 0.1038f, 0.1014f, 0.09894f, 0.09643f, 0.09385f, 0.0912f, 0.08847f, + 0.08566f, 0.08275f, 0.07974f, 0.0766f, 0.07334f, 0.06992f, 0.06633f, 0.06253f, 0.05849f, 0.05415f, + 0.04943f, 0.0442f, 0.03828f, 0.03125f, 0.0221f, -0.0f}; + + const static float cosvals[max] = { + 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.9999f, 0.9999f, 0.9999f, 0.9999f, + 0.9999f, 0.9998f, 0.9998f, 0.9998f, 0.9997f, 0.9997f, 0.9997f, 0.9996f, 0.9996f, 0.9995f, + 0.9995f, 0.9994f, 0.9994f, 0.9993f, 0.9993f, 0.9992f, 0.9991f, 0.9991f, 0.999f, 0.9989f, + 0.9989f, 0.9988f, 0.9987f, 0.9986f, 0.9986f, 0.9985f, 0.9984f, 0.9983f, 0.9982f, 0.9981f, + 0.998f, 0.9979f, 0.9978f, 0.9977f, 0.9976f, 0.9975f, 0.9974f, 0.9973f, 0.9972f, 0.9971f, + 0.9969f, 0.9968f, 0.9967f, 0.9966f, 0.9964f, 0.9963f, 0.9962f, 0.996f, 0.9959f, 0.9958f, + 0.9956f, 0.9955f, 0.9953f, 0.9952f, 0.995f, 0.9949f, 0.9947f, 0.9946f, 0.9944f, 0.9942f, + 0.9941f, 0.9939f, 0.9937f, 0.9936f, 0.9934f, 0.9932f, 0.993f, 0.9929f, 0.9927f, 0.9925f, + 0.9923f, 0.9921f, 0.9919f, 0.9917f, 0.9915f, 0.9913f, 0.9911f, 0.9909f, 0.9907f, 0.9905f, + 0.9903f, 0.9901f, 0.9898f, 0.9896f, 0.9894f, 0.9892f, 0.989f, 0.9887f, 0.9885f, 0.9883f, + 0.988f, 0.9878f, 0.9875f, 0.9873f, 0.9871f, 0.9868f, 0.9866f, 0.9863f, 0.9861f, 0.9858f, + 0.9855f, 0.9853f, 0.985f, 0.9847f, 0.9845f, 0.9842f, 0.9839f, 0.9837f, 0.9834f, 0.9831f, + 0.9828f, 0.9825f, 0.9823f, 0.982f, 0.9817f, 0.9814f, 0.9811f, 0.9808f, 0.9805f, 0.9802f, + 0.9799f, 0.9796f, 0.9793f, 0.9789f, 0.9786f, 0.9783f, 0.978f, 0.9777f, 0.9774f, 0.977f, + 0.9767f, 0.9764f, 0.976f, 0.9757f, 0.9754f, 0.975f, 0.9747f, 0.9743f, 0.974f, 0.9736f, + 0.9733f, 0.9729f, 0.9726f, 0.9722f, 0.9719f, 0.9715f, 0.9711f, 0.9708f, 0.9704f, 0.97f, + 0.9697f, 0.9693f, 0.9689f, 0.9685f, 0.9681f, 0.9678f, 0.9674f, 0.967f, 0.9666f, 0.9662f, + 0.9658f, 0.9654f, 0.965f, 0.9646f, 0.9642f, 0.9638f, 0.9634f, 0.963f, 0.9625f, 0.9621f, + 0.9617f, 0.9613f, 0.9609f, 0.9604f, 0.96f, 0.9596f, 0.9591f, 0.9587f, 0.9583f, 0.9578f, + 0.9574f, 0.9569f, 0.9565f, 0.956f, 0.9556f, 0.9551f, 0.9547f, 0.9542f, 0.9538f, 0.9533f, + 0.9528f, 0.9524f, 0.9519f, 0.9514f, 0.951f, 0.9505f, 0.95f, 0.9495f, 0.949f, 0.9486f, + 0.9481f, 0.9476f, 0.9471f, 0.9466f, 0.9461f, 0.9456f, 0.9451f, 0.9446f, 0.9441f, 0.9436f, + 0.9431f, 0.9426f, 0.9421f, 0.9415f, 0.941f, 0.9405f, 0.94f, 0.9395f, 0.9389f, 0.9384f, + 0.9379f, 0.9373f, 0.9368f, 0.9363f, 0.9357f, 0.9352f, 0.9346f, 0.9341f, 0.9335f, 0.933f, + 0.9324f, 0.9319f, 0.9313f, 0.9308f, 0.9302f, 0.9296f, 0.9291f, 0.9285f, 0.9279f, 0.9274f, + 0.9268f, 0.9262f, 0.9256f, 0.925f, 0.9245f, 0.9239f, 0.9233f, 0.9227f, 0.9221f, 0.9215f, + 0.9209f, 0.9203f, 0.9197f, 0.9191f, 0.9185f, 0.9179f, 0.9173f, 0.9167f, 0.9161f, 0.9154f, + 0.9148f, 0.9142f, 0.9136f, 0.913f, 0.9123f, 0.9117f, 0.9111f, 0.9104f, 0.9098f, 0.9092f, + 0.9085f, 0.9079f, 0.9072f, 0.9066f, 0.9059f, 0.9053f, 0.9046f, 0.904f, 0.9033f, 0.9027f, + 0.902f, 0.9013f, 0.9007f, 0.9f, 0.8993f, 0.8987f, 0.898f, 0.8973f, 0.8966f, 0.896f, + 0.8953f, 0.8946f, 0.8939f, 0.8932f, 0.8925f, 0.8918f, 0.8911f, 0.8904f, 0.8897f, 0.889f, + 0.8883f, 0.8876f, 0.8869f, 0.8862f, 0.8855f, 0.8848f, 0.8841f, 0.8834f, 0.8826f, 0.8819f, + 0.8812f, 0.8805f, 0.8797f, 0.879f, 0.8783f, 0.8775f, 0.8768f, 0.8761f, 0.8753f, 0.8746f, + 0.8738f, 0.8731f, 0.8723f, 0.8716f, 0.8708f, 0.8701f, 0.8693f, 0.8686f, 0.8678f, 0.867f, + 0.8663f, 0.8655f, 0.8647f, 0.864f, 0.8632f, 0.8624f, 0.8616f, 0.8609f, 0.8601f, 0.8593f, + 0.8585f, 0.8577f, 0.8569f, 0.8561f, 0.8554f, 0.8546f, 0.8538f, 0.853f, 0.8522f, 0.8514f, + 0.8505f, 0.8497f, 0.8489f, 0.8481f, 0.8473f, 0.8465f, 0.8457f, 0.8449f, 0.844f, 0.8432f, + 0.8424f, 0.8416f, 0.8407f, 0.8399f, 0.8391f, 0.8382f, 0.8374f, 0.8365f, 0.8357f, 0.8349f, + 0.834f, 0.8332f, 0.8323f, 0.8315f, 0.8306f, 0.8298f, 0.8289f, 0.828f, 0.8272f, 0.8263f, + 0.8255f, 0.8246f, 0.8237f, 0.8228f, 0.822f, 0.8211f, 0.8202f, 0.8193f, 0.8185f, 0.8176f, + 0.8167f, 0.8158f, 0.8149f, 0.814f, 0.8131f, 0.8123f, 0.8114f, 0.8105f, 0.8096f, 0.8087f, + 0.8078f, 0.8068f, 0.8059f, 0.805f, 0.8041f, 0.8032f, 0.8023f, 0.8014f, 0.8005f, 0.7995f, + 0.7986f, 0.7977f, 0.7968f, 0.7958f, 0.7949f, 0.794f, 0.793f, 0.7921f, 0.7912f, 0.7902f, + 0.7893f, 0.7883f, 0.7874f, 0.7865f, 0.7855f, 0.7846f, 0.7836f, 0.7827f, 0.7817f, 0.7807f, + 0.7798f, 0.7788f, 0.7779f, 0.7769f, 0.7759f, 0.775f, 0.774f, 0.773f, 0.772f, 0.7711f, + 0.7701f, 0.7691f, 0.7681f, 0.7671f, 0.7662f, 0.7652f, 0.7642f, 0.7632f, 0.7622f, 0.7612f, + 0.7602f, 0.7592f, 0.7582f, 0.7572f, 0.7562f, 0.7552f, 0.7542f, 0.7532f, 0.7522f, 0.7512f, + 0.7502f, 0.7491f, 0.7481f, 0.7471f, 0.7461f, 0.7451f, 0.744f, 0.743f, 0.742f, 0.741f, + 0.7399f, 0.7389f, 0.7379f, 0.7368f, 0.7358f, 0.7347f, 0.7337f, 0.7327f, 0.7316f, 0.7306f, + 0.7295f, 0.7285f, 0.7274f, 0.7264f, 0.7253f, 0.7242f, 0.7232f, 0.7221f, 0.7211f, 0.72f, + 0.7189f, 0.7179f, 0.7168f, 0.7157f, 0.7147f, 0.7136f, 0.7125f, 0.7114f, 0.7104f, 0.7093f, + 0.7082f, 0.7071f, 0.706f, 0.7049f, 0.7038f, 0.7028f, 0.7017f, 0.7006f, 0.6995f, 0.6984f, + 0.6973f, 0.6962f, 0.6951f, 0.694f, 0.6929f, 0.6918f, 0.6907f, 0.6895f, 0.6884f, 0.6873f, + 0.6862f, 0.6851f, 0.684f, 0.6828f, 0.6817f, 0.6806f, 0.6795f, 0.6784f, 0.6772f, 0.6761f, + 0.675f, 0.6738f, 0.6727f, 0.6716f, 0.6704f, 0.6693f, 0.6681f, 0.667f, 0.6659f, 0.6647f, + 0.6636f, 0.6624f, 0.6613f, 0.6601f, 0.659f, 0.6578f, 0.6567f, 0.6555f, 0.6543f, 0.6532f, + 0.652f, 0.6508f, 0.6497f, 0.6485f, 0.6473f, 0.6462f, 0.645f, 0.6438f, 0.6427f, 0.6415f, + 0.6403f, 0.6391f, 0.6379f, 0.6368f, 0.6356f, 0.6344f, 0.6332f, 0.632f, 0.6308f, 0.6296f, + 0.6284f, 0.6273f, 0.6261f, 0.6249f, 0.6237f, 0.6225f, 0.6213f, 0.6201f, 0.6189f, 0.6176f, + 0.6164f, 0.6152f, 0.614f, 0.6128f, 0.6116f, 0.6104f, 0.6092f, 0.6079f, 0.6067f, 0.6055f, + 0.6043f, 0.6031f, 0.6018f, 0.6006f, 0.5994f, 0.5982f, 0.5969f, 0.5957f, 0.5945f, 0.5932f, + 0.592f, 0.5908f, 0.5895f, 0.5883f, 0.587f, 0.5858f, 0.5846f, 0.5833f, 0.5821f, 0.5808f, + 0.5796f, 0.5783f, 0.5771f, 0.5758f, 0.5746f, 0.5733f, 0.572f, 0.5708f, 0.5695f, 0.5683f, + 0.567f, 0.5657f, 0.5645f, 0.5632f, 0.5619f, 0.5607f, 0.5594f, 0.5581f, 0.5568f, 0.5556f, + 0.5543f, 0.553f, 0.5517f, 0.5505f, 0.5492f, 0.5479f, 0.5466f, 0.5453f, 0.544f, 0.5428f, + 0.5415f, 0.5402f, 0.5389f, 0.5376f, 0.5363f, 0.535f, 0.5337f, 0.5324f, 0.5311f, 0.5298f, + 0.5285f, 0.5272f, 0.5259f, 0.5246f, 0.5233f, 0.522f, 0.5207f, 0.5194f, 0.518f, 0.5167f, + 0.5154f, 0.5141f, 0.5128f, 0.5115f, 0.5102f, 0.5088f, 0.5075f, 0.5062f, 0.5049f, 0.5035f, + 0.5022f, 0.5009f, 0.4996f, 0.4982f, 0.4969f, 0.4956f, 0.4942f, 0.4929f, 0.4916f, 0.4902f, + 0.4889f, 0.4876f, 0.4862f, 0.4849f, 0.4835f, 0.4822f, 0.4808f, 0.4795f, 0.4781f, 0.4768f, + 0.4755f, 0.4741f, 0.4727f, 0.4714f, 0.47f, 0.4687f, 0.4673f, 0.466f, 0.4646f, 0.4633f, + 0.4619f, 0.4605f, 0.4592f, 0.4578f, 0.4564f, 0.4551f, 0.4537f, 0.4523f, 0.451f, 0.4496f, + 0.4482f, 0.4469f, 0.4455f, 0.4441f, 0.4427f, 0.4414f, 0.44f, 0.4386f, 0.4372f, 0.4359f, + 0.4345f, 0.4331f, 0.4317f, 0.4303f, 0.4289f, 0.4276f, 0.4262f, 0.4248f, 0.4234f, 0.422f, + 0.4206f, 0.4192f, 0.4178f, 0.4164f, 0.415f, 0.4136f, 0.4122f, 0.4108f, 0.4094f, 0.408f, + 0.4066f, 0.4052f, 0.4038f, 0.4024f, 0.401f, 0.3996f, 0.3982f, 0.3968f, 0.3954f, 0.394f, + 0.3926f, 0.3912f, 0.3898f, 0.3883f, 0.3869f, 0.3855f, 0.3841f, 0.3827f, 0.3813f, 0.3798f, + 0.3784f, 0.377f, 0.3756f, 0.3742f, 0.3727f, 0.3713f, 0.3699f, 0.3685f, 0.367f, 0.3656f, + 0.3642f, 0.3628f, 0.3613f, 0.3599f, 0.3585f, 0.357f, 0.3556f, 0.3542f, 0.3527f, 0.3513f, + 0.3499f, 0.3484f, 0.347f, 0.3455f, 0.3441f, 0.3427f, 0.3412f, 0.3398f, 0.3383f, 0.3369f, + 0.3354f, 0.334f, 0.3326f, 0.3311f, 0.3297f, 0.3282f, 0.3268f, 0.3253f, 0.3239f, 0.3224f, + 0.321f, 0.3195f, 0.318f, 0.3166f, 0.3151f, 0.3137f, 0.3122f, 0.3108f, 0.3093f, 0.3078f, + 0.3064f, 0.3049f, 0.3035f, 0.302f, 0.3005f, 0.2991f, 0.2976f, 0.2962f, 0.2947f, 0.2932f, + 0.2918f, 0.2903f, 0.2888f, 0.2873f, 0.2859f, 0.2844f, 0.2829f, 0.2815f, 0.28f, 0.2785f, + 0.277f, 0.2756f, 0.2741f, 0.2726f, 0.2711f, 0.2697f, 0.2682f, 0.2667f, 0.2652f, 0.2638f, + 0.2623f, 0.2608f, 0.2593f, 0.2578f, 0.2563f, 0.2549f, 0.2534f, 0.2519f, 0.2504f, 0.2489f, + 0.2474f, 0.246f, 0.2445f, 0.243f, 0.2415f, 0.24f, 0.2385f, 0.237f, 0.2355f, 0.234f, + 0.2326f, 0.2311f, 0.2296f, 0.2281f, 0.2266f, 0.2251f, 0.2236f, 0.2221f, 0.2206f, 0.2191f, + 0.2176f, 0.2161f, 0.2146f, 0.2131f, 0.2116f, 0.2101f, 0.2086f, 0.2071f, 0.2056f, 0.2041f, + 0.2026f, 0.2011f, 0.1996f, 0.1981f, 0.1966f, 0.1951f, 0.1936f, 0.1921f, 0.1906f, 0.1891f, + 0.1876f, 0.1861f, 0.1845f, 0.183f, 0.1815f, 0.18f, 0.1785f, 0.177f, 0.1755f, 0.174f, + 0.1725f, 0.171f, 0.1695f, 0.1679f, 0.1664f, 0.1649f, 0.1634f, 0.1619f, 0.1604f, 0.1589f, + 0.1573f, 0.1558f, 0.1543f, 0.1528f, 0.1513f, 0.1498f, 0.1482f, 0.1467f, 0.1452f, 0.1437f, + 0.1422f, 0.1407f, 0.1391f, 0.1376f, 0.1361f, 0.1346f, 0.1331f, 0.1315f, 0.13f, 0.1285f, + 0.127f, 0.1255f, 0.1239f, 0.1224f, 0.1209f, 0.1194f, 0.1178f, 0.1163f, 0.1148f, 0.1133f, + 0.1117f, 0.1102f, 0.1087f, 0.1072f, 0.1056f, 0.1041f, 0.1026f, 0.1011f, 0.09954f, 0.09802f, + 0.09649f, 0.09496f, 0.09344f, 0.09191f, 0.09038f, 0.08885f, 0.08733f, 0.0858f, 0.08427f, 0.08274f, + 0.08121f, 0.07968f, 0.07815f, 0.07662f, 0.07509f, 0.07356f, 0.07203f, 0.0705f, 0.06897f, 0.06744f, + 0.06591f, 0.06438f, 0.06285f, 0.06132f, 0.05979f, 0.05826f, 0.05673f, 0.0552f, 0.05366f, 0.05213f, + 0.0506f, 0.04907f, 0.04754f, 0.046f, 0.04447f, 0.04294f, 0.04141f, 0.03987f, 0.03834f, 0.03681f, + 0.03527f, 0.03374f, 0.03221f, 0.03067f, 0.02914f, 0.02761f, 0.02607f, 0.02454f, 0.02301f, 0.02147f, + 0.01994f, 0.01841f, 0.01687f, 0.01534f, 0.01381f, 0.01227f, 0.01074f, 0.009204f, 0.00767f, 0.006136f, + 0.004602f, 0.003068f, 0.001534f, 6.123e-17f, -0.001534f, -0.003068f, -0.004602f, -0.006136f, -0.00767f, -0.009204f, + -0.01074f, -0.01227f, -0.01381f, -0.01534f, -0.01687f, -0.01841f, -0.01994f, -0.02147f, -0.02301f, -0.02454f, + -0.02607f, -0.02761f, -0.02914f, -0.03067f, -0.03221f, -0.03374f, -0.03527f, -0.03681f, -0.03834f, -0.03987f, + -0.04141f, -0.04294f, -0.04447f, -0.046f, -0.04754f, -0.04907f, -0.0506f, -0.05213f, -0.05366f, -0.0552f, + -0.05673f, -0.05826f, -0.05979f, -0.06132f, -0.06285f, -0.06438f, -0.06591f, -0.06744f, -0.06897f, -0.0705f, + -0.07203f, -0.07356f, -0.07509f, -0.07662f, -0.07815f, -0.07968f, -0.08121f, -0.08274f, -0.08427f, -0.0858f, + -0.08733f, -0.08885f, -0.09038f, -0.09191f, -0.09344f, -0.09496f, -0.09649f, -0.09802f, -0.09954f, -0.1011f, + -0.1026f, -0.1041f, -0.1056f, -0.1072f, -0.1087f, -0.1102f, -0.1117f, -0.1133f, -0.1148f, -0.1163f, + -0.1178f, -0.1194f, -0.1209f, -0.1224f, -0.1239f, -0.1255f, -0.127f, -0.1285f, -0.13f, -0.1315f, + -0.1331f, -0.1346f, -0.1361f, -0.1376f, -0.1391f, -0.1407f, -0.1422f, -0.1437f, -0.1452f, -0.1467f, + -0.1482f, -0.1498f, -0.1513f, -0.1528f, -0.1543f, -0.1558f, -0.1573f, -0.1589f, -0.1604f, -0.1619f, + -0.1634f, -0.1649f, -0.1664f, -0.1679f, -0.1695f, -0.171f, -0.1725f, -0.174f, -0.1755f, -0.177f, + -0.1785f, -0.18f, -0.1815f, -0.183f, -0.1845f, -0.1861f, -0.1876f, -0.1891f, -0.1906f, -0.1921f, + -0.1936f, -0.1951f, -0.1966f, -0.1981f, -0.1996f, -0.2011f, -0.2026f, -0.2041f, -0.2056f, -0.2071f, + -0.2086f, -0.2101f, -0.2116f, -0.2131f, -0.2146f, -0.2161f, -0.2176f, -0.2191f, -0.2206f, -0.2221f, + -0.2236f, -0.2251f, -0.2266f, -0.2281f, -0.2296f, -0.2311f, -0.2326f, -0.234f, -0.2355f, -0.237f, + -0.2385f, -0.24f, -0.2415f, -0.243f, -0.2445f, -0.246f, -0.2474f, -0.2489f, -0.2504f, -0.2519f, + -0.2534f, -0.2549f, -0.2563f, -0.2578f, -0.2593f, -0.2608f, -0.2623f, -0.2638f, -0.2652f, -0.2667f, + -0.2682f, -0.2697f, -0.2711f, -0.2726f, -0.2741f, -0.2756f, -0.277f, -0.2785f, -0.28f, -0.2815f, + -0.2829f, -0.2844f, -0.2859f, -0.2873f, -0.2888f, -0.2903f, -0.2918f, -0.2932f, -0.2947f, -0.2962f, + -0.2976f, -0.2991f, -0.3005f, -0.302f, -0.3035f, -0.3049f, -0.3064f, -0.3078f, -0.3093f, -0.3108f, + -0.3122f, -0.3137f, -0.3151f, -0.3166f, -0.318f, -0.3195f, -0.321f, -0.3224f, -0.3239f, -0.3253f, + -0.3268f, -0.3282f, -0.3297f, -0.3311f, -0.3326f, -0.334f, -0.3354f, -0.3369f, -0.3383f, -0.3398f, + -0.3412f, -0.3427f, -0.3441f, -0.3455f, -0.347f, -0.3484f, -0.3499f, -0.3513f, -0.3527f, -0.3542f, + -0.3556f, -0.357f, -0.3585f, -0.3599f, -0.3613f, -0.3628f, -0.3642f, -0.3656f, -0.367f, -0.3685f, + -0.3699f, -0.3713f, -0.3727f, -0.3742f, -0.3756f, -0.377f, -0.3784f, -0.3798f, -0.3813f, -0.3827f, + -0.3841f, -0.3855f, -0.3869f, -0.3883f, -0.3898f, -0.3912f, -0.3926f, -0.394f, -0.3954f, -0.3968f, + -0.3982f, -0.3996f, -0.401f, -0.4024f, -0.4038f, -0.4052f, -0.4066f, -0.408f, -0.4094f, -0.4108f, + -0.4122f, -0.4136f, -0.415f, -0.4164f, -0.4178f, -0.4192f, -0.4206f, -0.422f, -0.4234f, -0.4248f, + -0.4262f, -0.4276f, -0.4289f, -0.4303f, -0.4317f, -0.4331f, -0.4345f, -0.4359f, -0.4372f, -0.4386f, + -0.44f, -0.4414f, -0.4427f, -0.4441f, -0.4455f, -0.4469f, -0.4482f, -0.4496f, -0.451f, -0.4523f, + -0.4537f, -0.4551f, -0.4564f, -0.4578f, -0.4592f, -0.4605f, -0.4619f, -0.4633f, -0.4646f, -0.466f, + -0.4673f, -0.4687f, -0.47f, -0.4714f, -0.4727f, -0.4741f, -0.4755f, -0.4768f, -0.4781f, -0.4795f, + -0.4808f, -0.4822f, -0.4835f, -0.4849f, -0.4862f, -0.4876f, -0.4889f, -0.4902f, -0.4916f, -0.4929f, + -0.4942f, -0.4956f, -0.4969f, -0.4982f, -0.4996f, -0.5009f, -0.5022f, -0.5035f, -0.5049f, -0.5062f, + -0.5075f, -0.5088f, -0.5102f, -0.5115f, -0.5128f, -0.5141f, -0.5154f, -0.5167f, -0.518f, -0.5194f, + -0.5207f, -0.522f, -0.5233f, -0.5246f, -0.5259f, -0.5272f, -0.5285f, -0.5298f, -0.5311f, -0.5324f, + -0.5337f, -0.535f, -0.5363f, -0.5376f, -0.5389f, -0.5402f, -0.5415f, -0.5428f, -0.544f, -0.5453f, + -0.5466f, -0.5479f, -0.5492f, -0.5505f, -0.5517f, -0.553f, -0.5543f, -0.5556f, -0.5568f, -0.5581f, + -0.5594f, -0.5607f, -0.5619f, -0.5632f, -0.5645f, -0.5657f, -0.567f, -0.5683f, -0.5695f, -0.5708f, + -0.572f, -0.5733f, -0.5746f, -0.5758f, -0.5771f, -0.5783f, -0.5796f, -0.5808f, -0.5821f, -0.5833f, + -0.5846f, -0.5858f, -0.587f, -0.5883f, -0.5895f, -0.5908f, -0.592f, -0.5932f, -0.5945f, -0.5957f, + -0.5969f, -0.5982f, -0.5994f, -0.6006f, -0.6018f, -0.6031f, -0.6043f, -0.6055f, -0.6067f, -0.6079f, + -0.6092f, -0.6104f, -0.6116f, -0.6128f, -0.614f, -0.6152f, -0.6164f, -0.6176f, -0.6189f, -0.6201f, + -0.6213f, -0.6225f, -0.6237f, -0.6249f, -0.6261f, -0.6273f, -0.6284f, -0.6296f, -0.6308f, -0.632f, + -0.6332f, -0.6344f, -0.6356f, -0.6368f, -0.6379f, -0.6391f, -0.6403f, -0.6415f, -0.6427f, -0.6438f, + -0.645f, -0.6462f, -0.6473f, -0.6485f, -0.6497f, -0.6508f, -0.652f, -0.6532f, -0.6543f, -0.6555f, + -0.6567f, -0.6578f, -0.659f, -0.6601f, -0.6613f, -0.6624f, -0.6636f, -0.6647f, -0.6659f, -0.667f, + -0.6681f, -0.6693f, -0.6704f, -0.6716f, -0.6727f, -0.6738f, -0.675f, -0.6761f, -0.6772f, -0.6784f, + -0.6795f, -0.6806f, -0.6817f, -0.6828f, -0.684f, -0.6851f, -0.6862f, -0.6873f, -0.6884f, -0.6895f, + -0.6907f, -0.6918f, -0.6929f, -0.694f, -0.6951f, -0.6962f, -0.6973f, -0.6984f, -0.6995f, -0.7006f, + -0.7017f, -0.7028f, -0.7038f, -0.7049f, -0.706f, -0.7071f, -0.7082f, -0.7093f, -0.7104f, -0.7114f, + -0.7125f, -0.7136f, -0.7147f, -0.7157f, -0.7168f, -0.7179f, -0.7189f, -0.72f, -0.7211f, -0.7221f, + -0.7232f, -0.7242f, -0.7253f, -0.7264f, -0.7274f, -0.7285f, -0.7295f, -0.7306f, -0.7316f, -0.7327f, + -0.7337f, -0.7347f, -0.7358f, -0.7368f, -0.7379f, -0.7389f, -0.7399f, -0.741f, -0.742f, -0.743f, + -0.744f, -0.7451f, -0.7461f, -0.7471f, -0.7481f, -0.7491f, -0.7502f, -0.7512f, -0.7522f, -0.7532f, + -0.7542f, -0.7552f, -0.7562f, -0.7572f, -0.7582f, -0.7592f, -0.7602f, -0.7612f, -0.7622f, -0.7632f, + -0.7642f, -0.7652f, -0.7662f, -0.7671f, -0.7681f, -0.7691f, -0.7701f, -0.7711f, -0.772f, -0.773f, + -0.774f, -0.775f, -0.7759f, -0.7769f, -0.7779f, -0.7788f, -0.7798f, -0.7807f, -0.7817f, -0.7827f, + -0.7836f, -0.7846f, -0.7855f, -0.7865f, -0.7874f, -0.7883f, -0.7893f, -0.7902f, -0.7912f, -0.7921f, + -0.793f, -0.794f, -0.7949f, -0.7958f, -0.7968f, -0.7977f, -0.7986f, -0.7995f, -0.8005f, -0.8014f, + -0.8023f, -0.8032f, -0.8041f, -0.805f, -0.8059f, -0.8068f, -0.8078f, -0.8087f, -0.8096f, -0.8105f, + -0.8114f, -0.8123f, -0.8131f, -0.814f, -0.8149f, -0.8158f, -0.8167f, -0.8176f, -0.8185f, -0.8193f, + -0.8202f, -0.8211f, -0.822f, -0.8228f, -0.8237f, -0.8246f, -0.8255f, -0.8263f, -0.8272f, -0.828f, + -0.8289f, -0.8298f, -0.8306f, -0.8315f, -0.8323f, -0.8332f, -0.834f, -0.8349f, -0.8357f, -0.8365f, + -0.8374f, -0.8382f, -0.8391f, -0.8399f, -0.8407f, -0.8416f, -0.8424f, -0.8432f, -0.844f, -0.8449f, + -0.8457f, -0.8465f, -0.8473f, -0.8481f, -0.8489f, -0.8497f, -0.8505f, -0.8514f, -0.8522f, -0.853f, + -0.8538f, -0.8546f, -0.8554f, -0.8561f, -0.8569f, -0.8577f, -0.8585f, -0.8593f, -0.8601f, -0.8609f, + -0.8616f, -0.8624f, -0.8632f, -0.864f, -0.8647f, -0.8655f, -0.8663f, -0.867f, -0.8678f, -0.8686f, + -0.8693f, -0.8701f, -0.8708f, -0.8716f, -0.8723f, -0.8731f, -0.8738f, -0.8746f, -0.8753f, -0.8761f, + -0.8768f, -0.8775f, -0.8783f, -0.879f, -0.8797f, -0.8805f, -0.8812f, -0.8819f, -0.8826f, -0.8834f, + -0.8841f, -0.8848f, -0.8855f, -0.8862f, -0.8869f, -0.8876f, -0.8883f, -0.889f, -0.8897f, -0.8904f, + -0.8911f, -0.8918f, -0.8925f, -0.8932f, -0.8939f, -0.8946f, -0.8953f, -0.896f, -0.8966f, -0.8973f, + -0.898f, -0.8987f, -0.8993f, -0.9f, -0.9007f, -0.9013f, -0.902f, -0.9027f, -0.9033f, -0.904f, + -0.9046f, -0.9053f, -0.9059f, -0.9066f, -0.9072f, -0.9079f, -0.9085f, -0.9092f, -0.9098f, -0.9104f, + -0.9111f, -0.9117f, -0.9123f, -0.913f, -0.9136f, -0.9142f, -0.9148f, -0.9154f, -0.9161f, -0.9167f, + -0.9173f, -0.9179f, -0.9185f, -0.9191f, -0.9197f, -0.9203f, -0.9209f, -0.9215f, -0.9221f, -0.9227f, + -0.9233f, -0.9239f, -0.9245f, -0.925f, -0.9256f, -0.9262f, -0.9268f, -0.9274f, -0.9279f, -0.9285f, + -0.9291f, -0.9296f, -0.9302f, -0.9308f, -0.9313f, -0.9319f, -0.9324f, -0.933f, -0.9335f, -0.9341f, + -0.9346f, -0.9352f, -0.9357f, -0.9363f, -0.9368f, -0.9373f, -0.9379f, -0.9384f, -0.9389f, -0.9395f, + -0.94f, -0.9405f, -0.941f, -0.9415f, -0.9421f, -0.9426f, -0.9431f, -0.9436f, -0.9441f, -0.9446f, + -0.9451f, -0.9456f, -0.9461f, -0.9466f, -0.9471f, -0.9476f, -0.9481f, -0.9486f, -0.949f, -0.9495f, + -0.95f, -0.9505f, -0.951f, -0.9514f, -0.9519f, -0.9524f, -0.9528f, -0.9533f, -0.9538f, -0.9542f, + -0.9547f, -0.9551f, -0.9556f, -0.956f, -0.9565f, -0.9569f, -0.9574f, -0.9578f, -0.9583f, -0.9587f, + -0.9591f, -0.9596f, -0.96f, -0.9604f, -0.9609f, -0.9613f, -0.9617f, -0.9621f, -0.9625f, -0.963f, + -0.9634f, -0.9638f, -0.9642f, -0.9646f, -0.965f, -0.9654f, -0.9658f, -0.9662f, -0.9666f, -0.967f, + -0.9674f, -0.9678f, -0.9681f, -0.9685f, -0.9689f, -0.9693f, -0.9697f, -0.97f, -0.9704f, -0.9708f, + -0.9711f, -0.9715f, -0.9719f, -0.9722f, -0.9726f, -0.9729f, -0.9733f, -0.9736f, -0.974f, -0.9743f, + -0.9747f, -0.975f, -0.9754f, -0.9757f, -0.976f, -0.9764f, -0.9767f, -0.977f, -0.9774f, -0.9777f, + -0.978f, -0.9783f, -0.9786f, -0.9789f, -0.9793f, -0.9796f, -0.9799f, -0.9802f, -0.9805f, -0.9808f, + -0.9811f, -0.9814f, -0.9817f, -0.982f, -0.9823f, -0.9825f, -0.9828f, -0.9831f, -0.9834f, -0.9837f, + -0.9839f, -0.9842f, -0.9845f, -0.9847f, -0.985f, -0.9853f, -0.9855f, -0.9858f, -0.9861f, -0.9863f, + -0.9866f, -0.9868f, -0.9871f, -0.9873f, -0.9875f, -0.9878f, -0.988f, -0.9883f, -0.9885f, -0.9887f, + -0.989f, -0.9892f, -0.9894f, -0.9896f, -0.9898f, -0.9901f, -0.9903f, -0.9905f, -0.9907f, -0.9909f, + -0.9911f, -0.9913f, -0.9915f, -0.9917f, -0.9919f, -0.9921f, -0.9923f, -0.9925f, -0.9927f, -0.9929f, + -0.993f, -0.9932f, -0.9934f, -0.9936f, -0.9937f, -0.9939f, -0.9941f, -0.9942f, -0.9944f, -0.9946f, + -0.9947f, -0.9949f, -0.995f, -0.9952f, -0.9953f, -0.9955f, -0.9956f, -0.9958f, -0.9959f, -0.996f, + -0.9962f, -0.9963f, -0.9964f, -0.9966f, -0.9967f, -0.9968f, -0.9969f, -0.9971f, -0.9972f, -0.9973f, + -0.9974f, -0.9975f, -0.9976f, -0.9977f, -0.9978f, -0.9979f, -0.998f, -0.9981f, -0.9982f, -0.9983f, + -0.9984f, -0.9985f, -0.9986f, -0.9986f, -0.9987f, -0.9988f, -0.9989f, -0.9989f, -0.999f, -0.9991f, + -0.9991f, -0.9992f, -0.9993f, -0.9993f, -0.9994f, -0.9994f, -0.9995f, -0.9995f, -0.9996f, -0.9996f, + -0.9997f, -0.9997f, -0.9997f, -0.9998f, -0.9998f, -0.9998f, -0.9999f, -0.9999f, -0.9999f, -0.9999f, + -0.9999f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, + -1.0f, -1.0f, -1.0f, -1.0f, -0.9999f, -0.9999f, -0.9999f, -0.9999f, -0.9999f, -0.9998f, + -0.9998f, -0.9998f, -0.9997f, -0.9997f, -0.9997f, -0.9996f, -0.9996f, -0.9995f, -0.9995f, -0.9994f, + -0.9994f, -0.9993f, -0.9993f, -0.9992f, -0.9991f, -0.9991f, -0.999f, -0.9989f, -0.9989f, -0.9988f, + -0.9987f, -0.9986f, -0.9986f, -0.9985f, -0.9984f, -0.9983f, -0.9982f, -0.9981f, -0.998f, -0.9979f, + -0.9978f, -0.9977f, -0.9976f, -0.9975f, -0.9974f, -0.9973f, -0.9972f, -0.9971f, -0.9969f, -0.9968f, + -0.9967f, -0.9966f, -0.9964f, -0.9963f, -0.9962f, -0.996f, -0.9959f, -0.9958f, -0.9956f, -0.9955f, + -0.9953f, -0.9952f, -0.995f, -0.9949f, -0.9947f, -0.9946f, -0.9944f, -0.9942f, -0.9941f, -0.9939f, + -0.9937f, -0.9936f, -0.9934f, -0.9932f, -0.993f, -0.9929f, -0.9927f, -0.9925f, -0.9923f, -0.9921f, + -0.9919f, -0.9917f, -0.9915f, -0.9913f, -0.9911f, -0.9909f, -0.9907f, -0.9905f, -0.9903f, -0.9901f, + -0.9898f, -0.9896f, -0.9894f, -0.9892f, -0.989f, -0.9887f, -0.9885f, -0.9883f, -0.988f, -0.9878f, + -0.9875f, -0.9873f, -0.9871f, -0.9868f, -0.9866f, -0.9863f, -0.9861f, -0.9858f, -0.9855f, -0.9853f, + -0.985f, -0.9847f, -0.9845f, -0.9842f, -0.9839f, -0.9837f, -0.9834f, -0.9831f, -0.9828f, -0.9825f, + -0.9823f, -0.982f, -0.9817f, -0.9814f, -0.9811f, -0.9808f, -0.9805f, -0.9802f, -0.9799f, -0.9796f, + -0.9793f, -0.9789f, -0.9786f, -0.9783f, -0.978f, -0.9777f, -0.9774f, -0.977f, -0.9767f, -0.9764f, + -0.976f, -0.9757f, -0.9754f, -0.975f, -0.9747f, -0.9743f, -0.974f, -0.9736f, -0.9733f, -0.9729f, + -0.9726f, -0.9722f, -0.9719f, -0.9715f, -0.9711f, -0.9708f, -0.9704f, -0.97f, -0.9697f, -0.9693f, + -0.9689f, -0.9685f, -0.9681f, -0.9678f, -0.9674f, -0.967f, -0.9666f, -0.9662f, -0.9658f, -0.9654f, + -0.965f, -0.9646f, -0.9642f, -0.9638f, -0.9634f, -0.963f, -0.9625f, -0.9621f, -0.9617f, -0.9613f, + -0.9609f, -0.9604f, -0.96f, -0.9596f, -0.9591f, -0.9587f, -0.9583f, -0.9578f, -0.9574f, -0.9569f, + -0.9565f, -0.956f, -0.9556f, -0.9551f, -0.9547f, -0.9542f, -0.9538f, -0.9533f, -0.9528f, -0.9524f, + -0.9519f, -0.9514f, -0.951f, -0.9505f, -0.95f, -0.9495f, -0.949f, -0.9486f, -0.9481f, -0.9476f, + -0.9471f, -0.9466f, -0.9461f, -0.9456f, -0.9451f, -0.9446f, -0.9441f, -0.9436f, -0.9431f, -0.9426f, + -0.9421f, -0.9415f, -0.941f, -0.9405f, -0.94f, -0.9395f, -0.9389f, -0.9384f, -0.9379f, -0.9373f, + -0.9368f, -0.9363f, -0.9357f, -0.9352f, -0.9346f, -0.9341f, -0.9335f, -0.933f, -0.9324f, -0.9319f, + -0.9313f, -0.9308f, -0.9302f, -0.9296f, -0.9291f, -0.9285f, -0.9279f, -0.9274f, -0.9268f, -0.9262f, + -0.9256f, -0.925f, -0.9245f, -0.9239f, -0.9233f, -0.9227f, -0.9221f, -0.9215f, -0.9209f, -0.9203f, + -0.9197f, -0.9191f, -0.9185f, -0.9179f, -0.9173f, -0.9167f, -0.9161f, -0.9154f, -0.9148f, -0.9142f, + -0.9136f, -0.913f, -0.9123f, -0.9117f, -0.9111f, -0.9104f, -0.9098f, -0.9092f, -0.9085f, -0.9079f, + -0.9072f, -0.9066f, -0.9059f, -0.9053f, -0.9046f, -0.904f, -0.9033f, -0.9027f, -0.902f, -0.9013f, + -0.9007f, -0.9f, -0.8993f, -0.8987f, -0.898f, -0.8973f, -0.8966f, -0.896f, -0.8953f, -0.8946f, + -0.8939f, -0.8932f, -0.8925f, -0.8918f, -0.8911f, -0.8904f, -0.8897f, -0.889f, -0.8883f, -0.8876f, + -0.8869f, -0.8862f, -0.8855f, -0.8848f, -0.8841f, -0.8834f, -0.8826f, -0.8819f, -0.8812f, -0.8805f, + -0.8797f, -0.879f, -0.8783f, -0.8775f, -0.8768f, -0.8761f, -0.8753f, -0.8746f, -0.8738f, -0.8731f, + -0.8723f, -0.8716f, -0.8708f, -0.8701f, -0.8693f, -0.8686f, -0.8678f, -0.867f, -0.8663f, -0.8655f, + -0.8647f, -0.864f, -0.8632f, -0.8624f, -0.8616f, -0.8609f, -0.8601f, -0.8593f, -0.8585f, -0.8577f, + -0.8569f, -0.8561f, -0.8554f, -0.8546f, -0.8538f, -0.853f, -0.8522f, -0.8514f, -0.8505f, -0.8497f, + -0.8489f, -0.8481f, -0.8473f, -0.8465f, -0.8457f, -0.8449f, -0.844f, -0.8432f, -0.8424f, -0.8416f, + -0.8407f, -0.8399f, -0.8391f, -0.8382f, -0.8374f, -0.8365f, -0.8357f, -0.8349f, -0.834f, -0.8332f, + -0.8323f, -0.8315f, -0.8306f, -0.8298f, -0.8289f, -0.828f, -0.8272f, -0.8263f, -0.8255f, -0.8246f, + -0.8237f, -0.8228f, -0.822f, -0.8211f, -0.8202f, -0.8193f, -0.8185f, -0.8176f, -0.8167f, -0.8158f, + -0.8149f, -0.814f, -0.8131f, -0.8123f, -0.8114f, -0.8105f, -0.8096f, -0.8087f, -0.8078f, -0.8068f, + -0.8059f, -0.805f, -0.8041f, -0.8032f, -0.8023f, -0.8014f, -0.8005f, -0.7995f, -0.7986f, -0.7977f, + -0.7968f, -0.7958f, -0.7949f, -0.794f, -0.793f, -0.7921f, -0.7912f, -0.7902f, -0.7893f, -0.7883f, + -0.7874f, -0.7865f, -0.7855f, -0.7846f, -0.7836f, -0.7827f, -0.7817f, -0.7807f, -0.7798f, -0.7788f, + -0.7779f, -0.7769f, -0.7759f, -0.775f, -0.774f, -0.773f, -0.772f, -0.7711f, -0.7701f, -0.7691f, + -0.7681f, -0.7671f, -0.7662f, -0.7652f, -0.7642f, -0.7632f, -0.7622f, -0.7612f, -0.7602f, -0.7592f, + -0.7582f, -0.7572f, -0.7562f, -0.7552f, -0.7542f, -0.7532f, -0.7522f, -0.7512f, -0.7502f, -0.7491f, + -0.7481f, -0.7471f, -0.7461f, -0.7451f, -0.744f, -0.743f, -0.742f, -0.741f, -0.7399f, -0.7389f, + -0.7379f, -0.7368f, -0.7358f, -0.7347f, -0.7337f, -0.7327f, -0.7316f, -0.7306f, -0.7295f, -0.7285f, + -0.7274f, -0.7264f, -0.7253f, -0.7242f, -0.7232f, -0.7221f, -0.7211f, -0.72f, -0.7189f, -0.7179f, + -0.7168f, -0.7157f, -0.7147f, -0.7136f, -0.7125f, -0.7114f, -0.7104f, -0.7093f, -0.7082f, -0.7071f, + -0.706f, -0.7049f, -0.7038f, -0.7028f, -0.7017f, -0.7006f, -0.6995f, -0.6984f, -0.6973f, -0.6962f, + -0.6951f, -0.694f, -0.6929f, -0.6918f, -0.6907f, -0.6895f, -0.6884f, -0.6873f, -0.6862f, -0.6851f, + -0.684f, -0.6828f, -0.6817f, -0.6806f, -0.6795f, -0.6784f, -0.6772f, -0.6761f, -0.675f, -0.6738f, + -0.6727f, -0.6716f, -0.6704f, -0.6693f, -0.6681f, -0.667f, -0.6659f, -0.6647f, -0.6636f, -0.6624f, + -0.6613f, -0.6601f, -0.659f, -0.6578f, -0.6567f, -0.6555f, -0.6543f, -0.6532f, -0.652f, -0.6508f, + -0.6497f, -0.6485f, -0.6473f, -0.6462f, -0.645f, -0.6438f, -0.6427f, -0.6415f, -0.6403f, -0.6391f, + -0.6379f, -0.6368f, -0.6356f, -0.6344f, -0.6332f, -0.632f, -0.6308f, -0.6296f, -0.6284f, -0.6273f, + -0.6261f, -0.6249f, -0.6237f, -0.6225f, -0.6213f, -0.6201f, -0.6189f, -0.6176f, -0.6164f, -0.6152f, + -0.614f, -0.6128f, -0.6116f, -0.6104f, -0.6092f, -0.6079f, -0.6067f, -0.6055f, -0.6043f, -0.6031f, + -0.6018f, -0.6006f, -0.5994f, -0.5982f, -0.5969f, -0.5957f, -0.5945f, -0.5932f, -0.592f, -0.5908f, + -0.5895f, -0.5883f, -0.587f, -0.5858f, -0.5846f, -0.5833f, -0.5821f, -0.5808f, -0.5796f, -0.5783f, + -0.5771f, -0.5758f, -0.5746f, -0.5733f, -0.572f, -0.5708f, -0.5695f, -0.5683f, -0.567f, -0.5657f, + -0.5645f, -0.5632f, -0.5619f, -0.5607f, -0.5594f, -0.5581f, -0.5568f, -0.5556f, -0.5543f, -0.553f, + -0.5517f, -0.5505f, -0.5492f, -0.5479f, -0.5466f, -0.5453f, -0.544f, -0.5428f, -0.5415f, -0.5402f, + -0.5389f, -0.5376f, -0.5363f, -0.535f, -0.5337f, -0.5324f, -0.5311f, -0.5298f, -0.5285f, -0.5272f, + -0.5259f, -0.5246f, -0.5233f, -0.522f, -0.5207f, -0.5194f, -0.518f, -0.5167f, -0.5154f, -0.5141f, + -0.5128f, -0.5115f, -0.5102f, -0.5088f, -0.5075f, -0.5062f, -0.5049f, -0.5035f, -0.5022f, -0.5009f, + -0.4996f, -0.4982f, -0.4969f, -0.4956f, -0.4942f, -0.4929f, -0.4916f, -0.4902f, -0.4889f, -0.4876f, + -0.4862f, -0.4849f, -0.4835f, -0.4822f, -0.4808f, -0.4795f, -0.4781f, -0.4768f, -0.4755f, -0.4741f, + -0.4727f, -0.4714f, -0.47f, -0.4687f, -0.4673f, -0.466f, -0.4646f, -0.4633f, -0.4619f, -0.4605f, + -0.4592f, -0.4578f, -0.4564f, -0.4551f, -0.4537f, -0.4523f, -0.451f, -0.4496f, -0.4482f, -0.4469f, + -0.4455f, -0.4441f, -0.4427f, -0.4414f, -0.44f, -0.4386f, -0.4372f, -0.4359f, -0.4345f, -0.4331f, + -0.4317f, -0.4303f, -0.4289f, -0.4276f, -0.4262f, -0.4248f, -0.4234f, -0.422f, -0.4206f, -0.4192f, + -0.4178f, -0.4164f, -0.415f, -0.4136f, -0.4122f, -0.4108f, -0.4094f, -0.408f, -0.4066f, -0.4052f, + -0.4038f, -0.4024f, -0.401f, -0.3996f, -0.3982f, -0.3968f, -0.3954f, -0.394f, -0.3926f, -0.3912f, + -0.3898f, -0.3883f, -0.3869f, -0.3855f, -0.3841f, -0.3827f, -0.3813f, -0.3798f, -0.3784f, -0.377f, + -0.3756f, -0.3742f, -0.3727f, -0.3713f, -0.3699f, -0.3685f, -0.367f, -0.3656f, -0.3642f, -0.3628f, + -0.3613f, -0.3599f, -0.3585f, -0.357f, -0.3556f, -0.3542f, -0.3527f, -0.3513f, -0.3499f, -0.3484f, + -0.347f, -0.3455f, -0.3441f, -0.3427f, -0.3412f, -0.3398f, -0.3383f, -0.3369f, -0.3354f, -0.334f, + -0.3326f, -0.3311f, -0.3297f, -0.3282f, -0.3268f, -0.3253f, -0.3239f, -0.3224f, -0.321f, -0.3195f, + -0.318f, -0.3166f, -0.3151f, -0.3137f, -0.3122f, -0.3108f, -0.3093f, -0.3078f, -0.3064f, -0.3049f, + -0.3035f, -0.302f, -0.3005f, -0.2991f, -0.2976f, -0.2962f, -0.2947f, -0.2932f, -0.2918f, -0.2903f, + -0.2888f, -0.2873f, -0.2859f, -0.2844f, -0.2829f, -0.2815f, -0.28f, -0.2785f, -0.277f, -0.2756f, + -0.2741f, -0.2726f, -0.2711f, -0.2697f, -0.2682f, -0.2667f, -0.2652f, -0.2638f, -0.2623f, -0.2608f, + -0.2593f, -0.2578f, -0.2563f, -0.2549f, -0.2534f, -0.2519f, -0.2504f, -0.2489f, -0.2474f, -0.246f, + -0.2445f, -0.243f, -0.2415f, -0.24f, -0.2385f, -0.237f, -0.2355f, -0.234f, -0.2326f, -0.2311f, + -0.2296f, -0.2281f, -0.2266f, -0.2251f, -0.2236f, -0.2221f, -0.2206f, -0.2191f, -0.2176f, -0.2161f, + -0.2146f, -0.2131f, -0.2116f, -0.2101f, -0.2086f, -0.2071f, -0.2056f, -0.2041f, -0.2026f, -0.2011f, + -0.1996f, -0.1981f, -0.1966f, -0.1951f, -0.1936f, -0.1921f, -0.1906f, -0.1891f, -0.1876f, -0.1861f, + -0.1845f, -0.183f, -0.1815f, -0.18f, -0.1785f, -0.177f, -0.1755f, -0.174f, -0.1725f, -0.171f, + -0.1695f, -0.1679f, -0.1664f, -0.1649f, -0.1634f, -0.1619f, -0.1604f, -0.1589f, -0.1573f, -0.1558f, + -0.1543f, -0.1528f, -0.1513f, -0.1498f, -0.1482f, -0.1467f, -0.1452f, -0.1437f, -0.1422f, -0.1407f, + -0.1391f, -0.1376f, -0.1361f, -0.1346f, -0.1331f, -0.1315f, -0.13f, -0.1285f, -0.127f, -0.1255f, + -0.1239f, -0.1224f, -0.1209f, -0.1194f, -0.1178f, -0.1163f, -0.1148f, -0.1133f, -0.1117f, -0.1102f, + -0.1087f, -0.1072f, -0.1056f, -0.1041f, -0.1026f, -0.1011f, -0.09954f, -0.09802f, -0.09649f, -0.09496f, + -0.09344f, -0.09191f, -0.09038f, -0.08885f, -0.08733f, -0.0858f, -0.08427f, -0.08274f, -0.08121f, -0.07968f, + -0.07815f, -0.07662f, -0.07509f, -0.07356f, -0.07203f, -0.0705f, -0.06897f, -0.06744f, -0.06591f, -0.06438f, + -0.06285f, -0.06132f, -0.05979f, -0.05826f, -0.05673f, -0.0552f, -0.05366f, -0.05213f, -0.0506f, -0.04907f, + -0.04754f, -0.046f, -0.04447f, -0.04294f, -0.04141f, -0.03987f, -0.03834f, -0.03681f, -0.03527f, -0.03374f, + -0.03221f, -0.03067f, -0.02914f, -0.02761f, -0.02607f, -0.02454f, -0.02301f, -0.02147f, -0.01994f, -0.01841f, + -0.01687f, -0.01534f, -0.01381f, -0.01227f, -0.01074f, -0.009204f, -0.00767f, -0.006136f, -0.004602f, -0.003068f, + -0.001534f, -1.837e-16f, 0.001534f, 0.003068f, 0.004602f, 0.006136f, 0.00767f, 0.009204f, 0.01074f, 0.01227f, + 0.01381f, 0.01534f, 0.01687f, 0.01841f, 0.01994f, 0.02147f, 0.02301f, 0.02454f, 0.02607f, 0.02761f, + 0.02914f, 0.03067f, 0.03221f, 0.03374f, 0.03527f, 0.03681f, 0.03834f, 0.03987f, 0.04141f, 0.04294f, + 0.04447f, 0.046f, 0.04754f, 0.04907f, 0.0506f, 0.05213f, 0.05366f, 0.0552f, 0.05673f, 0.05826f, + 0.05979f, 0.06132f, 0.06285f, 0.06438f, 0.06591f, 0.06744f, 0.06897f, 0.0705f, 0.07203f, 0.07356f, + 0.07509f, 0.07662f, 0.07815f, 0.07968f, 0.08121f, 0.08274f, 0.08427f, 0.0858f, 0.08733f, 0.08885f, + 0.09038f, 0.09191f, 0.09344f, 0.09496f, 0.09649f, 0.09802f, 0.09954f, 0.1011f, 0.1026f, 0.1041f, + 0.1056f, 0.1072f, 0.1087f, 0.1102f, 0.1117f, 0.1133f, 0.1148f, 0.1163f, 0.1178f, 0.1194f, + 0.1209f, 0.1224f, 0.1239f, 0.1255f, 0.127f, 0.1285f, 0.13f, 0.1315f, 0.1331f, 0.1346f, + 0.1361f, 0.1376f, 0.1391f, 0.1407f, 0.1422f, 0.1437f, 0.1452f, 0.1467f, 0.1482f, 0.1498f, + 0.1513f, 0.1528f, 0.1543f, 0.1558f, 0.1573f, 0.1589f, 0.1604f, 0.1619f, 0.1634f, 0.1649f, + 0.1664f, 0.1679f, 0.1695f, 0.171f, 0.1725f, 0.174f, 0.1755f, 0.177f, 0.1785f, 0.18f, + 0.1815f, 0.183f, 0.1845f, 0.1861f, 0.1876f, 0.1891f, 0.1906f, 0.1921f, 0.1936f, 0.1951f, + 0.1966f, 0.1981f, 0.1996f, 0.2011f, 0.2026f, 0.2041f, 0.2056f, 0.2071f, 0.2086f, 0.2101f, + 0.2116f, 0.2131f, 0.2146f, 0.2161f, 0.2176f, 0.2191f, 0.2206f, 0.2221f, 0.2236f, 0.2251f, + 0.2266f, 0.2281f, 0.2296f, 0.2311f, 0.2326f, 0.234f, 0.2355f, 0.237f, 0.2385f, 0.24f, + 0.2415f, 0.243f, 0.2445f, 0.246f, 0.2474f, 0.2489f, 0.2504f, 0.2519f, 0.2534f, 0.2549f, + 0.2563f, 0.2578f, 0.2593f, 0.2608f, 0.2623f, 0.2638f, 0.2652f, 0.2667f, 0.2682f, 0.2697f, + 0.2711f, 0.2726f, 0.2741f, 0.2756f, 0.277f, 0.2785f, 0.28f, 0.2815f, 0.2829f, 0.2844f, + 0.2859f, 0.2873f, 0.2888f, 0.2903f, 0.2918f, 0.2932f, 0.2947f, 0.2962f, 0.2976f, 0.2991f, + 0.3005f, 0.302f, 0.3035f, 0.3049f, 0.3064f, 0.3078f, 0.3093f, 0.3108f, 0.3122f, 0.3137f, + 0.3151f, 0.3166f, 0.318f, 0.3195f, 0.321f, 0.3224f, 0.3239f, 0.3253f, 0.3268f, 0.3282f, + 0.3297f, 0.3311f, 0.3326f, 0.334f, 0.3354f, 0.3369f, 0.3383f, 0.3398f, 0.3412f, 0.3427f, + 0.3441f, 0.3455f, 0.347f, 0.3484f, 0.3499f, 0.3513f, 0.3527f, 0.3542f, 0.3556f, 0.357f, + 0.3585f, 0.3599f, 0.3613f, 0.3628f, 0.3642f, 0.3656f, 0.367f, 0.3685f, 0.3699f, 0.3713f, + 0.3727f, 0.3742f, 0.3756f, 0.377f, 0.3784f, 0.3798f, 0.3813f, 0.3827f, 0.3841f, 0.3855f, + 0.3869f, 0.3883f, 0.3898f, 0.3912f, 0.3926f, 0.394f, 0.3954f, 0.3968f, 0.3982f, 0.3996f, + 0.401f, 0.4024f, 0.4038f, 0.4052f, 0.4066f, 0.408f, 0.4094f, 0.4108f, 0.4122f, 0.4136f, + 0.415f, 0.4164f, 0.4178f, 0.4192f, 0.4206f, 0.422f, 0.4234f, 0.4248f, 0.4262f, 0.4276f, + 0.4289f, 0.4303f, 0.4317f, 0.4331f, 0.4345f, 0.4359f, 0.4372f, 0.4386f, 0.44f, 0.4414f, + 0.4427f, 0.4441f, 0.4455f, 0.4469f, 0.4482f, 0.4496f, 0.451f, 0.4523f, 0.4537f, 0.4551f, + 0.4564f, 0.4578f, 0.4592f, 0.4605f, 0.4619f, 0.4633f, 0.4646f, 0.466f, 0.4673f, 0.4687f, + 0.47f, 0.4714f, 0.4727f, 0.4741f, 0.4755f, 0.4768f, 0.4781f, 0.4795f, 0.4808f, 0.4822f, + 0.4835f, 0.4849f, 0.4862f, 0.4876f, 0.4889f, 0.4902f, 0.4916f, 0.4929f, 0.4942f, 0.4956f, + 0.4969f, 0.4982f, 0.4996f, 0.5009f, 0.5022f, 0.5035f, 0.5049f, 0.5062f, 0.5075f, 0.5088f, + 0.5102f, 0.5115f, 0.5128f, 0.5141f, 0.5154f, 0.5167f, 0.518f, 0.5194f, 0.5207f, 0.522f, + 0.5233f, 0.5246f, 0.5259f, 0.5272f, 0.5285f, 0.5298f, 0.5311f, 0.5324f, 0.5337f, 0.535f, + 0.5363f, 0.5376f, 0.5389f, 0.5402f, 0.5415f, 0.5428f, 0.544f, 0.5453f, 0.5466f, 0.5479f, + 0.5492f, 0.5505f, 0.5517f, 0.553f, 0.5543f, 0.5556f, 0.5568f, 0.5581f, 0.5594f, 0.5607f, + 0.5619f, 0.5632f, 0.5645f, 0.5657f, 0.567f, 0.5683f, 0.5695f, 0.5708f, 0.572f, 0.5733f, + 0.5746f, 0.5758f, 0.5771f, 0.5783f, 0.5796f, 0.5808f, 0.5821f, 0.5833f, 0.5846f, 0.5858f, + 0.587f, 0.5883f, 0.5895f, 0.5908f, 0.592f, 0.5932f, 0.5945f, 0.5957f, 0.5969f, 0.5982f, + 0.5994f, 0.6006f, 0.6018f, 0.6031f, 0.6043f, 0.6055f, 0.6067f, 0.6079f, 0.6092f, 0.6104f, + 0.6116f, 0.6128f, 0.614f, 0.6152f, 0.6164f, 0.6176f, 0.6189f, 0.6201f, 0.6213f, 0.6225f, + 0.6237f, 0.6249f, 0.6261f, 0.6273f, 0.6284f, 0.6296f, 0.6308f, 0.632f, 0.6332f, 0.6344f, + 0.6356f, 0.6368f, 0.6379f, 0.6391f, 0.6403f, 0.6415f, 0.6427f, 0.6438f, 0.645f, 0.6462f, + 0.6473f, 0.6485f, 0.6497f, 0.6508f, 0.652f, 0.6532f, 0.6543f, 0.6555f, 0.6567f, 0.6578f, + 0.659f, 0.6601f, 0.6613f, 0.6624f, 0.6636f, 0.6647f, 0.6659f, 0.667f, 0.6681f, 0.6693f, + 0.6704f, 0.6716f, 0.6727f, 0.6738f, 0.675f, 0.6761f, 0.6772f, 0.6784f, 0.6795f, 0.6806f, + 0.6817f, 0.6828f, 0.684f, 0.6851f, 0.6862f, 0.6873f, 0.6884f, 0.6895f, 0.6907f, 0.6918f, + 0.6929f, 0.694f, 0.6951f, 0.6962f, 0.6973f, 0.6984f, 0.6995f, 0.7006f, 0.7017f, 0.7028f, + 0.7038f, 0.7049f, 0.706f, 0.7071f, 0.7082f, 0.7093f, 0.7104f, 0.7114f, 0.7125f, 0.7136f, + 0.7147f, 0.7157f, 0.7168f, 0.7179f, 0.7189f, 0.72f, 0.7211f, 0.7221f, 0.7232f, 0.7242f, + 0.7253f, 0.7264f, 0.7274f, 0.7285f, 0.7295f, 0.7306f, 0.7316f, 0.7327f, 0.7337f, 0.7347f, + 0.7358f, 0.7368f, 0.7379f, 0.7389f, 0.7399f, 0.741f, 0.742f, 0.743f, 0.744f, 0.7451f, + 0.7461f, 0.7471f, 0.7481f, 0.7491f, 0.7502f, 0.7512f, 0.7522f, 0.7532f, 0.7542f, 0.7552f, + 0.7562f, 0.7572f, 0.7582f, 0.7592f, 0.7602f, 0.7612f, 0.7622f, 0.7632f, 0.7642f, 0.7652f, + 0.7662f, 0.7671f, 0.7681f, 0.7691f, 0.7701f, 0.7711f, 0.772f, 0.773f, 0.774f, 0.775f, + 0.7759f, 0.7769f, 0.7779f, 0.7788f, 0.7798f, 0.7807f, 0.7817f, 0.7827f, 0.7836f, 0.7846f, + 0.7855f, 0.7865f, 0.7874f, 0.7883f, 0.7893f, 0.7902f, 0.7912f, 0.7921f, 0.793f, 0.794f, + 0.7949f, 0.7958f, 0.7968f, 0.7977f, 0.7986f, 0.7995f, 0.8005f, 0.8014f, 0.8023f, 0.8032f, + 0.8041f, 0.805f, 0.8059f, 0.8068f, 0.8078f, 0.8087f, 0.8096f, 0.8105f, 0.8114f, 0.8123f, + 0.8131f, 0.814f, 0.8149f, 0.8158f, 0.8167f, 0.8176f, 0.8185f, 0.8193f, 0.8202f, 0.8211f, + 0.822f, 0.8228f, 0.8237f, 0.8246f, 0.8255f, 0.8263f, 0.8272f, 0.828f, 0.8289f, 0.8298f, + 0.8306f, 0.8315f, 0.8323f, 0.8332f, 0.834f, 0.8349f, 0.8357f, 0.8365f, 0.8374f, 0.8382f, + 0.8391f, 0.8399f, 0.8407f, 0.8416f, 0.8424f, 0.8432f, 0.844f, 0.8449f, 0.8457f, 0.8465f, + 0.8473f, 0.8481f, 0.8489f, 0.8497f, 0.8505f, 0.8514f, 0.8522f, 0.853f, 0.8538f, 0.8546f, + 0.8554f, 0.8561f, 0.8569f, 0.8577f, 0.8585f, 0.8593f, 0.8601f, 0.8609f, 0.8616f, 0.8624f, + 0.8632f, 0.864f, 0.8647f, 0.8655f, 0.8663f, 0.867f, 0.8678f, 0.8686f, 0.8693f, 0.8701f, + 0.8708f, 0.8716f, 0.8723f, 0.8731f, 0.8738f, 0.8746f, 0.8753f, 0.8761f, 0.8768f, 0.8775f, + 0.8783f, 0.879f, 0.8797f, 0.8805f, 0.8812f, 0.8819f, 0.8826f, 0.8834f, 0.8841f, 0.8848f, + 0.8855f, 0.8862f, 0.8869f, 0.8876f, 0.8883f, 0.889f, 0.8897f, 0.8904f, 0.8911f, 0.8918f, + 0.8925f, 0.8932f, 0.8939f, 0.8946f, 0.8953f, 0.896f, 0.8966f, 0.8973f, 0.898f, 0.8987f, + 0.8993f, 0.9f, 0.9007f, 0.9013f, 0.902f, 0.9027f, 0.9033f, 0.904f, 0.9046f, 0.9053f, + 0.9059f, 0.9066f, 0.9072f, 0.9079f, 0.9085f, 0.9092f, 0.9098f, 0.9104f, 0.9111f, 0.9117f, + 0.9123f, 0.913f, 0.9136f, 0.9142f, 0.9148f, 0.9154f, 0.9161f, 0.9167f, 0.9173f, 0.9179f, + 0.9185f, 0.9191f, 0.9197f, 0.9203f, 0.9209f, 0.9215f, 0.9221f, 0.9227f, 0.9233f, 0.9239f, + 0.9245f, 0.925f, 0.9256f, 0.9262f, 0.9268f, 0.9274f, 0.9279f, 0.9285f, 0.9291f, 0.9296f, + 0.9302f, 0.9308f, 0.9313f, 0.9319f, 0.9324f, 0.933f, 0.9335f, 0.9341f, 0.9346f, 0.9352f, + 0.9357f, 0.9363f, 0.9368f, 0.9373f, 0.9379f, 0.9384f, 0.9389f, 0.9395f, 0.94f, 0.9405f, + 0.941f, 0.9415f, 0.9421f, 0.9426f, 0.9431f, 0.9436f, 0.9441f, 0.9446f, 0.9451f, 0.9456f, + 0.9461f, 0.9466f, 0.9471f, 0.9476f, 0.9481f, 0.9486f, 0.949f, 0.9495f, 0.95f, 0.9505f, + 0.951f, 0.9514f, 0.9519f, 0.9524f, 0.9528f, 0.9533f, 0.9538f, 0.9542f, 0.9547f, 0.9551f, + 0.9556f, 0.956f, 0.9565f, 0.9569f, 0.9574f, 0.9578f, 0.9583f, 0.9587f, 0.9591f, 0.9596f, + 0.96f, 0.9604f, 0.9609f, 0.9613f, 0.9617f, 0.9621f, 0.9625f, 0.963f, 0.9634f, 0.9638f, + 0.9642f, 0.9646f, 0.965f, 0.9654f, 0.9658f, 0.9662f, 0.9666f, 0.967f, 0.9674f, 0.9678f, + 0.9681f, 0.9685f, 0.9689f, 0.9693f, 0.9697f, 0.97f, 0.9704f, 0.9708f, 0.9711f, 0.9715f, + 0.9719f, 0.9722f, 0.9726f, 0.9729f, 0.9733f, 0.9736f, 0.974f, 0.9743f, 0.9747f, 0.975f, + 0.9754f, 0.9757f, 0.976f, 0.9764f, 0.9767f, 0.977f, 0.9774f, 0.9777f, 0.978f, 0.9783f, + 0.9786f, 0.9789f, 0.9793f, 0.9796f, 0.9799f, 0.9802f, 0.9805f, 0.9808f, 0.9811f, 0.9814f, + 0.9817f, 0.982f, 0.9823f, 0.9825f, 0.9828f, 0.9831f, 0.9834f, 0.9837f, 0.9839f, 0.9842f, + 0.9845f, 0.9847f, 0.985f, 0.9853f, 0.9855f, 0.9858f, 0.9861f, 0.9863f, 0.9866f, 0.9868f, + 0.9871f, 0.9873f, 0.9875f, 0.9878f, 0.988f, 0.9883f, 0.9885f, 0.9887f, 0.989f, 0.9892f, + 0.9894f, 0.9896f, 0.9898f, 0.9901f, 0.9903f, 0.9905f, 0.9907f, 0.9909f, 0.9911f, 0.9913f, + 0.9915f, 0.9917f, 0.9919f, 0.9921f, 0.9923f, 0.9925f, 0.9927f, 0.9929f, 0.993f, 0.9932f, + 0.9934f, 0.9936f, 0.9937f, 0.9939f, 0.9941f, 0.9942f, 0.9944f, 0.9946f, 0.9947f, 0.9949f, + 0.995f, 0.9952f, 0.9953f, 0.9955f, 0.9956f, 0.9958f, 0.9959f, 0.996f, 0.9962f, 0.9963f, + 0.9964f, 0.9966f, 0.9967f, 0.9968f, 0.9969f, 0.9971f, 0.9972f, 0.9973f, 0.9974f, 0.9975f, + 0.9976f, 0.9977f, 0.9978f, 0.9979f, 0.998f, 0.9981f, 0.9982f, 0.9983f, 0.9984f, 0.9985f, + 0.9986f, 0.9986f, 0.9987f, 0.9988f, 0.9989f, 0.9989f, 0.999f, 0.9991f, 0.9991f, 0.9992f, + 0.9993f, 0.9993f, 0.9994f, 0.9994f, 0.9995f, 0.9995f, 0.9996f, 0.9996f, 0.9997f, 0.9997f, + 0.9997f, 0.9998f, 0.9998f, 0.9998f, 0.9999f, 0.9999f, 0.9999f, 0.9999f, 0.9999f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}; - const static float cosvals[max] = { - 1, 1, 1, 1, 1, 1, 0.9999, 0.9999, 0.9999, 0.9999, - 0.9999, 0.9998, 0.9998, 0.9998, 0.9997, 0.9997, 0.9997, 0.9996, 0.9996, 0.9995, - 0.9995, 0.9994, 0.9994, 0.9993, 0.9993, 0.9992, 0.9991, 0.9991, 0.999, 0.9989, - 0.9989, 0.9988, 0.9987, 0.9986, 0.9986, 0.9985, 0.9984, 0.9983, 0.9982, 0.9981, - 0.998, 0.9979, 0.9978, 0.9977, 0.9976, 0.9975, 0.9974, 0.9973, 0.9972, 0.9971, - 0.9969, 0.9968, 0.9967, 0.9966, 0.9964, 0.9963, 0.9962, 0.996, 0.9959, 0.9958, - 0.9956, 0.9955, 0.9953, 0.9952, 0.995, 0.9949, 0.9947, 0.9946, 0.9944, 0.9942, - 0.9941, 0.9939, 0.9937, 0.9936, 0.9934, 0.9932, 0.993, 0.9929, 0.9927, 0.9925, - 0.9923, 0.9921, 0.9919, 0.9917, 0.9915, 0.9913, 0.9911, 0.9909, 0.9907, 0.9905, - 0.9903, 0.9901, 0.9898, 0.9896, 0.9894, 0.9892, 0.989, 0.9887, 0.9885, 0.9883, - 0.988, 0.9878, 0.9875, 0.9873, 0.9871, 0.9868, 0.9866, 0.9863, 0.9861, 0.9858, - 0.9855, 0.9853, 0.985, 0.9847, 0.9845, 0.9842, 0.9839, 0.9837, 0.9834, 0.9831, - 0.9828, 0.9825, 0.9823, 0.982, 0.9817, 0.9814, 0.9811, 0.9808, 0.9805, 0.9802, - 0.9799, 0.9796, 0.9793, 0.9789, 0.9786, 0.9783, 0.978, 0.9777, 0.9774, 0.977, - 0.9767, 0.9764, 0.976, 0.9757, 0.9754, 0.975, 0.9747, 0.9743, 0.974, 0.9736, - 0.9733, 0.9729, 0.9726, 0.9722, 0.9719, 0.9715, 0.9711, 0.9708, 0.9704, 0.97, - 0.9697, 0.9693, 0.9689, 0.9685, 0.9681, 0.9678, 0.9674, 0.967, 0.9666, 0.9662, - 0.9658, 0.9654, 0.965, 0.9646, 0.9642, 0.9638, 0.9634, 0.963, 0.9625, 0.9621, - 0.9617, 0.9613, 0.9609, 0.9604, 0.96, 0.9596, 0.9591, 0.9587, 0.9583, 0.9578, - 0.9574, 0.9569, 0.9565, 0.956, 0.9556, 0.9551, 0.9547, 0.9542, 0.9538, 0.9533, - 0.9528, 0.9524, 0.9519, 0.9514, 0.951, 0.9505, 0.95, 0.9495, 0.949, 0.9486, - 0.9481, 0.9476, 0.9471, 0.9466, 0.9461, 0.9456, 0.9451, 0.9446, 0.9441, 0.9436, - 0.9431, 0.9426, 0.9421, 0.9415, 0.941, 0.9405, 0.94, 0.9395, 0.9389, 0.9384, - 0.9379, 0.9373, 0.9368, 0.9363, 0.9357, 0.9352, 0.9346, 0.9341, 0.9335, 0.933, - 0.9324, 0.9319, 0.9313, 0.9308, 0.9302, 0.9296, 0.9291, 0.9285, 0.9279, 0.9274, - 0.9268, 0.9262, 0.9256, 0.925, 0.9245, 0.9239, 0.9233, 0.9227, 0.9221, 0.9215, - 0.9209, 0.9203, 0.9197, 0.9191, 0.9185, 0.9179, 0.9173, 0.9167, 0.9161, 0.9154, - 0.9148, 0.9142, 0.9136, 0.913, 0.9123, 0.9117, 0.9111, 0.9104, 0.9098, 0.9092, - 0.9085, 0.9079, 0.9072, 0.9066, 0.9059, 0.9053, 0.9046, 0.904, 0.9033, 0.9027, - 0.902, 0.9013, 0.9007, 0.9, 0.8993, 0.8987, 0.898, 0.8973, 0.8966, 0.896, - 0.8953, 0.8946, 0.8939, 0.8932, 0.8925, 0.8918, 0.8911, 0.8904, 0.8897, 0.889, - 0.8883, 0.8876, 0.8869, 0.8862, 0.8855, 0.8848, 0.8841, 0.8834, 0.8826, 0.8819, - 0.8812, 0.8805, 0.8797, 0.879, 0.8783, 0.8775, 0.8768, 0.8761, 0.8753, 0.8746, - 0.8738, 0.8731, 0.8723, 0.8716, 0.8708, 0.8701, 0.8693, 0.8686, 0.8678, 0.867, - 0.8663, 0.8655, 0.8647, 0.864, 0.8632, 0.8624, 0.8616, 0.8609, 0.8601, 0.8593, - 0.8585, 0.8577, 0.8569, 0.8561, 0.8554, 0.8546, 0.8538, 0.853, 0.8522, 0.8514, - 0.8505, 0.8497, 0.8489, 0.8481, 0.8473, 0.8465, 0.8457, 0.8449, 0.844, 0.8432, - 0.8424, 0.8416, 0.8407, 0.8399, 0.8391, 0.8382, 0.8374, 0.8365, 0.8357, 0.8349, - 0.834, 0.8332, 0.8323, 0.8315, 0.8306, 0.8298, 0.8289, 0.828, 0.8272, 0.8263, - 0.8255, 0.8246, 0.8237, 0.8228, 0.822, 0.8211, 0.8202, 0.8193, 0.8185, 0.8176, - 0.8167, 0.8158, 0.8149, 0.814, 0.8131, 0.8123, 0.8114, 0.8105, 0.8096, 0.8087, - 0.8078, 0.8068, 0.8059, 0.805, 0.8041, 0.8032, 0.8023, 0.8014, 0.8005, 0.7995, - 0.7986, 0.7977, 0.7968, 0.7958, 0.7949, 0.794, 0.793, 0.7921, 0.7912, 0.7902, - 0.7893, 0.7883, 0.7874, 0.7865, 0.7855, 0.7846, 0.7836, 0.7827, 0.7817, 0.7807, - 0.7798, 0.7788, 0.7779, 0.7769, 0.7759, 0.775, 0.774, 0.773, 0.772, 0.7711, - 0.7701, 0.7691, 0.7681, 0.7671, 0.7662, 0.7652, 0.7642, 0.7632, 0.7622, 0.7612, - 0.7602, 0.7592, 0.7582, 0.7572, 0.7562, 0.7552, 0.7542, 0.7532, 0.7522, 0.7512, - 0.7502, 0.7491, 0.7481, 0.7471, 0.7461, 0.7451, 0.744, 0.743, 0.742, 0.741, - 0.7399, 0.7389, 0.7379, 0.7368, 0.7358, 0.7347, 0.7337, 0.7327, 0.7316, 0.7306, - 0.7295, 0.7285, 0.7274, 0.7264, 0.7253, 0.7242, 0.7232, 0.7221, 0.7211, 0.72, - 0.7189, 0.7179, 0.7168, 0.7157, 0.7147, 0.7136, 0.7125, 0.7114, 0.7104, 0.7093, - 0.7082, 0.7071, 0.706, 0.7049, 0.7038, 0.7028, 0.7017, 0.7006, 0.6995, 0.6984, - 0.6973, 0.6962, 0.6951, 0.694, 0.6929, 0.6918, 0.6907, 0.6895, 0.6884, 0.6873, - 0.6862, 0.6851, 0.684, 0.6828, 0.6817, 0.6806, 0.6795, 0.6784, 0.6772, 0.6761, - 0.675, 0.6738, 0.6727, 0.6716, 0.6704, 0.6693, 0.6681, 0.667, 0.6659, 0.6647, - 0.6636, 0.6624, 0.6613, 0.6601, 0.659, 0.6578, 0.6567, 0.6555, 0.6543, 0.6532, - 0.652, 0.6508, 0.6497, 0.6485, 0.6473, 0.6462, 0.645, 0.6438, 0.6427, 0.6415, - 0.6403, 0.6391, 0.6379, 0.6368, 0.6356, 0.6344, 0.6332, 0.632, 0.6308, 0.6296, - 0.6284, 0.6273, 0.6261, 0.6249, 0.6237, 0.6225, 0.6213, 0.6201, 0.6189, 0.6176, - 0.6164, 0.6152, 0.614, 0.6128, 0.6116, 0.6104, 0.6092, 0.6079, 0.6067, 0.6055, - 0.6043, 0.6031, 0.6018, 0.6006, 0.5994, 0.5982, 0.5969, 0.5957, 0.5945, 0.5932, - 0.592, 0.5908, 0.5895, 0.5883, 0.587, 0.5858, 0.5846, 0.5833, 0.5821, 0.5808, - 0.5796, 0.5783, 0.5771, 0.5758, 0.5746, 0.5733, 0.572, 0.5708, 0.5695, 0.5683, - 0.567, 0.5657, 0.5645, 0.5632, 0.5619, 0.5607, 0.5594, 0.5581, 0.5568, 0.5556, - 0.5543, 0.553, 0.5517, 0.5505, 0.5492, 0.5479, 0.5466, 0.5453, 0.544, 0.5428, - 0.5415, 0.5402, 0.5389, 0.5376, 0.5363, 0.535, 0.5337, 0.5324, 0.5311, 0.5298, - 0.5285, 0.5272, 0.5259, 0.5246, 0.5233, 0.522, 0.5207, 0.5194, 0.518, 0.5167, - 0.5154, 0.5141, 0.5128, 0.5115, 0.5102, 0.5088, 0.5075, 0.5062, 0.5049, 0.5035, - 0.5022, 0.5009, 0.4996, 0.4982, 0.4969, 0.4956, 0.4942, 0.4929, 0.4916, 0.4902, - 0.4889, 0.4876, 0.4862, 0.4849, 0.4835, 0.4822, 0.4808, 0.4795, 0.4781, 0.4768, - 0.4755, 0.4741, 0.4727, 0.4714, 0.47, 0.4687, 0.4673, 0.466, 0.4646, 0.4633, - 0.4619, 0.4605, 0.4592, 0.4578, 0.4564, 0.4551, 0.4537, 0.4523, 0.451, 0.4496, - 0.4482, 0.4469, 0.4455, 0.4441, 0.4427, 0.4414, 0.44, 0.4386, 0.4372, 0.4359, - 0.4345, 0.4331, 0.4317, 0.4303, 0.4289, 0.4276, 0.4262, 0.4248, 0.4234, 0.422, - 0.4206, 0.4192, 0.4178, 0.4164, 0.415, 0.4136, 0.4122, 0.4108, 0.4094, 0.408, - 0.4066, 0.4052, 0.4038, 0.4024, 0.401, 0.3996, 0.3982, 0.3968, 0.3954, 0.394, - 0.3926, 0.3912, 0.3898, 0.3883, 0.3869, 0.3855, 0.3841, 0.3827, 0.3813, 0.3798, - 0.3784, 0.377, 0.3756, 0.3742, 0.3727, 0.3713, 0.3699, 0.3685, 0.367, 0.3656, - 0.3642, 0.3628, 0.3613, 0.3599, 0.3585, 0.357, 0.3556, 0.3542, 0.3527, 0.3513, - 0.3499, 0.3484, 0.347, 0.3455, 0.3441, 0.3427, 0.3412, 0.3398, 0.3383, 0.3369, - 0.3354, 0.334, 0.3326, 0.3311, 0.3297, 0.3282, 0.3268, 0.3253, 0.3239, 0.3224, - 0.321, 0.3195, 0.318, 0.3166, 0.3151, 0.3137, 0.3122, 0.3108, 0.3093, 0.3078, - 0.3064, 0.3049, 0.3035, 0.302, 0.3005, 0.2991, 0.2976, 0.2962, 0.2947, 0.2932, - 0.2918, 0.2903, 0.2888, 0.2873, 0.2859, 0.2844, 0.2829, 0.2815, 0.28, 0.2785, - 0.277, 0.2756, 0.2741, 0.2726, 0.2711, 0.2697, 0.2682, 0.2667, 0.2652, 0.2638, - 0.2623, 0.2608, 0.2593, 0.2578, 0.2563, 0.2549, 0.2534, 0.2519, 0.2504, 0.2489, - 0.2474, 0.246, 0.2445, 0.243, 0.2415, 0.24, 0.2385, 0.237, 0.2355, 0.234, - 0.2326, 0.2311, 0.2296, 0.2281, 0.2266, 0.2251, 0.2236, 0.2221, 0.2206, 0.2191, - 0.2176, 0.2161, 0.2146, 0.2131, 0.2116, 0.2101, 0.2086, 0.2071, 0.2056, 0.2041, - 0.2026, 0.2011, 0.1996, 0.1981, 0.1966, 0.1951, 0.1936, 0.1921, 0.1906, 0.1891, - 0.1876, 0.1861, 0.1845, 0.183, 0.1815, 0.18, 0.1785, 0.177, 0.1755, 0.174, - 0.1725, 0.171, 0.1695, 0.1679, 0.1664, 0.1649, 0.1634, 0.1619, 0.1604, 0.1589, - 0.1573, 0.1558, 0.1543, 0.1528, 0.1513, 0.1498, 0.1482, 0.1467, 0.1452, 0.1437, - 0.1422, 0.1407, 0.1391, 0.1376, 0.1361, 0.1346, 0.1331, 0.1315, 0.13, 0.1285, - 0.127, 0.1255, 0.1239, 0.1224, 0.1209, 0.1194, 0.1178, 0.1163, 0.1148, 0.1133, - 0.1117, 0.1102, 0.1087, 0.1072, 0.1056, 0.1041, 0.1026, 0.1011, 0.09954, 0.09802, - 0.09649, 0.09496, 0.09344, 0.09191, 0.09038, 0.08885, 0.08733, 0.0858, 0.08427, 0.08274, - 0.08121, 0.07968, 0.07815, 0.07662, 0.07509, 0.07356, 0.07203, 0.0705, 0.06897, 0.06744, - 0.06591, 0.06438, 0.06285, 0.06132, 0.05979, 0.05826, 0.05673, 0.0552, 0.05366, 0.05213, - 0.0506, 0.04907, 0.04754, 0.046, 0.04447, 0.04294, 0.04141, 0.03987, 0.03834, 0.03681, - 0.03527, 0.03374, 0.03221, 0.03067, 0.02914, 0.02761, 0.02607, 0.02454, 0.02301, 0.02147, - 0.01994, 0.01841, 0.01687, 0.01534, 0.01381, 0.01227, 0.01074, 0.009204, 0.00767, 0.006136, - 0.004602, 0.003068, 0.001534, 6.123e-17, -0.001534, -0.003068, -0.004602, -0.006136, -0.00767, -0.009204, - -0.01074, -0.01227, -0.01381, -0.01534, -0.01687, -0.01841, -0.01994, -0.02147, -0.02301, -0.02454, - -0.02607, -0.02761, -0.02914, -0.03067, -0.03221, -0.03374, -0.03527, -0.03681, -0.03834, -0.03987, - -0.04141, -0.04294, -0.04447, -0.046, -0.04754, -0.04907, -0.0506, -0.05213, -0.05366, -0.0552, - -0.05673, -0.05826, -0.05979, -0.06132, -0.06285, -0.06438, -0.06591, -0.06744, -0.06897, -0.0705, - -0.07203, -0.07356, -0.07509, -0.07662, -0.07815, -0.07968, -0.08121, -0.08274, -0.08427, -0.0858, - -0.08733, -0.08885, -0.09038, -0.09191, -0.09344, -0.09496, -0.09649, -0.09802, -0.09954, -0.1011, - -0.1026, -0.1041, -0.1056, -0.1072, -0.1087, -0.1102, -0.1117, -0.1133, -0.1148, -0.1163, - -0.1178, -0.1194, -0.1209, -0.1224, -0.1239, -0.1255, -0.127, -0.1285, -0.13, -0.1315, - -0.1331, -0.1346, -0.1361, -0.1376, -0.1391, -0.1407, -0.1422, -0.1437, -0.1452, -0.1467, - -0.1482, -0.1498, -0.1513, -0.1528, -0.1543, -0.1558, -0.1573, -0.1589, -0.1604, -0.1619, - -0.1634, -0.1649, -0.1664, -0.1679, -0.1695, -0.171, -0.1725, -0.174, -0.1755, -0.177, - -0.1785, -0.18, -0.1815, -0.183, -0.1845, -0.1861, -0.1876, -0.1891, -0.1906, -0.1921, - -0.1936, -0.1951, -0.1966, -0.1981, -0.1996, -0.2011, -0.2026, -0.2041, -0.2056, -0.2071, - -0.2086, -0.2101, -0.2116, -0.2131, -0.2146, -0.2161, -0.2176, -0.2191, -0.2206, -0.2221, - -0.2236, -0.2251, -0.2266, -0.2281, -0.2296, -0.2311, -0.2326, -0.234, -0.2355, -0.237, - -0.2385, -0.24, -0.2415, -0.243, -0.2445, -0.246, -0.2474, -0.2489, -0.2504, -0.2519, - -0.2534, -0.2549, -0.2563, -0.2578, -0.2593, -0.2608, -0.2623, -0.2638, -0.2652, -0.2667, - -0.2682, -0.2697, -0.2711, -0.2726, -0.2741, -0.2756, -0.277, -0.2785, -0.28, -0.2815, - -0.2829, -0.2844, -0.2859, -0.2873, -0.2888, -0.2903, -0.2918, -0.2932, -0.2947, -0.2962, - -0.2976, -0.2991, -0.3005, -0.302, -0.3035, -0.3049, -0.3064, -0.3078, -0.3093, -0.3108, - -0.3122, -0.3137, -0.3151, -0.3166, -0.318, -0.3195, -0.321, -0.3224, -0.3239, -0.3253, - -0.3268, -0.3282, -0.3297, -0.3311, -0.3326, -0.334, -0.3354, -0.3369, -0.3383, -0.3398, - -0.3412, -0.3427, -0.3441, -0.3455, -0.347, -0.3484, -0.3499, -0.3513, -0.3527, -0.3542, - -0.3556, -0.357, -0.3585, -0.3599, -0.3613, -0.3628, -0.3642, -0.3656, -0.367, -0.3685, - -0.3699, -0.3713, -0.3727, -0.3742, -0.3756, -0.377, -0.3784, -0.3798, -0.3813, -0.3827, - -0.3841, -0.3855, -0.3869, -0.3883, -0.3898, -0.3912, -0.3926, -0.394, -0.3954, -0.3968, - -0.3982, -0.3996, -0.401, -0.4024, -0.4038, -0.4052, -0.4066, -0.408, -0.4094, -0.4108, - -0.4122, -0.4136, -0.415, -0.4164, -0.4178, -0.4192, -0.4206, -0.422, -0.4234, -0.4248, - -0.4262, -0.4276, -0.4289, -0.4303, -0.4317, -0.4331, -0.4345, -0.4359, -0.4372, -0.4386, - -0.44, -0.4414, -0.4427, -0.4441, -0.4455, -0.4469, -0.4482, -0.4496, -0.451, -0.4523, - -0.4537, -0.4551, -0.4564, -0.4578, -0.4592, -0.4605, -0.4619, -0.4633, -0.4646, -0.466, - -0.4673, -0.4687, -0.47, -0.4714, -0.4727, -0.4741, -0.4755, -0.4768, -0.4781, -0.4795, - -0.4808, -0.4822, -0.4835, -0.4849, -0.4862, -0.4876, -0.4889, -0.4902, -0.4916, -0.4929, - -0.4942, -0.4956, -0.4969, -0.4982, -0.4996, -0.5009, -0.5022, -0.5035, -0.5049, -0.5062, - -0.5075, -0.5088, -0.5102, -0.5115, -0.5128, -0.5141, -0.5154, -0.5167, -0.518, -0.5194, - -0.5207, -0.522, -0.5233, -0.5246, -0.5259, -0.5272, -0.5285, -0.5298, -0.5311, -0.5324, - -0.5337, -0.535, -0.5363, -0.5376, -0.5389, -0.5402, -0.5415, -0.5428, -0.544, -0.5453, - -0.5466, -0.5479, -0.5492, -0.5505, -0.5517, -0.553, -0.5543, -0.5556, -0.5568, -0.5581, - -0.5594, -0.5607, -0.5619, -0.5632, -0.5645, -0.5657, -0.567, -0.5683, -0.5695, -0.5708, - -0.572, -0.5733, -0.5746, -0.5758, -0.5771, -0.5783, -0.5796, -0.5808, -0.5821, -0.5833, - -0.5846, -0.5858, -0.587, -0.5883, -0.5895, -0.5908, -0.592, -0.5932, -0.5945, -0.5957, - -0.5969, -0.5982, -0.5994, -0.6006, -0.6018, -0.6031, -0.6043, -0.6055, -0.6067, -0.6079, - -0.6092, -0.6104, -0.6116, -0.6128, -0.614, -0.6152, -0.6164, -0.6176, -0.6189, -0.6201, - -0.6213, -0.6225, -0.6237, -0.6249, -0.6261, -0.6273, -0.6284, -0.6296, -0.6308, -0.632, - -0.6332, -0.6344, -0.6356, -0.6368, -0.6379, -0.6391, -0.6403, -0.6415, -0.6427, -0.6438, - -0.645, -0.6462, -0.6473, -0.6485, -0.6497, -0.6508, -0.652, -0.6532, -0.6543, -0.6555, - -0.6567, -0.6578, -0.659, -0.6601, -0.6613, -0.6624, -0.6636, -0.6647, -0.6659, -0.667, - -0.6681, -0.6693, -0.6704, -0.6716, -0.6727, -0.6738, -0.675, -0.6761, -0.6772, -0.6784, - -0.6795, -0.6806, -0.6817, -0.6828, -0.684, -0.6851, -0.6862, -0.6873, -0.6884, -0.6895, - -0.6907, -0.6918, -0.6929, -0.694, -0.6951, -0.6962, -0.6973, -0.6984, -0.6995, -0.7006, - -0.7017, -0.7028, -0.7038, -0.7049, -0.706, -0.7071, -0.7082, -0.7093, -0.7104, -0.7114, - -0.7125, -0.7136, -0.7147, -0.7157, -0.7168, -0.7179, -0.7189, -0.72, -0.7211, -0.7221, - -0.7232, -0.7242, -0.7253, -0.7264, -0.7274, -0.7285, -0.7295, -0.7306, -0.7316, -0.7327, - -0.7337, -0.7347, -0.7358, -0.7368, -0.7379, -0.7389, -0.7399, -0.741, -0.742, -0.743, - -0.744, -0.7451, -0.7461, -0.7471, -0.7481, -0.7491, -0.7502, -0.7512, -0.7522, -0.7532, - -0.7542, -0.7552, -0.7562, -0.7572, -0.7582, -0.7592, -0.7602, -0.7612, -0.7622, -0.7632, - -0.7642, -0.7652, -0.7662, -0.7671, -0.7681, -0.7691, -0.7701, -0.7711, -0.772, -0.773, - -0.774, -0.775, -0.7759, -0.7769, -0.7779, -0.7788, -0.7798, -0.7807, -0.7817, -0.7827, - -0.7836, -0.7846, -0.7855, -0.7865, -0.7874, -0.7883, -0.7893, -0.7902, -0.7912, -0.7921, - -0.793, -0.794, -0.7949, -0.7958, -0.7968, -0.7977, -0.7986, -0.7995, -0.8005, -0.8014, - -0.8023, -0.8032, -0.8041, -0.805, -0.8059, -0.8068, -0.8078, -0.8087, -0.8096, -0.8105, - -0.8114, -0.8123, -0.8131, -0.814, -0.8149, -0.8158, -0.8167, -0.8176, -0.8185, -0.8193, - -0.8202, -0.8211, -0.822, -0.8228, -0.8237, -0.8246, -0.8255, -0.8263, -0.8272, -0.828, - -0.8289, -0.8298, -0.8306, -0.8315, -0.8323, -0.8332, -0.834, -0.8349, -0.8357, -0.8365, - -0.8374, -0.8382, -0.8391, -0.8399, -0.8407, -0.8416, -0.8424, -0.8432, -0.844, -0.8449, - -0.8457, -0.8465, -0.8473, -0.8481, -0.8489, -0.8497, -0.8505, -0.8514, -0.8522, -0.853, - -0.8538, -0.8546, -0.8554, -0.8561, -0.8569, -0.8577, -0.8585, -0.8593, -0.8601, -0.8609, - -0.8616, -0.8624, -0.8632, -0.864, -0.8647, -0.8655, -0.8663, -0.867, -0.8678, -0.8686, - -0.8693, -0.8701, -0.8708, -0.8716, -0.8723, -0.8731, -0.8738, -0.8746, -0.8753, -0.8761, - -0.8768, -0.8775, -0.8783, -0.879, -0.8797, -0.8805, -0.8812, -0.8819, -0.8826, -0.8834, - -0.8841, -0.8848, -0.8855, -0.8862, -0.8869, -0.8876, -0.8883, -0.889, -0.8897, -0.8904, - -0.8911, -0.8918, -0.8925, -0.8932, -0.8939, -0.8946, -0.8953, -0.896, -0.8966, -0.8973, - -0.898, -0.8987, -0.8993, -0.9, -0.9007, -0.9013, -0.902, -0.9027, -0.9033, -0.904, - -0.9046, -0.9053, -0.9059, -0.9066, -0.9072, -0.9079, -0.9085, -0.9092, -0.9098, -0.9104, - -0.9111, -0.9117, -0.9123, -0.913, -0.9136, -0.9142, -0.9148, -0.9154, -0.9161, -0.9167, - -0.9173, -0.9179, -0.9185, -0.9191, -0.9197, -0.9203, -0.9209, -0.9215, -0.9221, -0.9227, - -0.9233, -0.9239, -0.9245, -0.925, -0.9256, -0.9262, -0.9268, -0.9274, -0.9279, -0.9285, - -0.9291, -0.9296, -0.9302, -0.9308, -0.9313, -0.9319, -0.9324, -0.933, -0.9335, -0.9341, - -0.9346, -0.9352, -0.9357, -0.9363, -0.9368, -0.9373, -0.9379, -0.9384, -0.9389, -0.9395, - -0.94, -0.9405, -0.941, -0.9415, -0.9421, -0.9426, -0.9431, -0.9436, -0.9441, -0.9446, - -0.9451, -0.9456, -0.9461, -0.9466, -0.9471, -0.9476, -0.9481, -0.9486, -0.949, -0.9495, - -0.95, -0.9505, -0.951, -0.9514, -0.9519, -0.9524, -0.9528, -0.9533, -0.9538, -0.9542, - -0.9547, -0.9551, -0.9556, -0.956, -0.9565, -0.9569, -0.9574, -0.9578, -0.9583, -0.9587, - -0.9591, -0.9596, -0.96, -0.9604, -0.9609, -0.9613, -0.9617, -0.9621, -0.9625, -0.963, - -0.9634, -0.9638, -0.9642, -0.9646, -0.965, -0.9654, -0.9658, -0.9662, -0.9666, -0.967, - -0.9674, -0.9678, -0.9681, -0.9685, -0.9689, -0.9693, -0.9697, -0.97, -0.9704, -0.9708, - -0.9711, -0.9715, -0.9719, -0.9722, -0.9726, -0.9729, -0.9733, -0.9736, -0.974, -0.9743, - -0.9747, -0.975, -0.9754, -0.9757, -0.976, -0.9764, -0.9767, -0.977, -0.9774, -0.9777, - -0.978, -0.9783, -0.9786, -0.9789, -0.9793, -0.9796, -0.9799, -0.9802, -0.9805, -0.9808, - -0.9811, -0.9814, -0.9817, -0.982, -0.9823, -0.9825, -0.9828, -0.9831, -0.9834, -0.9837, - -0.9839, -0.9842, -0.9845, -0.9847, -0.985, -0.9853, -0.9855, -0.9858, -0.9861, -0.9863, - -0.9866, -0.9868, -0.9871, -0.9873, -0.9875, -0.9878, -0.988, -0.9883, -0.9885, -0.9887, - -0.989, -0.9892, -0.9894, -0.9896, -0.9898, -0.9901, -0.9903, -0.9905, -0.9907, -0.9909, - -0.9911, -0.9913, -0.9915, -0.9917, -0.9919, -0.9921, -0.9923, -0.9925, -0.9927, -0.9929, - -0.993, -0.9932, -0.9934, -0.9936, -0.9937, -0.9939, -0.9941, -0.9942, -0.9944, -0.9946, - -0.9947, -0.9949, -0.995, -0.9952, -0.9953, -0.9955, -0.9956, -0.9958, -0.9959, -0.996, - -0.9962, -0.9963, -0.9964, -0.9966, -0.9967, -0.9968, -0.9969, -0.9971, -0.9972, -0.9973, - -0.9974, -0.9975, -0.9976, -0.9977, -0.9978, -0.9979, -0.998, -0.9981, -0.9982, -0.9983, - -0.9984, -0.9985, -0.9986, -0.9986, -0.9987, -0.9988, -0.9989, -0.9989, -0.999, -0.9991, - -0.9991, -0.9992, -0.9993, -0.9993, -0.9994, -0.9994, -0.9995, -0.9995, -0.9996, -0.9996, - -0.9997, -0.9997, -0.9997, -0.9998, -0.9998, -0.9998, -0.9999, -0.9999, -0.9999, -0.9999, - -0.9999, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -0.9999, -0.9999, -0.9999, -0.9999, -0.9999, -0.9998, - -0.9998, -0.9998, -0.9997, -0.9997, -0.9997, -0.9996, -0.9996, -0.9995, -0.9995, -0.9994, - -0.9994, -0.9993, -0.9993, -0.9992, -0.9991, -0.9991, -0.999, -0.9989, -0.9989, -0.9988, - -0.9987, -0.9986, -0.9986, -0.9985, -0.9984, -0.9983, -0.9982, -0.9981, -0.998, -0.9979, - -0.9978, -0.9977, -0.9976, -0.9975, -0.9974, -0.9973, -0.9972, -0.9971, -0.9969, -0.9968, - -0.9967, -0.9966, -0.9964, -0.9963, -0.9962, -0.996, -0.9959, -0.9958, -0.9956, -0.9955, - -0.9953, -0.9952, -0.995, -0.9949, -0.9947, -0.9946, -0.9944, -0.9942, -0.9941, -0.9939, - -0.9937, -0.9936, -0.9934, -0.9932, -0.993, -0.9929, -0.9927, -0.9925, -0.9923, -0.9921, - -0.9919, -0.9917, -0.9915, -0.9913, -0.9911, -0.9909, -0.9907, -0.9905, -0.9903, -0.9901, - -0.9898, -0.9896, -0.9894, -0.9892, -0.989, -0.9887, -0.9885, -0.9883, -0.988, -0.9878, - -0.9875, -0.9873, -0.9871, -0.9868, -0.9866, -0.9863, -0.9861, -0.9858, -0.9855, -0.9853, - -0.985, -0.9847, -0.9845, -0.9842, -0.9839, -0.9837, -0.9834, -0.9831, -0.9828, -0.9825, - -0.9823, -0.982, -0.9817, -0.9814, -0.9811, -0.9808, -0.9805, -0.9802, -0.9799, -0.9796, - -0.9793, -0.9789, -0.9786, -0.9783, -0.978, -0.9777, -0.9774, -0.977, -0.9767, -0.9764, - -0.976, -0.9757, -0.9754, -0.975, -0.9747, -0.9743, -0.974, -0.9736, -0.9733, -0.9729, - -0.9726, -0.9722, -0.9719, -0.9715, -0.9711, -0.9708, -0.9704, -0.97, -0.9697, -0.9693, - -0.9689, -0.9685, -0.9681, -0.9678, -0.9674, -0.967, -0.9666, -0.9662, -0.9658, -0.9654, - -0.965, -0.9646, -0.9642, -0.9638, -0.9634, -0.963, -0.9625, -0.9621, -0.9617, -0.9613, - -0.9609, -0.9604, -0.96, -0.9596, -0.9591, -0.9587, -0.9583, -0.9578, -0.9574, -0.9569, - -0.9565, -0.956, -0.9556, -0.9551, -0.9547, -0.9542, -0.9538, -0.9533, -0.9528, -0.9524, - -0.9519, -0.9514, -0.951, -0.9505, -0.95, -0.9495, -0.949, -0.9486, -0.9481, -0.9476, - -0.9471, -0.9466, -0.9461, -0.9456, -0.9451, -0.9446, -0.9441, -0.9436, -0.9431, -0.9426, - -0.9421, -0.9415, -0.941, -0.9405, -0.94, -0.9395, -0.9389, -0.9384, -0.9379, -0.9373, - -0.9368, -0.9363, -0.9357, -0.9352, -0.9346, -0.9341, -0.9335, -0.933, -0.9324, -0.9319, - -0.9313, -0.9308, -0.9302, -0.9296, -0.9291, -0.9285, -0.9279, -0.9274, -0.9268, -0.9262, - -0.9256, -0.925, -0.9245, -0.9239, -0.9233, -0.9227, -0.9221, -0.9215, -0.9209, -0.9203, - -0.9197, -0.9191, -0.9185, -0.9179, -0.9173, -0.9167, -0.9161, -0.9154, -0.9148, -0.9142, - -0.9136, -0.913, -0.9123, -0.9117, -0.9111, -0.9104, -0.9098, -0.9092, -0.9085, -0.9079, - -0.9072, -0.9066, -0.9059, -0.9053, -0.9046, -0.904, -0.9033, -0.9027, -0.902, -0.9013, - -0.9007, -0.9, -0.8993, -0.8987, -0.898, -0.8973, -0.8966, -0.896, -0.8953, -0.8946, - -0.8939, -0.8932, -0.8925, -0.8918, -0.8911, -0.8904, -0.8897, -0.889, -0.8883, -0.8876, - -0.8869, -0.8862, -0.8855, -0.8848, -0.8841, -0.8834, -0.8826, -0.8819, -0.8812, -0.8805, - -0.8797, -0.879, -0.8783, -0.8775, -0.8768, -0.8761, -0.8753, -0.8746, -0.8738, -0.8731, - -0.8723, -0.8716, -0.8708, -0.8701, -0.8693, -0.8686, -0.8678, -0.867, -0.8663, -0.8655, - -0.8647, -0.864, -0.8632, -0.8624, -0.8616, -0.8609, -0.8601, -0.8593, -0.8585, -0.8577, - -0.8569, -0.8561, -0.8554, -0.8546, -0.8538, -0.853, -0.8522, -0.8514, -0.8505, -0.8497, - -0.8489, -0.8481, -0.8473, -0.8465, -0.8457, -0.8449, -0.844, -0.8432, -0.8424, -0.8416, - -0.8407, -0.8399, -0.8391, -0.8382, -0.8374, -0.8365, -0.8357, -0.8349, -0.834, -0.8332, - -0.8323, -0.8315, -0.8306, -0.8298, -0.8289, -0.828, -0.8272, -0.8263, -0.8255, -0.8246, - -0.8237, -0.8228, -0.822, -0.8211, -0.8202, -0.8193, -0.8185, -0.8176, -0.8167, -0.8158, - -0.8149, -0.814, -0.8131, -0.8123, -0.8114, -0.8105, -0.8096, -0.8087, -0.8078, -0.8068, - -0.8059, -0.805, -0.8041, -0.8032, -0.8023, -0.8014, -0.8005, -0.7995, -0.7986, -0.7977, - -0.7968, -0.7958, -0.7949, -0.794, -0.793, -0.7921, -0.7912, -0.7902, -0.7893, -0.7883, - -0.7874, -0.7865, -0.7855, -0.7846, -0.7836, -0.7827, -0.7817, -0.7807, -0.7798, -0.7788, - -0.7779, -0.7769, -0.7759, -0.775, -0.774, -0.773, -0.772, -0.7711, -0.7701, -0.7691, - -0.7681, -0.7671, -0.7662, -0.7652, -0.7642, -0.7632, -0.7622, -0.7612, -0.7602, -0.7592, - -0.7582, -0.7572, -0.7562, -0.7552, -0.7542, -0.7532, -0.7522, -0.7512, -0.7502, -0.7491, - -0.7481, -0.7471, -0.7461, -0.7451, -0.744, -0.743, -0.742, -0.741, -0.7399, -0.7389, - -0.7379, -0.7368, -0.7358, -0.7347, -0.7337, -0.7327, -0.7316, -0.7306, -0.7295, -0.7285, - -0.7274, -0.7264, -0.7253, -0.7242, -0.7232, -0.7221, -0.7211, -0.72, -0.7189, -0.7179, - -0.7168, -0.7157, -0.7147, -0.7136, -0.7125, -0.7114, -0.7104, -0.7093, -0.7082, -0.7071, - -0.706, -0.7049, -0.7038, -0.7028, -0.7017, -0.7006, -0.6995, -0.6984, -0.6973, -0.6962, - -0.6951, -0.694, -0.6929, -0.6918, -0.6907, -0.6895, -0.6884, -0.6873, -0.6862, -0.6851, - -0.684, -0.6828, -0.6817, -0.6806, -0.6795, -0.6784, -0.6772, -0.6761, -0.675, -0.6738, - -0.6727, -0.6716, -0.6704, -0.6693, -0.6681, -0.667, -0.6659, -0.6647, -0.6636, -0.6624, - -0.6613, -0.6601, -0.659, -0.6578, -0.6567, -0.6555, -0.6543, -0.6532, -0.652, -0.6508, - -0.6497, -0.6485, -0.6473, -0.6462, -0.645, -0.6438, -0.6427, -0.6415, -0.6403, -0.6391, - -0.6379, -0.6368, -0.6356, -0.6344, -0.6332, -0.632, -0.6308, -0.6296, -0.6284, -0.6273, - -0.6261, -0.6249, -0.6237, -0.6225, -0.6213, -0.6201, -0.6189, -0.6176, -0.6164, -0.6152, - -0.614, -0.6128, -0.6116, -0.6104, -0.6092, -0.6079, -0.6067, -0.6055, -0.6043, -0.6031, - -0.6018, -0.6006, -0.5994, -0.5982, -0.5969, -0.5957, -0.5945, -0.5932, -0.592, -0.5908, - -0.5895, -0.5883, -0.587, -0.5858, -0.5846, -0.5833, -0.5821, -0.5808, -0.5796, -0.5783, - -0.5771, -0.5758, -0.5746, -0.5733, -0.572, -0.5708, -0.5695, -0.5683, -0.567, -0.5657, - -0.5645, -0.5632, -0.5619, -0.5607, -0.5594, -0.5581, -0.5568, -0.5556, -0.5543, -0.553, - -0.5517, -0.5505, -0.5492, -0.5479, -0.5466, -0.5453, -0.544, -0.5428, -0.5415, -0.5402, - -0.5389, -0.5376, -0.5363, -0.535, -0.5337, -0.5324, -0.5311, -0.5298, -0.5285, -0.5272, - -0.5259, -0.5246, -0.5233, -0.522, -0.5207, -0.5194, -0.518, -0.5167, -0.5154, -0.5141, - -0.5128, -0.5115, -0.5102, -0.5088, -0.5075, -0.5062, -0.5049, -0.5035, -0.5022, -0.5009, - -0.4996, -0.4982, -0.4969, -0.4956, -0.4942, -0.4929, -0.4916, -0.4902, -0.4889, -0.4876, - -0.4862, -0.4849, -0.4835, -0.4822, -0.4808, -0.4795, -0.4781, -0.4768, -0.4755, -0.4741, - -0.4727, -0.4714, -0.47, -0.4687, -0.4673, -0.466, -0.4646, -0.4633, -0.4619, -0.4605, - -0.4592, -0.4578, -0.4564, -0.4551, -0.4537, -0.4523, -0.451, -0.4496, -0.4482, -0.4469, - -0.4455, -0.4441, -0.4427, -0.4414, -0.44, -0.4386, -0.4372, -0.4359, -0.4345, -0.4331, - -0.4317, -0.4303, -0.4289, -0.4276, -0.4262, -0.4248, -0.4234, -0.422, -0.4206, -0.4192, - -0.4178, -0.4164, -0.415, -0.4136, -0.4122, -0.4108, -0.4094, -0.408, -0.4066, -0.4052, - -0.4038, -0.4024, -0.401, -0.3996, -0.3982, -0.3968, -0.3954, -0.394, -0.3926, -0.3912, - -0.3898, -0.3883, -0.3869, -0.3855, -0.3841, -0.3827, -0.3813, -0.3798, -0.3784, -0.377, - -0.3756, -0.3742, -0.3727, -0.3713, -0.3699, -0.3685, -0.367, -0.3656, -0.3642, -0.3628, - -0.3613, -0.3599, -0.3585, -0.357, -0.3556, -0.3542, -0.3527, -0.3513, -0.3499, -0.3484, - -0.347, -0.3455, -0.3441, -0.3427, -0.3412, -0.3398, -0.3383, -0.3369, -0.3354, -0.334, - -0.3326, -0.3311, -0.3297, -0.3282, -0.3268, -0.3253, -0.3239, -0.3224, -0.321, -0.3195, - -0.318, -0.3166, -0.3151, -0.3137, -0.3122, -0.3108, -0.3093, -0.3078, -0.3064, -0.3049, - -0.3035, -0.302, -0.3005, -0.2991, -0.2976, -0.2962, -0.2947, -0.2932, -0.2918, -0.2903, - -0.2888, -0.2873, -0.2859, -0.2844, -0.2829, -0.2815, -0.28, -0.2785, -0.277, -0.2756, - -0.2741, -0.2726, -0.2711, -0.2697, -0.2682, -0.2667, -0.2652, -0.2638, -0.2623, -0.2608, - -0.2593, -0.2578, -0.2563, -0.2549, -0.2534, -0.2519, -0.2504, -0.2489, -0.2474, -0.246, - -0.2445, -0.243, -0.2415, -0.24, -0.2385, -0.237, -0.2355, -0.234, -0.2326, -0.2311, - -0.2296, -0.2281, -0.2266, -0.2251, -0.2236, -0.2221, -0.2206, -0.2191, -0.2176, -0.2161, - -0.2146, -0.2131, -0.2116, -0.2101, -0.2086, -0.2071, -0.2056, -0.2041, -0.2026, -0.2011, - -0.1996, -0.1981, -0.1966, -0.1951, -0.1936, -0.1921, -0.1906, -0.1891, -0.1876, -0.1861, - -0.1845, -0.183, -0.1815, -0.18, -0.1785, -0.177, -0.1755, -0.174, -0.1725, -0.171, - -0.1695, -0.1679, -0.1664, -0.1649, -0.1634, -0.1619, -0.1604, -0.1589, -0.1573, -0.1558, - -0.1543, -0.1528, -0.1513, -0.1498, -0.1482, -0.1467, -0.1452, -0.1437, -0.1422, -0.1407, - -0.1391, -0.1376, -0.1361, -0.1346, -0.1331, -0.1315, -0.13, -0.1285, -0.127, -0.1255, - -0.1239, -0.1224, -0.1209, -0.1194, -0.1178, -0.1163, -0.1148, -0.1133, -0.1117, -0.1102, - -0.1087, -0.1072, -0.1056, -0.1041, -0.1026, -0.1011, -0.09954, -0.09802, -0.09649, -0.09496, - -0.09344, -0.09191, -0.09038, -0.08885, -0.08733, -0.0858, -0.08427, -0.08274, -0.08121, -0.07968, - -0.07815, -0.07662, -0.07509, -0.07356, -0.07203, -0.0705, -0.06897, -0.06744, -0.06591, -0.06438, - -0.06285, -0.06132, -0.05979, -0.05826, -0.05673, -0.0552, -0.05366, -0.05213, -0.0506, -0.04907, - -0.04754, -0.046, -0.04447, -0.04294, -0.04141, -0.03987, -0.03834, -0.03681, -0.03527, -0.03374, - -0.03221, -0.03067, -0.02914, -0.02761, -0.02607, -0.02454, -0.02301, -0.02147, -0.01994, -0.01841, - -0.01687, -0.01534, -0.01381, -0.01227, -0.01074, -0.009204, -0.00767, -0.006136, -0.004602, -0.003068, - -0.001534, -1.837e-16, 0.001534, 0.003068, 0.004602, 0.006136, 0.00767, 0.009204, 0.01074, 0.01227, - 0.01381, 0.01534, 0.01687, 0.01841, 0.01994, 0.02147, 0.02301, 0.02454, 0.02607, 0.02761, - 0.02914, 0.03067, 0.03221, 0.03374, 0.03527, 0.03681, 0.03834, 0.03987, 0.04141, 0.04294, - 0.04447, 0.046, 0.04754, 0.04907, 0.0506, 0.05213, 0.05366, 0.0552, 0.05673, 0.05826, - 0.05979, 0.06132, 0.06285, 0.06438, 0.06591, 0.06744, 0.06897, 0.0705, 0.07203, 0.07356, - 0.07509, 0.07662, 0.07815, 0.07968, 0.08121, 0.08274, 0.08427, 0.0858, 0.08733, 0.08885, - 0.09038, 0.09191, 0.09344, 0.09496, 0.09649, 0.09802, 0.09954, 0.1011, 0.1026, 0.1041, - 0.1056, 0.1072, 0.1087, 0.1102, 0.1117, 0.1133, 0.1148, 0.1163, 0.1178, 0.1194, - 0.1209, 0.1224, 0.1239, 0.1255, 0.127, 0.1285, 0.13, 0.1315, 0.1331, 0.1346, - 0.1361, 0.1376, 0.1391, 0.1407, 0.1422, 0.1437, 0.1452, 0.1467, 0.1482, 0.1498, - 0.1513, 0.1528, 0.1543, 0.1558, 0.1573, 0.1589, 0.1604, 0.1619, 0.1634, 0.1649, - 0.1664, 0.1679, 0.1695, 0.171, 0.1725, 0.174, 0.1755, 0.177, 0.1785, 0.18, - 0.1815, 0.183, 0.1845, 0.1861, 0.1876, 0.1891, 0.1906, 0.1921, 0.1936, 0.1951, - 0.1966, 0.1981, 0.1996, 0.2011, 0.2026, 0.2041, 0.2056, 0.2071, 0.2086, 0.2101, - 0.2116, 0.2131, 0.2146, 0.2161, 0.2176, 0.2191, 0.2206, 0.2221, 0.2236, 0.2251, - 0.2266, 0.2281, 0.2296, 0.2311, 0.2326, 0.234, 0.2355, 0.237, 0.2385, 0.24, - 0.2415, 0.243, 0.2445, 0.246, 0.2474, 0.2489, 0.2504, 0.2519, 0.2534, 0.2549, - 0.2563, 0.2578, 0.2593, 0.2608, 0.2623, 0.2638, 0.2652, 0.2667, 0.2682, 0.2697, - 0.2711, 0.2726, 0.2741, 0.2756, 0.277, 0.2785, 0.28, 0.2815, 0.2829, 0.2844, - 0.2859, 0.2873, 0.2888, 0.2903, 0.2918, 0.2932, 0.2947, 0.2962, 0.2976, 0.2991, - 0.3005, 0.302, 0.3035, 0.3049, 0.3064, 0.3078, 0.3093, 0.3108, 0.3122, 0.3137, - 0.3151, 0.3166, 0.318, 0.3195, 0.321, 0.3224, 0.3239, 0.3253, 0.3268, 0.3282, - 0.3297, 0.3311, 0.3326, 0.334, 0.3354, 0.3369, 0.3383, 0.3398, 0.3412, 0.3427, - 0.3441, 0.3455, 0.347, 0.3484, 0.3499, 0.3513, 0.3527, 0.3542, 0.3556, 0.357, - 0.3585, 0.3599, 0.3613, 0.3628, 0.3642, 0.3656, 0.367, 0.3685, 0.3699, 0.3713, - 0.3727, 0.3742, 0.3756, 0.377, 0.3784, 0.3798, 0.3813, 0.3827, 0.3841, 0.3855, - 0.3869, 0.3883, 0.3898, 0.3912, 0.3926, 0.394, 0.3954, 0.3968, 0.3982, 0.3996, - 0.401, 0.4024, 0.4038, 0.4052, 0.4066, 0.408, 0.4094, 0.4108, 0.4122, 0.4136, - 0.415, 0.4164, 0.4178, 0.4192, 0.4206, 0.422, 0.4234, 0.4248, 0.4262, 0.4276, - 0.4289, 0.4303, 0.4317, 0.4331, 0.4345, 0.4359, 0.4372, 0.4386, 0.44, 0.4414, - 0.4427, 0.4441, 0.4455, 0.4469, 0.4482, 0.4496, 0.451, 0.4523, 0.4537, 0.4551, - 0.4564, 0.4578, 0.4592, 0.4605, 0.4619, 0.4633, 0.4646, 0.466, 0.4673, 0.4687, - 0.47, 0.4714, 0.4727, 0.4741, 0.4755, 0.4768, 0.4781, 0.4795, 0.4808, 0.4822, - 0.4835, 0.4849, 0.4862, 0.4876, 0.4889, 0.4902, 0.4916, 0.4929, 0.4942, 0.4956, - 0.4969, 0.4982, 0.4996, 0.5009, 0.5022, 0.5035, 0.5049, 0.5062, 0.5075, 0.5088, - 0.5102, 0.5115, 0.5128, 0.5141, 0.5154, 0.5167, 0.518, 0.5194, 0.5207, 0.522, - 0.5233, 0.5246, 0.5259, 0.5272, 0.5285, 0.5298, 0.5311, 0.5324, 0.5337, 0.535, - 0.5363, 0.5376, 0.5389, 0.5402, 0.5415, 0.5428, 0.544, 0.5453, 0.5466, 0.5479, - 0.5492, 0.5505, 0.5517, 0.553, 0.5543, 0.5556, 0.5568, 0.5581, 0.5594, 0.5607, - 0.5619, 0.5632, 0.5645, 0.5657, 0.567, 0.5683, 0.5695, 0.5708, 0.572, 0.5733, - 0.5746, 0.5758, 0.5771, 0.5783, 0.5796, 0.5808, 0.5821, 0.5833, 0.5846, 0.5858, - 0.587, 0.5883, 0.5895, 0.5908, 0.592, 0.5932, 0.5945, 0.5957, 0.5969, 0.5982, - 0.5994, 0.6006, 0.6018, 0.6031, 0.6043, 0.6055, 0.6067, 0.6079, 0.6092, 0.6104, - 0.6116, 0.6128, 0.614, 0.6152, 0.6164, 0.6176, 0.6189, 0.6201, 0.6213, 0.6225, - 0.6237, 0.6249, 0.6261, 0.6273, 0.6284, 0.6296, 0.6308, 0.632, 0.6332, 0.6344, - 0.6356, 0.6368, 0.6379, 0.6391, 0.6403, 0.6415, 0.6427, 0.6438, 0.645, 0.6462, - 0.6473, 0.6485, 0.6497, 0.6508, 0.652, 0.6532, 0.6543, 0.6555, 0.6567, 0.6578, - 0.659, 0.6601, 0.6613, 0.6624, 0.6636, 0.6647, 0.6659, 0.667, 0.6681, 0.6693, - 0.6704, 0.6716, 0.6727, 0.6738, 0.675, 0.6761, 0.6772, 0.6784, 0.6795, 0.6806, - 0.6817, 0.6828, 0.684, 0.6851, 0.6862, 0.6873, 0.6884, 0.6895, 0.6907, 0.6918, - 0.6929, 0.694, 0.6951, 0.6962, 0.6973, 0.6984, 0.6995, 0.7006, 0.7017, 0.7028, - 0.7038, 0.7049, 0.706, 0.7071, 0.7082, 0.7093, 0.7104, 0.7114, 0.7125, 0.7136, - 0.7147, 0.7157, 0.7168, 0.7179, 0.7189, 0.72, 0.7211, 0.7221, 0.7232, 0.7242, - 0.7253, 0.7264, 0.7274, 0.7285, 0.7295, 0.7306, 0.7316, 0.7327, 0.7337, 0.7347, - 0.7358, 0.7368, 0.7379, 0.7389, 0.7399, 0.741, 0.742, 0.743, 0.744, 0.7451, - 0.7461, 0.7471, 0.7481, 0.7491, 0.7502, 0.7512, 0.7522, 0.7532, 0.7542, 0.7552, - 0.7562, 0.7572, 0.7582, 0.7592, 0.7602, 0.7612, 0.7622, 0.7632, 0.7642, 0.7652, - 0.7662, 0.7671, 0.7681, 0.7691, 0.7701, 0.7711, 0.772, 0.773, 0.774, 0.775, - 0.7759, 0.7769, 0.7779, 0.7788, 0.7798, 0.7807, 0.7817, 0.7827, 0.7836, 0.7846, - 0.7855, 0.7865, 0.7874, 0.7883, 0.7893, 0.7902, 0.7912, 0.7921, 0.793, 0.794, - 0.7949, 0.7958, 0.7968, 0.7977, 0.7986, 0.7995, 0.8005, 0.8014, 0.8023, 0.8032, - 0.8041, 0.805, 0.8059, 0.8068, 0.8078, 0.8087, 0.8096, 0.8105, 0.8114, 0.8123, - 0.8131, 0.814, 0.8149, 0.8158, 0.8167, 0.8176, 0.8185, 0.8193, 0.8202, 0.8211, - 0.822, 0.8228, 0.8237, 0.8246, 0.8255, 0.8263, 0.8272, 0.828, 0.8289, 0.8298, - 0.8306, 0.8315, 0.8323, 0.8332, 0.834, 0.8349, 0.8357, 0.8365, 0.8374, 0.8382, - 0.8391, 0.8399, 0.8407, 0.8416, 0.8424, 0.8432, 0.844, 0.8449, 0.8457, 0.8465, - 0.8473, 0.8481, 0.8489, 0.8497, 0.8505, 0.8514, 0.8522, 0.853, 0.8538, 0.8546, - 0.8554, 0.8561, 0.8569, 0.8577, 0.8585, 0.8593, 0.8601, 0.8609, 0.8616, 0.8624, - 0.8632, 0.864, 0.8647, 0.8655, 0.8663, 0.867, 0.8678, 0.8686, 0.8693, 0.8701, - 0.8708, 0.8716, 0.8723, 0.8731, 0.8738, 0.8746, 0.8753, 0.8761, 0.8768, 0.8775, - 0.8783, 0.879, 0.8797, 0.8805, 0.8812, 0.8819, 0.8826, 0.8834, 0.8841, 0.8848, - 0.8855, 0.8862, 0.8869, 0.8876, 0.8883, 0.889, 0.8897, 0.8904, 0.8911, 0.8918, - 0.8925, 0.8932, 0.8939, 0.8946, 0.8953, 0.896, 0.8966, 0.8973, 0.898, 0.8987, - 0.8993, 0.9, 0.9007, 0.9013, 0.902, 0.9027, 0.9033, 0.904, 0.9046, 0.9053, - 0.9059, 0.9066, 0.9072, 0.9079, 0.9085, 0.9092, 0.9098, 0.9104, 0.9111, 0.9117, - 0.9123, 0.913, 0.9136, 0.9142, 0.9148, 0.9154, 0.9161, 0.9167, 0.9173, 0.9179, - 0.9185, 0.9191, 0.9197, 0.9203, 0.9209, 0.9215, 0.9221, 0.9227, 0.9233, 0.9239, - 0.9245, 0.925, 0.9256, 0.9262, 0.9268, 0.9274, 0.9279, 0.9285, 0.9291, 0.9296, - 0.9302, 0.9308, 0.9313, 0.9319, 0.9324, 0.933, 0.9335, 0.9341, 0.9346, 0.9352, - 0.9357, 0.9363, 0.9368, 0.9373, 0.9379, 0.9384, 0.9389, 0.9395, 0.94, 0.9405, - 0.941, 0.9415, 0.9421, 0.9426, 0.9431, 0.9436, 0.9441, 0.9446, 0.9451, 0.9456, - 0.9461, 0.9466, 0.9471, 0.9476, 0.9481, 0.9486, 0.949, 0.9495, 0.95, 0.9505, - 0.951, 0.9514, 0.9519, 0.9524, 0.9528, 0.9533, 0.9538, 0.9542, 0.9547, 0.9551, - 0.9556, 0.956, 0.9565, 0.9569, 0.9574, 0.9578, 0.9583, 0.9587, 0.9591, 0.9596, - 0.96, 0.9604, 0.9609, 0.9613, 0.9617, 0.9621, 0.9625, 0.963, 0.9634, 0.9638, - 0.9642, 0.9646, 0.965, 0.9654, 0.9658, 0.9662, 0.9666, 0.967, 0.9674, 0.9678, - 0.9681, 0.9685, 0.9689, 0.9693, 0.9697, 0.97, 0.9704, 0.9708, 0.9711, 0.9715, - 0.9719, 0.9722, 0.9726, 0.9729, 0.9733, 0.9736, 0.974, 0.9743, 0.9747, 0.975, - 0.9754, 0.9757, 0.976, 0.9764, 0.9767, 0.977, 0.9774, 0.9777, 0.978, 0.9783, - 0.9786, 0.9789, 0.9793, 0.9796, 0.9799, 0.9802, 0.9805, 0.9808, 0.9811, 0.9814, - 0.9817, 0.982, 0.9823, 0.9825, 0.9828, 0.9831, 0.9834, 0.9837, 0.9839, 0.9842, - 0.9845, 0.9847, 0.985, 0.9853, 0.9855, 0.9858, 0.9861, 0.9863, 0.9866, 0.9868, - 0.9871, 0.9873, 0.9875, 0.9878, 0.988, 0.9883, 0.9885, 0.9887, 0.989, 0.9892, - 0.9894, 0.9896, 0.9898, 0.9901, 0.9903, 0.9905, 0.9907, 0.9909, 0.9911, 0.9913, - 0.9915, 0.9917, 0.9919, 0.9921, 0.9923, 0.9925, 0.9927, 0.9929, 0.993, 0.9932, - 0.9934, 0.9936, 0.9937, 0.9939, 0.9941, 0.9942, 0.9944, 0.9946, 0.9947, 0.9949, - 0.995, 0.9952, 0.9953, 0.9955, 0.9956, 0.9958, 0.9959, 0.996, 0.9962, 0.9963, - 0.9964, 0.9966, 0.9967, 0.9968, 0.9969, 0.9971, 0.9972, 0.9973, 0.9974, 0.9975, - 0.9976, 0.9977, 0.9978, 0.9979, 0.998, 0.9981, 0.9982, 0.9983, 0.9984, 0.9985, - 0.9986, 0.9986, 0.9987, 0.9988, 0.9989, 0.9989, 0.999, 0.9991, 0.9991, 0.9992, - 0.9993, 0.9993, 0.9994, 0.9994, 0.9995, 0.9995, 0.9996, 0.9996, 0.9997, 0.9997, - 0.9997, 0.9998, 0.9998, 0.9998, 0.9999, 0.9999, 0.9999, 0.9999, 0.9999, 1, - 1, 1, 1, 1, 1, 1}; - - const static uint64 mask = max-1; + const static uint64 mask = max-1; return logvals[h.first&mask]*cosvals[h.second&mask]; // Note that we are just using the Box–Muller transform to compute the result. In diff --git a/lib/3rdParty/dlib/include/dlib/matrix/matrix.h b/lib/3rdParty/dlib/include/dlib/matrix/matrix.h index 7908d9ba..6fd3a7c4 100644 --- a/lib/3rdParty/dlib/include/dlib/matrix/matrix.h +++ b/lib/3rdParty/dlib/include/dlib/matrix/matrix.h @@ -1595,9 +1595,10 @@ namespace dlib explicit literal_assign_helper(matrix* m_): m(m_), r(0), c(0),has_been_used(false) {next();} ~literal_assign_helper() { - DLIB_CASSERT(!has_been_used || r == m->nr(), - "You have used the matrix comma based assignment incorrectly by failing to\n" - "supply a full set of values for every element of a matrix object.\n"); + assert(!has_been_used || r == m->nr()); + //DLIB_CASSERT(!has_been_used || r == m->nr(), + // "You have used the matrix comma based assignment incorrectly by failing to\n" + // "supply a full set of values for every element of a matrix object.\n"); } const literal_assign_helper& operator, ( diff --git a/lib/3rdParty/dlib/include/dlib/opencv/cv_image.h b/lib/3rdParty/dlib/include/dlib/opencv/cv_image.h index 3d8ef882..632dae07 100644 --- a/lib/3rdParty/dlib/include/dlib/opencv/cv_image.h +++ b/lib/3rdParty/dlib/include/dlib/opencv/cv_image.h @@ -23,9 +23,11 @@ namespace dlib cv_image (const cv::Mat img) { - DLIB_CASSERT(img.depth() == cv::DataType::basic_pixel_type>::depth && - img.channels() == pixel_traits::num, - "The pixel type you gave doesn't match pixel used by the open cv Mat object."); + assert(img.depth() == cv::DataType::basic_pixel_type>::depth && + img.channels() == pixel_traits::num); + //DLIB_CASSERT(img.depth() == cv::DataType::basic_pixel_type>::depth && + // img.channels() == pixel_traits::num, + // "The pixel type you gave doesn't match pixel used by the open cv Mat object."); IplImage temp = img; init(&temp); } diff --git a/lib/local/CppInerop/LandmarkDetectorInterop.h b/lib/local/CppInerop/LandmarkDetectorInterop.h index ea12dc1d..8f7487b5 100644 --- a/lib/local/CppInerop/LandmarkDetectorInterop.h +++ b/lib/local/CppInerop/LandmarkDetectorInterop.h @@ -319,11 +319,11 @@ namespace CppInterop { cv::Vec6d pose = ::LandmarkDetector::GetCorrectedPoseWorld(*clnf, fx,fy, cx, cy); - vector> vecLines = ::LandmarkDetector::CalculateBox(pose, fx, fy, cx, cy); + vector> vecLines = ::LandmarkDetector::CalculateBox(pose, fx, fy, cx, cy); auto lines = gcnew System::Collections::Generic::List^>(); - for(pair line : vecLines) { + for(pair line : vecLines) { lines->Add(gcnew System::Tuple(System::Windows::Point(line.first.x, line.first.y), System::Windows::Point(line.second.x, line.second.y))); } diff --git a/lib/local/FaceAnalyser/AU_predictors/AU_all_best.txt b/lib/local/FaceAnalyser/AU_predictors/AU_all_best.txt index 20f275b7..d944851d 100644 --- a/lib/local/FaceAnalyser/AU_predictors/AU_all_best.txt +++ b/lib/local/FaceAnalyser/AU_predictors/AU_all_best.txt @@ -1,20 +1,35 @@ -svr_disfa/AU_1_static.dat AU01 -svr_disfa/AU_2_dyn.dat AU02 -svr_disfa/AU_4_static.dat AU04 -svm_combined/AU_4_dynamic_combined_all.dat AU04 -svr_disfa/AU_5_dyn.dat AU05 -svr_combined/AU_6_static_intensity_combined.dat AU06 -svr_disfa/AU_9_dyn.dat AU09 -svr_bp4d/AU_10_static_intensity.dat AU10 -svm_combined/AU_12_static_combined_all.dat AU12 -svr_combined/AU_12_static_intensity_combined.dat AU12 -svr_bp4d/AU_14_static_intensity.dat AU14 -svr_disfa/AU_15_dyn.dat AU15 -svm_combined/AU_15_dynamic_combined_all.dat AU15 -svr_combined/AU_17_static_intensity_combined.dat AU17 -svr_disfa/AU_20_dyn.dat AU20 -svm_bp4d/AU_23_static.dat AU23 -svr_disfa/AU_25_static.dat AU25 -svr_disfa/AU_26_dyn.dat AU26 -svm_semaine/AU_28_static.dat AU28 -svm_semaine/AU_45_dynamic.dat AU45 \ No newline at end of file +svm_combined/AU_1_dynamic.dat AU01 +svm_combined/AU_2_dynamic.dat AU02 +svm_combined/AU_4_static.dat AU04 +svm_combined/AU_5_static.dat AU05 +svm_combined/AU_6_static.dat AU06 +svm_combined/AU_7_static.dat AU07 +svm_combined/AU_9_dynamic.dat AU09 +svm_combined/AU_10_static.dat AU10 +svm_combined/AU_12_static.dat AU12 +svm_combined/AU_14_static.dat AU14 +svm_combined/AU_15_dynamic.dat AU15 +svm_combined/AU_17_dynamic.dat AU17 +svm_combined/AU_20_dynamic.dat AU20 +svm_combined/AU_23_static.dat AU23 +svm_combined/AU_25_dynamic.dat AU25 +svm_combined/AU_26_dynamic.dat AU26 +svm_combined/AU_28_static.dat AU28 +svm_combined/AU_45_dynamic.dat AU45 +svr_combined/AU_1_dynamic_intensity_comb.dat AU01 +svr_combined/AU_2_dynamic_intensity_comb.dat AU02 +svr_combined/AU_4_static_intensity_comb.dat AU04 +svr_combined/AU_5_dynamic_intensity.dat AU05 +svr_combined/AU_6_static_intensity_comb.dat AU06 +svr_combined/AU_7_static_intensity_comb.dat AU07 +svr_combined/AU_9_dynamic_intensity.dat AU09 +svr_combined/AU_10_static_intensity_comb.dat AU10 +svr_combined/AU_12_static_intensity_comb.dat AU12 +svr_combined/AU_14_static_intensity.dat AU14 +svr_combined/AU_15_dynamic_intensity_comb.dat AU15 +svr_combined/AU_17_dynamic_intensity_comb.dat AU17 +svr_combined/AU_20_dynamic_intensity.dat AU20 +svr_combined/AU_23_dynamic_intensity_comb.dat AU23 +svr_combined/AU_25_dynamic_intensity_comb.dat AU25 +svr_combined/AU_26_dynamic_intensity_comb.dat AU26 +svr_combined/AU_45_dynamic_intensity_comb.dat AU45 \ No newline at end of file diff --git a/lib/local/FaceAnalyser/AU_predictors/AU_all_static.txt b/lib/local/FaceAnalyser/AU_predictors/AU_all_static.txt index 97f1ffb5..41e696b4 100644 --- a/lib/local/FaceAnalyser/AU_predictors/AU_all_static.txt +++ b/lib/local/FaceAnalyser/AU_predictors/AU_all_static.txt @@ -1,23 +1,35 @@ -svr_disfa/AU_1_static.dat AU01 -svr_disfa/AU_2_static.dat AU02 -svr_disfa/AU_4_static.dat AU04 -svm_combined/AU_4_static_combined_all.dat AU04 -svr_disfa/AU_5_static.dat AU05 -svr_combined/AU_6_static_intensity_combined.dat AU06 -svm_bp4d/AU_7_static.dat AU07 -svr_disfa/AU_9_static.dat AU09 -svr_bp4d/AU_10_static_intensity.dat AU10 -svm_combined/AU_12_static_combined_all.dat AU12 -svr_combined/AU_12_static_intensity_combined.dat AU12 -svr_bp4d/AU_14_static_intensity.dat AU14 -svr_disfa/AU_15_static.dat AU15 -svm_combined/AU_15_static_combined_all.dat AU15 -svr_combined/AU_17_static_intensity_combined.dat AU17 -svm_combined/AU_17_static_combined_all.dat AU17 -svr_disfa/AU_20_static.dat AU20 -svm_bp4d/AU_23_static.dat AU23 -svr_disfa/AU_25_static.dat AU25 -svm_combined/AU_25_static_combined_all.dat AU25 -svr_disfa/AU_26_static.dat AU26 -svm_semaine/AU_28_static.dat AU28 -svm_semaine/AU_45_static.dat AU45 \ No newline at end of file +svm_combined/AU_1_static.dat AU01 +svm_combined/AU_2_static.dat AU02 +svm_combined/AU_4_static.dat AU04 +svm_combined/AU_5_static.dat AU05 +svm_combined/AU_6_static.dat AU06 +svm_combined/AU_7_static.dat AU07 +svm_combined/AU_9_static.dat AU09 +svm_combined/AU_10_static.dat AU10 +svm_combined/AU_12_static.dat AU12 +svm_combined/AU_14_static.dat AU14 +svm_combined/AU_15_static.dat AU15 +svm_combined/AU_17_static.dat AU17 +svm_combined/AU_20_static.dat AU20 +svm_combined/AU_23_static.dat AU23 +svm_combined/AU_25_static.dat AU25 +svm_combined/AU_26_static.dat AU26 +svm_combined/AU_28_static.dat AU28 +svm_combined/AU_45_static.dat AU45 +svr_combined/AU_1_static_intensity.dat AU01 +svr_combined/AU_2_static_intensity_comb.dat AU02 +svr_combined/AU_4_static_intensity_comb.dat AU04 +svr_combined/AU_5_static_intensity.dat AU05 +svr_combined/AU_6_static_intensity_comb.dat AU06 +svr_combined/AU_7_static_intensity_comb.dat AU07 +svr_combined/AU_9_static_intensity.dat AU09 +svr_combined/AU_10_static_intensity_comb.dat AU10 +svr_combined/AU_12_static_intensity_comb.dat AU12 +svr_combined/AU_14_static_intensity.dat AU14 +svr_combined/AU_15_static_intensity_comb.dat AU15 +svr_combined/AU_17_static_intensity_comb.dat AU17 +svr_combined/AU_20_static_intensity.dat AU20 +svr_combined/AU_23_static_intensity_comb.dat AU23 +svr_combined/AU_25_static_intensity.dat AU25 +svr_combined/AU_26_static_intensity_comb.dat AU26 +svr_combined/AU_45_static_intensity_comb.dat AU45 \ No newline at end of file diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_bp4d/AU_23_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_bp4d/AU_23_static.dat deleted file mode 100644 index 1caf6a08..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svm_bp4d/AU_23_static.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_bp4d/AU_7_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_bp4d/AU_7_static.dat deleted file mode 100644 index 25d01370..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svm_bp4d/AU_7_static.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_10_dynamic.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_10_dynamic.dat new file mode 100644 index 00000000..169a5b8a Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_10_dynamic.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_10_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_10_static.dat new file mode 100644 index 00000000..149fcf35 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_10_static.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_12_dynamic.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_12_dynamic.dat new file mode 100644 index 00000000..2f36f6fd Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_12_dynamic.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_12_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_12_static.dat new file mode 100644 index 00000000..2b0c3ab5 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_12_static.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_12_static_combined_all.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_12_static_combined_all.dat deleted file mode 100644 index ad1b61b9..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_12_static_combined_all.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_14_dynamic.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_14_dynamic.dat new file mode 100644 index 00000000..c31894a1 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_14_dynamic.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_14_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_14_static.dat new file mode 100644 index 00000000..e067b63d Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_14_static.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_15_dynamic.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_15_dynamic.dat new file mode 100644 index 00000000..886c0d14 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_15_dynamic.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_15_dynamic_combined_all.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_15_dynamic_combined_all.dat deleted file mode 100644 index 2fe049b6..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_15_dynamic_combined_all.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_15_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_15_static.dat new file mode 100644 index 00000000..4e8c136f Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_15_static.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_15_static_combined_all.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_15_static_combined_all.dat deleted file mode 100644 index cbc2f54b..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_15_static_combined_all.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_17_dynamic.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_17_dynamic.dat new file mode 100644 index 00000000..8764e93d Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_17_dynamic.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_17_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_17_static.dat new file mode 100644 index 00000000..4a44b6b1 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_17_static.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_1_dynamic.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_1_dynamic.dat new file mode 100644 index 00000000..8da47385 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_1_dynamic.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_1_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_1_static.dat new file mode 100644 index 00000000..4a93caf7 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_1_static.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_1_static_combined_all.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_1_static_combined_all.dat deleted file mode 100644 index d8059353..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_1_static_combined_all.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_20_dynamic.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_20_dynamic.dat new file mode 100644 index 00000000..3b2eb5ae Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_20_dynamic.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_20_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_20_static.dat new file mode 100644 index 00000000..64f27b30 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_20_static.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_23_dynamic.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_23_dynamic.dat new file mode 100644 index 00000000..8c8f7c8a Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_23_dynamic.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_23_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_23_static.dat new file mode 100644 index 00000000..12ec7fde Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_23_static.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_25_dynamic.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_25_dynamic.dat new file mode 100644 index 00000000..ee7f6eea Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_25_dynamic.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_25_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_25_static.dat new file mode 100644 index 00000000..c0a3226b Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_25_static.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_25_static_combined_all.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_25_static_combined_all.dat deleted file mode 100644 index 0e978e3b..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_25_static_combined_all.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_26_dynamic.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_26_dynamic.dat new file mode 100644 index 00000000..2b04a5ae Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_26_dynamic.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_26_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_26_static.dat new file mode 100644 index 00000000..fbc41322 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_26_static.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_28_dynamic.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_28_dynamic.dat new file mode 100644 index 00000000..5f84b18b Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_28_dynamic.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_28_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_28_static.dat new file mode 100644 index 00000000..a9af4fdd Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_28_static.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_2_dynamic.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_2_dynamic.dat new file mode 100644 index 00000000..8f9cb984 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_2_dynamic.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_2_dynamic_combined_all.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_2_dynamic_combined_all.dat deleted file mode 100644 index dbba5872..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_2_dynamic_combined_all.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_2_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_2_static.dat new file mode 100644 index 00000000..288634e9 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_2_static.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_2_static_combined_all.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_2_static_combined_all.dat deleted file mode 100644 index 33a1af86..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_2_static_combined_all.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_45_dynamic.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_45_dynamic.dat new file mode 100644 index 00000000..b58b9277 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_45_dynamic.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_45_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_45_static.dat new file mode 100644 index 00000000..830aee7d Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_45_static.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_4_dynamic.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_4_dynamic.dat new file mode 100644 index 00000000..e56d1b20 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_4_dynamic.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_4_dynamic_combined_all.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_4_dynamic_combined_all.dat deleted file mode 100644 index 1fe42297..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_4_dynamic_combined_all.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_4_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_4_static.dat new file mode 100644 index 00000000..08e875a6 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_4_static.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_4_static_combined_all.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_4_static_combined_all.dat deleted file mode 100644 index 498d0344..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_4_static_combined_all.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_5_dynamic.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_5_dynamic.dat new file mode 100644 index 00000000..fc0beebb Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_5_dynamic.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_5_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_5_static.dat new file mode 100644 index 00000000..c6dd7e18 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_5_static.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_6_dynamic.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_6_dynamic.dat new file mode 100644 index 00000000..e5dd4469 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_6_dynamic.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_6_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_6_static.dat new file mode 100644 index 00000000..c53afee7 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_6_static.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_7_dynamic.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_7_dynamic.dat new file mode 100644 index 00000000..55ea2ee8 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_7_dynamic.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_7_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_7_static.dat new file mode 100644 index 00000000..ec665e2d Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_7_static.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_9_dynamic.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_9_dynamic.dat new file mode 100644 index 00000000..aa120df4 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_9_dynamic.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_9_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_9_static.dat new file mode 100644 index 00000000..0c460579 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svm_combined/AU_9_static.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_semaine/AU_28_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_semaine/AU_28_static.dat deleted file mode 100644 index 82ac113e..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svm_semaine/AU_28_static.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_semaine/AU_45_dynamic.dat b/lib/local/FaceAnalyser/AU_predictors/svm_semaine/AU_45_dynamic.dat deleted file mode 100644 index 285b9fea..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svm_semaine/AU_45_dynamic.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svm_semaine/AU_45_static.dat b/lib/local/FaceAnalyser/AU_predictors/svm_semaine/AU_45_static.dat deleted file mode 100644 index fb2198fd..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svm_semaine/AU_45_static.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_bp4d/AU_10_static_intensity.dat b/lib/local/FaceAnalyser/AU_predictors/svr_bp4d/AU_10_static_intensity.dat deleted file mode 100644 index 669ef764..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_bp4d/AU_10_static_intensity.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_bp4d/AU_14_static_intensity.dat b/lib/local/FaceAnalyser/AU_predictors/svr_bp4d/AU_14_static_intensity.dat deleted file mode 100644 index 93f010b9..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_bp4d/AU_14_static_intensity.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_10_static_intensity_comb.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_10_static_intensity_comb.dat new file mode 100644 index 00000000..624731e3 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_10_static_intensity_comb.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_12_static_intensity_comb.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_12_static_intensity_comb.dat new file mode 100644 index 00000000..406fd810 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_12_static_intensity_comb.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_12_static_intensity_combined.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_12_static_intensity_combined.dat deleted file mode 100644 index 1f4fcb45..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_12_static_intensity_combined.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_14_static_intensity.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_14_static_intensity.dat new file mode 100644 index 00000000..83c864ee Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_14_static_intensity.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_15_dynamic_intensity_comb.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_15_dynamic_intensity_comb.dat new file mode 100644 index 00000000..00f802cf Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_15_dynamic_intensity_comb.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_15_static_intensity_comb.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_15_static_intensity_comb.dat new file mode 100644 index 00000000..3a22f41a Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_15_static_intensity_comb.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_17_dynamic_intensity_comb.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_17_dynamic_intensity_comb.dat new file mode 100644 index 00000000..8e5c2389 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_17_dynamic_intensity_comb.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_17_static_intensity_comb.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_17_static_intensity_comb.dat new file mode 100644 index 00000000..109c7740 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_17_static_intensity_comb.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_17_static_intensity_combined.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_17_static_intensity_combined.dat deleted file mode 100644 index eb5dbccf..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_17_static_intensity_combined.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_1_dynamic_intensity_comb.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_1_dynamic_intensity_comb.dat new file mode 100644 index 00000000..db183754 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_1_dynamic_intensity_comb.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_1_static_intensity.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_1_static_intensity.dat new file mode 100644 index 00000000..065b1c52 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_1_static_intensity.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_20_dynamic_intensity.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_20_dynamic_intensity.dat new file mode 100644 index 00000000..554df8c7 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_20_dynamic_intensity.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_20_static_intensity.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_20_static_intensity.dat new file mode 100644 index 00000000..eb78b669 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_20_static_intensity.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_23_dynamic_intensity_comb.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_23_dynamic_intensity_comb.dat new file mode 100644 index 00000000..a6f437a7 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_23_dynamic_intensity_comb.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_23_static_intensity_comb.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_23_static_intensity_comb.dat new file mode 100644 index 00000000..bd03fe24 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_23_static_intensity_comb.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_25_dynamic_intensity_comb.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_25_dynamic_intensity_comb.dat new file mode 100644 index 00000000..f161ad8c Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_25_dynamic_intensity_comb.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_25_static_intensity.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_25_static_intensity.dat new file mode 100644 index 00000000..411670da Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_25_static_intensity.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_26_dynamic_intensity_comb.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_26_dynamic_intensity_comb.dat new file mode 100644 index 00000000..c5b2597e Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_26_dynamic_intensity_comb.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_26_static_intensity_comb.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_26_static_intensity_comb.dat new file mode 100644 index 00000000..3119305f Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_26_static_intensity_comb.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_2_dynamic_intensity_comb.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_2_dynamic_intensity_comb.dat new file mode 100644 index 00000000..89391784 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_2_dynamic_intensity_comb.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_2_static_intensity_comb.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_2_static_intensity_comb.dat new file mode 100644 index 00000000..12f7ce84 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_2_static_intensity_comb.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_45_dynamic_intensity_comb.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_45_dynamic_intensity_comb.dat new file mode 100644 index 00000000..2f6c0b54 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_45_dynamic_intensity_comb.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_45_static_intensity_comb.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_45_static_intensity_comb.dat new file mode 100644 index 00000000..28bce9a0 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_45_static_intensity_comb.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_4_static_intensity_comb.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_4_static_intensity_comb.dat new file mode 100644 index 00000000..8204a879 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_4_static_intensity_comb.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_5_dynamic_intensity.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_5_dynamic_intensity.dat new file mode 100644 index 00000000..14f43f53 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_5_dynamic_intensity.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_5_static_intensity.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_5_static_intensity.dat new file mode 100644 index 00000000..5c3481b5 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_5_static_intensity.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_6_static_intensity_comb.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_6_static_intensity_comb.dat new file mode 100644 index 00000000..69c3005d Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_6_static_intensity_comb.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_6_static_intensity_combined.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_6_static_intensity_combined.dat deleted file mode 100644 index 14c5e689..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_6_static_intensity_combined.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_7_static_intensity_comb.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_7_static_intensity_comb.dat new file mode 100644 index 00000000..04b4a112 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_7_static_intensity_comb.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_9_dynamic_intensity.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_9_dynamic_intensity.dat new file mode 100644 index 00000000..c809ddcd Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_9_dynamic_intensity.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_9_static_intensity.dat b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_9_static_intensity.dat new file mode 100644 index 00000000..7cdfc5d6 Binary files /dev/null and b/lib/local/FaceAnalyser/AU_predictors/svr_combined/AU_9_static_intensity.dat differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_15_dyn.dat b/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_15_dyn.dat deleted file mode 100644 index b7d06302..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_15_dyn.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_15_static.dat b/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_15_static.dat deleted file mode 100644 index 34b15dce..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_15_static.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_1_dyn.dat b/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_1_dyn.dat deleted file mode 100644 index a25f7925..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_1_dyn.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_1_static.dat b/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_1_static.dat deleted file mode 100644 index 203a3c23..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_1_static.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_20_dyn.dat b/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_20_dyn.dat deleted file mode 100644 index 864d4132..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_20_dyn.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_20_static.dat b/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_20_static.dat deleted file mode 100644 index 5bdd3fde..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_20_static.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_25_static.dat b/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_25_static.dat deleted file mode 100644 index 846e0a62..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_25_static.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_26_dyn.dat b/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_26_dyn.dat deleted file mode 100644 index 84b87191..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_26_dyn.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_26_static.dat b/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_26_static.dat deleted file mode 100644 index 4999b067..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_26_static.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_2_dyn.dat b/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_2_dyn.dat deleted file mode 100644 index 63a70690..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_2_dyn.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_2_static.dat b/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_2_static.dat deleted file mode 100644 index b64fccf3..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_2_static.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_4_static.dat b/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_4_static.dat deleted file mode 100644 index 40adfa95..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_4_static.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_5_dyn.dat b/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_5_dyn.dat deleted file mode 100644 index 407ea6ac..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_5_dyn.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_5_static.dat b/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_5_static.dat deleted file mode 100644 index d6f0290b..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_5_static.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_9_dyn.dat b/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_9_dyn.dat deleted file mode 100644 index 6ccf1429..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_9_dyn.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_9_static.dat b/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_9_static.dat deleted file mode 100644 index f2abf44d..00000000 Binary files a/lib/local/FaceAnalyser/AU_predictors/svr_disfa/AU_9_static.dat and /dev/null differ diff --git a/lib/local/FaceAnalyser/CMakeLists.txt b/lib/local/FaceAnalyser/CMakeLists.txt index c08888fc..ce334505 100644 --- a/lib/local/FaceAnalyser/CMakeLists.txt +++ b/lib/local/FaceAnalyser/CMakeLists.txt @@ -1,3 +1,6 @@ +#TBB library +include_directories(${TBB_ROOT_DIR}/include) + include_directories(${BOOST_INCLUDE_DIR}) SET(SOURCE @@ -27,4 +30,4 @@ include_directories(../LandmarkDetector/include) add_library( FaceAnalyser ${SOURCE} ${HEADERS}) install (TARGETS FaceAnalyser DESTINATION bin) -install (FILES HEADERS DESTINATION include) +install (FILES ${HEADERS} DESTINATION include) diff --git a/lib/local/FaceAnalyser/FaceAnalyser.vcxproj b/lib/local/FaceAnalyser/FaceAnalyser.vcxproj index a7772f1d..8ac84ae5 100644 --- a/lib/local/FaceAnalyser/FaceAnalyser.vcxproj +++ b/lib/local/FaceAnalyser/FaceAnalyser.vcxproj @@ -96,6 +96,7 @@ false ./include;$(SolutionDir)lib\local\LandmarkDetector\include;%(AdditionalIncludeDirectories) StreamingSIMDExtensions2 + true true @@ -113,7 +114,8 @@ Disabled false ./include;$(SolutionDir)lib\local\LandmarkDetector\include;%(AdditionalIncludeDirectories) - AdvancedVectorExtensions2 + AdvancedVectorExtensions + true true @@ -135,6 +137,7 @@ ./include;$(SolutionDir)lib\local\LandmarkDetector\include;%(AdditionalIncludeDirectories) StreamingSIMDExtensions2 + true true @@ -158,7 +161,8 @@ ./include;$(SolutionDir)lib\local\LandmarkDetector\include;%(AdditionalIncludeDirectories) - AdvancedVectorExtensions2 + AdvancedVectorExtensions + true true diff --git a/lib/local/FaceAnalyser/include/FaceAnalyser.h b/lib/local/FaceAnalyser/include/FaceAnalyser.h index c27805ba..e5bd9f85 100644 --- a/lib/local/FaceAnalyser/include/FaceAnalyser.h +++ b/lib/local/FaceAnalyser/include/FaceAnalyser.h @@ -99,6 +99,10 @@ public: std::vector> GetCurrentAUsReg() const; // AU intensity std::vector> GetCurrentAUsCombined() const; // Both presense and intensity + // A standalone call for predicting AUs from a static image, the first element in the pair represents occurence the second intensity + // This call is useful for detecting action units in images + std::pair>, std::vector>> PredictStaticAUs(const cv::Mat& frame, const LandmarkDetector::CLNF& clnf, bool visualise = true); + void Reset(); void GetLatestHOG(cv::Mat_& hog_descriptor, int& num_rows, int& num_cols); @@ -118,8 +122,13 @@ public: std::vector GetAUClassNames() const; // Presence std::vector GetAURegNames() const; // Intensity - void ExtractAllPredictionsOfflineReg(vector>>& au_predictions, vector& confidences, vector& successes, vector& timestamps); - void ExtractAllPredictionsOfflineClass(vector>>& au_predictions, vector& confidences, vector& successes, vector& timestamps); + // Identify if models are static or dynamic (useful for correction and shifting) + std::vector GetDynamicAUClass() const; // Presence + std::vector> GetDynamicAUReg() const; // Intensity + + + void ExtractAllPredictionsOfflineReg(vector>>& au_predictions, vector& confidences, vector& successes, vector& timestamps, bool dynamic); + void ExtractAllPredictionsOfflineClass(vector>>& au_predictions, vector& confidences, vector& successes, vector& timestamps, bool dynamic); private: @@ -212,7 +221,7 @@ private: void UpdatePredictionTrack(cv::Mat_& prediction_corr_histogram, int& prediction_correction_count, vector& correction, const vector>& predictions, double ratio=0.25, int num_bins = 200, double min_val = -3, double max_val = 5, int min_frames = 10); void GetSampleHist(cv::Mat_& prediction_corr_histogram, int prediction_correction_count, vector& sample, double ratio, int num_bins = 200, double min_val = 0, double max_val = 5); - vector>> PostprocessPredictions(); + void PostprocessPredictions(); vector> au_prediction_correction_histogram; vector au_prediction_correction_count; @@ -233,6 +242,15 @@ private: double align_scale; int align_width; int align_height; + + // Useful placeholder for renormalizing the initial frames of shorter videos + int max_init_frames = 3000; + vector> hog_desc_frames_init; + vector> geom_descriptor_frames_init; + vector views; + bool postprocessed = false; + int frames_tracking_succ = 0; + }; //=========================================================================== } diff --git a/lib/local/FaceAnalyser/include/SVR_dynamic_lin_regressors.h b/lib/local/FaceAnalyser/include/SVR_dynamic_lin_regressors.h index f67550bf..ed31d432 100644 --- a/lib/local/FaceAnalyser/include/SVR_dynamic_lin_regressors.h +++ b/lib/local/FaceAnalyser/include/SVR_dynamic_lin_regressors.h @@ -89,6 +89,11 @@ public: return AU_names; } + std::vector GetCutoffs() const + { + return cutoffs; + } + private: // The names of Action Units this model is responsible for @@ -101,6 +106,9 @@ private: cv::Mat_ support_vectors; cv::Mat_ biases; + // For AU callibration (see the OpenFace paper) + std::vector cutoffs; + }; //=========================================================================== } diff --git a/lib/local/FaceAnalyser/src/FaceAnalyser.cpp b/lib/local/FaceAnalyser/src/FaceAnalyser.cpp index f516a030..ae26d73c 100644 --- a/lib/local/FaceAnalyser/src/FaceAnalyser.cpp +++ b/lib/local/FaceAnalyser/src/FaceAnalyser.cpp @@ -92,12 +92,11 @@ FaceAnalyser::FaceAnalyser(vector orientation_bins, double scale, int align_height = height; // Initialise the histograms that will represent bins from 0 - 1 (as HoG values are only stored as those) - // Set the number of bins for the histograms - num_bins_hog = 600; + num_bins_hog = 1000; max_val_hog = 1; - min_val_hog = 0; + min_val_hog = -0.005; - // The geometry histogram ranges from -3 to 3 + // The geometry histogram ranges from -60 to 60 num_bins_geom = 10000; max_val_geom = 60; min_val_geom = -60; @@ -168,6 +167,42 @@ std::vector FaceAnalyser::GetAURegNames() const return au_reg_names_all; } +std::vector FaceAnalyser::GetDynamicAUClass() const +{ + std::vector au_dynamic_class; + std::vector au_class_names_stat = AU_SVM_static_appearance_lin.GetAUNames(); + std::vector au_class_names_dyn = AU_SVM_dynamic_appearance_lin.GetAUNames(); + + for (size_t i = 0; i < au_class_names_stat.size(); ++i) + { + au_dynamic_class.push_back(false); + } + for (size_t i = 0; i < au_class_names_dyn.size(); ++i) + { + au_dynamic_class.push_back(true); + } + + return au_dynamic_class; +} + +std::vector> FaceAnalyser::GetDynamicAUReg() const +{ + std::vector> au_dynamic_reg; + std::vector au_reg_names_stat = AU_SVR_static_appearance_lin_regressors.GetAUNames(); + std::vector au_reg_names_dyn = AU_SVR_dynamic_appearance_lin_regressors.GetAUNames(); + + for (size_t i = 0; i < au_reg_names_stat.size(); ++i) + { + au_dynamic_reg.push_back(std::pair(au_reg_names_stat[i], false)); + } + for (size_t i = 0; i < au_reg_names_dyn.size(); ++i) + { + au_dynamic_reg.push_back(std::pair(au_reg_names_dyn[i], true)); + } + + return au_dynamic_reg; +} + cv::Mat_ FaceAnalyser::GetTriangulation() { return triangulation.clone(); @@ -267,6 +302,59 @@ void FaceAnalyser::ExtractCurrentMedians(vector& hog_medians, vector>, std::vector>> FaceAnalyser::PredictStaticAUs(const cv::Mat& frame, const LandmarkDetector::CLNF& clnf, bool visualise) +{ + + // First align the face + AlignFaceMask(aligned_face, frame, clnf, triangulation, true, align_scale, align_width, align_height); + + // Extract HOG descriptor from the frame and convert it to a useable format + cv::Mat_ hog_descriptor; + Extract_FHOG_descriptor(hog_descriptor, aligned_face, this->num_hog_rows, this->num_hog_cols); + + // Store the descriptor + hog_desc_frame = hog_descriptor; + + cv::Vec3d curr_orient(clnf.params_global[1], clnf.params_global[2], clnf.params_global[3]); + int orientation_to_use = GetViewId(this->head_orientations, curr_orient); + + // Geom descriptor and its median + geom_descriptor_frame = clnf.params_local.t(); + + // Stack with the actual feature point locations (without mean) + cv::Mat_ locs = clnf.pdm.princ_comp * geom_descriptor_frame.t(); + + cv::hconcat(locs.t(), geom_descriptor_frame.clone(), geom_descriptor_frame); + + // First convert the face image to double representation as a row vector + cv::Mat_ aligned_face_cols(1, aligned_face.cols * aligned_face.rows * aligned_face.channels(), aligned_face.data, 1); + cv::Mat_ aligned_face_cols_double; + aligned_face_cols.convertTo(aligned_face_cols_double, CV_64F); + + // Visualising the median HOG + if (visualise) + { + FaceAnalysis::Visualise_FHOG(hog_descriptor, num_hog_rows, num_hog_cols, hog_descriptor_visualisation); + } + + // Perform AU prediction + auto AU_predictions_intensity = PredictCurrentAUs(orientation_to_use); + auto AU_predictions_occurence = PredictCurrentAUsClass(orientation_to_use); + + // Make sure intensity is within range (0-5) + for (size_t au = 0; au < AU_predictions_intensity.size(); ++au) + { + if (AU_predictions_intensity[au].second < 0) + AU_predictions_intensity[au].second = 0; + + if (AU_predictions_intensity[au].second > 5) + AU_predictions_intensity[au].second = 5; + } + + return std::pair>, std::vector>>(AU_predictions_intensity, AU_predictions_occurence); + +} + void FaceAnalyser::AddNextFrame(const cv::Mat& frame, const LandmarkDetector::CLNF& clnf_model, double timestamp_seconds, bool online, bool visualise) { @@ -295,7 +383,7 @@ void FaceAnalyser::AddNextFrame(const cv::Mat& frame, const LandmarkDetector::CL // Extract HOG descriptor from the frame and convert it to a useable format cv::Mat_ hog_descriptor; Extract_FHOG_descriptor(hog_descriptor, aligned_face, this->num_hog_rows, this->num_hog_cols); - + // Store the descriptor hog_desc_frame = hog_descriptor; @@ -307,11 +395,23 @@ void FaceAnalyser::AddNextFrame(const cv::Mat& frame, const LandmarkDetector::CL bool update_median = true; // TODO test if this would be useful or not - //if(!this->AU_predictions.empty()) + //if(!this->AU_predictions_reg.empty()) //{ - // for(size_t i = 0; i < this->AU_predictions.size(); ++i) + // vector> dyns = this->GetDynamicAUReg(); + + // for(size_t i = 0; i < this->AU_predictions_reg.size(); ++i) // { - // if(this->AU_predictions[i].second > 1) + // bool stat = false; + // for (size_t n = 0; n < dyns.size(); ++n) + // { + // if (dyns[n].first.compare(AU_predictions_reg[i].first) == 0) + // { + // stat = !dyns[i].second; + // } + // } + + // // If static predictor above 1.5 assume it's not a neutral face + // if(this->AU_predictions_reg[i].second > 1.5 && stat) // { // update_median = false; // break; @@ -321,11 +421,16 @@ void FaceAnalyser::AddNextFrame(const cv::Mat& frame, const LandmarkDetector::CL update_median = update_median & clnf_model.detection_success; + if (clnf_model.detection_success) + frames_tracking_succ++; + // A small speedup if(frames_tracking % 2 == 1) { UpdateRunningMedian(this->hog_desc_hist[orientation_to_use], this->hog_hist_sum[orientation_to_use], this->hog_desc_median, hog_descriptor, update_median, this->num_bins_hog, this->min_val_hog, this->max_val_hog); + this->hog_desc_median.setTo(0, this->hog_desc_median < 0); } + // Geom descriptor and its median geom_descriptor_frame = clnf_model.params_local.t(); @@ -368,22 +473,19 @@ void FaceAnalyser::AddNextFrame(const cv::Mat& frame, const LandmarkDetector::CL AU_predictions_reg_corrected = CorrectOnlineAUs(AU_predictions_reg, orientation_to_use, true, false, clnf_model.detection_success); } - // Keep only closer to in-plane faces - double angle_norm = cv::sqrt(clnf_model.params_global[2] * clnf_model.params_global[2] + clnf_model.params_global[3] * clnf_model.params_global[3]); - // Add the reg predictions to the historic data for (size_t au = 0; au < AU_predictions_reg.size(); ++au) { // Find the appropriate AU (if not found add it) - // Only add if the detection was successful and not too out of plane - if(clnf_model.detection_success && angle_norm < 0.4) + // Only add if the detection was successful + if(clnf_model.detection_success) { AU_predictions_reg_all_hist[AU_predictions_reg[au].first].push_back(AU_predictions_reg[au].second); } else { - AU_predictions_reg_all_hist[AU_predictions_reg[au].first].push_back(-100.0); + AU_predictions_reg_all_hist[AU_predictions_reg[au].first].push_back(0); } } @@ -393,14 +495,14 @@ void FaceAnalyser::AddNextFrame(const cv::Mat& frame, const LandmarkDetector::CL { // Find the appropriate AU (if not found add it) - // Only add if the detection was successful and not too out of plane - if(clnf_model.detection_success && angle_norm < 0.4) + // Only add if the detection was successful + if(clnf_model.detection_success) { AU_predictions_class_all_hist[AU_predictions_class[au].first].push_back(AU_predictions_class[au].second); } else { - AU_predictions_class_all_hist[AU_predictions_class[au].first].push_back(-100.0); + AU_predictions_class_all_hist[AU_predictions_class[au].first].push_back(0); } } @@ -409,16 +511,28 @@ void FaceAnalyser::AddNextFrame(const cv::Mat& frame, const LandmarkDetector::CL { AU_predictions_reg = AU_predictions_reg_corrected; } + else + { + if (clnf_model.detection_success && frames_tracking_succ - 1 < max_init_frames) + { + hog_desc_frames_init.push_back(hog_descriptor); + geom_descriptor_frames_init.push_back(geom_descriptor_frame); + views.push_back(orientation_to_use); + } + } this->current_time_seconds = timestamp_seconds; view_used = orientation_to_use; - bool success = clnf_model.detection_success && angle_norm < 0.4; + bool success = clnf_model.detection_success; confidences.push_back(clnf_model.detection_certainty); valid_preds.push_back(success); timestamps.push_back(timestamp_seconds); + + + } void FaceAnalyser::GetGeomDescriptor(cv::Mat_& geom_desc) @@ -444,22 +558,19 @@ void FaceAnalyser::PredictAUs(const cv::Mat_& hog_features, const cv::Ma AU_predictions_reg_corrected = CorrectOnlineAUs(AU_predictions_reg, orientation_to_use, true, false, clnf_model.detection_success); } - // Keep only closer to in-plane faces - double angle_norm = cv::sqrt(clnf_model.params_global[2] * clnf_model.params_global[2] + clnf_model.params_global[3] * clnf_model.params_global[3]); - // Add the reg predictions to the historic data for (size_t au = 0; au < AU_predictions_reg.size(); ++au) { // Find the appropriate AU (if not found add it) - // Only add if the detection was successful and not too out of plane - if(clnf_model.detection_success && angle_norm < 0.4) + // Only add if the detection was successful + if(clnf_model.detection_success) { AU_predictions_reg_all_hist[AU_predictions_reg[au].first].push_back(AU_predictions_reg[au].second); } else { - AU_predictions_reg_all_hist[AU_predictions_reg[au].first].push_back(-100.0); + AU_predictions_reg_all_hist[AU_predictions_reg[au].first].push_back(0.0); } } @@ -469,14 +580,14 @@ void FaceAnalyser::PredictAUs(const cv::Mat_& hog_features, const cv::Ma { // Find the appropriate AU (if not found add it) - // Only add if the detection was successful and not too out of plane - if(clnf_model.detection_success && angle_norm < 0.4) + // Only add if the detection was successful + if(clnf_model.detection_success) { AU_predictions_class_all_hist[AU_predictions_class[au].first].push_back(AU_predictions_class[au].second); } else { - AU_predictions_class_all_hist[AU_predictions_class[au].first].push_back(-100.0); + AU_predictions_class_all_hist[AU_predictions_class[au].first].push_back(0.0); } } @@ -496,14 +607,65 @@ void FaceAnalyser::PredictAUs(const cv::Mat_& hog_features, const cv::Ma view_used = orientation_to_use; - bool success = clnf_model.detection_success && angle_norm < 0.4; + bool success = clnf_model.detection_success; confidences.push_back(clnf_model.detection_certainty); valid_preds.push_back(success); } -void FaceAnalyser::ExtractAllPredictionsOfflineReg(vector>>& au_predictions, vector& confidences, vector& successes, vector& timestamps) +// Perform prediction on initial n frames anew as the current neutral face estimate is better now +void FaceAnalyser::PostprocessPredictions() { + if(!postprocessed) + { + int success_ind = 0; + int all_ind = 0; + int all_frames_size = timestamps.size(); + + while(all_ind < all_frames_size && success_ind < max_init_frames) + { + + if(valid_preds[all_ind]) + { + + this->hog_desc_frame = hog_desc_frames_init[success_ind]; + this->geom_descriptor_frame = geom_descriptor_frames_init[success_ind]; + + // Perform AU prediction + auto AU_predictions_reg = PredictCurrentAUs(views[success_ind]); + + // Modify the predictions to the historic data + for (size_t au = 0; au < AU_predictions_reg.size(); ++au) + { + // Find the appropriate AU (if not found add it) + AU_predictions_reg_all_hist[AU_predictions_reg[au].first][all_ind] = AU_predictions_reg[au].second; + + } + + auto AU_predictions_class = PredictCurrentAUsClass(views[success_ind]); + + for (size_t au = 0; au < AU_predictions_class.size(); ++au) + { + // Find the appropriate AU (if not found add it) + AU_predictions_class_all_hist[AU_predictions_class[au].first][all_ind] = AU_predictions_class[au].second; + } + + success_ind++; + } + all_ind++; + + } + postprocessed = true; + } +} + +void FaceAnalyser::ExtractAllPredictionsOfflineReg(vector>>& au_predictions, vector& confidences, vector& successes, vector& timestamps, bool dynamic) +{ + if(dynamic) + { + PostprocessPredictions(); + } + timestamps = this->timestamps; au_predictions.clear(); // First extract the valid AU values and put them in a different format @@ -511,7 +673,10 @@ void FaceAnalyser::ExtractAllPredictionsOfflineReg(vector offsets; confidences = this->confidences; successes = this->valid_preds; + + vector dyn_au_names = AU_SVR_dynamic_appearance_lin_regressors.GetAUNames(); + // Allow these AUs to be person calirated based on expected number of neutral frames (learned from the data) for(auto au_iter = AU_predictions_reg_all_hist.begin(); au_iter != AU_predictions_reg_all_hist.end(); ++au_iter) { vector au_good; @@ -530,21 +695,44 @@ void FaceAnalyser::ExtractAllPredictionsOfflineReg(vector 5) au_predictions[au].second[frame] = 5; - + } else { @@ -568,11 +756,37 @@ void FaceAnalyser::ExtractAllPredictionsOfflineReg(vectorfirst; + + // Perform a moving average of 3 frames + int window_size = 3; + vector au_vals_tmp = au_iter->second; + for (size_t i = (window_size - 1) / 2; i < au_iter->second.size() - (window_size - 1) / 2; ++i) + { + double sum = 0; + for (int w = -(window_size - 1) / 2; w <= (window_size - 1) / 2; ++w) + { + sum += au_vals_tmp[i + w]; + } + sum = sum / window_size; + + au_iter->second[i] = sum; + } + + } } -void FaceAnalyser::ExtractAllPredictionsOfflineClass(vector>>& au_predictions, vector& confidences, vector& successes, vector& timestamps) +void FaceAnalyser::ExtractAllPredictionsOfflineClass(vector>>& au_predictions, vector& confidences, vector& successes, vector& timestamps, bool dynamic) { + if (dynamic) + { + PostprocessPredictions(); + } + timestamps = this->timestamps; au_predictions.clear(); @@ -581,6 +795,25 @@ void FaceAnalyser::ExtractAllPredictionsOfflineClass(vectorfirst; vector au_vals = au_iter->second; + // Perform a moving average of 7 frames on classifications + int window_size = 7; + vector au_vals_tmp = au_vals; + for (size_t i = (window_size - 1)/2; i < au_vals.size() - (window_size - 1) / 2; ++i) + { + double sum = 0; + for (int w = -(window_size - 1) / 2; w <= (window_size - 1) / 2; ++w) + { + sum += au_vals_tmp[i + w]; + } + sum = sum / window_size; + if (sum < 0.5) + sum = 0; + else + sum = 1; + + au_vals[i] = sum; + } + au_predictions.push_back(std::pair>(au_name, au_vals)); } @@ -631,6 +864,11 @@ void FaceAnalyser::Reset() confidences.clear(); valid_preds.clear(); + // Clean up the postprocessing data as well + hog_desc_frames_init.clear(); + geom_descriptor_frames_init.clear(); + postprocessed = false; + frames_tracking_succ = 0; } void FaceAnalyser::UpdateRunningMedian(cv::Mat_& histogram, int& hist_count, cv::Mat_& median, const cv::Mat_& descriptor, bool update, int num_bins, double min_val, double max_val) @@ -656,7 +894,6 @@ void FaceAnalyser::UpdateRunningMedian(cv::Mat_& histogram, int& h converted_descriptor.setTo(cv::Scalar(num_bins-1), converted_descriptor > num_bins - 1); converted_descriptor.setTo(cv::Scalar(0), converted_descriptor < 0); - // Only count the median till a certain number of frame seen? for(int i = 0; i < histogram.rows; ++i) { int index = (int)converted_descriptor.at(i); @@ -683,9 +920,9 @@ void FaceAnalyser::UpdateRunningMedian(cv::Mat_& histogram, int& h for(int j = 0; j < histogram.cols; ++j) { cummulative_sum += histogram.at(i, j); - if(cummulative_sum > cutoff_point) + if(cummulative_sum >= cutoff_point) { - median.at(i) = min_val + j * (length/num_bins) + (0.5*(length)/num_bins); + median.at(i) = min_val + ((double)j) * (length/((double)num_bins)) + (0.5*(length)/ ((double)num_bins)); break; } } @@ -753,7 +990,7 @@ vector> FaceAnalyser::PredictCurrentAUs(int view) vector svr_lin_dyn_aus; vector svr_lin_dyn_preds; - AU_SVR_dynamic_appearance_lin_regressors.Predict(svr_lin_dyn_preds, svr_lin_dyn_aus, hog_desc_frame, geom_descriptor_frame, this->hog_desc_median, this->geom_descriptor_frame); + AU_SVR_dynamic_appearance_lin_regressors.Predict(svr_lin_dyn_preds, svr_lin_dyn_aus, hog_desc_frame, geom_descriptor_frame, this->hog_desc_median, this->geom_descriptor_median); for(size_t i = 0; i < svr_lin_dyn_preds.size(); ++i) { @@ -796,7 +1033,6 @@ vector> FaceAnalyser::CorrectOnlineAUs(std::vector 1) { double scaling_curr = 5.0 / predictions[i].second; diff --git a/lib/local/FaceAnalyser/src/Face_utils.cpp b/lib/local/FaceAnalyser/src/Face_utils.cpp index 8b2ed4fe..52e00940 100644 --- a/lib/local/FaceAnalyser/src/Face_utils.cpp +++ b/lib/local/FaceAnalyser/src/Face_utils.cpp @@ -221,19 +221,19 @@ namespace FaceAnalysis destination_landmarks.col(1) = destination_landmarks.col(1) + warp_matrix(1,2); // Move the eyebrows up to include more of upper face - destination_landmarks.at(0,1) -= 15; - destination_landmarks.at(16,1) -= 15; + destination_landmarks.at(0,1) -= 30; + destination_landmarks.at(16,1) -= 30; - destination_landmarks.at(17,1) -= 7; - destination_landmarks.at(18,1) -= 7; - destination_landmarks.at(19,1) -= 7; - destination_landmarks.at(20,1) -= 7; - destination_landmarks.at(21,1) -= 7; - destination_landmarks.at(22,1) -= 7; - destination_landmarks.at(23,1) -= 7; - destination_landmarks.at(24,1) -= 7; - destination_landmarks.at(25,1) -= 7; - destination_landmarks.at(26,1) -= 7; + destination_landmarks.at(17,1) -= 30; + destination_landmarks.at(18,1) -= 30; + destination_landmarks.at(19,1) -= 30; + destination_landmarks.at(20,1) -= 30; + destination_landmarks.at(21,1) -= 30; + destination_landmarks.at(22,1) -= 30; + destination_landmarks.at(23,1) -= 30; + destination_landmarks.at(24,1) -= 30; + destination_landmarks.at(25,1) -= 30; + destination_landmarks.at(26,1) -= 30; destination_landmarks = cv::Mat(destination_landmarks.t()).reshape(1, 1).t(); @@ -249,7 +249,7 @@ namespace FaceAnalysis for(size_t i = 0; i < aligned_face_channels.size(); ++i) { - aligned_face_channels[i] = aligned_face_channels[i].mul(paw.pixel_mask); + cv::multiply(aligned_face_channels[i], paw.pixel_mask, aligned_face_channels[i], 1.0, CV_8U); } if(aligned_face.channels() == 3) diff --git a/lib/local/FaceAnalyser/src/GazeEstimation.cpp b/lib/local/FaceAnalyser/src/GazeEstimation.cpp index 4e31d965..58b03fb1 100644 --- a/lib/local/FaceAnalyser/src/GazeEstimation.cpp +++ b/lib/local/FaceAnalyser/src/GazeEstimation.cpp @@ -68,6 +68,10 @@ using namespace std; using namespace FaceAnalysis; +// For subpixel accuracy drawing +const int gaze_draw_shiftbits = 4; +const int gaze_draw_multiplier = 1 << 4; + cv::Point3f RaySphereIntersect(cv::Point3f rayOrigin, cv::Point3f rayDir, cv::Point3f sphereOrigin, float sphereRadius){ float dx = rayDir.x; @@ -190,9 +194,11 @@ void FaceAnalysis::DrawGaze(cv::Mat img, const LandmarkDetector::CLNF& clnf_mode cv::Mat_ proj_points; cv::Mat_ mesh_0 = (cv::Mat_(2, 3) << points_left[0].x, points_left[0].y, points_left[0].z, points_left[1].x, points_left[1].y, points_left[1].z); LandmarkDetector::Project(proj_points, mesh_0, fx, fy, cx, cy); - line(img, cv::Point(proj_points.at(0,0), proj_points.at(0, 1)), cv::Point(proj_points.at(1, 0), proj_points.at(1, 1)), cv::Scalar(110, 220, 0), 2, 8); + cv::line(img, cv::Point(cvRound(proj_points.at(0,0) * (double)gaze_draw_multiplier), cvRound(proj_points.at(0, 1) * (double)gaze_draw_multiplier)), + cv::Point(cvRound(proj_points.at(1, 0) * (double)gaze_draw_multiplier), cvRound(proj_points.at(1, 1) * (double)gaze_draw_multiplier)), cv::Scalar(110, 220, 0), 2, CV_AA, gaze_draw_shiftbits); cv::Mat_ mesh_1 = (cv::Mat_(2, 3) << points_right[0].x, points_right[0].y, points_right[0].z, points_right[1].x, points_right[1].y, points_right[1].z); LandmarkDetector::Project(proj_points, mesh_1, fx, fy, cx, cy); - line(img, cv::Point(proj_points.at(0, 0), proj_points.at(0, 1)), cv::Point(proj_points.at(1, 0), proj_points.at(1, 1)), cv::Scalar(110, 220, 0), 2, 8); + cv::line(img, cv::Point(cvRound(proj_points.at(0, 0) * (double)gaze_draw_multiplier), cvRound(proj_points.at(0, 1) * (double)gaze_draw_multiplier)), + cv::Point(cvRound(proj_points.at(1, 0) * (double)gaze_draw_multiplier), cvRound(proj_points.at(1, 1) * (double)gaze_draw_multiplier)), cv::Scalar(110, 220, 0), 2, CV_AA, gaze_draw_shiftbits); } \ No newline at end of file diff --git a/lib/local/FaceAnalyser/src/SVM_dynamic_lin.cpp b/lib/local/FaceAnalyser/src/SVM_dynamic_lin.cpp index eb812aa0..32334b27 100644 --- a/lib/local/FaceAnalyser/src/SVM_dynamic_lin.cpp +++ b/lib/local/FaceAnalyser/src/SVM_dynamic_lin.cpp @@ -75,7 +75,7 @@ void SVM_dynamic_lin::Read(std::ifstream& stream, const std::vector LandmarkDetector::ReadMatBin(stream, m_tmp); if(cv::norm(m_tmp - this->means > 0.00001)) { - cout << "Something went wrong with the SVR dynamic regressors" << endl; + cout << "Something went wrong with the SVM dynamic classifiers" << endl; } } diff --git a/lib/local/FaceAnalyser/src/SVM_static_lin.cpp b/lib/local/FaceAnalyser/src/SVM_static_lin.cpp index dbb07f3a..5c0f5b1f 100644 --- a/lib/local/FaceAnalyser/src/SVM_static_lin.cpp +++ b/lib/local/FaceAnalyser/src/SVM_static_lin.cpp @@ -75,7 +75,7 @@ void SVM_static_lin::Read(std::ifstream& stream, const std::vector& LandmarkDetector::ReadMatBin(stream, m_tmp); if(cv::norm(m_tmp - this->means > 0.00001)) { - cout << "Something went wrong with the SVR dynamic regressors" << endl; + cout << "Something went wrong with the SVM static classifiers" << endl; } } diff --git a/lib/local/FaceAnalyser/src/SVR_dynamic_lin_regressors.cpp b/lib/local/FaceAnalyser/src/SVR_dynamic_lin_regressors.cpp index bb9ef5c0..6e02600a 100644 --- a/lib/local/FaceAnalyser/src/SVR_dynamic_lin_regressors.cpp +++ b/lib/local/FaceAnalyser/src/SVR_dynamic_lin_regressors.cpp @@ -64,7 +64,13 @@ using namespace FaceAnalysis; void SVR_dynamic_lin_regressors::Read(std::ifstream& stream, const std::vector& au_names) { + + // For person specific calibration in a video + double cutoff; + stream.read((char*)&cutoff, 8); + cutoffs.push_back(cutoff); + // The feature normalization using the mean if(this->means.empty()) { LandmarkDetector::ReadMatBin(stream, this->means); @@ -115,7 +121,6 @@ void SVR_dynamic_lin_regressors::Predict(std::vector& predictions, std:: { if(AU_names.size() > 0) { - cv::Mat_ preds; if(fhog_descriptor.cols == this->means.cols) { @@ -136,7 +141,7 @@ void SVR_dynamic_lin_regressors::Predict(std::vector& predictions, std:: { predictions.push_back(*pred_it); } - + names = this->AU_names; } } \ No newline at end of file diff --git a/lib/local/FaceAnalyser/src/SVR_static_lin_regressors.cpp b/lib/local/FaceAnalyser/src/SVR_static_lin_regressors.cpp index cce89a1b..9fb984f2 100644 --- a/lib/local/FaceAnalyser/src/SVR_static_lin_regressors.cpp +++ b/lib/local/FaceAnalyser/src/SVR_static_lin_regressors.cpp @@ -75,7 +75,7 @@ void SVR_static_lin_regressors::Read(std::ifstream& stream, const std::vectormeans > 0.00001)) { - cout << "Something went wrong with the SVR dynamic regressors" << endl; + cout << "Something went wrong with the SVR static regressors" << endl; } } diff --git a/lib/local/LandmarkDetector/CMakeLists.txt b/lib/local/LandmarkDetector/CMakeLists.txt index 16b84531..a5e1a502 100644 --- a/lib/local/LandmarkDetector/CMakeLists.txt +++ b/lib/local/LandmarkDetector/CMakeLists.txt @@ -1,3 +1,6 @@ +#TBB library +include_directories(${TBB_ROOT_DIR}/include) + include_directories(${BOOST_INCLUDE_DIR}) SET(SOURCE @@ -35,4 +38,4 @@ include_directories(${LandmarkDetector_SOURCE_DIR}/include) add_library( LandmarkDetector ${SOURCE} ${HEADERS}) install (TARGETS LandmarkDetector DESTINATION bin) -install (FILES HEADERS DESTINATION include) \ No newline at end of file +install (FILES ${HEADERS} DESTINATION include) diff --git a/lib/local/LandmarkDetector/LandmarkDetector.vcxproj b/lib/local/LandmarkDetector/LandmarkDetector.vcxproj index ea634ccb..c06eb3c3 100644 --- a/lib/local/LandmarkDetector/LandmarkDetector.vcxproj +++ b/lib/local/LandmarkDetector/LandmarkDetector.vcxproj @@ -100,6 +100,7 @@ StreamingSIMDExtensions2 false /Zm300 %(AdditionalOptions) + true $(OutDir)$(TargetName)$(TargetExt) @@ -119,9 +120,10 @@ xcopy /I /E /Y /D "$(SolutionDir)lib\3rdParty\OpenCV3.1\classifiers" "$(OutDir)c NotUsing Level3 ProgramDatabase - AdvancedVectorExtensions2 + AdvancedVectorExtensions false /Zm300 %(AdditionalOptions) + true $(OutDir)$(TargetName)$(TargetExt) @@ -146,6 +148,7 @@ xcopy /I /E /Y /D "$(SolutionDir)lib\3rdParty\OpenCV3.1\classifiers" "$(OutDir)c Speed false /Zm300 %(AdditionalOptions) + true $(OutDir)$(TargetName)$(TargetExt) @@ -166,10 +169,11 @@ xcopy /I /E /Y /D "$(SolutionDir)lib\3rdParty\OpenCV3.1\classifiers" "$(OutDir)c Use Level3 ProgramDatabase - AdvancedVectorExtensions2 + AdvancedVectorExtensions Speed false /Zm300 %(AdditionalOptions) + true $(OutDir)$(TargetName)$(TargetExt) diff --git a/lib/local/LandmarkDetector/include/LandmarkDetectorUtils.h b/lib/local/LandmarkDetector/include/LandmarkDetectorUtils.h index 200cbe18..cdd6ab3a 100644 --- a/lib/local/LandmarkDetector/include/LandmarkDetectorUtils.h +++ b/lib/local/LandmarkDetector/include/LandmarkDetectorUtils.h @@ -76,8 +76,8 @@ namespace LandmarkDetector //============================================================================================= // Helper functions for parsing the inputs //============================================================================================= - void get_video_input_output_params(vector &input_video_file, vector &depth_dir, - vector &output_files, vector &output_video_files, bool& world_coordinates_pose, vector &arguments); + void get_video_input_output_params(vector &input_video_file, vector &depth_dir, vector &output_files, + vector &output_video_files, bool& world_coordinates_pose, string &output_codec, vector &arguments); void get_camera_params(int &device, float &fx, float &fy, float &cx, float &cy, vector &arguments); @@ -110,7 +110,7 @@ namespace LandmarkDetector void DrawBox(cv::Mat image, cv::Vec6d pose, cv::Scalar color, int thickness, float fx, float fy, float cx, float cy); // Drawing face bounding box - vector> CalculateBox(cv::Vec6d pose, float fx, float fy, float cx, float cy); + vector> CalculateBox(cv::Vec6d pose, float fx, float fy, float cx, float cy); void DrawBox(vector> lines, cv::Mat image, cv::Scalar color, int thickness); vector CalculateLandmarks(const cv::Mat_& shape2D, cv::Mat_& visibilities); diff --git a/lib/local/LandmarkDetector/include/Patch_experts.h b/lib/local/LandmarkDetector/include/Patch_experts.h index 94ef39d4..f1ab7386 100644 --- a/lib/local/LandmarkDetector/include/Patch_experts.h +++ b/lib/local/LandmarkDetector/include/Patch_experts.h @@ -116,7 +116,7 @@ public: int GetViewIdx(const cv::Vec6d& params_global, int scale) const; // The number of views at a particular scale - inline int nViews(int scale = 0) const { return centers[scale].size(); }; + inline int nViews(size_t scale = 0) const { return (int)centers[scale].size(); }; // Reading in all of the patch experts void Read(vector intensity_svr_expert_locations, vector depth_svr_expert_locations, vector intensity_ccnf_expert_locations); diff --git a/lib/local/LandmarkDetector/model/main_clnf_general.txt b/lib/local/LandmarkDetector/model/main_clnf_general.txt index 181a86af..ecb758d9 100644 --- a/lib/local/LandmarkDetector/model/main_clnf_general.txt +++ b/lib/local/LandmarkDetector/model/main_clnf_general.txt @@ -1,5 +1,5 @@ LandmarkDetector clnf_general.txt -LandmarkDetector_part model_inner/main_clnf_inner.txt inner 17 0 18 1 19 2 20 3 21 4 22 5 23 6 24 7 25 8 26 9 27 10 28 11 29 12 30 13 31 14 32 15 33 16 34 17 35 18 36 19 37 20 38 21 39 22 40 23 41 24 42 25 43 26 44 27 45 28 46 29 47 30 48 31 49 32 50 33 51 34 52 35 53 36 54 37 55 38 56 39 57 40 58 41 59 42 60 43 61 44 62 45 63 46 64 47 65 48 66 49 67 50 17 0 18 1 19 2 20 3 21 4 22 5 23 6 24 7 25 8 26 9 27 10 28 11 29 12 30 13 31 14 32 15 33 16 34 17 35 18 36 19 37 20 38 21 39 22 40 23 41 24 42 25 43 26 44 27 45 28 46 29 47 30 48 31 49 32 50 33 51 34 52 35 53 36 54 37 55 38 56 39 57 40 58 41 59 42 60 43 61 44 62 45 63 46 64 47 65 48 66 49 67 50 +LandmarkDetector_part model_inner/main_clnf_inner.txt inner 17 0 18 1 19 2 20 3 21 4 22 5 23 6 24 7 25 8 26 9 27 10 28 11 29 12 30 13 31 14 32 15 33 16 34 17 35 18 36 19 37 20 38 21 39 22 40 23 41 24 42 25 43 26 44 27 45 28 46 29 47 30 48 31 49 32 50 33 51 34 52 35 53 36 54 37 55 38 56 39 57 40 58 41 59 42 60 43 61 44 62 45 63 46 64 47 65 48 66 49 67 50 LandmarkDetector_part model_eye/main_clnf_synth_left.txt left_eye_28 36 8 37 10 38 12 39 14 40 16 41 18 LandmarkDetector_part model_eye/main_clnf_synth_right.txt right_eye_28 42 8 43 10 44 12 45 14 46 16 47 18 FaceDetConversion haarAlign.txt diff --git a/lib/local/LandmarkDetector/src/LandmarkDetectorModel.cpp b/lib/local/LandmarkDetector/src/LandmarkDetectorModel.cpp index 1c22bf8e..66695849 100644 --- a/lib/local/LandmarkDetector/src/LandmarkDetectorModel.cpp +++ b/lib/local/LandmarkDetector/src/LandmarkDetectorModel.cpp @@ -632,12 +632,6 @@ bool CLNF::DetectLandmarks(const cv::Mat_ &image, const cv::Mat_ & // Do the actual landmark detection hierarchical_models[part_model].DetectLandmarks(image, depth, hierarchical_params[part_model]); - // Reincorporate the models into main tracker - for (size_t mapping_ind = 0; mapping_ind < mappings.size(); ++mapping_ind) - { - detected_landmarks.at(mappings[mapping_ind].first) = hierarchical_models[part_model].detected_landmarks.at(mappings[mapping_ind].second); - detected_landmarks.at(mappings[mapping_ind].first + pdm.NumberOfPoints()) = hierarchical_models[part_model].detected_landmarks.at(mappings[mapping_ind].second + hierarchical_models[part_model].pdm.NumberOfPoints()); - } } else { @@ -650,9 +644,28 @@ bool CLNF::DetectLandmarks(const cv::Mat_ &image, const cv::Mat_ & // Recompute main model based on the fit part models if(parts_used) { + + for (size_t part_model = 0; part_model < hierarchical_models.size(); ++part_model) + { + vector> mappings = this->hierarchical_mapping[part_model]; + + if (!((hierarchical_model_names[part_model].compare("right_eye_28") == 0 || + hierarchical_model_names[part_model].compare("left_eye_28") == 0) + && !params.track_gaze)) + { + // Reincorporate the models into main tracker + for (size_t mapping_ind = 0; mapping_ind < mappings.size(); ++mapping_ind) + { + detected_landmarks.at(mappings[mapping_ind].first) = hierarchical_models[part_model].detected_landmarks.at(mappings[mapping_ind].second); + detected_landmarks.at(mappings[mapping_ind].first + pdm.NumberOfPoints()) = hierarchical_models[part_model].detected_landmarks.at(mappings[mapping_ind].second + hierarchical_models[part_model].pdm.NumberOfPoints()); + } + } + } + pdm.CalcParams(params_global, params_local, detected_landmarks); pdm.CalcShape2D(detected_landmarks, params_local, params_global); } + } // Check detection correctness diff --git a/lib/local/LandmarkDetector/src/LandmarkDetectorParameters.cpp b/lib/local/LandmarkDetector/src/LandmarkDetectorParameters.cpp index ba1153f8..c0e74a36 100644 --- a/lib/local/LandmarkDetector/src/LandmarkDetectorParameters.cpp +++ b/lib/local/LandmarkDetector/src/LandmarkDetectorParameters.cpp @@ -191,7 +191,7 @@ FaceModelParameters::FaceModelParameters(vector &arguments) } } - for (int i = arguments.size() - 1; i >= 0; --i) + for (int i = (int)arguments.size() - 1; i >= 0; --i) { if (!valid[i]) { diff --git a/lib/local/LandmarkDetector/src/LandmarkDetectorUtils.cpp b/lib/local/LandmarkDetector/src/LandmarkDetectorUtils.cpp index 48bec32d..caf366aa 100644 --- a/lib/local/LandmarkDetector/src/LandmarkDetectorUtils.cpp +++ b/lib/local/LandmarkDetector/src/LandmarkDetectorUtils.cpp @@ -76,6 +76,11 @@ using namespace std; namespace LandmarkDetector { +// For subpixel accuracy drawing +const int draw_shiftbits = 4; +const int draw_multiplier = 1 << 4; + + // Useful utility for creating directories for storing the output files void create_directory_from_file(string output_path) { @@ -115,8 +120,8 @@ void create_directories(string output_path) } // Extracting the following command line arguments -f, -fd, -op, -of, -ov (and possible ordered repetitions) -void get_video_input_output_params(vector &input_video_files, vector &depth_dirs, - vector &output_files, vector &output_video_files, bool& world_coordinates_pose, vector &arguments) +void get_video_input_output_params(vector &input_video_files, vector &depth_dirs, vector &output_files, + vector &output_video_files, bool& world_coordinates_pose, string& output_codec, vector &arguments) { bool* valid = new bool[arguments.size()]; @@ -128,46 +133,65 @@ void get_video_input_output_params(vector &input_video_files, vector &input_video_files, vector= 0; --i) @@ -253,19 +282,45 @@ void get_image_input_output_params(vector &input_image_files, vector &input_image_files, vector &input_image_files, vector rotBoxProj; Project(rotBoxProj, rotBox, fx, fy, cx, cy); - cv::Rect image_rect(0,0,image.cols, image.rows); + cv::Rect image_rect(0,0,image.cols * draw_multiplier, image.rows * draw_multiplier); for (size_t i = 0; i < edges.size(); ++i) { @@ -856,20 +911,21 @@ void DrawBox(cv::Mat image, cv::Vec6d pose, cv::Scalar color, int thickness, flo rotBoxProj.row(edges[i].first).copyTo(begin); rotBoxProj.row(edges[i].second).copyTo(end); - cv::Point p1((int)begin.at(0), (int)begin.at(1)); - cv::Point p2((int)end.at(0), (int)end.at(1)); + + cv::Point p1(cvRound(begin.at(0) * (double)draw_multiplier), cvRound(begin.at(1) * (double)draw_multiplier)); + cv::Point p2(cvRound(end.at(0) * (double)draw_multiplier), cvRound(end.at(1) * (double)draw_multiplier)); // Only draw the line if one of the points is inside the image if(p1.inside(image_rect) || p2.inside(image_rect)) { - cv::line(image, p1, p2, color, thickness); + cv::line(image, p1, p2, color, thickness, CV_AA, draw_shiftbits); } } } -vector> CalculateBox(cv::Vec6d pose, float fx, float fy, float cx, float cy) +vector> CalculateBox(cv::Vec6d pose, float fx, float fy, float cx, float cy) { double boxVerts[] = {-1, 1, -1, 1, 1, -1, @@ -913,7 +969,7 @@ vector> CalculateBox(cv::Vec6d pose, float fx, f cv::Mat_ rotBoxProj; Project(rotBoxProj, rotBox, fx, fy, cx, cy); - vector> lines; + vector> lines; for (size_t i = 0; i < edges.size(); ++i) { @@ -923,10 +979,10 @@ vector> CalculateBox(cv::Vec6d pose, float fx, f rotBoxProj.row(edges[i].first).copyTo(begin); rotBoxProj.row(edges[i].second).copyTo(end); - cv::Point p1((int)begin.at(0), (int)begin.at(1)); - cv::Point p2((int)end.at(0), (int)end.at(1)); + cv::Point2d p1(begin.at(0), begin.at(1)); + cv::Point2d p2(end.at(0), end.at(1)); - lines.push_back(pair(p1,p2)); + lines.push_back(pair(p1,p2)); } @@ -944,7 +1000,7 @@ void DrawBox(vector> lines, cv::Mat image, cv::Scalar // Only draw the line if one of the points is inside the image if(p1.inside(image_rect) || p2.inside(image_rect)) { - cv::line(image, p1, p2, color, thickness); + cv::line(image, p1, p2, color, thickness, CV_AA); } } @@ -1019,6 +1075,7 @@ vector CalculateLandmarks(CLNF& clnf_model) void Draw(cv::Mat img, const cv::Mat_& shape2D, const cv::Mat_& visibilities) { int n = shape2D.rows/2; + // Drawing feature points if(n >= 66) @@ -1027,14 +1084,15 @@ void Draw(cv::Mat img, const cv::Mat_& shape2D, const cv::Mat_& vis { if(visibilities.at(i)) { - cv::Point featurePoint((int)shape2D.at(i), (int)shape2D.at(i +n)); + cv::Point featurePoint(cvRound(shape2D.at(i) * (double)draw_multiplier), cvRound(shape2D.at(i + n) * (double)draw_multiplier)); // A rough heuristic for drawn point size int thickness = (int)std::ceil(3.0* ((double)img.cols) / 640.0); int thickness_2 = (int)std::ceil(1.0* ((double)img.cols) / 640.0); - cv::circle(img, featurePoint, 1, cv::Scalar(0,0,255), thickness); - cv::circle(img, featurePoint, 1, cv::Scalar(255,0,0), thickness_2); + cv::circle(img, featurePoint, 1 * draw_multiplier, cv::Scalar(0, 0, 255), thickness, CV_AA, draw_shiftbits); + cv::circle(img, featurePoint, 1 * draw_multiplier, cv::Scalar(255, 0, 0), thickness_2, CV_AA, draw_shiftbits); + } } } @@ -1042,7 +1100,7 @@ void Draw(cv::Mat img, const cv::Mat_& shape2D, const cv::Mat_& vis { for( int i = 0; i < n; ++i) { - cv::Point featurePoint((int)shape2D.at(i), (int)shape2D.at(i +n)); + cv::Point featurePoint(cvRound(shape2D.at(i) * (double)draw_multiplier), cvRound(shape2D.at(i + n) * (double)draw_multiplier)); // A rough heuristic for drawn point size int thickness = 1.0; @@ -1056,15 +1114,12 @@ void Draw(cv::Mat img, const cv::Mat_& shape2D, const cv::Mat_& vis if(i == 27) next_point = 20; - cv::Point nextFeaturePoint((int)shape2D.at(next_point), (int)shape2D.at(next_point+n)); + cv::Point nextFeaturePoint(cvRound(shape2D.at(next_point) * (double)draw_multiplier), cvRound(shape2D.at(next_point + n) * (double)draw_multiplier)); if( i < 8 || i > 19) - cv::line(img, featurePoint, nextFeaturePoint, cv::Scalar(255, 0, 0), thickness_2); + cv::line(img, featurePoint, nextFeaturePoint, cv::Scalar(255, 0, 0), thickness_2, CV_AA, draw_shiftbits); else - cv::line(img, featurePoint, nextFeaturePoint, cv::Scalar(0, 0, 255), thickness_2); + cv::line(img, featurePoint, nextFeaturePoint, cv::Scalar(0, 0, 255), thickness_2, CV_AA, draw_shiftbits); - //cv::circle(img, featurePoint, 1, Scalar(0,255,0), thickness); - //cv::circle(img, featurePoint, 1, Scalar(0,0,255), thickness_2); - } } @@ -1072,21 +1127,18 @@ void Draw(cv::Mat img, const cv::Mat_& shape2D, const cv::Mat_& vis { for( int i = 0; i < n; ++i) { - cv::Point featurePoint((int)shape2D.at(i), (int)shape2D.at(i +n)); + cv::Point featurePoint(cvRound(shape2D.at(i) * (double)draw_multiplier), cvRound(shape2D.at(i + n) * (double)draw_multiplier)); // A rough heuristic for drawn point size int thickness = 1.0; int thickness_2 = 1.0; - //cv::circle(img, featurePoint, 1, Scalar(0,255,0), thickness); - //cv::circle(img, featurePoint, 1, Scalar(0,0,255), thickness_2); - int next_point = i + 1; if(i == 5) next_point = 0; - cv::Point nextFeaturePoint((int)shape2D.at(next_point), (int)shape2D.at(next_point+n)); - cv::line(img, featurePoint, nextFeaturePoint, cv::Scalar(255, 0, 0), thickness_2); + cv::Point nextFeaturePoint(cvRound(shape2D.at(next_point) * (double)draw_multiplier), cvRound(shape2D.at(next_point + n) * (double)draw_multiplier)); + cv::line(img, featurePoint, nextFeaturePoint, cv::Scalar(255, 0, 0), thickness_2, CV_AA, draw_shiftbits); } } } @@ -1111,18 +1163,18 @@ void Draw(cv::Mat img, const cv::Mat_& shape2D) cv::Point featurePoint; if(shape2D.cols == 1) { - featurePoint = cv::Point((int)shape2D.at(i), (int)shape2D.at(i +n)); + featurePoint = cv::Point(cvRound(shape2D.at(i) * (double)draw_multiplier), cvRound(shape2D.at(i + n) * (double)draw_multiplier)); } else { - featurePoint = cv::Point((int)shape2D.at(i, 0), (int)shape2D.at(i, 1)); + featurePoint = cv::Point(cvRound(shape2D.at(i, 0) * (double)draw_multiplier), cvRound(shape2D.at(i, 1) * (double)draw_multiplier)); } // A rough heuristic for drawn point size int thickness = (int)std::ceil(5.0* ((double)img.cols) / 640.0); int thickness_2 = (int)std::ceil(1.5* ((double)img.cols) / 640.0); - cv::circle(img, featurePoint, 1, cv::Scalar(0,0,255), thickness); - cv::circle(img, featurePoint, 1, cv::Scalar(255,0,0), thickness_2); + cv::circle(img, featurePoint, 1 * draw_multiplier, cv::Scalar(0, 0, 255), thickness, CV_AA, draw_shiftbits); + cv::circle(img, featurePoint, 1 * draw_multiplier, cv::Scalar(255, 0, 0), thickness_2, CV_AA, draw_shiftbits); } @@ -1151,12 +1203,13 @@ void DrawLandmarks(cv::Mat img, vector landmarks) { for(cv::Point p : landmarks) { + // A rough heuristic for drawn point size int thickness = (int)std::ceil(5.0* ((double)img.cols) / 640.0); int thickness_2 = (int)std::ceil(1.5* ((double)img.cols) / 640.0); - cv::circle(img, p, 1, cv::Scalar(0,0,255), thickness); - cv::circle(img, p, 1, cv::Scalar(255,0,0), thickness_2); + cv::circle(img, p, 1, cv::Scalar(0,0,255), thickness, CV_AA); + cv::circle(img, p, 1, cv::Scalar(255,0,0), thickness_2, CV_AA); } } diff --git a/lib/local/LandmarkDetector/src/PDM.cpp b/lib/local/LandmarkDetector/src/PDM.cpp index ab6e78ef..ec4dda8b 100644 --- a/lib/local/LandmarkDetector/src/PDM.cpp +++ b/lib/local/LandmarkDetector/src/PDM.cpp @@ -184,7 +184,7 @@ void PDM::CalcShape2D(cv::Mat_& out_shape, const cv::Mat_& param cv::Mat_ Shape_3D = mean_shape + princ_comp * params_local; // create the 2D shape matrix (if it has not been defined yet) - if((out_shape.rows != mean_shape.rows) || (out_shape.cols = 1)) + if((out_shape.rows != mean_shape.rows) || (out_shape.cols != 1)) { out_shape.create(2*n,1); } diff --git a/matlab_runners/Action Unit Experiments/extract_UNBC_labels.m b/matlab_runners/Action Unit Experiments/extract_UNBC_labels.m new file mode 100644 index 00000000..c61e3c3d --- /dev/null +++ b/matlab_runners/Action Unit Experiments/extract_UNBC_labels.m @@ -0,0 +1,70 @@ +function [ labels, valid_ids, filenames ] = extract_UNBC_labels( UNBC_dir, recs, aus ) +%EXTRACT_SEMAINE_LABELS Summary of this function goes here +% Detailed explanation goes here + + UNBC_dir = [UNBC_dir, '/Frame_Labels/FACS/']; + + aus_UNBC = [4, 6, 7, 9, 10, 12, 20, 25, 26, 43]; + + inds_to_use = []; + + for i=1:numel(aus) + + inds_to_use = cat(1, inds_to_use, find(aus_UNBC == aus(i))); + + end + aus_UNBC = aus_UNBC(inds_to_use); + labels_all = {}; + valid_ids_all = {}; + filenames_all = {}; + + for i=1:numel(recs) + + % get all the dirs, etc. + + sessions = dir([UNBC_dir, recs{i}]); + sessions = sessions(3:end); + + num_sessions = numel(sessions); + + labels = cell(num_sessions, 1); + valid_ids = cell(num_sessions, 1); + filenames = cell(num_sessions, 1); + + for s=1:numel(sessions) + + frames = dir([UNBC_dir, '/', recs{i}, '/', sessions(s).name, '/*.txt']); + + labels_c = zeros(numel(frames), numel(aus)); + + for f=1:numel(frames) + + file = [UNBC_dir, '/', recs{i}, '/', sessions(s).name, '/', frames(f).name]; + + fileID = fopen(file); + C = textscan(fileID,'%d %d %d %d\n'); + fclose(fileID); + +% OCC = csvread(file); %import annotations for one video file + for au = 1:numel(C{1}) + labels_c(f, aus_UNBC == C{1}(au)) = C{2}(au); + end + + end + labels{s} = labels_c; + filenames(s) = {sessions(s).name}; + valid_ids{s} = true(size(labels_c,1),1); + end + + + labels_all = cat(1, labels_all, labels); + valid_ids_all = cat(1, valid_ids_all, valid_ids); + filenames_all = cat(1, filenames_all, filenames); + + end + + labels = labels_all; + valid_ids = valid_ids_all; + filenames = filenames_all; +end + diff --git a/matlab_runners/Action Unit Experiments/helpers/evaluate_regression_results.m b/matlab_runners/Action Unit Experiments/helpers/evaluate_regression_results.m new file mode 100644 index 00000000..f54b563f --- /dev/null +++ b/matlab_runners/Action Unit Experiments/helpers/evaluate_regression_results.m @@ -0,0 +1,54 @@ +function [ accuracies, F1s, corrs, ccc, rms, classes ] = evaluate_regression_results( labels, ground_truth ) +%EVALUATE_CLASSIFICATION_RESULTS Summary of this function goes here +% Detailed explanation goes here + + classes = sort(unique(ground_truth)); + accuracies = zeros(numel(classes),1); + F1s = zeros(numel(classes),1); + + corrs = corr(labels, ground_truth); + + rms = sqrt(mean((labels-ground_truth).^2)); + + std_g = std(ground_truth); + std_p = std(labels); + + ccc = 2 * corrs * std_g * std_p / (std_g^2 + std_p^2 + (mean(labels) - mean(ground_truth))^2); + + % the label is taken to belong to a class it is closest to + label_dists = zeros(numel(labels), numel(classes)); + + for i=1:numel(classes) + label_dists(:,i) = abs(labels - classes(i)); + end + + [~, labels] = min(label_dists'); + labels = labels'; + + for i=1:numel(classes) + labels(labels==i) = classes(i); + end + + for i=1:numel(classes) + + pos_samples = ground_truth == classes(i); + neg_samples = ground_truth ~= classes(i); + + pos_labels = labels == classes(i); + neg_labels = labels ~= classes(i); + + TPs = sum(pos_samples & pos_labels); + TNs = sum(neg_samples & neg_labels); + + FPs = sum(pos_labels & neg_samples); + FNs = sum(neg_labels & pos_samples); + + accuracies(i) = (TPs + TNs) / numel(pos_samples); + + F1s(i) = 2 * TPs / (2*TPs + FNs + FPs); + + end + + +end + diff --git a/matlab_runners/Action Unit Experiments/helpers/extract_BP4D_labels.m b/matlab_runners/Action Unit Experiments/helpers/extract_BP4D_labels.m new file mode 100644 index 00000000..b197f35b --- /dev/null +++ b/matlab_runners/Action Unit Experiments/helpers/extract_BP4D_labels.m @@ -0,0 +1,67 @@ +function [ labels, valid_ids, vid_ids, filenames ] = extract_BP4D_labels( BP4D_dir, recs, aus ) +%EXTRACT_SEMAINE_LABELS Summary of this function goes here +% Detailed explanation goes here + + aus_BP4D = [1, 2, 4, 6, 7, 10, 12, 14, 15, 17, 23]; + + inds_to_use = []; + + for i=1:numel(aus) + + inds_to_use = cat(1, inds_to_use, find(aus_BP4D == aus(i))); + + end + num_files = numel(dir([BP4D_dir, '/*.csv'])); + + labels = cell(num_files, 1); + valid_ids = cell(num_files, 1); + vid_ids = zeros(num_files, 2); + filenames = cell(num_files, 1); + + file_id = 1; + + for i=1:numel(recs) + + csvs = dir([BP4D_dir, '/', recs{i}, '*.csv']); + + for f=1:numel(csvs) + + file = [BP4D_dir, '/', csvs(f).name]; + + [~, filename,~] = fileparts(file); + filenames{file_id} = filename; + + OCC = csvread(file); %import annotations for one video file + frame_nums = OCC(2:end,1); %get all frame numbers + codes = OCC(2:end,2:end); %get codes for all action units + occlusions = OCC(2:end,end); + + codes = codes(:, aus_BP4D); + + % Finding the invalid regions + valid = occlusions ~= 1; + + for s=1:size(codes,2) + + valid = valid & codes(:,s) ~= 9; + + end + + vid_ids(file_id,:) = [frame_nums(1), frame_nums(end)]; + + labels{file_id} = codes(:, inds_to_use); + + % all indices in SEMAINE are valid + valid_ids{file_id} = valid; + + file_id = file_id + 1; + end + end + + labels = labels(1:file_id-1); + valid_ids = valid_ids(1:file_id-1); + vid_ids = vid_ids(1:file_id-1, :); + filenames = filenames(1:file_id-1); + +end + diff --git a/matlab_runners/Action Unit Experiments/helpers/extract_BP4D_labels_intensity.m b/matlab_runners/Action Unit Experiments/helpers/extract_BP4D_labels_intensity.m new file mode 100644 index 00000000..deda188e --- /dev/null +++ b/matlab_runners/Action Unit Experiments/helpers/extract_BP4D_labels_intensity.m @@ -0,0 +1,63 @@ +function [ labels, valid_ids, vid_ids, filenames ] = extract_BP4D_labels_intensity( BP4D_dir, recs, aus ) +%EXTRACT_SEMAINE_LABELS Summary of this function goes here +% Detailed explanation goes here + + files_all = dir(sprintf('%s/AU%02d/%s', BP4D_dir, aus(1), '/*.csv')); + num_files = numel(files_all); + + labels = cell(num_files, 1); + valid_ids = cell(num_files, 1); + vid_ids = zeros(num_files, 2); + filenames = cell(num_files, 1); + + file_id = 1; + + for r=1:numel(recs) + + files_root = sprintf('%s/AU%02d/', BP4D_dir, aus(1)); + files_all = dir([files_root, recs{r}, '*.csv']); + + for f=1:numel(files_all) + for au=aus + + % Need to find relevant files for the relevant user and for the + % relevant AU + files_root = sprintf('%s/AU%02d/', BP4D_dir, au); + files_all = dir([files_root, recs{r}, '*.csv']); + + file = [files_root, '/', files_all(f).name]; + + [~, filename,~] = fileparts(file); + filenames{file_id} = filename(1:7); + + intensities = csvread(file); % import annotations for one session + + frame_nums = intensities(:,1); % get all frame numbers + + codes = intensities(:,2); + + % Finding the invalid regions + valid = codes ~= 9; + + vid_ids(file_id,:) = [frame_nums(1), frame_nums(end)]; + + if(au == aus(1)) + valid_ids{file_id} = valid; + labels{file_id} = codes; + else + valid_ids{file_id} = valid_ids{file_id} & valid; + labels{file_id} = cat(2, labels{file_id}, codes); + end + + end + file_id = file_id + 1; + end + end + + labels = labels(1:file_id-1); + valid_ids = valid_ids(1:file_id-1); + vid_ids = vid_ids(1:file_id-1, :); + filenames = filenames(1:file_id-1); + +end + diff --git a/matlab_runners/Action Unit Experiments/helpers/extract_Bosphorus_labels.m b/matlab_runners/Action Unit Experiments/helpers/extract_Bosphorus_labels.m new file mode 100644 index 00000000..fbdcde84 --- /dev/null +++ b/matlab_runners/Action Unit Experiments/helpers/extract_Bosphorus_labels.m @@ -0,0 +1,103 @@ +function [ labels, valid_ids, filenames ] = extract_Bosphorus_labels( Bosphorus_dir, recs, aus ) +%EXTRACT_SEMAINE_LABELS Summary of this function goes here +% Detailed explanation goes here + + % Ignoring rare ones or ones that don't overlap with other datasets + aus_Bosphorus = [1, 2, 4, 5, 6, 7, 9, 10, 12, 14, 15, 17, 20, 23, 25, 26, 43]; + aus(aus == 45) = 43; + + %% + fid = fopen([Bosphorus_dir, './facscodes/facscodes.lst']); + % Skipping the header + fgetl(fid); + fgetl(fid); + + % Starting to read + data = fgetl(fid); + + all_aus = []; + valid = []; + + id = 1; + + filenames = {}; + + while ischar(data) + + d = strsplit(data, '->'); + data = fgetl(fid); + + filename = strtrim(d{1}); + + % Skip extreme poses + if(~isempty(findstr(filename, 'CR')) || ~isempty(findstr(filename, 'YR') > 0) || ~isempty(findstr(filename, 'PR_U'))|| ~isempty(findstr(filename, 'PR_D'))) + continue; + end + + % ignore labels from non requested users + if(isempty(strmatch(filename(1:5), recs))) + continue; + end + + filenames = cat(1, filenames, filename); + + aus_str = d{2}(3:end); + + % decode the AU data + aus_c = strsplit(aus_str, '+'); + + curr_img_au = zeros(1, 80); + + for i=1:numel(aus_c) + + if(aus_c{i} == '0') + + continue + end + + intensity = -1; + + intensity_str = aus_c{i}(end); + if(intensity_str == 'A') + intensity = 1; + elseif(intensity_str == 'B') + intensity = 2; + elseif(intensity_str == 'C') + intensity = 3; + elseif(intensity_str == 'D') + intensity = 4; + elseif(intensity_str == 'E') + intensity = 5; + end + + if(~isempty(str2num(aus_c{i}(1)))) + if(intensity ~= -1) + num = str2num(aus_c{i}(1:end-1)); + else + num = str2num(aus_c{i}(1:end)); + intensity = 3; % if no intensity given just assume 3 + end + else + if(intensity ~= -1) + num = str2num(aus_c{i}(2:end-1)); + else + num = str2num(aus_c{i}(2:end)); + intensity = 3; % if no intensity given just assume 3 + end + end + + curr_img_au(1, num) = intensity; + end + all_aus = cat(1, all_aus, curr_img_au); + valid = cat(1, valid, [true]); + + id = id + 1; + + end + %aus_bosph = dlmread(, '->', 3, 0); + fclose(fid); + + valid_ids = logical(valid); + labels = all_aus(:, aus); +end + diff --git a/matlab_runners/Action Unit Experiments/helpers/extract_FERA2011_labels.m b/matlab_runners/Action Unit Experiments/helpers/extract_FERA2011_labels.m new file mode 100644 index 00000000..09392f1d --- /dev/null +++ b/matlab_runners/Action Unit Experiments/helpers/extract_FERA2011_labels.m @@ -0,0 +1,45 @@ +function [ labels, valid_ids, filenames ] = extract_FERA2011_labels( FERA2011_dir, recs, aus ) +%EXTRACT_SEMAINE_LABELS Summary of this function goes here +% Detailed explanation goes here + + num_files = numel(recs); + + % speech invalidates lower face AUs + labels = cell(num_files, 1); + valid_ids = cell(num_files, 1); + filenames = cell(num_files, 1); + + file_id = 1; + + for i=1:numel(recs) + + file = [FERA2011_dir, '/', recs{i}, '/', recs{i}, '-au.dat']; + + [~, filename,~] = fileparts(file); + filenames{file_id} = filename; + + data = csvread(file); %import annotations for one video file + + speech = data(:,end); + + labels{file_id} = data(:, aus); + + % Finding the invalid regions + if(aus(1) >= 10) + valid = speech == 0; + else + valid = true(size(speech,1), 1); + end + + % all indices in SEMAINE are valid + valid_ids{file_id} = valid; + + file_id = file_id + 1; + end + + labels = labels(1:file_id-1); + valid_ids = valid_ids(1:file_id-1); + filenames = filenames(1:file_id-1); + +end + diff --git a/matlab_runners/Action Unit Experiments/helpers/extract_SEMAINE_labels.m b/matlab_runners/Action Unit Experiments/helpers/extract_SEMAINE_labels.m new file mode 100644 index 00000000..c7f122b4 --- /dev/null +++ b/matlab_runners/Action Unit Experiments/helpers/extract_SEMAINE_labels.m @@ -0,0 +1,52 @@ +function [ labels, valid_ids, vid_ids ] = extract_SEMAINE_labels( SEMAINE_dir, recs, aus ) +%EXTRACT_SEMAINE_LABELS Summary of this function goes here +% Detailed explanation goes here + + % Get the right eaf file + + aus_SEMAINE = [2 12 17 25 28 45]; + + inds_to_use = []; + + for i=1:numel(aus) + + inds_to_use = cat(1, inds_to_use, find(aus_SEMAINE == aus(i))); + + end + + labels = cell(numel(recs), 1); + valid_ids = cell(numel(recs), 1); + vid_ids = zeros(numel(recs), 2); + + for i=1:numel(recs) + + file = dir([SEMAINE_dir, '/', recs{i}, '/*.eaf']); + + vid_ids(i,:) = dlmread([SEMAINE_dir, '/', recs{i}, '.txt'], ' '); + + xml_file = [SEMAINE_dir, recs{i}, '\' file.name]; + [root_xml, name_xml, ~] = fileparts(xml_file); + m_file = [root_xml, name_xml, '.mat']; + + if(~exist(m_file, 'file')) + activations = ParseSEMAINEAnnotations([SEMAINE_dir, recs{i}, '\' file.name]); + save(m_file, 'activations'); + else + load(m_file); + end + if(size(activations,1) < vid_ids(i,2)) + vid_ids(i,2) = size(activations,1); + if(vid_ids(i,2) > 2999) + vid_ids(i,1) = vid_ids(i,2) - 2999; + end + end + + labels{i} = activations(vid_ids(i,1)+1:vid_ids(i,2), 1 + inds_to_use); + + % all indices in SEMAINE are valid + valid_ids{i} = ones(size(labels{i},1),1); + + end + +end + diff --git a/matlab_runners/Action Unit Experiments/helpers/extract_UNBC_labels.m b/matlab_runners/Action Unit Experiments/helpers/extract_UNBC_labels.m new file mode 100644 index 00000000..c61e3c3d --- /dev/null +++ b/matlab_runners/Action Unit Experiments/helpers/extract_UNBC_labels.m @@ -0,0 +1,70 @@ +function [ labels, valid_ids, filenames ] = extract_UNBC_labels( UNBC_dir, recs, aus ) +%EXTRACT_SEMAINE_LABELS Summary of this function goes here +% Detailed explanation goes here + + UNBC_dir = [UNBC_dir, '/Frame_Labels/FACS/']; + + aus_UNBC = [4, 6, 7, 9, 10, 12, 20, 25, 26, 43]; + + inds_to_use = []; + + for i=1:numel(aus) + + inds_to_use = cat(1, inds_to_use, find(aus_UNBC == aus(i))); + + end + aus_UNBC = aus_UNBC(inds_to_use); + labels_all = {}; + valid_ids_all = {}; + filenames_all = {}; + + for i=1:numel(recs) + + % get all the dirs, etc. + + sessions = dir([UNBC_dir, recs{i}]); + sessions = sessions(3:end); + + num_sessions = numel(sessions); + + labels = cell(num_sessions, 1); + valid_ids = cell(num_sessions, 1); + filenames = cell(num_sessions, 1); + + for s=1:numel(sessions) + + frames = dir([UNBC_dir, '/', recs{i}, '/', sessions(s).name, '/*.txt']); + + labels_c = zeros(numel(frames), numel(aus)); + + for f=1:numel(frames) + + file = [UNBC_dir, '/', recs{i}, '/', sessions(s).name, '/', frames(f).name]; + + fileID = fopen(file); + C = textscan(fileID,'%d %d %d %d\n'); + fclose(fileID); + +% OCC = csvread(file); %import annotations for one video file + for au = 1:numel(C{1}) + labels_c(f, aus_UNBC == C{1}(au)) = C{2}(au); + end + + end + labels{s} = labels_c; + filenames(s) = {sessions(s).name}; + valid_ids{s} = true(size(labels_c,1),1); + end + + + labels_all = cat(1, labels_all, labels); + valid_ids_all = cat(1, valid_ids_all, valid_ids); + filenames_all = cat(1, filenames_all, filenames); + + end + + labels = labels_all; + valid_ids = valid_ids_all; + filenames = filenames_all; +end + diff --git a/matlab_runners/Action Unit Experiments/helpers/find_BP4D.m b/matlab_runners/Action Unit Experiments/helpers/find_BP4D.m new file mode 100644 index 00000000..9266a179 --- /dev/null +++ b/matlab_runners/Action Unit Experiments/helpers/find_BP4D.m @@ -0,0 +1,28 @@ +if(exist('C:\tadas\face_datasets\fera_2015\bp4d\AUCoding/', 'file')) + BP4D_dir = 'C:\tadas\face_datasets\fera_2015\bp4d\AUCoding/'; + BP4D_dir_int = 'C:\tadas\face_datasets\fera_2015\bp4d\AU Intensity Codes3.0/'; +elseif(exist('E:\datasets\FERA_2015\BP4D\AUCoding/', 'file')) + BP4D_dir = 'E:\datasets\FERA_2015\BP4D\AUCoding/'; + BP4D_dir_int = 'E:\datasets\FERA_2015\BP4D\AU Intensity Codes3.0/'; +elseif(exist('D:\datasets\face_datasets\fera_2015\bp4d\AUCoding/','file')) + BP4D_dir = 'D:\datasets\face_datasets\fera_2015\bp4d\AUCoding/'; + BP4D_dir_int = 'D:\datasets\face_datasets\fera_2015\bp4d\AU Intensity Codes3.0/'; +elseif(exist('D:\Datasets\FERA_2015\BP4D\AUCoding/','file')) + BP4D_dir = 'D:\Datasets\FERA_2015\BP4D\AUCoding/'; + BP4D_dir_int = 'D:\Datasets\FERA_2015\BP4D\AU Intensity Codes3.0/'; +elseif(exist('I:\datasets\FERA_2015\BP4D\AUCoding/', 'file')) + BP4D_dir = 'I:\datasets\FERA_2015\BP4D\AUCoding/'; + BP4D_dir_int = 'I:\datasets\FERA_2015\BP4D\AU Intensity Codes3.0/'; +elseif(exist('D:/fera_2015/bp4d/AUCoding/', 'file')) + BP4D_dir = 'D:/fera_2015/bp4d/AUCoding/'; + BP4D_dir_int = 'D:/fera_2015/bp4d/AU Intensity Codes3.0/'; +else + fprintf('BP4D location not found (or not defined)\n'); +end + + +hog_data_dir = [BP4D_dir, '../processed_data']; + +train_recs = {'F001', 'F003', 'F005', 'F007', 'F009', 'F011', 'F013', 'F015', 'F017', 'F019', 'F021', 'F023', 'M001', 'M003', 'M005', 'M007', 'M009', 'M011', 'M013', 'M015' 'M017'}; +devel_recs = {'F002', 'F004', 'F006', 'F008', 'F010', 'F012', 'F014', 'F016', 'F018', 'F020', 'F022', 'M002', 'M004', 'M006', 'M008', 'M010', 'M012', 'M014', 'M016', 'M018'}; + diff --git a/matlab_runners/Action Unit Experiments/helpers/find_Bosphorus.m b/matlab_runners/Action Unit Experiments/helpers/find_Bosphorus.m new file mode 100644 index 00000000..39c101e5 --- /dev/null +++ b/matlab_runners/Action Unit Experiments/helpers/find_Bosphorus.m @@ -0,0 +1,21 @@ +if(exist('D:/Datasets/Bosphorus/', 'file')) + Bosphorus_dir = 'D:\Datasets\Bosphorus/'; +else + fprintf('Bosphorus dataset location not found (or not defined)\n'); +end + +hog_data_dir = ['D:\Datasets\face_datasets']; + +all_recs = dir([Bosphorus_dir, '/BosphorusDB/BosphorusDB/bs*']); +all_recs_mat = cat(1, all_recs.name); +all_recs = cell(numel(all_recs), 1); + +for i=1:size(all_recs_mat,1) + + all_recs{i} = all_recs_mat(i,:); + +end + +devel_recs = all_recs(1:3:end); +train_recs = setdiff(all_recs, devel_recs); + diff --git a/matlab_runners/Action Unit Experiments/helpers/find_FERA2011.m b/matlab_runners/Action Unit Experiments/helpers/find_FERA2011.m new file mode 100644 index 00000000..411fcba8 --- /dev/null +++ b/matlab_runners/Action Unit Experiments/helpers/find_FERA2011.m @@ -0,0 +1,31 @@ +if(exist('D:\Datasets\fera/au_training', 'file')) + FERA2011_dir = 'D:\Datasets\fera/au_training/'; + hog_data_dir = 'D:\Datasets\face_datasets\hog_aligned_rigid/'; +else + fprintf('FERA2011 location not found (or not defined)\n'); +end + +all_recs = {'train_001', 'train_002', 'train_003', 'train_004', 'train_005',... + 'train_006', 'train_007', 'train_008', 'train_009', 'train_010',... + 'train_011', 'train_012', 'train_013', 'train_014', 'train_015',... + 'train_016', 'train_017', 'train_018', 'train_019', 'train_020',... + 'train_021', 'train_022', 'train_023', 'train_024', 'train_025',... + 'train_026', 'train_027', 'train_028', 'train_029', 'train_030',... + 'train_031', 'train_032', 'train_033', 'train_034', 'train_035',... + 'train_036', 'train_037', 'train_038', 'train_039', 'train_040',... + 'train_041', 'train_042', 'train_043', 'train_044', 'train_045',... + 'train_046', 'train_047', 'train_048', 'train_049', 'train_050',... + 'train_051', 'train_052', 'train_053', 'train_054', 'train_055',... + 'train_056', 'train_057', 'train_058', 'train_059', 'train_060',... + 'train_061', 'train_062', 'train_063', 'train_064', 'train_065',... + 'train_066', 'train_067', 'train_068', 'train_069', 'train_070',... + 'train_071', 'train_072', 'train_073', 'train_074', 'train_075',... + 'train_076', 'train_077', 'train_078', 'train_079', 'train_080',... + 'train_081', 'train_082', 'train_083', 'train_084', 'train_085',... + 'train_086', 'train_087'}; + +% Making them person independent +train_recs = all_recs(1:56); +devel_recs = setdiff(all_recs, train_recs); + +all_aus = [1, 2, 4, 6, 7, 10, 12, 15, 17, 18, 25, 26]; \ No newline at end of file diff --git a/matlab_runners/Action Unit Experiments/helpers/find_SEMAINE.m b/matlab_runners/Action Unit Experiments/helpers/find_SEMAINE.m new file mode 100644 index 00000000..b7c6ed2b --- /dev/null +++ b/matlab_runners/Action Unit Experiments/helpers/find_SEMAINE.m @@ -0,0 +1,24 @@ +if(exist('E:\datasets\FERA_2015\semaine/SEMAINE-Sessions/', 'file')) + SEMAINE_dir = 'E:\datasets\FERA_2015\semaine/SEMAINE-Sessions/'; +elseif(exist('I:\datasets\FERA_2015\Semaine\SEMAINE-Sessions/', 'file')) + SEMAINE_dir = 'I:\datasets\FERA_2015\Semaine\SEMAINE-Sessions/'; +elseif(exist('C:\tadas\face_datasets\fera_2015\semaine/SEMAINE-Sessions/', 'file')) + SEMAINE_dir = 'C:\tadas\face_datasets\fera_2015\semaine/SEMAINE-Sessions/'; +elseif(exist('D:\datasets\face_datasets\fera_2015\semaine\SEMAINE-Sessions/', 'file')) + SEMAINE_dir = 'D:\datasets\face_datasets\fera_2015\semaine\SEMAINE-Sessions/'; +elseif(exist('D:\Datasets\FERA_2015\semaine\SEMAINE-Sessions/', 'file')) + SEMAINE_dir = 'D:\Datasets\FERA_2015\semaine\SEMAINE-Sessions/'; +elseif(exist('D:/fera_2015/semaine/SEMAINE-Sessions/', 'file')) + SEMAINE_dir = 'D:/fera_2015/semaine/SEMAINE-Sessions/'; +else + fprintf('DISFA location not found (or not defined)\n'); +end + +if(exist('SEMAINE_dir', 'var')) + hog_data_dir = [SEMAINE_dir, '../processed_data/']; +end + +train_recs = {'rec1', 'rec12', 'rec14', 'rec19', 'rec23', 'rec25', 'rec37', 'rec39', 'rec43', 'rec45', 'rec48', 'rec50', 'rec52', 'rec54', 'rec56', 'rec60'}; +devel_recs = {'rec9', 'rec13', 'rec15', 'rec20', 'rec24', 'rec26', 'rec38', 'rec42', 'rec44', 'rec46', 'rec49', 'rec51', 'rec53', 'rec55', 'rec58'}; + +aus_SEMAINE = [2 12 17 25 28 45]; \ No newline at end of file diff --git a/matlab_runners/Action Unit Experiments/helpers/find_UNBC.m b/matlab_runners/Action Unit Experiments/helpers/find_UNBC.m new file mode 100644 index 00000000..06bb3733 --- /dev/null +++ b/matlab_runners/Action Unit Experiments/helpers/find_UNBC.m @@ -0,0 +1,17 @@ +if(exist('D:\Datasets\UNBC/', 'file')) + UNBC_dir = 'D:\Datasets\UNBC/'; + hog_data_dir = 'D:\Datasets\face_datasets\hog_aligned_rigid'; +else + fprintf('UNBC location not found (or not defined)\n'); +end + +all_recs = {'042-ll042', '043-jh043', '047-jl047', '048-aa048', '049-bm049',... + '052-dr052', '059-fn059', '064-ak064', '066-mg066', '080-bn080',... + '092-ch092', '095-tv095', '096-bg096', '097-gf097', '101-mg101',... + '103-jk103', '106-nm106', '107-hs107', '108-th108', '109-ib109',... + '115-jy115', '120-kz120', '121-vw121', '123-jh123', '124-dn124'}; + +devel_recs = all_recs(1:5:25); +train_recs = setdiff(all_recs, devel_recs); + +all_aus = [4, 6, 7, 9, 10, 12, 20, 25, 26, 43]; \ No newline at end of file diff --git a/matlab_runners/Action Unit Experiments/results/BP4D_valid_res_class.txt b/matlab_runners/Action Unit Experiments/results/BP4D_valid_res_class.txt new file mode 100644 index 00000000..7e624a5b --- /dev/null +++ b/matlab_runners/Action Unit Experiments/results/BP4D_valid_res_class.txt @@ -0,0 +1,11 @@ +AU1 class, Precision - 0.501, Recall - 0.521, F1 - 0.511 +AU2 class, Precision - 0.379, Recall - 0.451, F1 - 0.412 +AU4 class, Precision - 0.459, Recall - 0.503, F1 - 0.480 +AU6 class, Precision - 0.738, Recall - 0.774, F1 - 0.755 +AU7 class, Precision - 0.762, Recall - 0.732, F1 - 0.747 +AU10 class, Precision - 0.847, Recall - 0.842, F1 - 0.844 +AU12 class, Precision - 0.888, Recall - 0.816, F1 - 0.850 +AU14 class, Precision - 0.547, Recall - 0.807, F1 - 0.652 +AU15 class, Precision - 0.402, Recall - 0.416, F1 - 0.409 +AU17 class, Precision - 0.632, Recall - 0.592, F1 - 0.611 +AU23 class, Precision - 0.338, Recall - 0.597, F1 - 0.431 diff --git a/matlab_runners/Action Unit Experiments/results/BP4D_valid_res_int.txt b/matlab_runners/Action Unit Experiments/results/BP4D_valid_res_int.txt new file mode 100644 index 00000000..60463028 --- /dev/null +++ b/matlab_runners/Action Unit Experiments/results/BP4D_valid_res_int.txt @@ -0,0 +1,5 @@ +AU6 results - rms 0.863, corr 0.780, ccc - 0.735 +AU10 results - rms 1.035, corr 0.738, ccc - 0.684 +AU12 results - rms 0.814, corr 0.867, ccc - 0.834 +AU14 results - rms 1.107, corr 0.531, ccc - 0.486 +AU17 results - rms 0.834, corr 0.592, ccc - 0.487 diff --git a/matlab_runners/Action Unit Experiments/results/Bosphorus_res_class.txt b/matlab_runners/Action Unit Experiments/results/Bosphorus_res_class.txt new file mode 100644 index 00000000..a15af3a8 --- /dev/null +++ b/matlab_runners/Action Unit Experiments/results/Bosphorus_res_class.txt @@ -0,0 +1,17 @@ +AU1 class, Precision - 0.396, Recall - 0.724, F1 - 0.512 +AU2 class, Precision - 0.266, Recall - 0.850, F1 - 0.405 +AU4 class, Precision - 0.513, Recall - 0.877, F1 - 0.648 +AU5 class, Precision - 0.293, Recall - 0.968, F1 - 0.450 +AU6 class, Precision - 0.343, Recall - 0.823, F1 - 0.484 +AU7 class, Precision - 0.793, Recall - 0.750, F1 - 0.771 +AU9 class, Precision - 0.318, Recall - 0.960, F1 - 0.478 +AU10 class, Precision - 0.349, Recall - 0.769, F1 - 0.480 +AU12 class, Precision - 0.671, Recall - 0.863, F1 - 0.755 +AU14 class, Precision - 0.184, Recall - 0.872, F1 - 0.304 +AU15 class, Precision - 0.184, Recall - 0.858, F1 - 0.302 +AU17 class, Precision - 0.295, Recall - 0.886, F1 - 0.443 +AU20 class, Precision - 0.115, Recall - 0.930, F1 - 0.205 +AU23 class, Precision - 0.106, Recall - 0.874, F1 - 0.189 +AU25 class, Precision - 0.855, Recall - 0.871, F1 - 0.863 +AU26 class, Precision - 0.360, Recall - 0.813, F1 - 0.499 +AU45 class, Precision - 0.321, Recall - 0.768, F1 - 0.453 diff --git a/matlab_runners/Action Unit Experiments/results/Bosphorus_res_int.txt b/matlab_runners/Action Unit Experiments/results/Bosphorus_res_int.txt new file mode 100644 index 00000000..f4ff4c44 --- /dev/null +++ b/matlab_runners/Action Unit Experiments/results/Bosphorus_res_int.txt @@ -0,0 +1,17 @@ +AU1 intensity, Corr - 0.717, RMS - 0.894, CCC - 0.667 +AU2 intensity, Corr - 0.696, RMS - 0.774, CCC - 0.625 +AU4 intensity, Corr - 0.802, RMS - 0.603, CCC - 0.775 +AU5 intensity, Corr - 0.746, RMS - 0.835, CCC - 0.639 +AU6 intensity, Corr - 0.556, RMS - 0.736, CCC - 0.532 +AU7 intensity, Corr - 0.831, RMS - 0.757, CCC - 0.804 +AU9 intensity, Corr - 0.779, RMS - 0.551, CCC - 0.738 +AU10 intensity, Corr - 0.494, RMS - 0.721, CCC - 0.473 +AU12 intensity, Corr - 0.807, RMS - 0.717, CCC - 0.751 +AU14 intensity, Corr - 0.347, RMS - 0.905, CCC - 0.278 +AU15 intensity, Corr - 0.526, RMS - 0.539, CCC - 0.447 +AU17 intensity, Corr - 0.561, RMS - 0.882, CCC - 0.484 +AU20 intensity, Corr - 0.411, RMS - 0.885, CCC - 0.282 +AU23 intensity, Corr - 0.354, RMS - 0.754, CCC - 0.268 +AU25 intensity, Corr - 0.846, RMS - 0.816, CCC - 0.813 +AU26 intensity, Corr - 0.513, RMS - 0.958, CCC - 0.464 +AU45 intensity, Corr - 0.867, RMS - 0.550, CCC - 0.848 diff --git a/matlab_runners/Action Unit Experiments/results/DISFA_valid_res.txt b/matlab_runners/Action Unit Experiments/results/DISFA_valid_res.txt new file mode 100644 index 00000000..bcc07514 --- /dev/null +++ b/matlab_runners/Action Unit Experiments/results/DISFA_valid_res.txt @@ -0,0 +1,12 @@ +AU1 results - corr 0.825, rms 0.413, ccc - 0.803 +AU2 results - corr 0.765, rms 0.444, ccc - 0.659 +AU4 results - corr 0.863, rms 0.583, ccc - 0.838 +AU5 results - corr 0.749, rms 0.179, ccc - 0.717 +AU6 results - corr 0.702, rms 0.604, ccc - 0.657 +AU9 results - corr 0.742, rms 0.384, ccc - 0.689 +AU12 results - corr 0.865, rms 0.510, ccc - 0.850 +AU15 results - corr 0.747, rms 0.268, ccc - 0.714 +AU17 results - corr 0.646, rms 0.515, ccc - 0.578 +AU20 results - corr 0.637, rms 0.304, ccc - 0.595 +AU25 results - corr 0.926, rms 0.499, ccc - 0.920 +AU26 results - corr 0.805, rms 0.447, ccc - 0.764 diff --git a/matlab_runners/Action Unit Experiments/results/DISFA_valid_res_back.txt b/matlab_runners/Action Unit Experiments/results/DISFA_valid_res_back.txt new file mode 100644 index 00000000..850f8976 --- /dev/null +++ b/matlab_runners/Action Unit Experiments/results/DISFA_valid_res_back.txt @@ -0,0 +1,12 @@ +AU1 results - corr 0.832, rms 0.405, ccc - 0.809 +AU2 results - corr 0.763, rms 0.445, ccc - 0.658 +AU4 results - corr 0.863, rms 0.583, ccc - 0.838 +AU5 results - corr 0.750, rms 0.179, ccc - 0.720 +AU6 results - corr 0.702, rms 0.604, ccc - 0.657 +AU9 results - corr 0.745, rms 0.382, ccc - 0.690 +AU12 results - corr 0.865, rms 0.510, ccc - 0.850 +AU15 results - corr 0.753, rms 0.264, ccc - 0.717 +AU17 results - corr 0.656, rms 0.499, ccc - 0.589 +AU20 results - corr 0.633, rms 0.305, ccc - 0.589 +AU25 results - corr 0.914, rms 0.543, ccc - 0.903 +AU26 results - corr 0.805, rms 0.447, ccc - 0.763 diff --git a/matlab_runners/Action Unit Experiments/results/FERA2011_res_class.txt b/matlab_runners/Action Unit Experiments/results/FERA2011_res_class.txt new file mode 100644 index 00000000..3ee062d3 --- /dev/null +++ b/matlab_runners/Action Unit Experiments/results/FERA2011_res_class.txt @@ -0,0 +1,11 @@ +AU1 class, Precision - 0.588, Recall - 0.708, F1 - 0.643 +AU2 class, Precision - 0.473, Recall - 0.749, F1 - 0.580 +AU4 class, Precision - 0.509, Recall - 0.745, F1 - 0.605 +AU6 class, Precision - 0.834, Recall - 0.667, F1 - 0.741 +AU7 class, Precision - 0.685, Recall - 0.792, F1 - 0.735 +AU10 class, Precision - 0.520, Recall - 0.737, F1 - 0.610 +AU12 class, Precision - 0.919, Recall - 0.654, F1 - 0.764 +AU15 class, Precision - 0.362, Recall - 0.634, F1 - 0.461 +AU17 class, Precision - 0.230, Recall - 0.279, F1 - 0.252 +AU25 class, Precision - 0.205, Recall - 0.871, F1 - 0.332 +AU26 class, Precision - 0.122, Recall - 0.974, F1 - 0.217 diff --git a/matlab_runners/Action Unit Experiments/results/SEMAINE_valid_res.txt b/matlab_runners/Action Unit Experiments/results/SEMAINE_valid_res.txt new file mode 100644 index 00000000..61d76d11 --- /dev/null +++ b/matlab_runners/Action Unit Experiments/results/SEMAINE_valid_res.txt @@ -0,0 +1,6 @@ +AU2 class, Precision - 0.369, Recall - 0.744, F1 - 0.493 +AU12 class, Precision - 0.427, Recall - 0.782, F1 - 0.553 +AU17 class, Precision - 0.126, Recall - 0.815, F1 - 0.219 +AU25 class, Precision - 0.344, Recall - 0.574, F1 - 0.430 +AU28 class, Precision - 0.486, Recall - 0.475, F1 - 0.481 +AU45 class, Precision - 0.289, Recall - 0.621, F1 - 0.394 diff --git a/matlab_runners/Action Unit Experiments/results/UNBC_valid_res_int.txt b/matlab_runners/Action Unit Experiments/results/UNBC_valid_res_int.txt new file mode 100644 index 00000000..cfac00f2 --- /dev/null +++ b/matlab_runners/Action Unit Experiments/results/UNBC_valid_res_int.txt @@ -0,0 +1,6 @@ +AU6 results - rms 0.889, corr 0.510, ccc - 0.447 +AU7 results - rms 0.632, corr 0.583, ccc - 0.524 +AU10 results - rms 1.264, corr 0.074, ccc - 0.018 +AU12 results - rms 0.740, corr 0.636, ccc - 0.580 +AU25 results - rms 0.519, corr 0.513, ccc - 0.466 +AU26 results - rms 0.563, corr 0.411, ccc - 0.365 diff --git a/matlab_runners/Action Unit Experiments/run_AU_prediction_BP4D.m b/matlab_runners/Action Unit Experiments/run_AU_prediction_BP4D.m new file mode 100644 index 00000000..de807b68 --- /dev/null +++ b/matlab_runners/Action Unit Experiments/run_AU_prediction_BP4D.m @@ -0,0 +1,202 @@ +clear + +bp4d_loc = 'D:/Datasets/FERA_2015/BP4D/BP4D-training/'; + +out_loc = './out_bp4d/'; + +if(~exist(out_loc, 'dir')) + mkdir(out_loc); +end + +%% +executable = '"../../x64/Release/FeatureExtraction.exe"'; + +bp4d_dirs = {'F002', 'F004', 'F006', 'F008', 'F010', 'F012', 'F014', 'F016', 'F018', 'F020', 'F022', 'M002', 'M004', 'M006', 'M008', 'M010', 'M012', 'M014', 'M016', 'M018'}; + +%% Before running BP4D convert it to a smaller format and move each person to the same directory +% This is done so that dynamic models would work on it as otherwise the +% clips are a bit too short + +new_bp4d_dirs = {}; + +% This might take some time +for i = 1:numel(bp4d_dirs) + dirs = dir([bp4d_loc, '/', bp4d_dirs{i}, '/T*']); + + tmp_dir = [bp4d_loc, '/../tmp/', bp4d_dirs{i}, '/']; + new_bp4d_dirs = cat(1, new_bp4d_dirs, tmp_dir); + + if(~exist(tmp_dir, 'file')) + mkdir(tmp_dir); + + % Move all images and resize them + for d=1:numel(dirs) + + in_files = dir([bp4d_loc, '/', bp4d_dirs{i}, '/', dirs(d).name, '/*.jpg']); + + for img_ind=1:numel(in_files) + + img_file = [bp4d_loc, '/', bp4d_dirs{i}, '/', dirs(d).name, '/', in_files(img_ind).name]; + img = imread(img_file); + img = imresize(img, 0.5); + img_out = [tmp_dir, dirs(d).name, '_', in_files(img_ind).name]; + imwrite(img, img_out); + + end + + end + + end + +end +%% + +parfor f1=1:numel(new_bp4d_dirs) + + command = [executable ' -asvid -no2Dfp -no3Dfp -noMparams -noPose -noGaze ']; + + [f,~,~] = fileparts(new_bp4d_dirs{f1}); + [~,f,~] = fileparts(f); + output_file = [out_loc f '.au.txt']; + + command = cat(2, command, [' -fdir "' new_bp4d_dirs{f1} '" -of "' output_file '"']); + + dos(command); + +end + +%% +addpath('./helpers/'); + +find_BP4D; + +aus_BP4D = [1, 2, 4, 6, 7, 10, 12, 14, 15, 17, 23]; + +[ labels_gt, valid_ids, vid_ids, filenames] = extract_BP4D_labels(BP4D_dir, bp4d_dirs, aus_BP4D); +labels_gt = cat(1, labels_gt{:}); + +%% Identifying which column IDs correspond to which AU +tab = readtable([out_loc, bp4d_dirs{1}, '.au.txt']); +column_names = tab.Properties.VariableNames; + +% As there are both classes and intensities list and evaluate both of them +aus_pred_int = []; +aus_pred_class = []; + +inds_int_in_file = []; +inds_class_in_file = []; + +for c=1:numel(column_names) + if(strfind(column_names{c}, '_r') > 0) + aus_pred_int = cat(1, aus_pred_int, int32(str2num(column_names{c}(3:end-2)))); + inds_int_in_file = cat(1, inds_int_in_file, c); + end + if(strfind(column_names{c}, '_c') > 0) + aus_pred_class = cat(1, aus_pred_class, int32(str2num(column_names{c}(3:end-2)))); + inds_class_in_file = cat(1, inds_class_in_file, c); + end +end + +%% +inds_au_class = zeros(size(aus_BP4D)); + +for ind=1:numel(aus_BP4D) + if(~isempty(find(aus_pred_class==aus_BP4D(ind), 1))) + inds_au_class(ind) = find(aus_pred_class==aus_BP4D(ind)); + end +end + +preds_all_class = []; + +for i=1:numel(new_bp4d_dirs) + + [f,~,~] = fileparts(new_bp4d_dirs{i}); + [~,f,~] = fileparts(f); + + fname = [out_loc, f, '.au.txt']; + preds = dlmread(fname, ',', 1, 0); + + + % Read all of the classification AUs + preds_class = preds(:, inds_class_in_file); + + preds_all_class = cat(1, preds_all_class, preds_class); +end + +%% +f = fopen('results/BP4D_valid_res_class.txt', 'w'); +for au = 1:numel(aus_BP4D) + + if(inds_au_class(au) ~= 0) + tp = sum(labels_gt(:,au) == 1 & preds_all_class(:, inds_au_class(au)) == 1); + fp = sum(labels_gt(:,au) == 0 & preds_all_class(:, inds_au_class(au)) == 1); + fn = sum(labels_gt(:,au) == 1 & preds_all_class(:, inds_au_class(au)) == 0); + tn = sum(labels_gt(:,au) == 0 & preds_all_class(:, inds_au_class(au)) == 0); + + precision = tp./(tp+fp); + recall = tp./(tp+fn); + + f1 = 2 * precision .* recall ./ (precision + recall); + + fprintf(f, 'AU%d class, Precision - %.3f, Recall - %.3f, F1 - %.3f\n', aus_BP4D(au), precision, recall, f1); + end + +end +fclose(f); + +%% +addpath('./helpers/'); + +find_BP4D; + +aus_BP4D = [6, 10, 12, 14, 17]; +[ labels_gt, valid_ids, vid_ids, filenames] = extract_BP4D_labels_intensity(BP4D_dir_int, devel_recs, aus_BP4D); +valid_ids = cat(1, valid_ids{:}); +labels_gt = cat(1, labels_gt{:}); + +%% Identifying which column IDs correspond to which AU +tab = readtable([out_loc, bp4d_dirs{1}, '.au.txt']); +column_names = tab.Properties.VariableNames; + +% As there are both classes and intensities list and evaluate both of them +aus_pred_int = []; +inds_int_in_file = []; + +for c=1:numel(column_names) + if(strfind(column_names{c}, '_r') > 0) + aus_pred_int = cat(1, aus_pred_int, int32(str2num(column_names{c}(3:end-2)))); + inds_int_in_file = cat(1, inds_int_in_file, c); + end +end + +%% +inds_au_int = zeros(size(aus_BP4D)); + +for ind=1:numel(aus_BP4D) + if(~isempty(find(aus_pred_int==aus_BP4D(ind), 1))) + inds_au_int(ind) = find(aus_pred_int==aus_BP4D(ind)); + end +end + +preds_all_int = []; + +for i=1:numel(new_bp4d_dirs) + + [f,~,~] = fileparts(new_bp4d_dirs{i}); + [~,f,~] = fileparts(f); + + fname = [out_loc, f, '.au.txt']; + preds = dlmread(fname, ',', 1, 0); + + % Read all of the intensity AUs + preds_int = preds(:, inds_int_in_file); + preds_all_int = cat(1, preds_all_int, preds_int); +end + +%% +f = fopen('results/BP4D_valid_res_int.txt', 'w'); +for au = 1:numel(aus_BP4D) + [ accuracies, F1s, corrs, ccc, rms, classes ] = evaluate_au_prediction_results( preds_all_int(valid_ids, inds_au_int(au)), labels_gt(valid_ids,au)); + fprintf(f, 'AU%d results - rms %.3f, corr %.3f, ccc - %.3f\n', aus_BP4D(au), rms, corrs, ccc); +end +fclose(f); \ No newline at end of file diff --git a/matlab_runners/Action Unit Experiments/run_AU_prediction_Bosphorus.m b/matlab_runners/Action Unit Experiments/run_AU_prediction_Bosphorus.m new file mode 100644 index 00000000..fff14c52 --- /dev/null +++ b/matlab_runners/Action Unit Experiments/run_AU_prediction_Bosphorus.m @@ -0,0 +1,190 @@ +% Perform static model prediction using images + +clear + +addpath('./helpers'); + +find_Bosphorus; +out_loc = './out_bosph/'; + +if(~exist(out_loc, 'dir')) + mkdir(out_loc); +end + +%% +executable = '"../../x64/Release/FaceLandmarkImg.exe"'; + +bosph_dirs = dir([Bosphorus_dir, '/BosphorusDB/BosphorusDB/bs*']); + +%% +parfor f1=1:numel(bosph_dirs) + + command = executable; + + input_dir = [Bosphorus_dir, '/BosphorusDB/BosphorusDB/', bosph_dirs(f1).name]; + command = cat(2, command, [' -fdir "' input_dir '" -ofdir "' out_loc '"']); + command = cat(2, command, ' -multi_view 1 -wild -q'); + + dos(command); + +end + +%% + +aus_Bosph = [1, 2, 4, 5, 6, 7, 9, 10, 12, 14, 15, 17, 20, 23, 25, 26, 45]; + +[ labels_gt, valid_ids, filenames] = extract_Bosphorus_labels(Bosphorus_dir, all_recs, aus_Bosph); + +%% Read the predicted values + +% First read the first file to get the ids and line numbers +% au occurences +fid = fopen([out_loc, filenames{1}, '_det_0.pts']); +data = fgetl(fid); + +ind = 0; +beg_ind = -1; +end_ind = -1; +aus_det = []; +aus_det_id = []; + +while ischar(data) + if(~isempty(findstr(data, 'au occurences:'))) + num_occurences = str2num(data(numel('au occurences:')+1:end)); + % Skip ahead two lines + data = fgetl(fid); + data = fgetl(fid); + ind = ind + 2; + beg_ind = ind; + end + + if(beg_ind ~= -1 && end_ind == -1) + if(~isempty(findstr(data, '}'))) + end_ind = ind; + else + d = strsplit(data, ' '); + aus_det = cat(1, aus_det, str2num(d{1}(3:end))); + aus_det_id = cat(1, aus_det_id, ind - beg_ind + 1); + end + end + + data = fgetl(fid); + ind = ind + 1; +end +fclose(fid); + +%% +labels_pred = zeros(size(labels_gt)); +for i=1:numel(filenames) + + % Will need to read the relevant AUs only + if(exist([out_loc, filenames{i}, '_det_0.pts'], 'file')) + fid = fopen([out_loc, filenames{i}, '_det_0.pts']); + for k=1:beg_ind + data = fgetl(fid); + end + + for k=1:num_occurences + data = fgetl(fid); + if(sum(aus_Bosph == aus_det(k))>0) + d = strsplit(data, ' '); + labels_pred(i, aus_Bosph == aus_det(k)) = str2num(d{2}); + end + end + + fclose(fid); + end +end + +%% +f = fopen('results/Bosphorus_res_class.txt', 'w'); +labels_gt_bin = labels_gt; +labels_gt_bin(labels_gt_bin > 1) = 1; +for au = 1:numel(aus_Bosph) + + tp = sum(labels_gt_bin(:,au) == 1 & labels_pred(:, au) == 1); + fp = sum(labels_gt_bin(:,au) == 0 & labels_pred(:, au) == 1); + fn = sum(labels_gt_bin(:,au) == 1 & labels_pred(:, au) == 0); + tn = sum(labels_gt_bin(:,au) == 0 & labels_pred(:, au) == 0); + + precision = tp./(tp+fp); + recall = tp./(tp+fn); + + f1 = 2 * precision .* recall ./ (precision + recall); + + fprintf(f, 'AU%d class, Precision - %.3f, Recall - %.3f, F1 - %.3f\n', aus_Bosph(au), precision, recall, f1); + +end +fclose(f); + +%% Read the predicted values for intensities + +% First read the first file to get the ids and line numbers +% au occurences +fid = fopen([out_loc, filenames{1}, '_det_0.pts']); +data = fgetl(fid); + +ind = 0; +beg_ind = -1; +end_ind = -1; +aus_det = []; +aus_det_id = []; + +while ischar(data) + if(~isempty(findstr(data, 'au intensities:'))) + num_occurences = str2num(data(numel('au intensities:')+1:end)); + % Skip ahead two lines + data = fgetl(fid); + data = fgetl(fid); + ind = ind + 2; + beg_ind = ind; + end + + if(beg_ind ~= -1 && end_ind == -1) + if(~isempty(findstr(data, '}'))) + end_ind = ind; + else + d = strsplit(data, ' '); + aus_det = cat(1, aus_det, str2num(d{1}(3:end))); + aus_det_id = cat(1, aus_det_id, ind - beg_ind + 1); + end + end + + data = fgetl(fid); + ind = ind + 1; +end +fclose(fid); + +%% +labels_pred = zeros(size(labels_gt)); +for i=1:numel(filenames) + + % Will need to read the relevant AUs only + if(exist([out_loc, filenames{i}, '_det_0.pts'], 'file')) + fid = fopen([out_loc, filenames{i}, '_det_0.pts']); + for k=1:beg_ind + data = fgetl(fid); + end + + for k=1:num_occurences + data = fgetl(fid); + if(sum(aus_Bosph == aus_det(k))>0) + d = strsplit(data, ' '); + labels_pred(i, aus_Bosph == aus_det(k)) = str2num(d{2}); + end + end + + fclose(fid); + end +end + +%% +f = fopen('results/Bosphorus_res_int.txt', 'w'); +for au = 1:numel(aus_Bosph) + + [ ~, ~, corrs, ccc, rms, ~ ] = evaluate_regression_results( labels_pred(:, au), labels_gt(:, au)); + + fprintf(f, 'AU%d intensity, Corr - %.3f, RMS - %.3f, CCC - %.3f\n', aus_Bosph(au), corrs, rms, ccc); + +end +fclose(f); diff --git a/matlab_runners/Action Unit Experiments/run_AU_prediction_DISFA.m b/matlab_runners/Action Unit Experiments/run_AU_prediction_DISFA.m index 5dd78759..20b0c7dc 100644 --- a/matlab_runners/Action Unit Experiments/run_AU_prediction_DISFA.m +++ b/matlab_runners/Action Unit Experiments/run_AU_prediction_DISFA.m @@ -1,10 +1,10 @@ clear DISFA_dir = 'D:/Datasets/DISFA/Videos_LeftCamera/'; -clm_exe = '"../../x64/Release/FeatureExtraction.exe"'; +executable = '"../../x64/Release/FeatureExtraction.exe"'; videos = dir([DISFA_dir, '*.avi']); -output = 'AU_preds/'; +output = 'out_DISFA/'; if(~exist(output, 'file')) mkdir(output); end @@ -20,7 +20,7 @@ parfor v = 1:numel(videos) % where to output tracking results output_file = [output name '_au.txt']; - command = [clm_exe ' -f "' vid_file '" -of "' output_file '" -q -no2Dfp -no3Dfp -noMparams -noPose -noGaze']; + command = [executable ' -f "' vid_file '" -of "' output_file '" -q -no2Dfp -no3Dfp -noMparams -noPose -noGaze']; dos(command); @@ -33,7 +33,7 @@ end % the results Label_dir = 'D:/Datasets/DISFA/ActionUnit_Labels/'; -prediction_dir = 'AU_preds/'; +prediction_dir = 'out_DISFA/'; label_folders = dir([Label_dir, 'SN*']); @@ -83,11 +83,11 @@ for i=1:numel(preds_files) end %% now do the actual evaluation that the collection has been done -f = fopen('DISFA_valid_res.txt', 'w'); +f = fopen('results/DISFA_valid_res.txt', 'w'); au_res = zeros(1, numel(AUs_disfa)); for au = 1:numel(AUs_disfa) [ accuracies, F1s, corrs, ccc, rms, classes ] = evaluate_au_prediction_results( preds_all(:,au), labels_all(:,au)); - fprintf(f, 'AU%d results - corr %.3f, ccc - %.3f\n', AUs_disfa(au), corrs, ccc); + fprintf(f, 'AU%d results - corr %.3f, rms %.3f, ccc - %.3f\n', AUs_disfa(au), corrs, rms, ccc); au_res(au) = ccc; end fclose(f); \ No newline at end of file diff --git a/matlab_runners/Action Unit Experiments/run_AU_prediction_FERA2011.m b/matlab_runners/Action Unit Experiments/run_AU_prediction_FERA2011.m new file mode 100644 index 00000000..f2d2f28a --- /dev/null +++ b/matlab_runners/Action Unit Experiments/run_AU_prediction_FERA2011.m @@ -0,0 +1,116 @@ +clear + +fera_loc = 'D:\Datasets\fera\'; + +out_loc = './out_fera/'; + +if(~exist(out_loc, 'dir')) + mkdir(out_loc); +end + +%% +executable = '"../../x64/Release/FeatureExtraction.exe"'; + +fera_dirs = dir([fera_loc, 'au_train*']); + +for f1=1:numel(fera_dirs) + + fera_dirs_level_2 = dir([fera_loc, fera_dirs(f1).name]); + fera_dirs_level_2 = fera_dirs_level_2(3:end); + + parfor f2=1:numel(fera_dirs_level_2) + + vid_files = dir([fera_loc, fera_dirs(f1).name, '/', fera_dirs_level_2(f2).name, '/*.avi']); + + for v=1:numel(vid_files) + + command = [executable ' -asvid -q -no2Dfp -no3Dfp -noMparams -noPose -noGaze -au_static ']; + + curr_vid = [fera_loc, fera_dirs(f1).name, '/', fera_dirs_level_2(f2).name, '/', vid_files(v).name]; + + [~,name,~] = fileparts(curr_vid); + output_file = [out_loc name '.au.txt']; + + command = cat(2, command, [' -f "' curr_vid '" -of "' output_file '"']); + + + dos(command); + end + end +end + +%% +addpath('./helpers/'); + +find_FERA2011; + +[ labels_gt, valid_ids, filenames] = extract_FERA2011_labels(FERA2011_dir, all_recs, all_aus); +labels_gt = cat(1, labels_gt{:}); + +for i=1:numel(filenames) + filenames{i} = filenames{i}(1:end-3); +end + +%% Identifying which column IDs correspond to which AU +tab = readtable([out_loc, 'train_001.au.txt']); +column_names = tab.Properties.VariableNames; + +% As there are both classes and intensities list and evaluate both of them +aus_pred_class = []; + +inds_class_in_file = []; + +for c=1:numel(column_names) + if(strfind(column_names{c}, '_c') > 0) + aus_pred_class = cat(1, aus_pred_class, int32(str2num(column_names{c}(3:end-2)))); + inds_class_in_file = cat(1, inds_class_in_file, c); + end +end + +%% +inds_au_class = zeros(size(all_aus)); + +for ind=1:numel(all_aus) + if(~isempty(find(aus_pred_class==all_aus(ind), 1))) + inds_au_class(ind) = find(aus_pred_class==all_aus(ind)); + end +end + +%% +preds_all_class = []; + +for i=1:numel(filenames) + + fname = dir([out_loc, '/*', filenames{i}, '.au.txt']); + fname = fname(1).name; + + preds = dlmread([out_loc '/' fname], ',', 1, 0); + + % Read all of the intensity AUs + preds_class = preds(:, inds_class_in_file); + + preds_all_class = cat(1, preds_all_class, preds_class); +end + +%% +f = fopen('results/FERA2011_res_class.txt', 'w'); +au_res = []; +for au = 1:numel(all_aus) + if(inds_au_class(au) ~= 0) + + tp = sum(labels_gt(:,au) == 1 & preds_all_class(:, inds_au_class(au)) == 1); + fp = sum(labels_gt(:,au) == 0 & preds_all_class(:, inds_au_class(au)) == 1); + fn = sum(labels_gt(:,au) == 1 & preds_all_class(:, inds_au_class(au)) == 0); + tn = sum(labels_gt(:,au) == 0 & preds_all_class(:, inds_au_class(au)) == 0); + + precision = tp./(tp+fp); + recall = tp./(tp+fn); + + f1 = 2 * precision .* recall ./ (precision + recall); + + fprintf(f, 'AU%d class, Precision - %.3f, Recall - %.3f, F1 - %.3f\n', all_aus(au), precision, recall, f1); + au_res = cat(1, au_res, f1); + end + +end +fclose(f); \ No newline at end of file diff --git a/matlab_runners/Action Unit Experiments/run_AU_prediction_SEMAINE.m b/matlab_runners/Action Unit Experiments/run_AU_prediction_SEMAINE.m new file mode 100644 index 00000000..4947b075 --- /dev/null +++ b/matlab_runners/Action Unit Experiments/run_AU_prediction_SEMAINE.m @@ -0,0 +1,117 @@ +clear + +addpath(genpath('helpers/')); +find_SEMAINE; + +out_loc = './out_SEMAINE/'; + +if(~exist(out_loc, 'dir')) + mkdir(out_loc); +end + +executable = '"../../x64/Release/FeatureExtraction.exe"'; +%% +parfor f1=1:numel(devel_recs) + + + if(isdir([SEMAINE_dir, devel_recs{f1}])) + + vid_file = dir([SEMAINE_dir, devel_recs{f1}, '/*.avi']); + + f1_dir = devel_recs{f1}; + + command = [executable, ' -fx 800 -fy 800 -q -no2Dfp -no3Dfp -noMparams -noPose -noGaze ']; + + curr_vid = [SEMAINE_dir, f1_dir, '/', vid_file.name]; + + name = f1_dir; + output_aus = [out_loc name '.au.txt']; + + command = cat(2, command, [' -f "' curr_vid '" -of "' output_aus]); + dos(command); + + end +end + +%% Actual model evaluation +[ labels, valid_ids, vid_ids ] = extract_SEMAINE_labels(SEMAINE_dir, devel_recs, aus_SEMAINE); + +labels_gt = cat(1, labels{:}); + +%% Identifying which column IDs correspond to which AU +tab = readtable([out_loc, devel_recs{1}, '.au.txt']); +column_names = tab.Properties.VariableNames; + +% As there are both classes and intensities list and evaluate both of them +aus_pred_int = []; +aus_pred_class = []; + +inds_int_in_file = []; +inds_class_in_file = []; + +for c=1:numel(column_names) + if(strfind(column_names{c}, '_r') > 0) + aus_pred_int = cat(1, aus_pred_int, int32(str2num(column_names{c}(3:end-2)))); + inds_int_in_file = cat(1, inds_int_in_file, c); + end + if(strfind(column_names{c}, '_c') > 0) + aus_pred_class = cat(1, aus_pred_class, int32(str2num(column_names{c}(3:end-2)))); + inds_class_in_file = cat(1, inds_class_in_file, c); + end +end + +%% +inds_au_int = zeros(size(aus_SEMAINE)); +inds_au_class = zeros(size(aus_SEMAINE)); + +for ind=1:numel(aus_SEMAINE) + if(~isempty(find(aus_pred_int==aus_SEMAINE(ind), 1))) + inds_au_int(ind) = find(aus_pred_int==aus_SEMAINE(ind)); + end +end + +for ind=1:numel(aus_SEMAINE) + if(~isempty(find(aus_pred_class==aus_SEMAINE(ind), 1))) + inds_au_class(ind) = find(aus_pred_class==aus_SEMAINE(ind)); + end +end + +preds_all_class = []; +preds_all_int = []; + +for i=1:numel(devel_recs) + + fname = [out_loc, devel_recs{i}, '.au.txt']; + preds = dlmread(fname, ',', 1, 0); + + % Read all of the intensity AUs + preds_int = preds(vid_ids(i,1):vid_ids(i,2) - 1, inds_int_in_file); + + % Read all of the classification AUs + preds_class = preds(vid_ids(i,1):vid_ids(i,2) - 1, inds_class_in_file); + + preds_all_class = cat(1, preds_all_class, preds_class); + preds_all_int = cat(1, preds_all_int, preds_int); +end + +%% +f = fopen('results/SEMAINE_valid_res.txt', 'w'); +f1s = zeros(1, numel(aus_SEMAINE)); +for au = 1:numel(aus_SEMAINE) + + if(inds_au_class(au) ~= 0) + tp = sum(labels_gt(:,au) == 1 & preds_all_class(:, inds_au_class(au)) == 1); + fp = sum(labels_gt(:,au) == 0 & preds_all_class(:, inds_au_class(au)) == 1); + fn = sum(labels_gt(:,au) == 1 & preds_all_class(:, inds_au_class(au)) == 0); + tn = sum(labels_gt(:,au) == 0 & preds_all_class(:, inds_au_class(au)) == 0); + + precision = tp./(tp+fp); + recall = tp./(tp+fn); + + f1 = 2 * precision .* recall ./ (precision + recall); + f1s(au) = f1; + fprintf(f, 'AU%d class, Precision - %.3f, Recall - %.3f, F1 - %.3f\n', aus_SEMAINE(au), precision, recall, f1); + end + +end +fclose(f); \ No newline at end of file diff --git a/matlab_runners/Action Unit Experiments/run_AU_prediction_UNBC.m b/matlab_runners/Action Unit Experiments/run_AU_prediction_UNBC.m new file mode 100644 index 00000000..9e71ae32 --- /dev/null +++ b/matlab_runners/Action Unit Experiments/run_AU_prediction_UNBC.m @@ -0,0 +1,107 @@ +clear + +unbc_loc = 'D:/Datasets/UNBC/Images/'; + +out_loc = './out_unbc/'; + +if(~exist(out_loc, 'dir')) + mkdir(out_loc); +end + +%% +executable = '"../../x64/Release/FeatureExtraction.exe"'; + +unbc_dirs = {'042-ll042', '043-jh043', '047-jl047', '048-aa048', '049-bm049',... + '052-dr052', '059-fn059', '064-ak064', '066-mg066', '080-bn080',... + '092-ch092', '095-tv095', '096-bg096', '097-gf097', '101-mg101',... + '103-jk103', '106-nm106', '107-hs107', '108-th108', '109-ib109',... + '115-jy115', '120-kz120', '121-vw121', '123-jh123', '124-dn124'}; + +for f1=1:numel(unbc_dirs) + + if(isdir([unbc_loc, unbc_dirs{f1}])) + + unbc_2_dirs = dir([unbc_loc, unbc_dirs{f1}]); + unbc_2_dirs = unbc_2_dirs(3:end); + + f1_dir = unbc_dirs{f1}; + + command = [executable ' -asvid -q -no2Dfp -no3Dfp -noMparams -noPose -noGaze ']; + + for f2=1:numel(unbc_2_dirs) + f2_dir = unbc_2_dirs(f2).name; + if(isdir([unbc_loc, unbc_dirs{f1}])) + + curr_vid = [unbc_loc, f1_dir, '/', f2_dir, '/']; + + name = [f1_dir '_' f2_dir]; + output_file = [out_loc name '.au.txt']; + + command = cat(2, command, [' -fdir "' curr_vid '" -of "' output_file '"']); + end + end + + dos(command); + end +end + +%% +addpath('./helpers/'); + +find_UNBC; + +aus_UNBC = [6, 7, 10, 12, 25, 26]; + +[ labels_gt, valid_ids, filenames] = extract_UNBC_labels(UNBC_dir, unbc_dirs, aus_UNBC); +labels_gt = cat(1, labels_gt{:}); + +%% Identifying which column IDs correspond to which AU +tab = readtable([out_loc, '042-ll042_ll042t1aaaff.au.txt']); +column_names = tab.Properties.VariableNames; + +% As there are both classes and intensities list and evaluate both of them +aus_pred_int = []; + +inds_int_in_file = []; + +for c=1:numel(column_names) + if(strfind(column_names{c}, '_r') > 0) + aus_pred_int = cat(1, aus_pred_int, int32(str2num(column_names{c}(3:end-2)))); + inds_int_in_file = cat(1, inds_int_in_file, c); + end +end + +%% +inds_au_int = zeros(size(aus_UNBC)); + +for ind=1:numel(aus_UNBC) + if(~isempty(find(aus_pred_int==aus_UNBC(ind), 1))) + inds_au_int(ind) = find(aus_pred_int==aus_UNBC(ind)); + end +end + + +preds_all_int = []; + +for i=1:numel(filenames) + + fname = dir([out_loc, '/*', filenames{i}, '.au.txt']); + fname = fname(1).name; + + preds = dlmread([out_loc '/' fname], ',', 1, 0); + + % Read all of the intensity AUs + preds_int = preds(:, inds_int_in_file); + + preds_all_int = cat(1, preds_all_int, preds_int); +end + +%% +f = fopen('results/UNBC_valid_res_int.txt', 'w'); +for au = 1:numel(aus_UNBC) + + [ accuracies, F1s, corrs, ccc, rms, classes ] = evaluate_au_prediction_results( preds_all_int(:, inds_au_int(au)), labels_gt(:,au)); + fprintf(f, 'AU%d results - rms %.3f, corr %.3f, ccc - %.3f\n', aus_UNBC(au), rms, corrs, ccc); + +end +fclose(f); \ No newline at end of file diff --git a/matlab_runners/Demos/feature_extraction_demo_img_seq.m b/matlab_runners/Demos/feature_extraction_demo_img_seq.m index 1b27f14f..aff1b730 100644 --- a/matlab_runners/Demos/feature_extraction_demo_img_seq.m +++ b/matlab_runners/Demos/feature_extraction_demo_img_seq.m @@ -1,4 +1,4 @@ -clm_exe = '"../../x64/Release/FeatureExtraction.exe"'; +executable = '"../../x64/Release/FeatureExtraction.exe"'; output = './output_features_seq/'; @@ -10,8 +10,7 @@ in_dirs = {'../../image_sequence'}; % some parameters verbose = true; -command = clm_exe; -command = cat(2, command, ' -rigid '); +command = executable; % Remove for a speedup command = cat(2, command, ' -verbose '); diff --git a/matlab_runners/Demos/feature_extraction_demo_vid.m b/matlab_runners/Demos/feature_extraction_demo_vid.m index 53351bd2..8c8b5d4c 100644 --- a/matlab_runners/Demos/feature_extraction_demo_vid.m +++ b/matlab_runners/Demos/feature_extraction_demo_vid.m @@ -1,4 +1,4 @@ -clm_exe = '"../../x64/Release/FeatureExtraction.exe"'; +executable = '"../../x64/Release/FeatureExtraction.exe"'; output = './output_features_vid/'; @@ -10,8 +10,7 @@ in_files = dir('../../videos/1815_01_008_tony_blair.avi'); % some parameters verbose = true; -command = clm_exe; -command = cat(2, command, ' -rigid '); +command = executable; % Remove for a speedup command = cat(2, command, ' -verbose '); diff --git a/matlab_runners/Demos/run_demo_images.m b/matlab_runners/Demos/run_demo_images.m index f66ae49e..3e33b62b 100644 --- a/matlab_runners/Demos/run_demo_images.m +++ b/matlab_runners/Demos/run_demo_images.m @@ -1,6 +1,6 @@ clear -clm_exe = '"../../x64/Release/FaceLandmarkImg.exe"'; +executable = '"../../x64/Release/FaceLandmarkImg.exe"'; in_dir = '../../videos/'; out_dir = './demo_img/'; @@ -22,7 +22,7 @@ model = 'model/main_clnf_general.txt'; % Trained on in-the-wild %model = 'model/main_clnf_wild.txt'; -command = clm_exe; +command = executable; command = cat(2, command, [' -fdir "' in_dir '"']); diff --git a/matlab_runners/Demos/run_demo_video_multi.m b/matlab_runners/Demos/run_demo_video_multi.m index 988acac9..d5519257 100644 --- a/matlab_runners/Demos/run_demo_video_multi.m +++ b/matlab_runners/Demos/run_demo_video_multi.m @@ -1,4 +1,4 @@ -clm_exe = '"../../x64/Release/FaceLandmarkVidMulti.exe"'; +executable = '"../../x64/Release/FaceLandmarkVidMulti.exe"'; output = './demo_vid/'; @@ -20,7 +20,7 @@ model = 'model/main_clnf_general.txt'; % Trained on in-the-wild %model = 'model/main_clnf_wild.txt'; -command = clm_exe; +command = executable; command = cat(2, command, [' -mloc "', model, '"']); % add all videos to single argument list (so as not to load the model anew % for every video) diff --git a/matlab_runners/Demos/run_demo_videos.m b/matlab_runners/Demos/run_demo_videos.m index de0ebf3b..7d1f4065 100644 --- a/matlab_runners/Demos/run_demo_videos.m +++ b/matlab_runners/Demos/run_demo_videos.m @@ -1,4 +1,4 @@ -clm_exe = '"../../x64/Release/FaceLandmarkVid.exe"'; +executable = '"../../x64/Release/FaceLandmarkVid.exe"'; output = './demo_vid/'; @@ -21,7 +21,7 @@ model = 'model/main_clnf_general.txt'; % Trained on in-the-wild %model = 'model/main_clnf_wild.txt'; -command = clm_exe; +command = executable; command = cat(2, command, [' -mloc "', model, '"']); % add all videos to single argument list (so as not to load the model anew % for every video) diff --git a/matlab_runners/Feature Point Experiments/Run_CLM_fitting_on_images.m b/matlab_runners/Feature Point Experiments/Run_CLM_fitting_on_images.m index ebe1207e..131a15de 100644 --- a/matlab_runners/Feature Point Experiments/Run_CLM_fitting_on_images.m +++ b/matlab_runners/Feature Point Experiments/Run_CLM_fitting_on_images.m @@ -46,7 +46,7 @@ command = cat(2, command, [' -mloc ' model ' ']); command = cat(2, command, [' -multi_view ' num2str(multi_view) ' ']); tic -for i=1:numel(dataset_dirs) +parfor i=1:numel(dataset_dirs) input_loc = ['-fdir "', dataset_dirs{i}, '" ']; command_c = cat(2, command, input_loc); diff --git a/matlab_runners/Feature Point Experiments/results/fps_yt.mat b/matlab_runners/Feature Point Experiments/results/fps_yt.mat index 399ddeab..af63eceb 100644 Binary files a/matlab_runners/Feature Point Experiments/results/fps_yt.mat and b/matlab_runners/Feature Point Experiments/results/fps_yt.mat differ diff --git a/matlab_runners/Feature Point Experiments/results/fps_yt.txt b/matlab_runners/Feature Point Experiments/results/fps_yt.txt index b1d3e4ca..8c126310 100644 --- a/matlab_runners/Feature Point Experiments/results/fps_yt.txt +++ b/matlab_runners/Feature Point Experiments/results/fps_yt.txt @@ -1,3 +1,3 @@ Model, mean, median -OpenFace (CLNF): 0.0561, 0.0512 +OpenFace (CLNF): 0.0562, 0.0515 CLM: 0.0683, 0.0602 diff --git a/matlab_runners/Feature Point Experiments/results/in-the-wild-res-no-outline.pdf b/matlab_runners/Feature Point Experiments/results/in-the-wild-res-no-outline.pdf index cfddb547..02921760 100644 Binary files a/matlab_runners/Feature Point Experiments/results/in-the-wild-res-no-outline.pdf and b/matlab_runners/Feature Point Experiments/results/in-the-wild-res-no-outline.pdf differ diff --git a/matlab_runners/Feature Point Experiments/results/landmark_detections.mat b/matlab_runners/Feature Point Experiments/results/landmark_detections.mat index bf9d68de..9548166b 100644 Binary files a/matlab_runners/Feature Point Experiments/results/landmark_detections.mat and b/matlab_runners/Feature Point Experiments/results/landmark_detections.mat differ diff --git a/matlab_runners/Feature Point Experiments/run_clm_feature_point_tests_wild.m b/matlab_runners/Feature Point Experiments/run_clm_feature_point_tests_wild.m index 9df6594a..0587666d 100644 --- a/matlab_runners/Feature Point Experiments/run_clm_feature_point_tests_wild.m +++ b/matlab_runners/Feature Point Experiments/run_clm_feature_point_tests_wild.m @@ -6,7 +6,7 @@ curr_dir = cd('.'); if(exist([getenv('USERPROFILE') '/Dropbox/AAM/test data/'], 'file')) database_root = [getenv('USERPROFILE') '/Dropbox/AAM/test data/']; else - database_root = 'F:/Dropbox/Dropbox/AAM/test data/'; + database_root = 'D:/Dropbox/Dropbox/AAM/test data/'; end %% Run using CLNF in the wild model diff --git a/matlab_runners/Feature Point Experiments/run_yt_dataset.m b/matlab_runners/Feature Point Experiments/run_yt_dataset.m index bb72a233..aeca5b8c 100644 --- a/matlab_runners/Feature Point Experiments/run_yt_dataset.m +++ b/matlab_runners/Feature Point Experiments/run_yt_dataset.m @@ -11,7 +11,7 @@ end if(exist([getenv('USERPROFILE') '/Dropbox/AAM/test data/'], 'file')) database_root = [getenv('USERPROFILE') '/Dropbox/AAM/test data/']; else - database_root = 'F:/Dropbox/Dropbox/AAM/test data/'; + database_root = 'D:/Dropbox/Dropbox/AAM/test data/'; end database_root = [database_root, '/ytceleb_annotations_CVPR2014/']; diff --git a/matlab_runners/Full_test_suite.m b/matlab_runners/Full_test_suite.m index 72480ab5..29cbbe69 100644 --- a/matlab_runners/Full_test_suite.m +++ b/matlab_runners/Full_test_suite.m @@ -1,8 +1,6 @@ % This is sort of the unit test for the whole module (needs datasets) % Will take over an hour to run all -% TODO need some unit testy things, some asserts - tic %% Head pose cd('Head Pose Experiments'); @@ -24,13 +22,21 @@ cd('../'); %% AUs cd('Action Unit Experiments'); run_AU_prediction_DISFA -assert(mean(au_res) > 0.6); +assert(mean(au_res) > 0.7); + +run_AU_prediction_SEMAINE +assert(mean(f1s) > 0.42); + +run_AU_prediction_FERA2011 +assert(mean(au_res) > 0.5); + cd('../'); %% Gaze cd('Gaze Experiments'); extract_mpii_gaze_test -assert(median_error < 9.5) +assert(mean_error < 9.5) +assert(median_error < 9.0) cd('../'); %% Demos diff --git a/matlab_runners/Gaze Experiments/extract_mpii_gaze_test.m b/matlab_runners/Gaze Experiments/extract_mpii_gaze_test.m index b1f990bf..fd0fa7d8 100644 --- a/matlab_runners/Gaze Experiments/extract_mpii_gaze_test.m +++ b/matlab_runners/Gaze Experiments/extract_mpii_gaze_test.m @@ -5,6 +5,8 @@ curr_dir = cd('.'); % Replace this with your downloaded 300-W train data if(exist([getenv('USERPROFILE') '/Dropbox/AAM/eye_clm/mpii_data/'], 'file')) database_root = [getenv('USERPROFILE') '/Dropbox/AAM/eye_clm/mpii_data/']; +elseif(exist('D:\Dropbox/Dropbox/AAM/eye_clm/mpii_data/', 'file')) + database_root = 'D:\Dropbox/Dropbox/AAM/eye_clm/mpii_data/'; else fprintf('MPII gaze dataset not found\n'); end diff --git a/matlab_runners/Gaze Experiments/mpii_1500_errs.mat b/matlab_runners/Gaze Experiments/mpii_1500_errs.mat index 098ca619..bb9f304c 100644 Binary files a/matlab_runners/Gaze Experiments/mpii_1500_errs.mat and b/matlab_runners/Gaze Experiments/mpii_1500_errs.mat differ diff --git a/matlab_runners/Gaze Experiments/mpii_1500_errs.txt b/matlab_runners/Gaze Experiments/mpii_1500_errs.txt index 6e6f0f99..4058ebdb 100644 --- a/matlab_runners/Gaze Experiments/mpii_1500_errs.txt +++ b/matlab_runners/Gaze Experiments/mpii_1500_errs.txt @@ -1,2 +1,2 @@ Mean error, median error -9.977, 9.329 +9.469, 8.773 diff --git a/matlab_runners/Head Pose Experiments/calcBUerror.m b/matlab_runners/Head Pose Experiments/calcBUerror.m index 464af792..be3e0ed1 100644 --- a/matlab_runners/Head Pose Experiments/calcBUerror.m +++ b/matlab_runners/Head Pose Experiments/calcBUerror.m @@ -1,4 +1,4 @@ -function [meanError, all_rot_preds, all_rot_gts, all_errors, rels_all] = calcBUerror(resDir, gtDir) +function [meanError, all_rot_preds, all_rot_gts, all_errors, rels_all, seq_ids] = calcBUerror(resDir, gtDir) seqNames = {'jam1','jam2','jam3','jam4','jam5','jam6','jam7','jam8','jam9', ... 'jim1','jim2','jim3','jim4','jim5','jim6','jim7','jim8','jim9', ... @@ -12,6 +12,8 @@ rot = cell(1,numel(seqNames)); rotg = cell(1,numel(seqNames)); rels_all = []; +seq_ids = {}; + for i = 1:numel(seqNames) [frame t, rels, sc tx ty tz rx ry rz] = textread([resDir seqNames{i} '.txt'], '%f, %f, %f, %f, %f, %f, %f, %f, %f, %f', 'headerlines', 1); @@ -54,7 +56,7 @@ for i = 1:numel(seqNames) rotMeanErr(i,:) = mean(abs((rot{i}(:,:)-rotg{i}(:,:)))); rotRMS(i,:) = sqrt(mean(((rot{i}(:,:)-rotg{i}(:,:))).^2)); - + seq_ids = cat(1, seq_ids, repmat(seqNames(i), size(rot{i},1), 1)); end allRot = cell2mat(rot'); allRotg = cell2mat(rotg'); diff --git a/matlab_runners/Head Pose Experiments/calcBiwiError.m b/matlab_runners/Head Pose Experiments/calcBiwiError.m index 2c80b879..52aec56c 100644 --- a/matlab_runners/Head Pose Experiments/calcBiwiError.m +++ b/matlab_runners/Head Pose Experiments/calcBiwiError.m @@ -1,4 +1,4 @@ -function [meanError, all_rot_preds, all_rot_gts, meanErrors, all_errors, rels_all] = calcBiwiError(resDir, gtDir) +function [meanError, all_rot_preds, all_rot_gts, meanErrors, all_errors, rels_all, seq_ids] = calcBiwiError(resDir, gtDir) seqNames = {'01','02','03','04','05','06','07','08','09', ... '10', '11','12','13','14','15','16','17','18','19', ... @@ -10,7 +10,8 @@ rot = cell(1,numel(seqNames)); rotg = cell(1,numel(seqNames)); rels_all = []; -tic; +seq_ids = {}; + for i=1:numel(seqNames) posesGround = load ([gtDir '/' seqNames{i} '/groundTruthPose.txt']); @@ -49,6 +50,9 @@ for i=1:numel(seqNames) rotMeanErr(i,:) = mean(abs((rot{i}(:,:)-rotg{i}(:,:)))); rotRMS(i,:) = sqrt(mean(((rot{i}(:,:)-rotg{i}(:,:))).^2)); + + seq_ids = cat(1, seq_ids, repmat(seqNames(i), size(rot{i},1), 1)); + end %% meanErrors = rotMeanErr; diff --git a/matlab_runners/Head Pose Experiments/calcIctError.m b/matlab_runners/Head Pose Experiments/calcIctError.m index 4f23f4e2..b0df1a90 100644 --- a/matlab_runners/Head Pose Experiments/calcIctError.m +++ b/matlab_runners/Head Pose Experiments/calcIctError.m @@ -1,4 +1,4 @@ -function [meanError, all_rot_preds, all_rot_gts, meanErrors, all_errors, rels_all] = calcIctError(resDir, gtDir) +function [meanError, all_rot_preds, all_rot_gts, meanErrors, all_errors, rels_all, seq_ids] = calcIctError(resDir, gtDir) %CALCICTERROR Summary of this function goes here % Detailed explanation goes here @@ -13,6 +13,8 @@ function [meanError, all_rot_preds, all_rot_gts, meanErrors, all_errors, rels_al rels_all = []; + seq_ids = {}; + for i = 1:numel(sequences) [~, name,~] = fileparts(sequences(i).name); @@ -53,7 +55,9 @@ function [meanError, all_rot_preds, all_rot_gts, meanErrors, all_errors, rels_al % Now compute the errors rotMeanErr(i,:) = mean(abs((rot{i}(:,:)-rotg{i}(:,:)))); rotRMS(i,:) = sqrt(mean(((rot{i}(:,:)-rotg{i}(:,:))).^2)); - + + seq_ids = cat(1, seq_ids, repmat({[name 'ict']}, size(rot{i},1), 1)); + end allRot = cell2mat(rot'); allRotg = cell2mat(rotg'); diff --git a/matlab_runners/Head Pose Experiments/find_paired_matches.m b/matlab_runners/Head Pose Experiments/find_paired_matches.m new file mode 100644 index 00000000..1c96bb32 --- /dev/null +++ b/matlab_runners/Head Pose Experiments/find_paired_matches.m @@ -0,0 +1,51 @@ +% Working out corrections for head pose and model correlations +clear +%% +% first need to run run_clm_head_pose_tests_clnf +if(exist([getenv('USERPROFILE') '/Dropbox/AAM/test data/'], 'file')) + database_root = [getenv('USERPROFILE') '/Dropbox/AAM/test data/']; +else + database_root = 'F:/Dropbox/Dropbox/AAM/test data/'; +end +buDir = [database_root, '/bu/uniform-light/']; +resFolderBUclnf_general = [database_root, '/bu/uniform-light/CLMr3/']; +[~, pred_hp_bu, gt_hp_bu, ~, rels_bu] = calcBUerror(resFolderBUclnf_general, buDir); + +biwi_dir = '/biwi pose/'; +biwi_results_root = '/biwi pose results/'; +res_folder_clnf_general = '/biwi pose results//CLMr4/'; +[~, pred_hp_biwi, gt_hp_biwi, ~, ~, rels_biwi] = calcBiwiError([database_root res_folder_clnf_general], [database_root biwi_dir]); + +ict_dir = ['ict/']; +ict_results_root = ['ict results/']; +res_folder_ict_clnf_general = 'ict results//CLMr4/'; +[~, pred_hp_ict, gt_hp_ict, ~, ~, rel_ict] = calcIctError([database_root res_folder_ict_clnf_general], [database_root ict_dir]); + +% Finding matching pairs to make sure they are independently distributed? + +% +%% +all_hps = cat(1, pred_hp_bu, pred_hp_biwi, pred_hp_ict); +all_gts = cat(1, gt_hp_bu, gt_hp_biwi, gt_hp_ict); +all_rels = cat(1, rels_bu, rels_biwi, rel_ict); + +rel_frames = all_rels > 0.8; + +all_err = mean(abs(all_gts - all_hps), 2); + +all_hps = all_hps(rel_frames, :); +all_gts = all_gts(rel_frames, :); + +% Variation along pitch when others are close to 0 +pitch_bins = [-40:5:40]; +for p = pitch_bins + rel_frames = find(abs(all_gts(:,2))<3 & abs(all_gts(:,3))<3 & abs(all_gts(:,1) - p)<3); + if ~isempty(rel_frames) + corr_coeff = corr(all_hps(rel_frames,1), all_gts(rel_frames,1)); + fprintf('%d, %.3f\n', numel(rel_frames), corr_coeff); + end +end + +plot(find(abs(all_gts(:,1))<1 & abs(all_gts(:,3))<1)); + +plot(find(abs(all_gts(:,1))<1 & abs(all_gts(:,2))<1)); \ No newline at end of file diff --git a/matlab_runners/Head Pose Experiments/results/Pose_OF.mat b/matlab_runners/Head Pose Experiments/results/Pose_OF.mat index 08c9e0ed..68e460cf 100644 Binary files a/matlab_runners/Head Pose Experiments/results/Pose_OF.mat and b/matlab_runners/Head Pose Experiments/results/Pose_OF.mat differ diff --git a/matlab_runners/Head Pose Experiments/results/Pose_OF.txt b/matlab_runners/Head Pose Experiments/results/Pose_OF.txt index 338e150c..9e98decc 100644 --- a/matlab_runners/Head Pose Experiments/results/Pose_OF.txt +++ b/matlab_runners/Head Pose Experiments/results/Pose_OF.txt @@ -1,4 +1,4 @@ Dataset and model, pitch, yaw, roll, mean, median -biwi error: 7.990, 5.614, 4.448, 6.017, 2.624 +biwi error: 7.955, 5.583, 4.402, 5.980, 2.624 bu error: 2.762, 4.103, 2.568, 3.145, 2.118 ict error: 3.619, 3.606, 3.625, 3.617, 2.027 diff --git a/matlab_runners/Head Pose Experiments/run_f2f_videos.m b/matlab_runners/Head Pose Experiments/run_f2f_videos.m new file mode 100644 index 00000000..f72927ab --- /dev/null +++ b/matlab_runners/Head Pose Experiments/run_f2f_videos.m @@ -0,0 +1,75 @@ +executable = '"../../x64/Release/FeatureExtraction.exe"'; + +outputDir = 'D:\Datasets\face2face\2007_processed/'; + +% First collect the filenames of the data to be used +input_label_dir = 'D:\Datasets\face2face\f2f-2007-all-transcriptions/'; + +folds = dir([input_label_dir, '*Rapport*']); + +listener_file_labels = {}; +speaker_file_labels = {}; + +listener_vid_files = {}; +speaker_vid_files = {}; + +speaker_vid_dir = 'D:\Datasets\face2face\f2f-2007-all-movie-speaker/'; +listener_vid_dir = 'D:\Datasets\face2face\f2f-2007-all-movie-listener/'; +verbose = true; +for i=1:numel(folds) + + listener_file = dir([input_label_dir, folds(i).name, '/*.L.nod.eaf']); + speaker_file = dir([input_label_dir, folds(i).name, '/*.S.nod.eaf']); + + if(~isempty(listener_file)) + % Need to find the appropriate video file if it exists + num = listener_file.name(end-15:end-10); + vid_file_dir = dir([listener_vid_dir, '/*', num, '*']); + vid_file = dir([listener_vid_dir, '/', vid_file_dir.name, '/*.mp4']); + if(~isempty(vid_file)) + listener_vid_files = cat(1, listener_vid_files, [listener_vid_dir, '/', vid_file_dir.name, '/', vid_file.name]); + listener_file_labels = cat(1, listener_file_labels, [input_label_dir, '/' folds(i).name, '/' listener_file.name]); + end + end + + if(~isempty(speaker_file)) + num = speaker_file.name(end-15:end-10); + vid_file_dir = dir([speaker_vid_dir, '/*', num, '*']); + vid_file = dir([speaker_vid_dir, '/', vid_file_dir.name, '/*.mp4']); + if(~isempty(vid_file)) + speaker_vid_files = cat(1, speaker_vid_files, [speaker_vid_dir, '/', vid_file_dir.name, '/', vid_file.name]); + speaker_file_labels = cat(1, speaker_file_labels, [input_label_dir, '/' folds(i).name, '/' speaker_file.name]); + end + end + +end + +file_labels = cat(1, listener_file_labels, speaker_file_labels); +video_files = cat(1, listener_vid_files, speaker_vid_files); + +parfor i=1:numel(file_labels) + + [~,short_name,vid_ext] = fileparts(video_files{i}); + + command = executable; + + inputFile = video_files{i}; + outputFile = [outputDir short_name '.txt']; + + outputEaf = [outputDir short_name '.eaf']; + + command = cat(2, command, [' -f "' inputFile '" -of "' outputFile '"']); + + if(verbose) + outputVideo = [outputDir short_name '.track.avi']; + command = cat(2, command, [' -ov "' outputVideo '"']); + end + + command = cat(2, command, [' -no2Dfp -no3Dfp -noMparams -noAUs -noGaze']); + + dos(command); + + copyfile(file_labels{i}, outputEaf); + copyfile(video_files{i}, [outputDir '/' short_name, '.mp4']); + +end \ No newline at end of file diff --git a/matlab_runners/Head Pose Experiments/run_f2f_videos_2006.m b/matlab_runners/Head Pose Experiments/run_f2f_videos_2006.m new file mode 100644 index 00000000..1f66069a --- /dev/null +++ b/matlab_runners/Head Pose Experiments/run_f2f_videos_2006.m @@ -0,0 +1,78 @@ +executable = '"../../x64/Release/FeatureExtraction.exe"'; + +outputDir = 'D:\Datasets\face2face\2006_processed/'; + +% First collect the filenames of the data to be used +input_label_dir = 'D:\Datasets\face2face\rapport-oct-2006-all-transcriptions/'; + +folds = dir([input_label_dir, '*SES*']); + +listener_file_labels = {}; +speaker_file_labels = {}; + +listener_vid_files = {}; +speaker_vid_files = {}; + +speaker_vid_dir = 'D:\Datasets\face2face\rapport-oct-2006-all-movie-speaker/'; +listener_vid_dir = 'D:\Datasets\face2face\rapport-oct-2006-all-movie-listener/'; +verbose = true; +for i=1:numel(folds) + + listener_file = dir([input_label_dir, folds(i).name, '/*.L.nod.eaf']); + speaker_file = dir([input_label_dir, folds(i).name, '/*.S.nod.eaf']); + + if(~isempty(listener_file)) + % Need to find the appropriate video file if it exists + num = listener_file.name(end-13:end-10); + vid_file_dir = dir([listener_vid_dir, '/*', num, '*']); + vid_file = dir([listener_vid_dir, '/', vid_file_dir.name, '/*.mp4']); + if(~isempty(vid_file)) + listener_vid_files = cat(1, listener_vid_files, [listener_vid_dir, '/', vid_file_dir.name, '/', vid_file.name]); + listener_file_labels = cat(1, listener_file_labels, [input_label_dir, '/' folds(i).name, '/' listener_file.name]); + end + end + + if(~isempty(speaker_file)) + num = speaker_file.name(end-13:end-10); + vid_file_dir = dir([speaker_vid_dir, '/*', num, '*']); + vid_file = dir([speaker_vid_dir, '/', vid_file_dir.name, '/*.mp4']); + if(~isempty(vid_file)) + speaker_vid_files = cat(1, speaker_vid_files, [speaker_vid_dir, '/', vid_file_dir.name, '/', vid_file.name]); + speaker_file_labels = cat(1, speaker_file_labels, [input_label_dir, '/' folds(i).name, '/' speaker_file.name]); + end + end + +end + +% file_labels = cat(1, listener_file_labels, speaker_file_labels); +% video_files = cat(1, listener_vid_files, speaker_vid_files); + +file_labels = listener_file_labels; +video_files = listener_vid_files; + +parfor i=1:numel(file_labels) + + [~,short_name,vid_ext] = fileparts(video_files{i}); + + command = executable; + + inputFile = video_files{i}; + outputFile = [outputDir short_name '.txt']; + + outputEaf = [outputDir short_name '.eaf']; + + command = cat(2, command, [' -f "' inputFile '" -of "' outputFile '"']); + + if(verbose) + outputVideo = [outputDir short_name '.track.avi']; + command = cat(2, command, [' -ov "' outputVideo '"']); + end + + command = cat(2, command, [' -no2Dfp -no3Dfp -noMparams -noAUs -noGaze']); + + dos(command); + + copyfile(file_labels{i}, outputEaf); + copyfile(video_files{i}, [outputDir '/' short_name, '.mp4']); + +end \ No newline at end of file diff --git a/matlab_runners/Readme.txt b/matlab_runners/Readme.txt index 965223ad..a724b14c 100644 --- a/matlab_runners/Readme.txt +++ b/matlab_runners/Readme.txt @@ -39,7 +39,9 @@ run_yt_dataset.m run the CLNF model on the YTCeleb Database (https://sites.googl ======================== Action Unit Experiments ============================ -Evaluating our Facial Action Unit detection system on DISFA. As the models were partly trained on DISFA the results might not generalise across datasets. However, this demonstrates how AU prediction can be done with our system. +Evaluating our Facial Action Unit detection system on DISFA, FERA2011 and SEMAINE datasets. + +As the models were partially trained/validated on DISFA, FERA2011, BP4D, UNBC, Bosphorus, and SEMAINE datasets the results might not generalise across datasets. However, this demonstrates how AU prediction can be done with our system. ======================== Gaze Experiments ============================ diff --git a/matlab_version/AU_training/data extraction/ParseSEMAINEAnnotations.m b/matlab_version/AU_training/data extraction/ParseSEMAINEAnnotations.m new file mode 100644 index 00000000..ee366e2e --- /dev/null +++ b/matlab_version/AU_training/data extraction/ParseSEMAINEAnnotations.m @@ -0,0 +1,181 @@ + +% Function ParseSEMAINEAnnotations is intended to demonstrate example usage +% of SEMAINE Action Unit annotations made with ELAN annotation toolbox. +% This function loads the XML structure from an ELAN annotation file with +% ".eaf" extension, parses it and returns a numerical matrix called +% "activations" of size NUMBER OF FRAMES X NUMBER OF ACTION UNITS. The +% matrix holds binary activation status for each frame / AU combination. +% The matrix also has a row header showing which AU corresponds to which +% row as well as a column header displaying original frame indexes. + +% The function takes 1 compulsory and 2 optional arguments: + +% - "filepath" (compulsory) - complete path to an annotation file to parse. +% For example, "/matlab/annotation.eaf" or "C:\matlab\annotation.eaf" on +% Windows. + +% - "startFrame" (optional) - ignore all annotations before "startFrame". +% Default is 1. + +% - "endFrame" (optional) - ignore all annotations after "endFrame". +% Default is the last frame of a video. + +% The function requires XML IO Toolbox +% (http://www.mathworks.com/matlabcentral/fileexchange/12907-xml-io-tools) +% to run properly (supplied). + +function activations = ParseSEMAINEAnnotations (filepath, startFrame, endFrame) + activations = []; + + % Framerate value used to convert ELAN millisecond time slots to more + % usual frames. 50 is a valid framerate for all SEMAINE videos. + framerate = 50; + + % A fixed set of 6 Action Units selected for the challenge from the + % SEMAINE annotations + aus = [2 12 17 25 28 45]; + + % Total number of AUs. + naus = length(aus); + + % Load XML structure from the file, return in case of a problem. + [success, XML] = OpenXML(filepath); + if ~success + return + end + + % Parse annotation time slots + tslots = ParseTimeSlots(XML); + + % Init start and end frames with default values + if nargin < 2 + startFrame = 1; + end + + if nargin < 3 + % Get total number of time slots + ntslots = length(tslots); + % Get last slot ID + lastID = strcat('ts', num2str(ntslots)); + % Get last time slot value in ms + lastValue = tslots(lastID); + % Convert last time slot value in ms to frames + endFrame = floor((lastValue / 1000) * framerate); + end + + % Get total number of tiers. There are 65 of them, 1 for speech, 32 for + % activations (1 per AU) and 32 for intensities. We are going to ignore + % intensity tiers. + ntiers = length(XML.TIER); + + % Compose vector of frame indexes to extract annotations from + frames = (startFrame:endFrame); + + % Preallocate activations matrix + activations = zeros(length(frames), naus); + + indx = 1; + % Go through all tiers skipping the first one (speech) as well as every + % intensity tier. A single activation tier is processed at every + % iteration. + for k = 2:2:ntiers + tier = XML.TIER(k); + % Only extract annotations of selected AUs, skip the rest + au = strcat('AU', num2str(aus(indx))); + if strcmp(au, tier.ATTRIBUTE.TIER_ID) + % Read all activation periods from the current tier + activationTier = ParseActivationTier(tier, tslots); + % Convert of all activation periods into frame level numerical + % representation + activations(:, indx) = ParseOccurrences(activationTier, frames, framerate); + + indx = indx + 1; + end + + if indx > naus + break + end + end + + activations = [frames' activations]; + activations = [[0 aus]; activations]; +end + +function occurrences = ParseOccurrences (activations, frames, framerate) + % Preallocate activations vector + occurrences = zeros(length(frames), 1); + % Go through all activation periods, convert ms into frames and init + % corresponding values of activations vector with 1 leaving the rest be 0 + for i = 1:length(activations) + % Convert ms into frames + sframe = floor((activations(i).start / 1000) * framerate); + eframe = floor((activations(i).end / 1000) * framerate); + + % Determine indexes of frames vector corresponding to the above + % time frame + sindx = find(frames == sframe); + eindx = find(frames == eframe); + + % Mark active set of frames with 1 + occurrences(sindx:eindx) = 1; + end +end + +function activationTier = ParseActivationTier (tier, tslots) + % Get total number of activation periods + nactivations = length(tier.ANNOTATION); + % Preallocate activation tier structure holding start and end time + % stamps of all activation periods for the given AU + activationTier = repmat(struct('start', 0, 'end', 0), nactivations, 1); + % Go through all activation periods and init activation tier + % structure array + for i = 1:nactivations + % Read start time slot ID of the current activation period + t = tier.ANNOTATION(i).ALIGNABLE_ANNOTATION.ATTRIBUTE.TIME_SLOT_REF1; + % Read time in ms corresponding to the time slot ID + activationTier(i).start = tslots(t); + + % Read end time slot ID of the current activation period + t = tier.ANNOTATION(i).ALIGNABLE_ANNOTATION.ATTRIBUTE.TIME_SLOT_REF2; + % Read time in ms corresponding to the time slot ID + activationTier(i).end = tslots(t); + end +end + +function tslots = ParseTimeSlots (xmlObject) + % Get total number of time slots + nslots = length(xmlObject.TIME_ORDER.TIME_SLOT); + % Preallocate cell arrays of time slot IDs and values + tids = cell(nslots, 1); + tvalues = zeros(nslots, 1); + % Read all time slot IDs and numerical values (in ms) + for i = 1:nslots + tids{i} = xmlObject.TIME_ORDER.TIME_SLOT(i).ATTRIBUTE.TIME_SLOT_ID; + tvalues(i) = xmlObject.TIME_ORDER.TIME_SLOT(i).ATTRIBUTE.TIME_VALUE; + end + % Map time slot IDs and values together so that values are accessible + % by their IDs + tslots = containers.Map(tids, tvalues); +end + +function [success, xmlObject] = OpenXML (xmlPath) + fprintf(' *** Attempting to load \"%s\" ... ', xmlPath); + xmlObject = []; + success = false; + % Check if the specified file exists and return error otherwise + if exist(xmlPath, 'file') + % Load XML structure + xmlObject = xml_read(xmlPath); + % Check if XML object loaded correctly, return error otherwise + if isempty(xmlObject) + fprintf(' ERROR - unable to read xml tree *** \n'); + return + else + success = true; + end + else + fprintf(' ERROR - specified path does not exist *** \n'); + return + end + fprintf(' Done *** \n'); +end \ No newline at end of file diff --git a/matlab_version/AU_training/data extraction/create_file_list_single_au_classification.m b/matlab_version/AU_training/data extraction/create_file_list_single_au_classification.m new file mode 100644 index 00000000..b96d6194 --- /dev/null +++ b/matlab_version/AU_training/data extraction/create_file_list_single_au_classification.m @@ -0,0 +1,98 @@ +AU_dir = 'D:/Databases/DISFA/ActionUnit_Labels/'; + +aus = [1,2,4,5,6,9,12,15,17,20,25,26]; + +subjects = dir([AU_dir, 'SN*']); + +% Store all of the AU directories in a cell +input_label_dirs = cell(numel(subjects), 1); +for i=1:numel(subjects) + input_label_dirs{i} = [AU_dir, subjects(i).name, '/', subjects(i).name]; +end + +for user=1:numel(subjects) + + testing_label_files = input_label_dirs(user); + + training_label_files = setdiff(input_label_dirs, testing_label_files); + + training_labels_all = []; + + testing_labels_all = []; + + % First extract AU information + for au=aus + + % Extract all of the AUs from the current user + [training_labels, training_vid_inds_all, training_frame_inds_all] = extract_au_labels(training_label_files, au); + [testing_labels, testing_vid_inds_all, testing_frame_inds_all] = extract_au_labels(testing_label_files, au); + + training_labels_all = cat(2, training_labels_all, training_labels); + testing_labels_all = cat(2, testing_labels_all, testing_labels); + + end + + % File lists for each of the AUs + for au_ind=1:numel(aus) + + % extract the interesting frames for training, the interesting ones + % are the AU + + positive_samples = training_labels_all(:,au_ind) > 0; + + active_samples = sum(training_labels_all,2) > 10; + + % Remove neighboring images as they are not very informative + negative_samples = sum(training_labels_all,2) == 0; + neg_inds = find(negative_samples); + neg_to_use = randperm(numel(neg_inds)); + % taking a number of neutral samples that bring the positive and + % negative samples to a balanced level + neg_to_use = neg_inds(neg_to_use(1:(2*sum(positive_samples) - sum(active_samples | positive_samples)))); + negative_samples(:) = false; + negative_samples(neg_to_use) = true; + + % Collect all the data for training now + training_samples = positive_samples | active_samples | negative_samples; + + % Create a training file list file + f_train_file_list = fopen(sprintf('%s/%s_au%02d_filelist_train.txt', 'single_au_class', subjects(user).name, aus(au_ind)), 'w'); + + sample_inds_train = find(training_samples); + + for sample_ind = sample_inds_train' + + img_file_l = sprintf('../../LeftVideo%s_comp/frame_det_%06d.png', training_vid_inds_all{sample_ind}, training_frame_inds_all(sample_ind)); + img_file_r = sprintf('../../RightVideo%s_comp/frame_det_%06d.png', training_vid_inds_all{sample_ind}, training_frame_inds_all(sample_ind)); + + au_class = training_labels_all(sample_ind, au_ind) > 1; + + fprintf(f_train_file_list, '%s %d\r\n', img_file_l, au_class); + fprintf(f_train_file_list, '%s %d\r\n', img_file_r, au_class); + + end + fclose(f_train_file_list); + + % Create a testing file list file + f_train_file_list = fopen(sprintf('%s/%s_au%02d_filelist_test.txt', 'single_au_class', subjects(user).name, aus(au_ind)), 'w'); + + + testing_samples = true(size(testing_labels_all,1),1); + sample_inds_test = find(testing_samples); + + for sample_ind = sample_inds_test' + + img_file_l = sprintf('../../LeftVideo%s_comp/frame_det_%06d.png', testing_vid_inds_all{sample_ind}, testing_frame_inds_all(sample_ind)); + img_file_r = sprintf('../../RightVideo%s_comp/frame_det_%06d.png', testing_vid_inds_all{sample_ind}, testing_frame_inds_all(sample_ind)); + + au_class = testing_labels_all(sample_ind, au_ind) > 1; + + fprintf(f_train_file_list, '%s %d\r\n', img_file_l, au_class); + fprintf(f_train_file_list, '%s %d\r\n', img_file_r, au_class); + + end + fclose(f_train_file_list); + + end + +end \ No newline at end of file diff --git a/matlab_version/AU_training/data extraction/extract_BP4D_labels.m b/matlab_version/AU_training/data extraction/extract_BP4D_labels.m new file mode 100644 index 00000000..b197f35b --- /dev/null +++ b/matlab_version/AU_training/data extraction/extract_BP4D_labels.m @@ -0,0 +1,67 @@ +function [ labels, valid_ids, vid_ids, filenames ] = extract_BP4D_labels( BP4D_dir, recs, aus ) +%EXTRACT_SEMAINE_LABELS Summary of this function goes here +% Detailed explanation goes here + + aus_BP4D = [1, 2, 4, 6, 7, 10, 12, 14, 15, 17, 23]; + + inds_to_use = []; + + for i=1:numel(aus) + + inds_to_use = cat(1, inds_to_use, find(aus_BP4D == aus(i))); + + end + num_files = numel(dir([BP4D_dir, '/*.csv'])); + + labels = cell(num_files, 1); + valid_ids = cell(num_files, 1); + vid_ids = zeros(num_files, 2); + filenames = cell(num_files, 1); + + file_id = 1; + + for i=1:numel(recs) + + csvs = dir([BP4D_dir, '/', recs{i}, '*.csv']); + + for f=1:numel(csvs) + + file = [BP4D_dir, '/', csvs(f).name]; + + [~, filename,~] = fileparts(file); + filenames{file_id} = filename; + + OCC = csvread(file); %import annotations for one video file + frame_nums = OCC(2:end,1); %get all frame numbers + codes = OCC(2:end,2:end); %get codes for all action units + occlusions = OCC(2:end,end); + + codes = codes(:, aus_BP4D); + + % Finding the invalid regions + valid = occlusions ~= 1; + + for s=1:size(codes,2) + + valid = valid & codes(:,s) ~= 9; + + end + + vid_ids(file_id,:) = [frame_nums(1), frame_nums(end)]; + + labels{file_id} = codes(:, inds_to_use); + + % all indices in SEMAINE are valid + valid_ids{file_id} = valid; + + file_id = file_id + 1; + end + end + + labels = labels(1:file_id-1); + valid_ids = valid_ids(1:file_id-1); + vid_ids = vid_ids(1:file_id-1, :); + filenames = filenames(1:file_id-1); + +end + diff --git a/matlab_version/AU_training/data extraction/extract_BP4D_labels_intensity.m b/matlab_version/AU_training/data extraction/extract_BP4D_labels_intensity.m new file mode 100644 index 00000000..deda188e --- /dev/null +++ b/matlab_version/AU_training/data extraction/extract_BP4D_labels_intensity.m @@ -0,0 +1,63 @@ +function [ labels, valid_ids, vid_ids, filenames ] = extract_BP4D_labels_intensity( BP4D_dir, recs, aus ) +%EXTRACT_SEMAINE_LABELS Summary of this function goes here +% Detailed explanation goes here + + files_all = dir(sprintf('%s/AU%02d/%s', BP4D_dir, aus(1), '/*.csv')); + num_files = numel(files_all); + + labels = cell(num_files, 1); + valid_ids = cell(num_files, 1); + vid_ids = zeros(num_files, 2); + filenames = cell(num_files, 1); + + file_id = 1; + + for r=1:numel(recs) + + files_root = sprintf('%s/AU%02d/', BP4D_dir, aus(1)); + files_all = dir([files_root, recs{r}, '*.csv']); + + for f=1:numel(files_all) + for au=aus + + % Need to find relevant files for the relevant user and for the + % relevant AU + files_root = sprintf('%s/AU%02d/', BP4D_dir, au); + files_all = dir([files_root, recs{r}, '*.csv']); + + file = [files_root, '/', files_all(f).name]; + + [~, filename,~] = fileparts(file); + filenames{file_id} = filename(1:7); + + intensities = csvread(file); % import annotations for one session + + frame_nums = intensities(:,1); % get all frame numbers + + codes = intensities(:,2); + + % Finding the invalid regions + valid = codes ~= 9; + + vid_ids(file_id,:) = [frame_nums(1), frame_nums(end)]; + + if(au == aus(1)) + valid_ids{file_id} = valid; + labels{file_id} = codes; + else + valid_ids{file_id} = valid_ids{file_id} & valid; + labels{file_id} = cat(2, labels{file_id}, codes); + end + + end + file_id = file_id + 1; + end + end + + labels = labels(1:file_id-1); + valid_ids = valid_ids(1:file_id-1); + vid_ids = vid_ids(1:file_id-1, :); + filenames = filenames(1:file_id-1); + +end + diff --git a/matlab_version/AU_training/data extraction/extract_Bosphorus_labels.m b/matlab_version/AU_training/data extraction/extract_Bosphorus_labels.m new file mode 100644 index 00000000..fbdcde84 --- /dev/null +++ b/matlab_version/AU_training/data extraction/extract_Bosphorus_labels.m @@ -0,0 +1,103 @@ +function [ labels, valid_ids, filenames ] = extract_Bosphorus_labels( Bosphorus_dir, recs, aus ) +%EXTRACT_SEMAINE_LABELS Summary of this function goes here +% Detailed explanation goes here + + % Ignoring rare ones or ones that don't overlap with other datasets + aus_Bosphorus = [1, 2, 4, 5, 6, 7, 9, 10, 12, 14, 15, 17, 20, 23, 25, 26, 43]; + aus(aus == 45) = 43; + + %% + fid = fopen([Bosphorus_dir, './facscodes/facscodes.lst']); + % Skipping the header + fgetl(fid); + fgetl(fid); + + % Starting to read + data = fgetl(fid); + + all_aus = []; + valid = []; + + id = 1; + + filenames = {}; + + while ischar(data) + + d = strsplit(data, '->'); + data = fgetl(fid); + + filename = strtrim(d{1}); + + % Skip extreme poses + if(~isempty(findstr(filename, 'CR')) || ~isempty(findstr(filename, 'YR') > 0) || ~isempty(findstr(filename, 'PR_U'))|| ~isempty(findstr(filename, 'PR_D'))) + continue; + end + + % ignore labels from non requested users + if(isempty(strmatch(filename(1:5), recs))) + continue; + end + + filenames = cat(1, filenames, filename); + + aus_str = d{2}(3:end); + + % decode the AU data + aus_c = strsplit(aus_str, '+'); + + curr_img_au = zeros(1, 80); + + for i=1:numel(aus_c) + + if(aus_c{i} == '0') + + continue + end + + intensity = -1; + + intensity_str = aus_c{i}(end); + if(intensity_str == 'A') + intensity = 1; + elseif(intensity_str == 'B') + intensity = 2; + elseif(intensity_str == 'C') + intensity = 3; + elseif(intensity_str == 'D') + intensity = 4; + elseif(intensity_str == 'E') + intensity = 5; + end + + if(~isempty(str2num(aus_c{i}(1)))) + if(intensity ~= -1) + num = str2num(aus_c{i}(1:end-1)); + else + num = str2num(aus_c{i}(1:end)); + intensity = 3; % if no intensity given just assume 3 + end + else + if(intensity ~= -1) + num = str2num(aus_c{i}(2:end-1)); + else + num = str2num(aus_c{i}(2:end)); + intensity = 3; % if no intensity given just assume 3 + end + end + + curr_img_au(1, num) = intensity; + end + all_aus = cat(1, all_aus, curr_img_au); + valid = cat(1, valid, [true]); + + id = id + 1; + + end + %aus_bosph = dlmread(, '->', 3, 0); + fclose(fid); + + valid_ids = logical(valid); + labels = all_aus(:, aus); +end + diff --git a/matlab_version/AU_training/data extraction/extract_FERA2011_labels.m b/matlab_version/AU_training/data extraction/extract_FERA2011_labels.m new file mode 100644 index 00000000..09392f1d --- /dev/null +++ b/matlab_version/AU_training/data extraction/extract_FERA2011_labels.m @@ -0,0 +1,45 @@ +function [ labels, valid_ids, filenames ] = extract_FERA2011_labels( FERA2011_dir, recs, aus ) +%EXTRACT_SEMAINE_LABELS Summary of this function goes here +% Detailed explanation goes here + + num_files = numel(recs); + + % speech invalidates lower face AUs + labels = cell(num_files, 1); + valid_ids = cell(num_files, 1); + filenames = cell(num_files, 1); + + file_id = 1; + + for i=1:numel(recs) + + file = [FERA2011_dir, '/', recs{i}, '/', recs{i}, '-au.dat']; + + [~, filename,~] = fileparts(file); + filenames{file_id} = filename; + + data = csvread(file); %import annotations for one video file + + speech = data(:,end); + + labels{file_id} = data(:, aus); + + % Finding the invalid regions + if(aus(1) >= 10) + valid = speech == 0; + else + valid = true(size(speech,1), 1); + end + + % all indices in SEMAINE are valid + valid_ids{file_id} = valid; + + file_id = file_id + 1; + end + + labels = labels(1:file_id-1); + valid_ids = valid_ids(1:file_id-1); + filenames = filenames(1:file_id-1); + +end + diff --git a/matlab_version/AU_training/data extraction/extract_SEMAINE_labels.m b/matlab_version/AU_training/data extraction/extract_SEMAINE_labels.m new file mode 100644 index 00000000..c7f122b4 --- /dev/null +++ b/matlab_version/AU_training/data extraction/extract_SEMAINE_labels.m @@ -0,0 +1,52 @@ +function [ labels, valid_ids, vid_ids ] = extract_SEMAINE_labels( SEMAINE_dir, recs, aus ) +%EXTRACT_SEMAINE_LABELS Summary of this function goes here +% Detailed explanation goes here + + % Get the right eaf file + + aus_SEMAINE = [2 12 17 25 28 45]; + + inds_to_use = []; + + for i=1:numel(aus) + + inds_to_use = cat(1, inds_to_use, find(aus_SEMAINE == aus(i))); + + end + + labels = cell(numel(recs), 1); + valid_ids = cell(numel(recs), 1); + vid_ids = zeros(numel(recs), 2); + + for i=1:numel(recs) + + file = dir([SEMAINE_dir, '/', recs{i}, '/*.eaf']); + + vid_ids(i,:) = dlmread([SEMAINE_dir, '/', recs{i}, '.txt'], ' '); + + xml_file = [SEMAINE_dir, recs{i}, '\' file.name]; + [root_xml, name_xml, ~] = fileparts(xml_file); + m_file = [root_xml, name_xml, '.mat']; + + if(~exist(m_file, 'file')) + activations = ParseSEMAINEAnnotations([SEMAINE_dir, recs{i}, '\' file.name]); + save(m_file, 'activations'); + else + load(m_file); + end + if(size(activations,1) < vid_ids(i,2)) + vid_ids(i,2) = size(activations,1); + if(vid_ids(i,2) > 2999) + vid_ids(i,1) = vid_ids(i,2) - 2999; + end + end + + labels{i} = activations(vid_ids(i,1)+1:vid_ids(i,2), 1 + inds_to_use); + + % all indices in SEMAINE are valid + valid_ids{i} = ones(size(labels{i},1),1); + + end + +end + diff --git a/matlab_version/AU_training/data extraction/extract_UNBC_labels.m b/matlab_version/AU_training/data extraction/extract_UNBC_labels.m new file mode 100644 index 00000000..c61e3c3d --- /dev/null +++ b/matlab_version/AU_training/data extraction/extract_UNBC_labels.m @@ -0,0 +1,70 @@ +function [ labels, valid_ids, filenames ] = extract_UNBC_labels( UNBC_dir, recs, aus ) +%EXTRACT_SEMAINE_LABELS Summary of this function goes here +% Detailed explanation goes here + + UNBC_dir = [UNBC_dir, '/Frame_Labels/FACS/']; + + aus_UNBC = [4, 6, 7, 9, 10, 12, 20, 25, 26, 43]; + + inds_to_use = []; + + for i=1:numel(aus) + + inds_to_use = cat(1, inds_to_use, find(aus_UNBC == aus(i))); + + end + aus_UNBC = aus_UNBC(inds_to_use); + labels_all = {}; + valid_ids_all = {}; + filenames_all = {}; + + for i=1:numel(recs) + + % get all the dirs, etc. + + sessions = dir([UNBC_dir, recs{i}]); + sessions = sessions(3:end); + + num_sessions = numel(sessions); + + labels = cell(num_sessions, 1); + valid_ids = cell(num_sessions, 1); + filenames = cell(num_sessions, 1); + + for s=1:numel(sessions) + + frames = dir([UNBC_dir, '/', recs{i}, '/', sessions(s).name, '/*.txt']); + + labels_c = zeros(numel(frames), numel(aus)); + + for f=1:numel(frames) + + file = [UNBC_dir, '/', recs{i}, '/', sessions(s).name, '/', frames(f).name]; + + fileID = fopen(file); + C = textscan(fileID,'%d %d %d %d\n'); + fclose(fileID); + +% OCC = csvread(file); %import annotations for one video file + for au = 1:numel(C{1}) + labels_c(f, aus_UNBC == C{1}(au)) = C{2}(au); + end + + end + labels{s} = labels_c; + filenames(s) = {sessions(s).name}; + valid_ids{s} = true(size(labels_c,1),1); + end + + + labels_all = cat(1, labels_all, labels); + valid_ids_all = cat(1, valid_ids_all, valid_ids); + filenames_all = cat(1, filenames_all, filenames); + + end + + labels = labels_all; + valid_ids = valid_ids_all; + filenames = filenames_all; +end + diff --git a/matlab_version/AU_training/data extraction/extract_au_labels.m b/matlab_version/AU_training/data extraction/extract_au_labels.m new file mode 100644 index 00000000..0b0de089 --- /dev/null +++ b/matlab_version/AU_training/data extraction/extract_au_labels.m @@ -0,0 +1,29 @@ +function [ labels, vid_inds, frame_inds ] = extract_au_labels( input_folders, au_id) +%EXTRACT_AU_LABELS Summary of this function goes here +% Detailed explanation goes here + + labels = []; + vid_inds = []; + frame_inds = []; + for i=1:numel(input_folders) + + in_file = sprintf('%s_au%d.txt', input_folders{i}, au_id); + + A = dlmread(in_file, ','); + + vid_inds_curr = cell(numel(A(:,2)), 1); + + labels = cat(1, labels, A(:,2)); + + [~,curr_name,~] = fileparts(input_folders{i}); + + frame_inds_curr = 0:numel(A(:,2))-1; + frame_inds = cat(1, frame_inds, frame_inds_curr'); + + vid_inds_curr(:) = {curr_name}; + vid_inds = cat(1, vid_inds, vid_inds_curr); + + end + +end + diff --git a/matlab_version/AU_training/data extraction/extract_features_BP4D.m b/matlab_version/AU_training/data extraction/extract_features_BP4D.m new file mode 100644 index 00000000..305b29b0 --- /dev/null +++ b/matlab_version/AU_training/data extraction/extract_features_BP4D.m @@ -0,0 +1,73 @@ +clear + +features_exe = '"..\..\..\x64\Release\FeatureExtraction.exe"'; + +find_BP4D; +BP4D_dir = [BP4D_dir '\..\BP4D-training\']; + +bp4d_dirs = train_recs; +out_loc = [BP4D_dir '\..\processed_data\train\']; + +parfor f1=1:numel(bp4d_dirs) + + if(isdir([BP4D_dir, bp4d_dirs{f1}])) + + bp4d_2_dirs = dir([BP4D_dir, bp4d_dirs{f1}]); + bp4d_2_dirs = bp4d_2_dirs(3:end); + + f1_dir = bp4d_dirs{f1}; + + for f2=1:numel(bp4d_2_dirs) + f2_dir = bp4d_2_dirs(f2).name; + if(isdir([BP4D_dir, bp4d_dirs{f1}])) + command = features_exe; + + curr_vid = [BP4D_dir, f1_dir, '/', f2_dir, '/']; + + name = [f1_dir '_' f2_dir]; + output_file = [out_loc name '/']; + + output_hog = [out_loc name '.hog']; + output_params = [out_loc name '.params.txt']; + + command = cat(2, command, [' -fx 2000 -fy 2000 -rigid -q -asvid -fdir "' curr_vid '" -simalign "' output_file '" -simscale 0.7 -simsize 112']); + command = cat(2, command, [' -hogalign "' output_hog '"']); + command = cat(2, command, [' -of "' output_params '" -no2Dfp -no3Dfp -noAUs -noPose -noGaze']); + dos(command); + end + end + end +end + +bp4d_dirs = devel_recs; +out_loc = [BP4D_dir '\..\processed_data\devel\']; +parfor f1=1:numel(bp4d_dirs) + + if(isdir([BP4D_dir, bp4d_dirs{f1}])) + + bp4d_2_dirs = dir([BP4D_dir, bp4d_dirs{f1}]); + bp4d_2_dirs = bp4d_2_dirs(3:end); + + f1_dir = bp4d_dirs{f1}; + + for f2=1:numel(bp4d_2_dirs) + f2_dir = bp4d_2_dirs(f2).name; + if(isdir([BP4D_dir, bp4d_dirs{f1}])) + command = features_exe; + + curr_vid = [BP4D_dir, f1_dir, '/', f2_dir, '/']; + + name = [f1_dir '_' f2_dir]; + output_file = [out_loc name '/']; + + output_hog = [out_loc name '.hog']; + output_params = [out_loc name '.params.txt']; + + command = cat(2, command, [' -fx 2000 -fy 2000 -rigid -q -asvid -fdir "' curr_vid '" -simalign "' output_file '" -simscale 0.7 -simsize 112']); + command = cat(2, command, [' -hogalign "' output_hog '"']); + command = cat(2, command, [' -of "' output_params '" -no2Dfp -no3Dfp -noAUs -noPose -noGaze']); + dos(command); + end + end + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/data extraction/extract_features_Bosphorus.m b/matlab_version/AU_training/data extraction/extract_features_Bosphorus.m new file mode 100644 index 00000000..832feef3 --- /dev/null +++ b/matlab_version/AU_training/data extraction/extract_features_Bosphorus.m @@ -0,0 +1,32 @@ +clear +features_exe = '"..\..\..\x64\Release\FeatureExtraction.exe"'; + +bosph_loc = 'D:\Datasets\Bosphorus\BosphorusDB\BosphorusDB/'; + +out_loc = 'D:\Datasets\face_datasets/'; + +% Go two levels deep +bosph_dirs = dir([bosph_loc, '/bs*']); + +for f1=1:numel(bosph_dirs) + + name = [bosph_dirs(f1).name]; + + curr_vids = dir([bosph_loc, '/' name, '/*.png']); + + parfor i=1:numel(curr_vids) + command = features_exe; + input_file = [bosph_loc, '/' name '/', curr_vids(i).name]; + [~, curr_name, ~] = fileparts(curr_vids(i).name); + output_file = [out_loc, '/hog_aligned_rigid_b/', curr_name, '/']; + + output_hog = [out_loc, '/hog_aligned_rigid_b/',curr_name '.hog']; + output_params = [out_loc, '/model_params_b/', curr_name '.txt']; + + command = cat(2, command, [' -rigid -f "' input_file '" -simalign "' output_file '" -simscale 0.7 -simsize 112 ']); + command = cat(2, command, [' -hogalign "' output_hog '"' ' -of "' output_params ]); + command = cat(2, command, ['" -no2Dfp -no3Dfp -noAUs -noPose -noGaze -q ']); + dos(command); + end + +end \ No newline at end of file diff --git a/matlab_version/AU_training/data extraction/extract_features_CK.m b/matlab_version/AU_training/data extraction/extract_features_CK.m new file mode 100644 index 00000000..a61d0fc5 --- /dev/null +++ b/matlab_version/AU_training/data extraction/extract_features_CK.m @@ -0,0 +1,42 @@ +clear +features_exe = '"..\..\..\x64\Release\FeatureExtraction.exe"'; + +ck_loc = 'D:\Datasets\ck+\cohn-kanade-images\'; + +out_loc = 'D:\datasets\face_datasets/hog_aligned_rigid\'; +out_loc_params = 'D:\datasets\face_datasets/clm_params\'; + +% Go two levels deep +ck_dirs = dir(ck_loc); +ck_dirs = ck_dirs(3:end); + +parfor f1=1:numel(ck_dirs) + + ck_dirs_level_2 = dir([ck_loc, ck_dirs(f1).name]); + ck_dirs_level_2 = ck_dirs_level_2(3:end); + + for f2=1:numel(ck_dirs_level_2) + + if(~isdir([ck_loc, ck_dirs(f1).name, '/', ck_dirs_level_2(f2).name])) + continue; + end + + command = features_exe; + + curr_vid = [ck_loc, ck_dirs(f1).name, '/', ck_dirs_level_2(f2).name]; + + name = [ck_dirs(f1).name, '_', ck_dirs_level_2(f2).name]; + + output_file = [out_loc name '/']; + + output_hog = [out_loc name '.hog']; + output_params = [out_loc_params name '.txt']; + + command = cat(2, command, [' -rigid -asvid -fdir "' curr_vid '" -simalign "' output_file '" -simscale 0.7 -simsize 112 -g -q ']); + command = cat(2, command, [' -hogalign "' output_hog, '"' ]); + + dos(command); + + end + +end \ No newline at end of file diff --git a/matlab_version/AU_training/data extraction/extract_features_DISFA.m b/matlab_version/AU_training/data extraction/extract_features_DISFA.m new file mode 100644 index 00000000..5ccbc5c6 --- /dev/null +++ b/matlab_version/AU_training/data extraction/extract_features_DISFA.m @@ -0,0 +1,84 @@ +% Biwi dataset experiment + +features_exe = '"..\..\..\x64\Release\FeatureExtraction.exe"'; + +if(exist('D:/Databases/DISFA/', 'dir')) + DISFA_loc = 'D:/Databases/DISFA/'; +elseif(exist('D:/Datasets/DISFA/', 'dir')) + DISFA_loc = 'D:/Datasets/DISFA/'; +elseif(exist('E:/datasets/DISFA/', 'dir')) + DISFA_loc = 'E:/datasets/DISFA/'; +elseif(exist('C:/tadas/DISFA', 'dir')) + DISFA_loc = 'C:/tadas/DISFA/'; +elseif(exist('D:\datasets\face_datasets\DISFA/', 'dir')) + DISFA_loc = 'D:\datasets\face_datasets\DISFA/'; +else + fprintf('DISFA not found\n'); +end + +output = [DISFA_loc, '/aligned_rigid/']; +output_hog_root = [DISFA_loc '/hog_aligned_rigid/']; +output_params_root = [DISFA_loc '/model_params/']; + +DISFA_loc_1 = [DISFA_loc, 'Videos_LeftCamera/']; +DISFA_loc_2 = [DISFA_loc, 'Video_RightCamera/']; + +if(~exist(output, 'dir')) + mkdir(output); +end + +if(~exist(output_hog_root, 'dir')) + mkdir(output_hog_root); +end + +if(~exist(output_params_root, 'dir')) + mkdir(output_params_root); +end + +disfa_loc_1_files = dir([DISFA_loc_1, '/*.avi']); +disfa_loc_2_files = dir([DISFA_loc_2, '/*.avi']); + +%% +tic; + +parfor i=1:numel(disfa_loc_1_files) + + command = features_exe; + + input_file = [DISFA_loc_1 disfa_loc_1_files(i).name]; + + [~,name,~] = fileparts(disfa_loc_1_files(i).name); + output_file = [output name '/']; + + output_hog = [output_hog_root name '.hog']; + output_params = [output_params_root '/' name '.txt']; + + command = cat(2, command, [' -rigid -f "' input_file '" -simalign "' output_file '" -simscale 0.7 -simsize 112']); + command = cat(2, command, [' -hogalign "' output_hog '"' ]); + command = cat(2, command, [' -of "' output_params '" -no2Dfp -no3Dfp -noAUs -noPose -noGaze -q']); + + dos(command); +end + +%% +parfor i=1:numel(disfa_loc_2_files) + + command = features_exe; + + input_file = [DISFA_loc_2 disfa_loc_2_files(i).name]; + + [~,name,~] = fileparts(disfa_loc_2_files(i).name); + output_file = [output name '/']; + + output_hog = [output_hog_root name '.hog']; + + output_params = [output_params_root '/' name '.txt']; + + command = cat(2, command, [' -rigid -f "' input_file '" -simalign "' output_file '" -simscale 0.7 -simsize 112']); + command = cat(2, command, [' -hogalign "' output_hog '"']); + command = cat(2, command, [' -of "' output_params '" -no2Dfp -no3Dfp -noAUs -noPose -noGaze -q']); + + dos(command); +end + +timeTaken = toc; \ No newline at end of file diff --git a/matlab_version/AU_training/data extraction/extract_features_FERA_2011.m b/matlab_version/AU_training/data extraction/extract_features_FERA_2011.m new file mode 100644 index 00000000..34071b0d --- /dev/null +++ b/matlab_version/AU_training/data extraction/extract_features_FERA_2011.m @@ -0,0 +1,46 @@ +clear +features_exe = '"..\..\..\x64\Release\FeatureExtraction.exe"'; + +fera_loc = 'D:\Datasets\fera\'; + +out_loc = 'D:\Datasets\face_datasets\hog_aligned_rigid\'; +out_loc_params = 'D:\Datasets\face_datasets\model_params\'; + +% Go two levels deep +fera_dirs = dir(fera_loc); +fera_dirs = fera_dirs(3:end); + +for f1=1:numel(fera_dirs) + + fera_dirs_level_2 = dir([fera_loc, fera_dirs(f1).name]); + fera_dirs_level_2 = fera_dirs_level_2(3:end); + + for f2=1:numel(fera_dirs_level_2) + + vid_files = dir([fera_loc, fera_dirs(f1).name, '/', fera_dirs_level_2(f2).name, '/*.avi']); + + parfor v=1:numel(vid_files) + + command = features_exe; + + curr_vid = [fera_loc, fera_dirs(f1).name, '/', fera_dirs_level_2(f2).name, '/', vid_files(v).name]; + + [~,name,~] = fileparts(curr_vid); + output_file = [out_loc fera_dirs(f1).name '_' name '/']; + + output_hog = [out_loc fera_dirs(f1).name '_' name '.hog']; + + output_params = [out_loc_params fera_dirs(f1).name '_' name '.txt']; + + command = cat(2, command, [' -rigid -f "' curr_vid '" -simalign "' output_file '" -simscale 0.7 -simsize 112']); + command = cat(2, command, [' -hogalign "' output_hog '"']); + + command = cat(2, command, [' -of "' output_params '" -no2Dfp -no3Dfp -noAUs -noPose -noGaze -q']); + + dos(command); + + end + + end + +end \ No newline at end of file diff --git a/matlab_version/AU_training/data extraction/extract_features_SEMAINE.m b/matlab_version/AU_training/data extraction/extract_features_SEMAINE.m new file mode 100644 index 00000000..355a7056 --- /dev/null +++ b/matlab_version/AU_training/data extraction/extract_features_SEMAINE.m @@ -0,0 +1,71 @@ + +features_exe = '"..\..\..\x64\Release\FeatureExtraction.exe"'; + +find_SEMAINE; + + +% Go two levels deep +semaine_dirs = train_recs; +out_loc = [SEMAINE_dir, '../processed_data/train/']; + +parfor f1=1:numel(semaine_dirs) + + if(isdir([SEMAINE_dir, semaine_dirs{f1}])) + + vid_files = dir([SEMAINE_dir, semaine_dirs{f1}, '/*.avi']); + + f1_dir = semaine_dirs{f1}; + + for v=1:numel(vid_files) + + command = features_exe; + + curr_vid = [SEMAINE_dir, f1_dir, '/', vid_files(v).name]; + + name = f1_dir; + output_file = [out_loc name '/']; + + output_hog = [out_loc name '.hog']; + output_params = [out_loc name '.params.txt']; + + command = cat(2, command, [' -rigid -f "' curr_vid '" -simalign "' output_file '" -simscale 0.7 -simsize 112']); + command = cat(2, command, [' -hogalign "' output_hog '"']); + command = cat(2, command, [' -of "' output_params '" -no2Dfp -no3Dfp -noAUs -noPose -noGaze -q']); + dos(command); + + end + end +end + +%% +semaine_dirs = devel_recs; +out_loc = [SEMAINE_dir, '../processed_data/devel/']; + +parfor f1=1:numel(semaine_dirs) + + if(isdir([SEMAINE_dir, semaine_dirs{f1}])) + + vid_files = dir([SEMAINE_dir, semaine_dirs{f1}, '/*.avi']); + + f1_dir = semaine_dirs{f1}; + + for v=1:numel(vid_files) + + command = features_exe; + + curr_vid = [SEMAINE_dir, f1_dir, '/', vid_files(v).name]; + + name = f1_dir; + output_file = [out_loc name '/']; + + output_hog = [out_loc name '.hog']; + output_params = [out_loc name '.params.txt']; + + command = cat(2, command, [' -rigid -f "' curr_vid '" -simalign "' output_file '" -simscale 0.7 -simsize 112']); + command = cat(2, command, [' -hogalign "' output_hog '"']); + command = cat(2, command, [' -of "' output_params '" -no2Dfp -no3Dfp -noAUs -noPose -noGaze -q']); + dos(command); + + end + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/data extraction/extract_features_UNBC.m b/matlab_version/AU_training/data extraction/extract_features_UNBC.m new file mode 100644 index 00000000..6c51aff0 --- /dev/null +++ b/matlab_version/AU_training/data extraction/extract_features_UNBC.m @@ -0,0 +1,43 @@ +clear +features_exe = '"..\..\..\x64\Release\FeatureExtraction.exe"'; + +unbc_loc = 'D:\Datasets\UNBC\Images/'; + +out_loc = 'D:\Datasets\face_datasets/'; + +% Go two levels deep +unbc_dirs = dir(unbc_loc); +unbc_dirs = unbc_dirs(3:end); + +parfor f1=1:numel(unbc_dirs) + + unbc_dirs_level_2 = dir([unbc_loc, unbc_dirs(f1).name]); + unbc_dirs_level_2 = unbc_dirs_level_2(3:end); + + for f2=1:numel(unbc_dirs_level_2) + + if(~isdir([unbc_loc, unbc_dirs(f1).name, '/', unbc_dirs_level_2(f2).name])) + continue; + end + + command = features_exe; + + curr_vid = [unbc_loc, unbc_dirs(f1).name, '/', unbc_dirs_level_2(f2).name]; + + name = [unbc_dirs(f1).name, '_', unbc_dirs_level_2(f2).name]; + + output_file = [out_loc, '/hog_aligned_rigid/', name '/']; + + output_hog = [out_loc, '/hog_aligned_rigid/', name '.hog']; + output_params = [out_loc, '/model_params/', name '.txt']; + + command = cat(2, command, [' -rigid -asvid -fdir "' curr_vid '" -simalign "' output_file '" -simscale 0.7 -simsize 112 -g']); + command = cat(2, command, [' -hogalign "' output_hog '"']); + + command = cat(2, command, [' -of "' output_params '" -no2Dfp -no3Dfp -noAUs -noPose -noGaze -q']); + + dos(command); + + end + +end \ No newline at end of file diff --git a/matlab_version/AU_training/data extraction/find_BP4D.m b/matlab_version/AU_training/data extraction/find_BP4D.m new file mode 100644 index 00000000..9266a179 --- /dev/null +++ b/matlab_version/AU_training/data extraction/find_BP4D.m @@ -0,0 +1,28 @@ +if(exist('C:\tadas\face_datasets\fera_2015\bp4d\AUCoding/', 'file')) + BP4D_dir = 'C:\tadas\face_datasets\fera_2015\bp4d\AUCoding/'; + BP4D_dir_int = 'C:\tadas\face_datasets\fera_2015\bp4d\AU Intensity Codes3.0/'; +elseif(exist('E:\datasets\FERA_2015\BP4D\AUCoding/', 'file')) + BP4D_dir = 'E:\datasets\FERA_2015\BP4D\AUCoding/'; + BP4D_dir_int = 'E:\datasets\FERA_2015\BP4D\AU Intensity Codes3.0/'; +elseif(exist('D:\datasets\face_datasets\fera_2015\bp4d\AUCoding/','file')) + BP4D_dir = 'D:\datasets\face_datasets\fera_2015\bp4d\AUCoding/'; + BP4D_dir_int = 'D:\datasets\face_datasets\fera_2015\bp4d\AU Intensity Codes3.0/'; +elseif(exist('D:\Datasets\FERA_2015\BP4D\AUCoding/','file')) + BP4D_dir = 'D:\Datasets\FERA_2015\BP4D\AUCoding/'; + BP4D_dir_int = 'D:\Datasets\FERA_2015\BP4D\AU Intensity Codes3.0/'; +elseif(exist('I:\datasets\FERA_2015\BP4D\AUCoding/', 'file')) + BP4D_dir = 'I:\datasets\FERA_2015\BP4D\AUCoding/'; + BP4D_dir_int = 'I:\datasets\FERA_2015\BP4D\AU Intensity Codes3.0/'; +elseif(exist('D:/fera_2015/bp4d/AUCoding/', 'file')) + BP4D_dir = 'D:/fera_2015/bp4d/AUCoding/'; + BP4D_dir_int = 'D:/fera_2015/bp4d/AU Intensity Codes3.0/'; +else + fprintf('BP4D location not found (or not defined)\n'); +end + + +hog_data_dir = [BP4D_dir, '../processed_data']; + +train_recs = {'F001', 'F003', 'F005', 'F007', 'F009', 'F011', 'F013', 'F015', 'F017', 'F019', 'F021', 'F023', 'M001', 'M003', 'M005', 'M007', 'M009', 'M011', 'M013', 'M015' 'M017'}; +devel_recs = {'F002', 'F004', 'F006', 'F008', 'F010', 'F012', 'F014', 'F016', 'F018', 'F020', 'F022', 'M002', 'M004', 'M006', 'M008', 'M010', 'M012', 'M014', 'M016', 'M018'}; + diff --git a/matlab_version/AU_training/data extraction/find_Bosphorus.m b/matlab_version/AU_training/data extraction/find_Bosphorus.m new file mode 100644 index 00000000..39c101e5 --- /dev/null +++ b/matlab_version/AU_training/data extraction/find_Bosphorus.m @@ -0,0 +1,21 @@ +if(exist('D:/Datasets/Bosphorus/', 'file')) + Bosphorus_dir = 'D:\Datasets\Bosphorus/'; +else + fprintf('Bosphorus dataset location not found (or not defined)\n'); +end + +hog_data_dir = ['D:\Datasets\face_datasets']; + +all_recs = dir([Bosphorus_dir, '/BosphorusDB/BosphorusDB/bs*']); +all_recs_mat = cat(1, all_recs.name); +all_recs = cell(numel(all_recs), 1); + +for i=1:size(all_recs_mat,1) + + all_recs{i} = all_recs_mat(i,:); + +end + +devel_recs = all_recs(1:3:end); +train_recs = setdiff(all_recs, devel_recs); + diff --git a/matlab_version/AU_training/data extraction/find_DISFA.m b/matlab_version/AU_training/data extraction/find_DISFA.m new file mode 100644 index 00000000..6c1796f6 --- /dev/null +++ b/matlab_version/AU_training/data extraction/find_DISFA.m @@ -0,0 +1,49 @@ +% load all of the data together (for efficiency) +% it will be split up accordingly at later stages +if(exist('F:/datasets/DISFA/', 'file')) + DISFA_dir = 'F:/datasets/DISFA/'; +elseif(exist('D:/Databases/DISFA/', 'file')) + DISFA_dir = 'D:/Databases/DISFA/'; +elseif(exist('D:\datasets\face_datasets\DISFA/', 'file')) + DISFA_dir = 'D:\datasets\face_datasets\DISFA/'; +elseif(exist('D:\Datasets\DISFA/', 'file')) + DISFA_dir = 'D:\Datasets\DISFA/'; +elseif(exist('Z:/datasets/DISFA/', 'file')) + DISFA_dir = 'Z:/Databases/DISFA/'; +elseif(exist('E:/datasets/DISFA/', 'file')) + DISFA_dir = 'E:/datasets/DISFA/'; +elseif(exist('C:/tadas/DISFA/', 'file')) + DISFA_dir = 'C:/tadas/DISFA/'; +else + fprintf('DISFA location not found (or not defined)\n'); +end + +hog_data_dir = [DISFA_dir, '/hog_aligned_rigid/']; + +users = {'SN001'; + 'SN002'; + 'SN003'; + 'SN004'; + 'SN005'; + 'SN006'; + 'SN007'; + 'SN008'; + 'SN009'; + 'SN010'; + 'SN011'; + 'SN012'; + 'SN016'; + 'SN017'; + 'SN018'; + 'SN021'; + 'SN023'; + 'SN024'; + 'SN025'; + 'SN026'; + 'SN027'; + 'SN028'; + 'SN029'; + 'SN030'; + 'SN031'; + 'SN032'; + 'SN013'}; diff --git a/matlab_version/AU_training/data extraction/find_FERA2011.m b/matlab_version/AU_training/data extraction/find_FERA2011.m new file mode 100644 index 00000000..411fcba8 --- /dev/null +++ b/matlab_version/AU_training/data extraction/find_FERA2011.m @@ -0,0 +1,31 @@ +if(exist('D:\Datasets\fera/au_training', 'file')) + FERA2011_dir = 'D:\Datasets\fera/au_training/'; + hog_data_dir = 'D:\Datasets\face_datasets\hog_aligned_rigid/'; +else + fprintf('FERA2011 location not found (or not defined)\n'); +end + +all_recs = {'train_001', 'train_002', 'train_003', 'train_004', 'train_005',... + 'train_006', 'train_007', 'train_008', 'train_009', 'train_010',... + 'train_011', 'train_012', 'train_013', 'train_014', 'train_015',... + 'train_016', 'train_017', 'train_018', 'train_019', 'train_020',... + 'train_021', 'train_022', 'train_023', 'train_024', 'train_025',... + 'train_026', 'train_027', 'train_028', 'train_029', 'train_030',... + 'train_031', 'train_032', 'train_033', 'train_034', 'train_035',... + 'train_036', 'train_037', 'train_038', 'train_039', 'train_040',... + 'train_041', 'train_042', 'train_043', 'train_044', 'train_045',... + 'train_046', 'train_047', 'train_048', 'train_049', 'train_050',... + 'train_051', 'train_052', 'train_053', 'train_054', 'train_055',... + 'train_056', 'train_057', 'train_058', 'train_059', 'train_060',... + 'train_061', 'train_062', 'train_063', 'train_064', 'train_065',... + 'train_066', 'train_067', 'train_068', 'train_069', 'train_070',... + 'train_071', 'train_072', 'train_073', 'train_074', 'train_075',... + 'train_076', 'train_077', 'train_078', 'train_079', 'train_080',... + 'train_081', 'train_082', 'train_083', 'train_084', 'train_085',... + 'train_086', 'train_087'}; + +% Making them person independent +train_recs = all_recs(1:56); +devel_recs = setdiff(all_recs, train_recs); + +all_aus = [1, 2, 4, 6, 7, 10, 12, 15, 17, 18, 25, 26]; \ No newline at end of file diff --git a/matlab_version/AU_training/data extraction/find_SEMAINE.m b/matlab_version/AU_training/data extraction/find_SEMAINE.m new file mode 100644 index 00000000..647e1f27 --- /dev/null +++ b/matlab_version/AU_training/data extraction/find_SEMAINE.m @@ -0,0 +1,22 @@ +if(exist('E:\datasets\FERA_2015\semaine/SEMAINE-Sessions/', 'file')) + SEMAINE_dir = 'E:\datasets\FERA_2015\semaine/SEMAINE-Sessions/'; +elseif(exist('I:\datasets\FERA_2015\Semaine\SEMAINE-Sessions/', 'file')) + SEMAINE_dir = 'I:\datasets\FERA_2015\Semaine\SEMAINE-Sessions/'; +elseif(exist('C:\tadas\face_datasets\fera_2015\semaine/SEMAINE-Sessions/', 'file')) + SEMAINE_dir = 'C:\tadas\face_datasets\fera_2015\semaine/SEMAINE-Sessions/'; +elseif(exist('D:\datasets\face_datasets\fera_2015\semaine\SEMAINE-Sessions/', 'file')) + SEMAINE_dir = 'D:\datasets\face_datasets\fera_2015\semaine\SEMAINE-Sessions/'; +elseif(exist('D:\Datasets\FERA_2015\semaine\SEMAINE-Sessions/', 'file')) + SEMAINE_dir = 'D:\Datasets\FERA_2015\semaine\SEMAINE-Sessions/'; +elseif(exist('D:/fera_2015/semaine/SEMAINE-Sessions/', 'file')) + SEMAINE_dir = 'D:/fera_2015/semaine/SEMAINE-Sessions/'; +else + fprintf('DISFA location not found (or not defined)\n'); +end + +if(exist('SEMAINE_dir', 'var')) + hog_data_dir = [SEMAINE_dir, '../processed_data/']; +end + +train_recs = {'rec1', 'rec12', 'rec14', 'rec19', 'rec23', 'rec25', 'rec37', 'rec39', 'rec43', 'rec45', 'rec48', 'rec50', 'rec52', 'rec54', 'rec56', 'rec60'}; +devel_recs = {'rec9', 'rec13', 'rec15', 'rec20', 'rec24', 'rec26', 'rec38', 'rec42', 'rec44', 'rec46', 'rec49', 'rec51', 'rec53', 'rec55', 'rec58'}; diff --git a/matlab_version/AU_training/data extraction/find_UNBC.m b/matlab_version/AU_training/data extraction/find_UNBC.m new file mode 100644 index 00000000..06bb3733 --- /dev/null +++ b/matlab_version/AU_training/data extraction/find_UNBC.m @@ -0,0 +1,17 @@ +if(exist('D:\Datasets\UNBC/', 'file')) + UNBC_dir = 'D:\Datasets\UNBC/'; + hog_data_dir = 'D:\Datasets\face_datasets\hog_aligned_rigid'; +else + fprintf('UNBC location not found (or not defined)\n'); +end + +all_recs = {'042-ll042', '043-jh043', '047-jl047', '048-aa048', '049-bm049',... + '052-dr052', '059-fn059', '064-ak064', '066-mg066', '080-bn080',... + '092-ch092', '095-tv095', '096-bg096', '097-gf097', '101-mg101',... + '103-jk103', '106-nm106', '107-hs107', '108-th108', '109-ib109',... + '115-jy115', '120-kz120', '121-vw121', '123-jh123', '124-dn124'}; + +devel_recs = all_recs(1:5:25); +train_recs = setdiff(all_recs, devel_recs); + +all_aus = [4, 6, 7, 9, 10, 12, 20, 25, 26, 43]; \ No newline at end of file diff --git a/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/.DS_Store b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/.DS_Store new file mode 100644 index 00000000..cdb87fb9 Binary files /dev/null and b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/.DS_Store differ diff --git a/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/base64decode.m b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/base64decode.m new file mode 100644 index 00000000..fd553577 --- /dev/null +++ b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/base64decode.m @@ -0,0 +1,117 @@ +function y = base64decode(x, outfname, alg) +%BASE64DECODE Perform base64 decoding on a string. +% +% INPUT: +% x - block of data to be decoded. Can be a string or a numeric +% vector containing integers in the range 0-255. Any character +% not part of the 65-character base64 subset set is silently +% ignored. Characters occuring after a '=' padding character are +% never decoded. If the length of the string to decode (after +% ignoring non-base64 chars) is not a multiple of 4, then a +% warning is generated. +% +% outfname - if provided the binary date from decoded string will be +% saved into a file. Since Base64 coding is often used to embbed +% binary data in xml files, this option can be used to extract and +% save them. +% +% alg - Algorithm to use: can take values 'java' or 'matlab'. Optional +% variable defaulting to 'java' which is a little faster. If +% 'java' is chosen than core of the code is performed by a call to +% a java library. Optionally all operations can be performed using +% matleb code. +% +% OUTPUT: +% y - array of binary data returned as uint8 +% +% This function is used to decode strings from the Base64 encoding specified +% in RFC 2045 - MIME (Multipurpose Internet Mail Extensions). The Base64 +% encoding is designed to represent arbitrary sequences of octets in a form +% that need not be humanly readable. A 65-character subset ([A-Za-z0-9+/=]) +% of US-ASCII is used, enabling 6 bits to be represented per printable +% character. +% +% See also BASE64ENCODE. +% +% Written by Jarek Tuszynski, SAIC, jaroslaw.w.tuszynski_at_saic.com +% +% Matlab version based on 2004 code by Peter J. Acklam +% E-mail: pjacklam@online.no +% URL: http://home.online.no/~pjacklam +% http://home.online.no/~pjacklam/matlab/software/util/datautil/base64encode.m + +if nargin<3, alg='java'; end +if nargin<2, outfname=''; end + +%% if x happen to be a filename than read the file +if (numel(x)<256) + if (exist(x, 'file')==2) + fid = fopen(x,'rb'); + x = fread(fid, 'uint8'); + fclose(fid); + end +end +x = uint8(x(:)); % unify format + +%% Perform conversion +switch (alg) + case 'java' + base64 = org.apache.commons.codec.binary.Base64; + y = base64.decode(x); + y = mod(int16(y),256); % convert from int8 to uint8 + case 'matlab' + %% Perform the mapping + % A-Z -> 0 - 25 + % a-z -> 26 - 51 + % 0-9 -> 52 - 61 + % + - -> 62 '-' is URL_SAFE alternative + % / _ -> 63 '_' is URL_SAFE alternative + map = uint8(zeros(1,256)+65); + map(uint8(['A':'Z', 'a':'z', '0':'9', '+/=']))= 0:64; + map(uint8('-_'))= 62:63; % URL_SAFE alternatives + x = map(x); % mapping + + x(x>64)=[]; % remove non-base64 chars + if rem(numel(x), 4) + warning('Length of base64 data not a multiple of 4; padding input.'); + end + x(x==64)=[]; % remove padding characters + + %% add padding and reshape + nebytes = length(x); % number of encoded bytes + nchunks = ceil(nebytes/4); % number of chunks/groups + if rem(nebytes, 4)>0 + x(end+1 : 4*nchunks) = 0; % add padding + end + x = reshape(uint8(x), 4, nchunks); + y = repmat(uint8(0), 3, nchunks); % for the decoded data + + %% Rearrange every 4 bytes into 3 bytes + % 00aaaaaa 00bbbbbb 00cccccc 00dddddd + % to form + % aaaaaabb bbbbcccc ccdddddd + y(1,:) = bitshift(x(1,:), 2); % 6 highest bits of y(1,:) + y(1,:) = bitor(y(1,:), bitshift(x(2,:), -4)); % 2 lowest bits of y(1,:) + y(2,:) = bitshift(x(2,:), 4); % 4 highest bits of y(2,:) + y(2,:) = bitor(y(2,:), bitshift(x(3,:), -2)); % 4 lowest bits of y(2,:) + y(3,:) = bitshift(x(3,:), 6); % 2 highest bits of y(3,:) + y(3,:) = bitor(y(3,:), x(4,:)); % 6 lowest bits of y(3,:) + + %% remove extra padding + switch rem(nebytes, 4) + case 2 + y = y(1:end-2); + case 3 + y = y(1:end-1); + end +end + +%% reshape to a row vector and make it a character array +y = uint8(reshape(y, 1, numel(y))); + +%% save to file if needed +if ~isempty(outfname) + fid = fopen(outfname,'wb'); + fwrite(fid, y, 'uint8'); + fclose(fid); +end diff --git a/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/base64encode.m b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/base64encode.m new file mode 100644 index 00000000..405b66aa --- /dev/null +++ b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/base64encode.m @@ -0,0 +1,138 @@ +function y = base64encode(x, alg, isChunked, url_safe) +%BASE64ENCODE Perform base64 encoding on a string. +% INPUT: +% x - block of data to be encoded. Can be a string or a numeric +% vector containing integers in the range 0-255. +% alg - Algorithm to use: can take values 'java' or 'matlab'. Optional +% variable defaulting to 'java' which is a little faster. If +% 'java' is chosen than core of the code is performed by a call to +% a java library. Optionally all operations can be performed using +% matleb code. +% isChunked - encode output into 76 character blocks. The returned +% encoded string is broken into lines of no more than +% 76 characters each, and each line will end with EOL. Notice that +% if resulting string is saved as part of an xml file, those EOL's +% are often stripped by xmlwrite funtrion prior to saving. +% url_safe - use Modified Base64 for URL applications ('base64url' +% encoding) "Base64 alphabet" ([A-Za-z0-9-_=]). +% +% +% OUTPUT: +% y - character array using only "Base64 alphabet" characters +% +% This function may be used to encode strings into the Base64 encoding +% specified in RFC 2045 - MIME (Multipurpose Internet Mail Extensions). +% The Base64 encoding is designed to represent arbitrary sequences of +% octets in a form that need not be humanly readable. A 65-character +% subset ([A-Za-z0-9+/=]) of US-ASCII is used, enabling 6 bits to be +% represented per printable character. +% +% See also BASE64DECODE. +% +% Written by Jarek Tuszynski, SAIC, jaroslaw.w.tuszynski_at_saic.com +% +% Matlab version based on 2004 code by Peter J. Acklam +% E-mail: pjacklam@online.no +% URL: http://home.online.no/~pjacklam +% http://home.online.no/~pjacklam/matlab/software/util/datautil/base64encode.m + +if nargin<2, alg='java'; end +if nargin<3, isChunked=false; end +if ~islogical(isChunked) + if isnumeric(isChunked) + isChunked=(isChunked>0); + else + isChunked=false; + end +end +if nargin<4, url_safe=false; end +if ~islogical(url_safe) + if isnumeric(url_safe) + url_safe=(url_safe>0); + else + url_safe=false; + end +end + + +%% if x happen to be a filename than read the file +if (numel(x)<256) + if (exist(x, 'file')==2) + fid = fopen(x,'rb'); + x = fread(fid, 'uint8'); % read image file as a raw binary + fclose(fid); + end +end + +%% Perform conversion +switch (alg) + case 'java' + base64 = org.apache.commons.codec.binary.Base64; + y = base64.encodeBase64(x, isChunked); + if url_safe + y = strrep(y,'=','-'); + y = strrep(y,'/','_'); + end + + case 'matlab' + + %% add padding if necessary, to make the length of x a multiple of 3 + x = uint8(x(:)); + ndbytes = length(x); % number of decoded bytes + nchunks = ceil(ndbytes / 3); % number of chunks/groups + if rem(ndbytes, 3)>0 + x(end+1 : 3*nchunks) = 0; % add padding + end + x = reshape(x, [3, nchunks]); % reshape the data + y = repmat(uint8(0), 4, nchunks); % for the encoded data + + %% Split up every 3 bytes into 4 pieces + % aaaaaabb bbbbcccc ccdddddd + % to form + % 00aaaaaa 00bbbbbb 00cccccc 00dddddd + y(1,:) = bitshift(x(1,:), -2); % 6 highest bits of x(1,:) + y(2,:) = bitshift(bitand(x(1,:), 3), 4); % 2 lowest bits of x(1,:) + y(2,:) = bitor(y(2,:), bitshift(x(2,:), -4)); % 4 highest bits of x(2,:) + y(3,:) = bitshift(bitand(x(2,:), 15), 2); % 4 lowest bits of x(2,:) + y(3,:) = bitor(y(3,:), bitshift(x(3,:), -6)); % 2 highest bits of x(3,:) + y(4,:) = bitand(x(3,:), 63); % 6 lowest bits of x(3,:) + + %% Perform the mapping + % 0 - 25 -> A-Z + % 26 - 51 -> a-z + % 52 - 61 -> 0-9 + % 62 -> + + % 63 -> / + map = ['A':'Z', 'a':'z', '0':'9', '+/']; + if (url_safe), map(63:64)='-_'; end + y = map(y(:)+1); + + %% Add padding if necessary. + npbytes = 3 * nchunks - ndbytes; % number of padding bytes + if npbytes>0 + y(end-npbytes+1 : end) = '='; % '=' is used for padding + end + + %% break into lines with length LineLength + if (isChunked) + eol = sprintf('\n'); + nebytes = numel(y); + nlines = ceil(nebytes / 76); % number of lines + neolbytes = length(eol); % number of bytes in eol string + + % pad data so it becomes a multiple of 76 elements + y(nebytes + 1 : 76 * nlines) = 0; + y = reshape(y, 76, nlines); + + % insert eol strings + y(end + 1 : end + neolbytes, :) = eol(:, ones(1, nlines)); + + % remove padding, but keep the last eol string + m = nebytes + neolbytes * (nlines - 1); + n = (76+neolbytes)*nlines - neolbytes; + y(m+1 : n) = []; + end +end + +%% reshape to a row vector and make it a character array +y = char(reshape(y, 1, numel(y))); diff --git a/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/gen_object_display.m b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/gen_object_display.m new file mode 100644 index 00000000..8def90ea --- /dev/null +++ b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/gen_object_display.m @@ -0,0 +1,143 @@ +function gen_object_display( obj_struct,indent ) +% +% gen_object_display - general function to display an object's content +% +% format: gen_object_display( obj_struct,indent ) +% +% input: obj_struct - a copy of the object stored inside a structure +% indent - amount of "indent" when printing to the screen +% +% output: to the screen +% +% example: gen_object_display( struct( my_object_handle) ); +% gen_object_display( ny_structure ); +% +% Correction History: +% 2006-11-01 - Jarek Tuszynski - added support for struct arrays + +%% handle insufficient input +if ( nargin == 0 ) + help gen_object_display; + return; +elseif (nargin == 1) + indent = 1; +end + +%% check input for errors +% if ~isstruct( obj_struct ) +% fprintf( '\n\n\tMake sure that ''obj_struct'' is a struct type\n' ); +% return +% end + +% if (iscell( obj_struct )) +% for i =1:length(obj_struct) +% gen_object_display( obj_struct{i},indent + 2 ); +% end +% return +% end +if ~isstruct( obj_struct ) + space = sprintf( sprintf( '%%%ds',indent ),' ' ); + fprintf( ' %s', space); + disp(obj_struct); + return +end + +% find the longest name +field_list = fieldnames( obj_struct ); +max_strlen = 0; +for idx = 1:length( field_list ) + max_strlen = max( max_strlen,length(field_list{idx}) ); +end + +%% setup the display format (spacing) +space = sprintf( sprintf( '%%%ds',indent ),' ' ); +name_format = sprintf( ' %s%%%ds: ', space, max_strlen ); +name_format2= sprintf( ' %s%%%ds', space, max_strlen ); +max_displen = 110 - max_strlen - indent; + +%% display each field, if it is not too long +for iItem = 1:length( obj_struct ) % loop added by JT + for idx = 1:length( field_list ) + + % prepare field name to be displayed + name = sprintf( name_format,field_list{idx} ); + %temp = getfield( obj_struct,field_list{idx} ); % original by OG + temp = obj_struct(iItem).(field_list{idx}); % modification by JT + + % proceed according the variable's type + switch (1) + case islogical( temp ), % case added by JT + if isscalar(temp) + if (temp) + fprintf( '%strue\n',name ); + else + fprintf( '%sfalse\n',name ); + end + else + fprintf( '%s[%dx%d logical]\n',name,size(temp,1),size(temp,2) ); + end + case ischar( temp ), + if (length(temp) + fprintf( '[No method to display type]' ); + end + fprintf( '\n' ); + end + end + if (length(obj_struct)>1), fprintf('\n'); end % added by JT +end % added by JT \ No newline at end of file diff --git a/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/html/test.html b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/html/test.html new file mode 100644 index 00000000..fac51aa9 --- /dev/null +++ b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/html/test.html @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + +
Apples44%
Bannanas23%
Oranges13%
Other10%
+
\ No newline at end of file diff --git a/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/html/xml_tutorial_script.html b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/html/xml_tutorial_script.html new file mode 100644 index 00000000..c2bf98c4 --- /dev/null +++ b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/html/xml_tutorial_script.html @@ -0,0 +1,2538 @@ + + + + + Tutorial for xml_io_tools Package

Tutorial for xml_io_tools Package

By Jarek Tuszynski

Package xml_io_tools can read XML files into MATLAB struct and writes MATLAB data types to XML files with help of simple interface to MATLAB's xmlwrite and xmlread functions.

Two function to simplify reading and writing XML files from MATLAB:

  • Function xml_read first calls MATLAB's xmlread function and than converts its output ('Document Object Model' tree of Java objects) to tree of MATLAB struct's. The output is in the format of nested structs and cells. In the output data structure field names are based on XML tags.
  • Function xml_write first convert input tree of MATLAB structs and cells and other types to tree of 'Document Object Model' nodes, and then writes resulting object to XML file using MATLAB's xmlwrite function. .

Contents

This package can:

  • Read most XML files, created inside and outside of MATLAB environment, and convert them to MATLAB data structures.
  • Write any MATLAB's struct tree to XML file
  • Handle XML attributes and special XML nodes like comments, processing instructions and CDATA sections
  • Supports base64 encoding and decoding to allow handling embeded binary data
  • Be studied, modified, customized, rewritten and used in other packages without any limitations. All code is included and documented. Software is distributed under BSD Licence (included).

This package does not:

  • Guarantee to recover the same Matlab objects that were saved. If you need to be able to recover carbon copy of the structure that was saved than you will have to use one of the packages that uses special set of tags saved as xml attributes that help to guide the parsing of XML code. This package does not use those tags.
  • Guarantee to work with older versions of MATLAB. Functions do not work with versions of MATLAB prior to 7.1 (26-Jul-2005).

Change History

  • 2006-11-06 - original version
  • 2006-11-26 - corrected xml_write to handle writing Matlab's column arrays to xml files. Bug discovered and diagnosed by Kalyan Dutta.
  • 2006-11-28 - made changes to handle special node types like: COMMENTS and CDATA sections
  • 2007-03-12 - Writing CDATA sections still did not worked. The problem was diagnosed and fixed by Alberto Amaro. The fix involved rewriting xmlwrite to use Apache Xerces java files directly instead of MATLAB's XMLUtils java class.
  • 2007-06-21 - Fixed problem reported by Anna Kelbert in Reviews about not writing attributes of ROOT node. Also: added support for Processing Instructions, added support for global text nodes: Processing Instructions and comments, allowed writing tag names with special characters
  • 2007-07-20 - Added tutorial script file. Extended support for global text nodes. Added more Preference fields.
  • 2008-01-23 - Fixed problem reported by Anna Krewet of converting dates in format '2007-01-01' to numbers. Improved and added warning messages. Added detection of old Matlab versions incompatible with the library. Expanded documentation.
  • 2008-06-23 - Fixed problem with writing 1D array reported by Mark Neil. Extended xml_read's Pref.Num2Str to 3 settings (never, smart and always) for better control. Added parameter Pref.KeepNS for keeping or ignoring namespace data when reading. Fixed a bug related to writing 2D cell arrays brought up by Andrej's Mosat review.
  • 2008-09-11 - Resubmitting last upload - zip file is still old
  • 2009-02-26 - Small changes. More error handling. More robust in case of large binary objects. Added support for Base64 encoding/decoding of binary objects (using functions by Peter J. Acklam).
  • 2009-06-26 - changes to xml_read: added CellItem parameter to allow better control of reading files with 'item' notation (see comment by Shlomi); changed try-catch statements so xml_read would work for mablab versions prior to 7.5 (see Thomas Pilutti comment)
  • 2009-12-03 - added PreserveSpace parameter for contolling empty string handling as suggested by Sebastiaan. Fix suggested by Michael Murphy. Fixed number recognition code as suggested by Yuan Ren.
  • 2010-05-04 - implemented fixes suggested by Dylan Reynolds from Airbus.
  • 2010-07-28 - implemented support for 2D arrays of cells and structs suggested by Rodney Behn from MIT Lincoln Laboratory. Also attempted large scale cleanup of xml_write function
  • 2010-08-18 - minor extension to allow better handling of logical scalars and arrays and function handles suggested by Andreas Richter and others
  • 2010-09-20 - allow reading and writing of sparse matrices. Improve reading of 1D boolean arrays.
  • 2010-11-05 - Fix problem with empty cells reported by Richard Cotton; fixed issues with reading boolean arrays reported by Zohar Bar-Yehuda; Improved speed of base64 coding and decoding by switching to java based code.

Licence

The package is distributed under BSD License

format compact; % viewing preference
+clear variables;
+type('license.txt')
+
+Copyright (c) 2007, Jaroslaw Tuszynski
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without 
+modification, are permitted provided that the following conditions are 
+met:
+
+    * Redistributions of source code must retain the above copyright 
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright 
+      notice, this list of conditions and the following disclaimer in 
+      the documentation and/or other materials provided with the distribution
+      
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+POSSIBILITY OF SUCH DAMAGE.
+
+

Write XML file based on a Struct using "xml_write"

Any MATLAB data struct can be saved to XML file.

MyTree=[];
+MyTree.MyNumber = 13;
+MyTree.MyString = 'Hello World';
+xml_write('test.xml', MyTree);
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <MyNumber>13</MyNumber>
+   <MyString>Hello World</MyString>
+</MyTree>
+

Read XML file producing a Struct using "xml_read"

[tree treeName] = xml_read ('test.xml');
+disp([treeName{1} ' ='])
+gen_object_display(tree)
+
MyTree =
+    MyNumber: [13]
+    MyString: 'Hello World'
+

"Pref.XmlEngine" flag in "xml_write"

Occasionaly some operations are performed better by Apache Xerces XML engine than default xmlread function. That is why xml_write provide an option for choosing the underlaying xml engine. Code below performs the same operation as the previous section but using Apache Xerces XML engine. Notice that in this case name of root element was passed as variable and not extracted from the variable name.

Pref=[]; Pref.XmlEngine = 'Xerces';  % use Xerces xml generator directly
+xml_write('test.xml', MyTree, 'TreeOfMine', Pref);
+type('test.xml')
+
+<?xml version="1.0" encoding="UTF-8"?>
+<TreeOfMine>
+    <MyNumber>13</MyNumber>
+    <MyString>Hello World</MyString>
+</TreeOfMine>
+
+

Writing Struct with different type MATLAB arrays

MyTree=[];
+MyTree.Empty   = [];                   % Empty variable
+MyTree.Num_1x1 = 13;                   % simple scalar
+MyTree.Vec_1x3 = [1 2 3];              % horizontal vector
+MyTree.Vec_4x1 = [1; 2; 3; 4];         % vertical vector
+MyTree.Mat_2x2 = [1, 2; 3, 4];         % 2D matrix
+MyTree.Cube_3D = reshape(1:8,[2 2 2]); % 3D array
+MyTree.String1 = '[2003 10 30]';       % number string with    [] brackets
+MyTree.String2 = ' 2003 10 30 ';       % number string without [] brackets
+MyTree.Logical_1x1 = false;            % single logical
+MyTree.Logical_2x2 = [false, true; true, false]; % 2D matrix of logicals
+MyTree.Logical_Str = 'False False	True True';
+MyTree.Int_2x2 = uint8([1 2;3 4]);     % 2D matrix of uint8 integers
+MyTree.Complex_1x1 = complex(1, 7);    % complex scalar
+MyTree.Complex_2x2 = complex([1 2;3 4],[2 2;7 7]); % 2D matrix of complex numbers
+MyTree.Sparse_9x9 = sparse(1:9,1:9,1); % sparse 9x9 matrix
+MyTree.Function = @sum;                % function handle
+xml_write('test.xml', MyTree);
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <Empty/>
+   <Num_1x1>13</Num_1x1>
+   <Vec_1x3>[1 2 3]</Vec_1x3>
+   <Vec_4x1>[1;2;3;4]</Vec_4x1>
+   <Mat_2x2>[1 2;3 4]</Mat_2x2>
+   <Cube_3D>[1;2;3;4;5;6;7;8]</Cube_3D>
+   <String1>[2003 10 30]</String1>
+   <String2>2003 10 30</String2>
+   <Logical_1x1>[false]</Logical_1x1>
+   <Logical_2x2>[false true;true false]</Logical_2x2>
+   <Logical_Str>False False True True</Logical_Str>
+   <Int_2x2>[uint8([1 2;3 4])]</Int_2x2>
+   <Complex_1x1>1+i*7</Complex_1x1>
+   <Complex_2x2>[1+i*2 2+i*2;3+i*7 4+i*7]</Complex_2x2>
+   <Sparse_9x9>[sparse([1;2;3;4;5;6;7;8;9], [1;2;3;4;5;6;7;8;9], [1;1;1;1;1;1;1;1;1], 9, 9)]</Sparse_9x9>
+   <Function>[@sum]</Function>
+</MyTree>
+

Read Struct with MATLAB arrays

Notice that 'Cube_3D' did not preserve original dimentions

[tree treeName] = xml_read ('test.xml');
+disp([treeName{1} ' ='])
+gen_object_display(tree)
+
MyTree =
+          Empty: [0x0 double]
+        Num_1x1: [13]
+        Vec_1x3: [1  2  3]
+        Vec_4x1: [4x1 double]
+        Mat_2x2: [2x2 double]
+        Cube_3D: [8x1 double]
+        String1: [2003    10    30]
+        String2: [2003    10    30]
+    Logical_1x1: false
+    Logical_2x2: [2x2 logical]
+    Logical_Str: [1x4 logical]
+        Int_2x2: [2x2 double]
+    Complex_1x1: [1+7i]
+    Complex_2x2: [2x2 double]
+     Sparse_9x9: [9x9 double]
+       Function: [No method to display type]
+

"Pref.StructItem" flag in "xml_write" (controls 1D arrays of structs)

Create a simple structure with 1D array of struct's

MyTree = [];
+MyTree.a(1).b = 'jack';
+MyTree.a(2).b = 'john';
+gen_object_display(MyTree)
+
    a: [1x2 struct]
+       b: 'jack'
+
+       b: 'john'
+
+

Write XML with "StructItem = true" (default). Notice single 'a' section and multiple 'item' sub-sections. Those subsections are used to store array elements

wPref.StructItem = true;
+xml_write('test.xml', MyTree, 'MyTree',wPref);
+type('test.xml')
+fprintf('\nxml_read output:\n')
+gen_object_display(xml_read ('test.xml'))
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <a>
+      <item>
+         <b>jack</b>
+      </item>
+      <item>
+         <b>john</b>
+      </item>
+   </a>
+</MyTree>
+
+xml_read output:
+    a: [2x1 struct]
+       b: 'jack'
+
+       b: 'john'
+
+

Write XML with "StructItem = false". Notice multiple 'a' sections

wPref.StructItem = false;
+xml_write('test.xml', MyTree, 'MyTree',wPref);
+type('test.xml')
+fprintf('\nxml_read output:\n')
+gen_object_display(xml_read ('test.xml'))
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <a>
+      <b>jack</b>
+   </a>
+   <a>
+      <b>john</b>
+   </a>
+</MyTree>
+
+xml_read output:
+    a: [2x1 struct]
+       b: 'jack'
+
+       b: 'john'
+
+

Notice that xml_read function produced the same struct when reading both files

Potential problems with "StructItem = true":

wPref.StructItem = true;
+MyTree1 = []; MyTree1.a.b    = 'jack';
+MyTree2 = []; MyTree2.a(1).b = 'jack';
+MyTree3 = []; MyTree3.a(2).b = 'jack';
+xml_write('test.xml', MyTree1, [], wPref); type('test.xml');
+xml_write('test.xml', MyTree2, [], wPref); type('test.xml');
+xml_write('test.xml', MyTree3, [], wPref); type('test.xml');
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree1>
+   <a>
+      <b>jack</b>
+   </a>
+</MyTree1>
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree2>
+   <a>
+      <b>jack</b>
+   </a>
+</MyTree2>
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree3>
+   <a>
+      <item>
+         <b/>
+      </item>
+      <item>
+         <b>jack</b>
+      </item>
+   </a>
+</MyTree3>
+

Notice that MyTree1 and MyTree2 produce identical files with no 'items', while MyTree2 and MyTree3 produce very different file structures. It was pointed out to me that files produced from MyTree2 and MyTree3 can not belong to the same schema, which can be a problem. The solution is to use cells.

wPref.CellItem = true;
+wPref.NoCells  = true;
+MyTree2 = []; MyTree2.a{1}.b = 'jack';
+MyTree3 = []; MyTree3.a{2}.b = 'jack';
+xml_write('test.xml', MyTree2, [], wPref); type('test.xml');
+xml_write('test.xml', MyTree3, [], wPref); type('test.xml');
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree2>
+   <a>
+      <item>
+         <b>jack</b>
+      </item>
+   </a>
+</MyTree2>
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree3>
+   <a>
+      <item/>
+      <item>
+         <b>jack</b>
+      </item>
+   </a>
+</MyTree3>
+

"Pref.CellItem" flag in "xml_write" (controls 1D arrays of cells)

Create a simple structure with cell arrays

MyTree = [];
+MyTree.a = {'jack', 'john'};
+disp(MyTree)
+
    a: {'jack'  'john'}
+

Write XML with "CellItem = true" (default). Notice single 'a' section and multiple 'item' sections

Pref=[]; Pref.CellItem = true;
+xml_write('test.xml', MyTree, 'MyTree',Pref);
+type('test.xml')
+fprintf('\nxml_read output:\n');
+disp(xml_read ('test.xml'))
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <a>
+      <item>jack</item>
+      <item>john</item>
+   </a>
+</MyTree>
+
+xml_read output:
+    a: {'jack'  'john'}
+

Write XML with "CellItem = false". Notice multiple 'a' sections

Pref=[]; Pref.CellItem = false;
+xml_write('test.xml', MyTree, 'MyTree',Pref);
+type('test.xml')
+fprintf('\nxml_read output:\n');
+disp(xml_read ('test.xml'))
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <a>jack</a>
+   <a>john</a>
+</MyTree>
+
+xml_read output:
+    a: {'jack'  'john'}
+

Notice that xml_read function produced the same struct when reading both files

"Pref.NoCells" flag in "xml_read"

Create a cell/struct mixture object

MyTree = [];
+MyTree.a{1}.b = 'jack';
+MyTree.a{2}.b = [];
+MyTree.a{2}.c = 'john';
+gen_object_display(MyTree);
+
    a: [1x2 cell] = 
+       b: 'jack'
+
+       b: [0x0 double]
+       c: 'john'
+
+

Save it to xml file

Pref=[]; Pref.CellItem = false;
+xml_write('test.xml', MyTree, 'MyTree',Pref);
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <a>
+      <b>jack</b>
+   </a>
+   <a>
+      <b/>
+      <c>john</c>
+   </a>
+</MyTree>
+

Read above file with "Pref.NoCells=true" (default) - output is quite different then input By default program is trying to convert everything to struct's and arrays of structs. In case arrays of structs all the structs in array need to have the same fields, and if they are not than MATLAB creates empty fields.

Pref=[]; Pref.NoCells=true;
+gen_object_display(xml_read('test.xml', Pref))
+
    a: [2x1 struct]
+       b: 'jack'
+       c: [0x0 double]
+
+       b: [0x0 double]
+       c: 'john'
+
+

Read above file with "Pref.NoCells=false" - now input and output are the same Cell arrays of structs allow structs in array to have different fields.

Pref=[]; Pref.NoCells=false;
+gen_object_display(xml_read('test.xml', Pref))
+
    a: [1x2 cell] = 
+       b: 'jack'
+
+       b: [0x0 double]
+       c: 'john'
+
+

"Pref.ItemName" flag in "xml_write" (customize 1D arrays of structs and cells)

Create a cell/struct mixture object

MyTree = [];
+MyTree.a{1}.b = 'jack';
+MyTree.a{2}.c = 'john';
+gen_object_display(MyTree);
+
    a: [1x2 cell] = 
+       b: 'jack'
+
+       c: 'john'
+
+

Save it to xml file, using 'item' notation but with different name

Pref=[];
+Pref.CellItem = true;
+Pref.ItemName = 'MyItem';
+xml_write('test.xml', MyTree, 'MyTree',Pref);
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <a>
+      <MyItem>
+         <b>jack</b>
+      </MyItem>
+      <MyItem>
+         <c>john</c>
+      </MyItem>
+   </a>
+</MyTree>
+

"Pref.ItemName" flag in "xml_read"

Read above file with default settings ("Pref.ItemName = 'item'") The results do not match the original structure

Pref=[]; Pref.NoCells  = false;
+gen_object_display(xml_read('test.xml', Pref))
+
    a: [1x1 struct]
+       MyItem: [1x2 cell] = 
+               b: 'jack'
+
+               c: 'john'
+
+

Read above file with "Pref.ItemName = 'MyItem'" - now saved and read MATLAB structures are the same

Pref=[];
+Pref.ItemName = 'MyItem';
+Pref.NoCells  = false;
+gen_object_display(xml_read('test.xml', Pref))
+
    a: [1x2 cell] = 
+       b: 'jack'
+
+       c: 'john'
+
+

"Pref.CellItem" flag in "xml_read"

"Pref.ItemName" is used to create xml files with clearly marked arrays "Pref.CellItem" flag in "xml_read" ensures that they are always read as arrays by forcing output to stay in cell format. In cell format s{1} is different than s, while s(1) is indistinguishable from s.

Create a test file

MyTree = [];
+MyTree.a1{1}.b = 'jack'; % a1 - single struct
+MyTree.a2{1}.b = 'jack'; % a2 - cell array of structs with the same fields
+MyTree.a2{2}.b = 'john';
+MyTree.a3{1}.b = 'jack'; % a3 - cell array of structs with the different fields
+MyTree.a3{2}.c = 'john';
+Pref=[];
+Pref.CellItem = true;
+Pref.Debug = true;
+xml_write('test.xml', MyTree, 'MyTree',Pref);
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <a1>
+      <item>
+         <b>jack</b>
+      </item>
+   </a1>
+   <a2>
+      <item>
+         <b>jack</b>
+      </item>
+      <item>
+         <b>john</b>
+      </item>
+   </a2>
+   <a3>
+      <item>
+         <b>jack</b>
+      </item>
+      <item>
+         <c>john</c>
+      </item>
+   </a3>
+</MyTree>
+

Read above file with "Pref.CellItem = true" (default) All outputs are in cell format

Pref=[];
+Pref.NoCells  = false;  % allow cell output
+Pref.CellItem = true;   % keep 'item' arrays as cells
+gen_object_display(xml_read('test.xml', Pref))
+
    a1: [1x1 cell] = 
+        b: 'jack'
+
+    a2: [1x1 cell] = 
+            [1x1 struct]    [1x1 struct]
+
+    a3: [1x1 cell] = 
+            [1x1 struct]    [1x1 struct]
+
+

Read above file with "Pref.CellItem = false" Outputs format is determined by content

Pref=[];
+Pref.NoCells  = false; % allow cell output
+Pref.CellItem = false; % allow 'item' arrays to beheave like other fields
+gen_object_display(xml_read('test.xml', Pref))
+
    a1: [1x1 struct]
+        b: 'jack'
+    a2: [2x1 struct]
+        b: 'jack'
+
+        b: 'john'
+
+    a3: [1x2 cell] = 
+        b: 'jack'
+
+        c: 'john'
+
+

Read above file with "Pref.CellItem = false" and "Pref.NoCells = true" All outputs are in struct format

Pref=[];
+Pref.NoCells  = true;  % don't allow cell output
+Pref.CellItem = false; % allow 'item' arrays to beheave like other fields
+gen_object_display(xml_read('test.xml', Pref))
+
    a1: [1x1 struct]
+        b: 'jack'
+    a2: [2x1 struct]
+        b: 'jack'
+
+        b: 'john'
+
+    a3: [2x1 struct]
+        b: 'jack'
+        c: [0x0 double]
+
+        b: [0x0 double]
+        c: 'john'
+
+

"Pref.CellTable" flag in "xml_write" (controls 2D arrays of cells)

Create a structure with 2D arrays of cells

MyTree = [];
+MyTree.M = {[1,2;3,4], 'M12'; struct('a','jack'), {11, 'N12'; 21, 'N22'}};
+gen_object_display(MyTree)
+
    M: [2x2 cell] = 
+           [2x2 double]    'M12'
+           [1x1 struct]    {2x2 cell}
+

Write XML with "CellTable = 'Html" (default). This option mimics use of HTML "tr" and "td" tags to encode 2D tables. Tag names can be changed using TableName parameter (see below)

wPref = [];
+wPref.CellTable = 'Html';
+xml_write('test.xml', MyTree, 'MyTree',wPref);
+type('test.xml')
+fprintf('\nxml_read output:\n')
+rPref=[]; rPref.NoCells=false;
+gen_object_display(xml_read('test.xml', rPref))
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <M>
+      <tr>
+         <td>[1 2;3 4]</td>
+         <td>M12</td>
+      </tr>
+      <tr>
+         <td>
+            <a>jack</a>
+         </td>
+         <td>
+            <tr>
+               <td>11</td>
+               <td>N12</td>
+            </tr>
+            <tr>
+               <td>21</td>
+               <td>N22</td>
+            </tr>
+         </td>
+      </tr>
+   </M>
+</MyTree>
+
+xml_read output:
+    M: [2x2 cell] = 
+           [2x2 double]    'M12'
+           [1x1 struct]    {2x2 cell}
+

Write XML with "CellTable = 'Vector'". Converts 2D arrays to 1D array and item or regular notation. This option is mostly provided for backward compatibility since this was the behavior in prior verions of the code

wPref = [];
+wPref.CellTable = 'Vector';
+xml_write('test.xml', MyTree, 'MyTree',wPref);
+type('test.xml')
+fprintf('\nxml_read output:\n')
+rPref=[]; rPref.NoCells=false;
+gen_object_display(xml_read('test.xml', rPref))
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <M>
+      <item>[1 2;3 4]</item>
+      <item>
+         <a>jack</a>
+      </item>
+      <item>M12</item>
+      <item>
+         <item>11</item>
+         <item>21</item>
+         <item>N12</item>
+         <item>N22</item>
+      </item>
+   </M>
+</MyTree>
+
+xml_read output:
+    M: [1x4 cell] = 
+            1     2
+     3     4
+
+       a: 'jack'
+
+       M12
+
+           [11]    [21]    'N12'    'N22'
+
+

Create a simpler structure without struct's

MyTree = [];
+MyTree.M = {[1,2;3,4], 'M12'; 'M21', {11, 'N12'; 21, 'N22'}};
+gen_object_display(MyTree)
+
    M: [2x2 cell] = 
+           [2x2 double]    'M12'
+           'M21'    {2x2 cell}
+

Write XML with "CellTable = 'Matlab". This option encodes tables consisting of numbers, strings and other cell arrays as MATLAB command string. Unlike 'Html' option it does not work if one of the cells is a struct

wPref = [];
+wPref.CellTable = 'Matlab';
+xml_write('test.xml', MyTree, 'MyTree',wPref);
+type('test.xml')
+fprintf('\nxml_read output:\n')
+rPref=[]; rPref.NoCells=false;
+gen_object_display(xml_read('test.xml', rPref))
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <M>{[1 2;3 4],'M12';'M21',{11,'N12';21,'N22';};}</M>
+</MyTree>
+
+xml_read output:
+    M: [2x2 cell] = 
+           [2x2 double]    'M12'
+           'M21'    {2x2 cell}
+

Write 2D cell array in HTML format

MyTree = [];
+MyTree.table.ATTRIBUTE.border=1;
+MyTree.table.CONTENT = {'Apples', '44%'; 'Bannanas', '23%'; 'Oranges', '13%'; 'Other', '10%'};
+xml_write('html/test.html', MyTree);
+type('html/test.html')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <table border="1">
+      <tr>
+         <td>Apples</td>
+         <td>44%</td>
+      </tr>
+      <tr>
+         <td>Bannanas</td>
+         <td>23%</td>
+      </tr>
+      <tr>
+         <td>Oranges</td>
+         <td>13%</td>
+      </tr>
+      <tr>
+         <td>Other</td>
+         <td>10%</td>
+      </tr>
+   </table>
+</MyTree>
+

Click on test.html to opened this file with a web brouwser

"Pref.StructTable" flag in "xml_write" (controls 2D arrays of structs)

Create a simple structure with arrays of struct's

MyTree = [];
+MyTree.a(1,1).b = 'jack';
+MyTree.a(1,2).b = 'john';
+MyTree.a(2,1).b = 'jim';
+MyTree.a(2,2).b = 'jill';
+gen_object_display(MyTree)
+
    a: [2x2 struct]
+      a(1,1) =
+        b: 'jack'
+      a(1,2) =
+        b: 'john'
+      a(2,1) =
+        b: 'jim'
+      a(2,2) =
+        b: 'jill'
+

Write XML with "StructTable = 'Html" (default). This option mimics use of HTML "tr" and "td" tags to encode 2D tables. Tag names can be changed using TableName parameter (see below)

wPref = [];
+wPref.StructTable = 'Html';
+xml_write('test.xml', MyTree, 'MyTree',wPref);
+type('test.xml')
+fprintf('\nxml_read output:\n')
+gen_object_display(xml_read ('test.xml'))
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <a>
+      <tr>
+         <td>
+            <b>jack</b>
+         </td>
+         <td>
+            <b>john</b>
+         </td>
+      </tr>
+      <tr>
+         <td>
+            <b>jim</b>
+         </td>
+         <td>
+            <b>jill</b>
+         </td>
+      </tr>
+   </a>
+</MyTree>
+
+xml_read output:
+    a: [2x2 struct]
+      a(1,1) =
+        b: 'jack'
+      a(1,2) =
+        b: 'john'
+      a(2,1) =
+        b: 'jim'
+      a(2,2) =
+        b: 'jill'
+

Write XML with "CellTable = 'Vector'". Converts 2D arrays to 1D array and item or regular notation. This option is mostly provided for backward compatibility since this was the behavior in prior verions of the code

wPref = [];
+wPref.StructTable = 'Vector';
+xml_write('test.xml', MyTree, 'MyTree',wPref);
+type('test.xml')
+fprintf('\nxml_read output:\n')
+gen_object_display(xml_read ('test.xml'))
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <a>
+      <item>
+         <b>jack</b>
+      </item>
+      <item>
+         <b>jim</b>
+      </item>
+      <item>
+         <b>john</b>
+      </item>
+      <item>
+         <b>jill</b>
+      </item>
+   </a>
+</MyTree>
+
+xml_read output:
+    a: [4x1 struct]
+       b: 'jack'
+
+       b: 'jim'
+
+       b: 'john'
+
+       b: 'jill'
+
+

"Pref.TableName" flag in "xml_write" (controls encoding tags used for 2D arrays)

Create a cell object

MyTree = [];
+MyTree.M = {[1,2;3,4], 'M12'; 21, {11, 'N12'; 21, 'N22'}};
+gen_object_display(MyTree);
+
    M: [2x2 cell] = 
+           [2x2 double]    'M12'
+           [21]    {2x2 cell}
+

Save it to xml file, using 'Html' notation but with different names for rows and cells

Pref=[]; Pref.TableName = {'row','cell'};
+xml_write('test.xml', MyTree, 'MyTree',Pref);
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <M>
+      <row>
+         <cell>[1 2;3 4]</cell>
+         <cell>M12</cell>
+      </row>
+      <row>
+         <cell>21</cell>
+         <cell>
+            <row>
+               <cell>11</cell>
+               <cell>N12</cell>
+            </row>
+            <row>
+               <cell>21</cell>
+               <cell>N22</cell>
+            </row>
+         </cell>
+      </row>
+   </M>
+</MyTree>
+

"Pref.TableName" flag in "xml_read"

Read above file with default settings ("Pref.TableName = {'tr','td'}") The results do not match the original structure

Pref=[]; Pref.NoCells  = false;
+gen_object_display(xml_read('test.xml', Pref))
+
    M: [1x1 struct]
+       row: [2x1 struct]
+            cell: [1x2 cell] = 
+                       1     2
+     3     4
+
+                  M12
+
+
+            cell: [1x2 cell] = 
+                      21
+
+                  row: [2x1 struct]
+                       cell: [1x2 cell] = 
+                                 11
+
+                             N12
+
+
+                       cell: [1x2 cell] = 
+                                 21
+
+                             N22
+
+
+
+
+

Read above file with "Pref.TableName = {'row','cell'}" - now saved and read MATLAB structures are the same

Pref=[];
+Pref.TableName = {'row','cell'};
+Pref.NoCells  = false;
+gen_object_display(xml_read('test.xml', Pref))
+
    M: [2x2 cell] = 
+           [2x2 double]    'M12'
+           [21]    {2x2 cell}
+

"Pref.Str2Num" flag in xml_read (control conversion to numbers while reading)

Create a cell/struct mixture object

MyTree = [];
+MyTree.str     = 'sphere';
+MyTree.num1    =  123;
+MyTree.num2    = '123';
+MyTree.num3    = '[Inf,NaN]';
+MyTree.calc    = '1+2+3+4';
+MyTree.func    = 'sin(pi)/2';
+MyTree.String1 = '[2003 10 30]';
+MyTree.String2 = '2003 10 30';   % array resembling date
+MyTree.ISO8601 = '2003-10-30';   % date in ISO 8601 format
+MyTree.US_date = '2003/10/30';   % US style date format
+MyTree.complex = '2003i-10e-30'; % complex number resembling a date
+gen_object_display(MyTree);
+
        str: 'sphere'
+       num1: [123]
+       num2: '123'
+       num3: '[Inf,NaN]'
+       calc: '1+2+3+4'
+       func: 'sin(pi)/2'
+    String1: '[2003 10 30]'
+    String2: '2003 10 30'
+    ISO8601: '2003-10-30'
+    US_date: '2003/10/30'
+    complex: '2003i-10e-30'
+

Save it to xml file

xml_write('test.xml', MyTree);
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <str>sphere</str>
+   <num1>123</num1>
+   <num2>123</num2>
+   <num3>[Inf,NaN]</num3>
+   <calc>1+2+3+4</calc>
+   <func>sin(pi)/2</func>
+   <String1>[2003 10 30]</String1>
+   <String2>2003 10 30</String2>
+   <ISO8601>2003-10-30</ISO8601>
+   <US_date>2003/10/30</US_date>
+   <complex>2003i-10e-30</complex>
+</MyTree>
+

Read above file with default settings ("Pref.Str2Num = true" or "Pref.Str2Num = 'smart'"). Under this setting all strings that look like numbers are converted to numbers, except for strings that are recognized by MATLAB 'datenum' function as dates

gen_object_display(xml_read('test.xml'))
+
        str: 'sphere'
+       num1: [123]
+       num2: [123]
+       num3: [Inf  NaN]
+       calc: [10]
+       func: 'sin(pi)/2'
+    String1: [2003    10    30]
+    String2: [2003    10    30]
+    ISO8601: '2003-10-30'
+    US_date: '2003/10/30'
+    complex: [-1e-029+2003i]
+

Note that all the fields of 'MyTree' can be converted to numbers (even 'sphere') but by default the function is trying to 'judge' if a string should be converted to a number or not

MyCell = {'sphere','1+2+3+4','sin(pi)/2','2003 10 30','2003-10-30','2003/10/30','2003i-10e-30'};
+cellfun(@str2num, MyCell, 'UniformOutput', false)
+
ans = 
+  Columns 1 through 6
+    [21x21 double]    [10]    [6.1232e-017]    [1x3 double]    [1963]    [6.6767]
+  Column 7
+    [-1.0000e-029 +2.0030e+003i]
+

Read above file with "Pref.Str2Num = false" or "Pref.Str2Num = 'never'" to keep all the fields in string format

Pref=[]; Pref.Str2Num = false;
+gen_object_display(xml_read('test.xml', Pref))
+
        str: 'sphere'
+       num1: '123'
+       num2: '123'
+       num3: '[Inf,NaN]'
+       calc: '1+2+3+4'
+       func: 'sin(pi)/2'
+    String1: '[2003 10 30]'
+    String2: '2003 10 30'
+    ISO8601: '2003-10-30'
+    US_date: '2003/10/30'
+    complex: '2003i-10e-30'
+

Read above file with "Pref.Str2Num = always" to convert all strings that look like numbers to numbers note the likelly unintendet conversion of 'ISO8601'

Pref=[]; Pref.Str2Num   = 'always';
+gen_object_display(xml_read('test.xml', Pref))
+
        str: 'sphere'
+       num1: [123]
+       num2: [123]
+       num3: [Inf  NaN]
+       calc: [10]
+       func: 'sin(pi)/2'
+    String1: [2003    10    30]
+    String2: [2003    10    30]
+    ISO8601: [1963]
+    US_date: '2003/10/30'
+    complex: [-1e-029+2003i]
+

Notice that all three settings will produce the same output for "num1" and "num2" and there is no way to reproduce the original "MyTree" structure.

"Pref.PreserveSpace" flag in xml_write (control handling of strings with leading/trailing spaces)

Create a struct with strings

MyTree=[];
+MyTree.Empty     = '';
+MyTree.OneSpace  = ' ';
+MyTree.TwoSpaces = '  ';
+MyTree.String1   = ' Hello      World ';
+

Write XML with "PreserveSpace = false" (default).

Pref=[]; Pref.PreserveSpace = false; % (default setting)
+xml_write('test.xml', MyTree, [], Pref);
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <Empty/>
+   <OneSpace/>
+   <TwoSpaces/>
+   <String1>Hello World</String1>
+</MyTree>
+

Write XML with "PreserveSpace = true".

Pref=[]; Pref.PreserveSpace = true;
+xml_write('test.xml', MyTree, [], Pref);
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <Empty/>
+   <OneSpace> </OneSpace>
+   <TwoSpaces>  </TwoSpaces>
+   <String1> Hello      World </String1>
+</MyTree>
+

"Pref.PreserveSpace" flag in xml_read

Read file while using "PreserveSpace = false" (default).

Pref=[]; Pref.PreserveSpace = false; % (default setting)
+gen_object_display(xml_read('test.xml',Pref))
+
        Empty: [0x0 double]
+     OneSpace: [0x0 double]
+    TwoSpaces: [0x0 double]
+      String1: 'Hello      World'
+

Read file while using "PreserveSpace = true".

Pref=[]; Pref.PreserveSpace = true;
+gen_object_display(xml_read('test.xml',Pref))
+
        Empty: [0x0 double]
+     OneSpace: ' '
+    TwoSpaces: '  '
+      String1: ' Hello      World '
+

Write XML files with ATTRIBUTEs

In order to add node attributes a special ATTRIBUTE field is used. ATTRIBUTEs have to be of simple types like numbers or strings (not struct or cells). Attributes are easy to attach to structs nodes like MyTree below.

MyTree=[];
+MyTree.MyNumber = 13;
+MyTree.MyString = 'Hello World'; % simple case
+MyTree.ATTRIBUTE.Num = 2;
+xml_write('test.xml', MyTree);
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree Num="2">
+   <MyNumber>13</MyNumber>
+   <MyString>Hello World</MyString>
+</MyTree>
+

In case when one needs to attach attributes to nodes which are not structs (for example strings, numbers or calls) then special CONTENT field needs to be used to make the node a struct node.

MyTree=[];
+MyTree.MyNumber = 13;
+MyTree.MyString.CONTENT = 'Hello World'; % simple case
+MyTree.MyString.ATTRIBUTE.Num = 2;
+xml_write('test.xml', MyTree);
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <MyNumber>13</MyNumber>
+   <MyString Num="2">Hello World</MyString>
+</MyTree>
+

"Pref.Str2Num" flag in file with ATTRIBUTEs

Create a cell/struct mixture object

MyTree = [];
+MyTree.X.ATTRIBUTE.str     = 'sphere';
+MyTree.X.ATTRIBUTE.num1    =  123;
+MyTree.X.ATTRIBUTE.num2    = '123';
+MyTree.X.ATTRIBUTE.num3    = '[Inf,NaN]';
+MyTree.X.ATTRIBUTE.calc    = '1+2+3+4';
+MyTree.X.ATTRIBUTE.func    = 'sin(pi)/2';
+MyTree.X.ATTRIBUTE.String1 = '[2003 10 30]';
+MyTree.X.ATTRIBUTE.String2 = '2003 10 30';   % array resembling date
+MyTree.X.ATTRIBUTE.ISO8601 = '2003-10-30';   % date in ISO 8601 format
+MyTree.X.ATTRIBUTE.US_date = '2003/10/30';   % US style date format
+MyTree.X.ATTRIBUTE.complex = '2003i-10e-30'; % complex number resembling a date
+gen_object_display(MyTree);
+
    X: [1x1 struct]
+       ATTRIBUTE: [1x1 struct]
+                      str: 'sphere'
+                     num1: [123]
+                     num2: '123'
+                     num3: '[Inf,NaN]'
+                     calc: '1+2+3+4'
+                     func: 'sin(pi)/2'
+                  String1: '[2003 10 30]'
+                  String2: '2003 10 30'
+                  ISO8601: '2003-10-30'
+                  US_date: '2003/10/30'
+                  complex: '2003i-10e-30'
+

Save it to xml file

xml_write('test.xml', MyTree);
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <X ISO8601="2003-10-30" String1="[2003 10 30]" String2="2003 10 30" US_date="2003/10/30" calc="1+2+3+4" complex="2003i-10e-30" func="sin(pi)/2" num1="123" num2="123" num3="[Inf,NaN]" str="sphere"/>
+</MyTree>
+

Read above file with default settings ("Pref.Str2Num = true" or "Pref.Str2Num = 'smart'"). Under this setting all strings that look like numbers are converted to numbers, except for strings that are recognized by MATLAB 'datenum' function as dates

gen_object_display(xml_read('test.xml'))
+
    X: [1x1 struct]
+         CONTENT: [0x0 double]
+       ATTRIBUTE: [1x1 struct]
+                  ISO8601: '2003-10-30'
+                  String1: '[2003 10 30]'
+                  String2: '2003 10 30'
+                  US_date: '2003/10/30'
+                     calc: '1+2+3+4'
+                  complex: [-1e-029+2003i]
+                     func: 'sin(pi)/2'
+                     num1: [123]
+                     num2: [123]
+                     num3: '[Inf,NaN]'
+                      str: 'sphere'
+

Read above file with "Pref.Str2Num = false" or "Pref.Str2Num = 'never'" to keep all the fields in string format

Pref=[]; Pref.Str2Num = false;
+gen_object_display(xml_read('test.xml', Pref))
+
    X: [1x1 struct]
+         CONTENT: [0x0 double]
+       ATTRIBUTE: [1x1 struct]
+                  ISO8601: '2003-10-30'
+                  String1: '[2003 10 30]'
+                  String2: '2003 10 30'
+                  US_date: '2003/10/30'
+                     calc: '1+2+3+4'
+                  complex: '2003i-10e-30'
+                     func: 'sin(pi)/2'
+                     num1: '123'
+                     num2: '123'
+                     num3: '[Inf,NaN]'
+                      str: 'sphere'
+

Read above file with "Pref.Str2Num = always" to convert all strings that look like numbers to numbers

Pref=[]; Pref.Str2Num   = 'always';
+gen_object_display(xml_read('test.xml', Pref))
+
    X: [1x1 struct]
+         CONTENT: [0x0 double]
+       ATTRIBUTE: [1x1 struct]
+                  ISO8601: '2003-10-30'
+                  String1: '[2003 10 30]'
+                  String2: '2003 10 30'
+                  US_date: '2003/10/30'
+                     calc: '1+2+3+4'
+                  complex: [-1e-029+2003i]
+                     func: 'sin(pi)/2'
+                     num1: [123]
+                     num2: [123]
+                     num3: '[Inf,NaN]'
+                      str: 'sphere'
+

Notice that all three settings will produce the same output for "num1" and "num2" and there is no way to reproduce the original "MyTree" structure.

Write XML files with COMMENTs

Insertion of Comments is done with help of special COMMENT field. Note that MATLAB's xmlwrite is less readable due to lack of end-of-line characters around comment section.

MyTree=[];
+MyTree.COMMENT = 'This is a comment';
+MyTree.MyNumber = 13;
+MyTree.MyString.CONTENT = 'Hello World';
+xml_write('test.xml', MyTree);
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree><!--This is a comment-->
+   <MyNumber>13</MyNumber>
+   <MyString>Hello World</MyString>
+</MyTree>
+

Same operation using Apache Xerces XML engine gives the same result

Pref=[]; Pref.XmlEngine = 'Xerces';  % use Xerces xml generator directly
+xml_write('test.xml', MyTree, 'MyTree', Pref);
+type('test.xml')
+
+<?xml version="1.0" encoding="UTF-8"?>
+<MyTree>
+    <!--This is a comment-->
+    <MyNumber>13</MyNumber>
+    <MyString>Hello World</MyString>
+</MyTree>
+
+

Comments in XML top level (method #1) This method uses cell array

MyTree=[];
+MyTree.MyNumber = 13;
+MyTree.MyString = 'Hello World';
+xml_write('test.xml', MyTree, {'MyTree', [], 'This is a global comment'});
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?><!--This is a global comment-->
+<MyTree>
+   <MyNumber>13</MyNumber>
+   <MyString>Hello World</MyString>
+</MyTree>
+

Same operation using Apache Xerces XML engine gives even nicer results.

Pref=[]; Pref.XmlEngine = 'Xerces';  % use Xerces xml generator directly
+xml_write('test.xml', MyTree, {'MyTree', [], 'This is a global comment'}, Pref);
+type('test.xml')
+
+<?xml version="1.0" encoding="UTF-8"?>
+<!--This is a global comment-->
+<MyTree>
+    <MyNumber>13</MyNumber>
+    <MyString>Hello World</MyString>
+</MyTree>
+
+

Comments in XML top level (method #2) This method adds an extra top layer to the struct 'tree' and sets "Pref.RootOnly = false", which informs the function about the extra layer. Notice that RootName is also saved as a part of the 'tree', and does not have to be passed in separately.

MyTree=[];
+MyTree.COMMENT = 'This is a global comment';
+MyTree.MyTest.MyNumber = 13;
+MyTree.MyTest.MyString = 'Hello World';
+Pref=[]; Pref.RootOnly = false;
+xml_write('test.xml', MyTree, [], Pref);
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?><!--This is a global comment-->
+<MyTest>
+   <MyNumber>13</MyNumber>
+   <MyString>Hello World</MyString>
+</MyTest>
+

Same operation using Apache Xerces XML engine

Pref=[]; Pref.XmlEngine = 'Xerces';  % use Xerces xml generator directly
+Pref.RootOnly  = false;
+xml_write('test.xml', MyTree, [], Pref);
+type('test.xml')
+
+<?xml version="1.0" encoding="UTF-8"?>
+<!--This is a global comment-->
+<MyTest>
+    <MyNumber>13</MyNumber>
+    <MyString>Hello World</MyString>
+</MyTest>
+
+

Write XML files with PROCESSING_INSTRUCTIONs

Insertion of Processing Instructions is done through use of special PROCESSING_INSTRUCTION field, which stores the instruction string. The string has to be in 'target data' format separated by space.

MyTree=[];
+MyTree.PROCESSING_INSTRUCTION = 'xml-stylesheet type="a" href="foo"';
+MyTree.MyNumber = 13;
+MyTree.MyString = 'Hello World';
+xml_write('test.xml', MyTree);
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree><?xml-stylesheet type="a" href="foo"?>
+   <MyNumber>13</MyNumber>
+   <MyString>Hello World</MyString>
+</MyTree>
+

Same operation using Apache Xerces XML engine

Pref=[]; Pref.XmlEngine = 'Xerces';  % use Xerces xml generator directly
+xml_write('test.xml', MyTree, 'MyTree', Pref);
+type('test.xml')
+
+<?xml version="1.0" encoding="UTF-8"?>
+<MyTree><?xml-stylesheet type="a" href="foo"?>
+    <MyNumber>13</MyNumber>
+    <MyString>Hello World</MyString>
+</MyTree>
+
+

PROCESSING_INSTRUCTIONs in XML top level (method #1) This method uses cell array

MyTree=[];
+MyTree.MyNumber = 13;
+MyTree.MyString = 'Hello World';
+xml_write('test.xml', MyTree, {'MyTree', 'xml-stylesheet type="a" href="foo"'});
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type="a" href="foo"?>
+<MyTree>
+   <MyNumber>13</MyNumber>
+   <MyString>Hello World</MyString>
+</MyTree>
+

Same operation using Apache Xerces XML engine

Pref=[]; Pref.XmlEngine = 'Xerces';  % use Xerces xml generator directly
+xml_write('test.xml', MyTree, {'MyTree', 'xml-stylesheet type="a" href="foo"'}, Pref);
+type('test.xml')
+
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="a" href="foo"?>
+<MyTree>
+    <MyNumber>13</MyNumber>
+    <MyString>Hello World</MyString>
+</MyTree>
+
+

PROCESSING_INSTRUCTIONs in XML top level (method #2) This method adds an extra top layer to the struct 'tree' and sets pref.RootOnly=false, which informs the function about the extra layer. Notice that RootName is also saved as a part of the 'tree', and does not have to be passed in separately.

MyTree=[];
+MyTree.PROCESSING_INSTRUCTION =  'xml-stylesheet type="a" href="foo"';
+MyTree.MyTest.MyNumber = 13;
+MyTree.MyTest.MyString = 'Hello World';
+Pref=[]; Pref.RootOnly = false;
+xml_write('test.xml', MyTree, [], Pref);
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type="a" href="foo"?>
+<MyTest>
+   <MyNumber>13</MyNumber>
+   <MyString>Hello World</MyString>
+</MyTest>
+

Same operation using Apache Xerces XML engine

Pref=[]; Pref.XmlEngine = 'Xerces';  % use Xerces xml generator directly
+Pref.RootOnly  = false;
+xml_write('test.xml', MyTree, 'MyTree', Pref);
+type('test.xml')
+
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="a" href="foo"?>
+<MyTest>
+    <MyNumber>13</MyNumber>
+    <MyString>Hello World</MyString>
+</MyTest>
+
+

Write XML files with CDATA Sections

"In an XML document a CDATA (Character DATA) section is a section of element content that is marked for the parser to interpret as only character data, not markup." (from Wikipedia) To insert CDATA Sections one use special CDATA_SECTION field, which stores the instruction string. Note that MATLAB's xmlwrite created wrong xml code for CDATA section

MyTree=[];
+MyTree.CDATA_SECTION = '<A>txt</A>';
+MyTree.MyNumber = 13;
+MyTree.MyString = 'Hello World';
+xml_write('test.xml', MyTree);
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>&lt;A&gt;txt&lt;/A&gt;<MyNumber>13</MyNumber>
+   <MyString>Hello World</MyString>
+</MyTree>
+

Same operation using Apache Xerces XML engine produces correct results

Pref=[]; Pref.XmlEngine = 'Xerces';  % use Xerces xml generator directly
+xml_write('test.xml', MyTree, 'MyTree', Pref);
+type('test.xml')
+
+<?xml version="1.0" encoding="UTF-8"?>
+<MyTree><![CDATA[<A>txt</A>]]><MyNumber>13</MyNumber>
+    <MyString>Hello World</MyString>
+</MyTree>
+
+

Write XML files with special characters in TAG names

The input to xml_write requires that all tags one wants in XML document have to be encoded as field names of MATLAB's struct's. Matlab has a lot of restrictions on variable names. This section is about XML tags with names not allowed as MATLAB variables, or more specifically with characters allowed as xml tag names but not allowed as MATLAB variable names. Characters like that can be replaced by their hexadecimal representation just as it is done by genvarname function. Alternative way of writing the first example is:

MyTree=[];
+MyTree.('MyNumber') = 13;               % same as MyTree.MyNumber = 13;
+MyTree.MyString.CONTENT = 'Hello World';
+MyTree.MyString.ATTRIBUTE.('Num') = 2;  % same as MyTree.MyString.ATTRIBUTE.Num = 2;
+xml_write('test.xml', MyTree);
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <MyNumber>13</MyNumber>
+   <MyString Num="2">Hello World</MyString>
+</MyTree>
+

This approach fails for some characters like dash '-', colon ':', and international characters.

MyTree=[];
+try
+  MyTree.('My-Number') = 13;
+  MyTree.MyString.CONTENT = 'Hello World';
+  MyTree.MyString.ATTRIBUTE.('Num_ö') = 2;
+catch  %#ok<CTCH>
+  err = lasterror; %#ok<LERR>
+  disp(err.message);
+end
+
Invalid field name: 'My-Number'.
+

It can be overcome by replacing offending characters with their hexadecimal representation. That can be done manually or with use of genvarname function. Note that MATLAB 'type' function does not show correctly 'ö' letter in xml file, but opening the file in editor shows that it is correct.

MyTree=[];
+MyTree.(genvarname('My-Number')) = 13;
+MyTree.MyString.CONTENT = 'Hello World';
+MyTree.MyString.ATTRIBUTE.Num_0xF6 = 2;
+gen_object_display(MyTree);
+xml_write('test.xml', MyTree);
+type('test.xml')
+
    My0x2DNumber: [13]
+        MyString: [1x1 struct]
+                    CONTENT: 'Hello World'
+                  ATTRIBUTE: [1x1 struct]
+                             Num_0xF6: [2]
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <My-Number>13</My-Number>
+   <MyString Num_ö="2">Hello World</MyString>
+</MyTree>
+

Also two of the characters '-' and ':' can be encoded by a special strings: '_DASH_' and '_COLON_' respectively

MyTree=[];
+MyTree.My_DASH_Number = 13;
+MyTree.MyString.CONTENT = 'Hello World';
+MyTree.MyString.ATTRIBUTE.Num0xF6 = 2;
+xml_write('test.xml', MyTree);
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <My-Number>13</My-Number>
+   <MyString Numö="2">Hello World</MyString>
+</MyTree>
+

Write XML files with Namespaces

No extra special fields are needed to define XML namespaces, only colon character written using '0x3A' or '_COLON_'. Below is an example of a namespace definition

MyTree=[];
+MyTree.f_COLON_child.ATTRIBUTE.xmlns_COLON_f = 'http://www.foo.com';
+MyTree.f_COLON_child.f_COLON_MyNumber = 13;
+MyTree.f_COLON_child.f_COLON_MyString = 'Hello World';
+xml_write('test.xml', MyTree, 'MyTree');
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <f:child xmlns:f="http://www.foo.com">
+      <f:MyNumber>13</f:MyNumber>
+      <f:MyString>Hello World</f:MyString>
+   </f:child>
+</MyTree>
+

Same operation using Apache Xerces XML engine

Pref=[]; Pref.XmlEngine = 'Xerces';  % use Xerces xml generator directly
+xml_write('test.xml', MyTree, 'f_COLON_MyTree', Pref);
+type('test.xml')
+
+<?xml version="1.0" encoding="UTF-8"?>
+<f:MyTree>
+    <f:child xmlns:f="http://www.foo.com">
+        <f:MyNumber>13</f:MyNumber>
+        <f:MyString>Hello World</f:MyString>
+    </f:child>
+</f:MyTree>
+
+

"Pref.KeepNS" flag in "xml_read"

Thise option allow keeping or exclusion of namespaces in tag names. By default the namespace data is kept but it produces much longer field names in the output structure. Ignoring namespace will produce more readible output. Perform default read of file with namespace

tree = xml_read('test.xml');
+gen_object_display(tree);
+
    f_COLON_child: [1x1 struct]
+                   f_COLON_MyNumber: [13]
+                   f_COLON_MyString: 'Hello World'
+                          ATTRIBUTE: [1x1 struct]
+                                     xmlns_COLON_f: 'http://www.foo.com'
+

Now the same operation with KeepNS = false.

Pref=[]; Pref.KeepNS = false; % do not read attributes
+tree = xml_read('test.xml', Pref);
+gen_object_display(tree);
+
    child: [1x1 struct]
+            MyNumber: [13]
+            MyString: 'Hello World'
+           ATTRIBUTE: [1x1 struct]
+                      f: 'http://www.foo.com'
+

Read XML files with special node types

Display and read the file, then show the data structure. Note that MATLAB 'type' function shows 'ö' letter incorrectly as 'A¶' in xml file, but opening the file in editor shows that it is correct.

fprintf('Test xml file:\n');
+type('test_file.xml')
+
Test xml file:
+
+<?xml version="1.0" encoding="utf-8" ?> 
+<?xml-stylesheet type="text/css" href="foo.css"?>
+<!-- This is a Global Comment -->
+<aaa xmlns:xsi="http://www.foo.org">
+  <?ProcInst type="local processing instruction"?>
+  <!-- local comment 1 -->
+  bbb
+  <!-- local comment 2 -->
+  ccc
+  <matrix bad-name='fff'>
+    5e3+2*i, Inf
+    NaN,     pi
+  </matrix>
+  <ee_e> ee_e </ee_e>
+  <ff-f> ff-f </ff-f>
+  <ggög> ggög </ggög>
+  <![CDATA[
+    Here <ddd>xml</ddd> tags are treated as ...
+    ... text
+	]]>
+</aaa>
+
+
+

Read only the Root Element (default)

[tree GlobalTextNodes] = xml_read('test_file.xml');
+fprintf('Global Data (Root name, Global Processing Instructions and Global Comments):\n');
+disp(GlobalTextNodes')
+fprintf('\nStructure read from the file (uncludes COMMENT and CDATA sections):\n');
+gen_object_display(tree);
+
Global Data (Root name, Global Processing Instructions and Global Comments):
+    'aaa'
+    'xml-stylesheet type="text/css" href="foo.css"'
+    'This is a Global Comment'
+
+Structure read from the file (uncludes COMMENT and CDATA sections):
+    PROCESSING_INSTRUCTION: 'ProcInst type="local processing instruction"'
+                   COMMENT: [1x2 cell] = 
+                            local comment 1
+
+                            local comment 2
+
+                   CONTENT: [1x2 cell] = 
+                            bbb
+
+                            ccc
+
+                    matrix: [1x1 struct]
+                              CONTENT: [2x2 double]
+                            ATTRIBUTE: [1x1 struct]
+                                       bad_DASH_name: 'fff'
+                      ee_e: 'ee_e'
+                 ff_DASH_f: 'ff-f'
+                   gg0xF6g: 'ggög'
+             CDATA_SECTION: 'Here <ddd>xml</ddd> tags are treated as ...
+    ... text'
+                 ATTRIBUTE: [1x1 struct]
+                            xmlns_COLON_xsi: 'http://www.foo.org'
+

Read the whole tree including global Comments and Processing Instructions

Pref=[]; Pref.RootOnly = false;
+[tree GlobalTextNodes] = xml_read('test_file.xml', Pref);
+fprintf('Global Data (Root name, Global Processing Instructions and Global Comments):\n');
+disp(GlobalTextNodes')
+fprintf('\nStructure read from the file (uncludes COMMENT and CDATA sections):\n');
+gen_object_display(tree);
+
Global Data (Root name, Global Processing Instructions and Global Comments):
+    'aaa'
+    'xml-stylesheet type="text/css" href="foo.css"'
+    'This is a Global Comment'
+
+Structure read from the file (uncludes COMMENT and CDATA sections):
+    PROCESSING_INSTRUCTION: 'xml-stylesheet type="text/css" href="foo.css"'
+                   COMMENT: 'This is a Global Comment'
+                       aaa: [1x1 struct]
+                            PROCESSING_INSTRUCTION: 'ProcInst type="local processing instruction"'
+                                           COMMENT: [1x2 cell] = 
+                                                    local comment 1
+
+                                                    local comment 2
+
+                                           CONTENT: [1x2 cell] = 
+                                                    bbb
+
+                                                    ccc
+
+                                            matrix: [1x1 struct]
+                                                      CONTENT: [2x2 double]
+                                                    ATTRIBUTE: [1x1 struct]
+                                                               bad_DASH_name: 'fff'
+                                              ee_e: 'ee_e'
+                                         ff_DASH_f: 'ff-f'
+                                           gg0xF6g: 'ggög'
+                                     CDATA_SECTION: 'Here <ddd>xml</ddd> tags are treated as ...
+    ... text'
+                                         ATTRIBUTE: [1x1 struct]
+                                                    xmlns_COLON_xsi: 'http://www.foo.org'
+

"Pref.ReadAttr" flag in "xml_read" (control handling of nodes with attributes)

Those option allow exclusion of attributes

Pref=[]; Pref.ReadAttr = false; % do not read attributes
+tree = xml_read('test_file.xml', Pref);
+gen_object_display(tree);
+
    PROCESSING_INSTRUCTION: 'ProcInst type="local processing instruction"'
+                   COMMENT: [1x2 cell] = 
+                            local comment 1
+
+                            local comment 2
+
+                   CONTENT: [1x2 cell] = 
+                            bbb
+
+                            ccc
+
+                    matrix: [2x2 double]
+                      ee_e: 'ee_e'
+                 ff_DASH_f: 'ff-f'
+                   gg0xF6g: 'ggög'
+             CDATA_SECTION: 'Here <ddd>xml</ddd> tags are treated as ...
+    ... text'
+

"Pref.ReadSpec" flag in "xml_read"

Those option allow exclusion of special nodes, like comments, processing instructions, CData sections, etc.

Pref=[]; Pref.ReadSpec = false; % do not read special node types
+tree = xml_read('test_file.xml', Pref);
+gen_object_display(tree);
+
      CONTENT: [1x2 cell] = 
+               bbb
+
+               ccc
+
+       matrix: [1x1 struct]
+                 CONTENT: [2x2 double]
+               ATTRIBUTE: [1x1 struct]
+                          bad_DASH_name: 'fff'
+         ee_e: 'ee_e'
+    ff_DASH_f: 'ff-f'
+      gg0xF6g: 'ggög'
+    ATTRIBUTE: [1x1 struct]
+               xmlns_COLON_xsi: 'http://www.foo.org'
+

"Pref.RootOnly" flag in "xml_read"

As it was shown in previous examples RootOnly parameter can be used to capture global (top level) special nodes (like COMMENTs and PROCESSING_INSTRUCTIONs) which are ignored by default

Pref=[]; Pref.RootOnly = false; % do not read special node types
+tree = xml_read('test_file.xml', Pref);
+gen_object_display(tree);
+
    PROCESSING_INSTRUCTION: 'xml-stylesheet type="text/css" href="foo.css"'
+                   COMMENT: 'This is a Global Comment'
+                       aaa: [1x1 struct]
+                            PROCESSING_INSTRUCTION: 'ProcInst type="local processing instruction"'
+                                           COMMENT: [1x2 cell] = 
+                                                    local comment 1
+
+                                                    local comment 2
+
+                                           CONTENT: [1x2 cell] = 
+                                                    bbb
+
+                                                    ccc
+
+                                            matrix: [1x1 struct]
+                                                      CONTENT: [2x2 double]
+                                                    ATTRIBUTE: [1x1 struct]
+                                                               bad_DASH_name: 'fff'
+                                              ee_e: 'ee_e'
+                                         ff_DASH_f: 'ff-f'
+                                           gg0xF6g: 'ggög'
+                                     CDATA_SECTION: 'Here <ddd>xml</ddd> tags are treated as ...
+    ... text'
+                                         ATTRIBUTE: [1x1 struct]
+                                                    xmlns_COLON_xsi: 'http://www.foo.org'
+

"Pref.RootOnly" flag in "xml_write"

Writing previously read tree with default "Pref.RootOnly = true" gives wrong output file

Pref=[]; Pref.RootOnly = true; % do not read special node types
+xml_write('test.xml', tree, [], Pref);
+fprintf('Test xml file:\n');
+type('test.xml')
+
Test xml file:
+
+<?xml version="1.0" encoding="utf-8"?>
+<tree><?xml-stylesheet type="text/css" href="foo.css"?><!--This is a Global Comment-->
+   <aaa xmlns:xsi="http://www.foo.org"><?ProcInst type="local processing instruction"?><!--local comment 1--><!--local comment 2-->
+      <item>bbb</item>
+      <item>ccc</item>
+      <matrix bad-name="fff">[5000+i*2 Inf;NaN 3.14159265358979]</matrix>
+      <ee_e>ee_e</ee_e>
+      <ff-f>ff-f</ff-f>
+      <ggög>ggög</ggög>Here &lt;ddd&gt;xml&lt;/ddd&gt; tags are treated as ...
+    ... text</aaa>
+</tree>
+

Writing the same tree with "Pref.RootOnly = false" gives correct output

Pref=[]; Pref.RootOnly = false; % do not read special node types
+xml_write('test.xml', tree, [], Pref);
+fprintf('Test xml file:\n');
+type('test.xml')
+
Test xml file:
+
+<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type="text/css" href="foo.css"?><!--This is a Global Comment-->
+<aaa xmlns:xsi="http://www.foo.org"><?ProcInst type="local processing instruction"?><!--local comment 1--><!--local comment 2-->
+   <item>bbb</item>
+   <item>ccc</item>
+   <matrix bad-name="fff">[5000+i*2 Inf;NaN 3.14159265358979]</matrix>
+   <ee_e>ee_e</ee_e>
+   <ff-f>ff-f</ff-f>
+   <ggög>ggög</ggög>Here &lt;ddd&gt;xml&lt;/ddd&gt; tags are treated as ...
+    ... text</aaa>
+

"Pref.NumLevels" flag in "xml_read"

This parameter allows user to skip parts of the tree in order to save time and memory. Usefull only in a rare case when a small portion of large XML file is needed.

Create test tile

MyTree = [];
+MyTree.Level1 = 1;
+MyTree.Level1_.Level2 = 2;
+MyTree.Level1_.Level2_.Level3 = 3;
+MyTree.Level1_.Level2_.Level3_.Level4 = 4;
+xml_write('test.xml', MyTree);
+fprintf('Test xml file:\n');
+type('test.xml')
+
Test xml file:
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <Level1>1</Level1>
+   <Level1_>
+      <Level2>2</Level2>
+      <Level2_>
+         <Level3>3</Level3>
+         <Level3_>
+            <Level4>4</Level4>
+         </Level3_>
+      </Level2_>
+   </Level1_>
+</MyTree>
+

Use Default ("Pref.NumLevels = infinity") setting

tree = xml_read('test.xml');
+gen_object_display(tree);
+
     Level1: [1]
+    Level1_: [1x1 struct]
+              Level2: [2]
+             Level2_: [1x1 struct]
+                       Level3: [3]
+                      Level3_: [1x1 struct]
+                               Level4: [4]
+

Limit the read to only 2 levels

Pref=[]; Pref.NumLevels = 2;
+tree = xml_read('test.xml', Pref);
+gen_object_display(tree);
+
     Level1: [1]
+    Level1_: [1x1 struct]
+              Level2: [2]
+             Level2_: [0x0 double]
+

Create DOM object based on a Struct using "xml_write"

Create Struct tree

MyTree=[];
+MyTree.MyNumber = 13;
+MyTree.MyString = 'Hello World';
+

Convert Struct to DOM object using xml_write

DOM = xml_write([], MyTree);
+xmlwrite('test.xml', DOM);   % Save DOM object using MATLAB function
+type('test.xml')
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <MyNumber>13</MyNumber>
+   <MyString>Hello World</MyString>
+</MyTree>
+

Convert DOM object to Struct using "xml_read"

DOM = xmlread('test.xml');       % Read DOM object using MATLAB function
+[tree treeName] = xml_read(DOM); % Convert DOM object to Struct
+disp([treeName{1} ' ='])
+gen_object_display(tree)
+
MyTree =
+    MyNumber: [13]
+    MyString: 'Hello World'
+

Write XML file based on a DOM using "xml_write_xerces"

xmlwrite_xerces('test.xml', DOM); % Save DOM object using Xerces library
+type('test.xml')
+
+<?xml version="1.0" encoding="UTF-8"?>
+<MyTree>
+    <MyNumber>13</MyNumber>
+    <MyString>Hello World</MyString>
+</MyTree>
+
+

Write XML to string instead of a file

DOM = xml_write([], MyTree);
+str = xmlwrite(DOM);
+disp(str)
+
<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <MyNumber>13</MyNumber>
+   <MyString>Hello World</MyString>
+</MyTree>
+

Write XML file with embedded binary data encoded as Base64 (using java version)

fid = fopen('football.jpg', 'rb');
+raw1 = uint8(fread(fid, 'uint8'));                % read image file as a raw binary
+fclose(fid);
+
+MyTree=[];
+MyTree.Size = 13;
+MyTree.MyString = 'Hello World'; % simple case
+MyTree.MyImage.ATTRIBUTE.EncodingMIMEType = 'base64';
+MyTree.MyImage.CONTENT = base64encode(raw1,'java');% perform base64 encoding of the binary data
+xml_write('test.xml', MyTree);             % write xml file
+

Read XML file with embedded binary data encoded as Base64 (using java version)

tree = xml_read('test.xml', Pref);         % read xml file
+raw  = base64decode(tree.MyImage.CONTENT, '', 'java');   % convert xml image to raw binary
+fid = fopen('MyFootball.jpg', 'wb');
+fwrite(fid, raw, 'uint8');                 % dumb the raw binary to the hard disk
+fclose(fid);
+I = imread('MyFootball.jpg');              % read it as an image
+imshow(I);
+

Write XML file with embedded binary data encoded as Base64 (simpler version using only matlab code

Notice that process of writing to xml stripped all end-of-lie characters from base64 code.

isChunked = true; % break into chunks 76 characters long
+url_safe  = true; % 'base64url' encoding
+code = base64encode('license.txt', 'matlab', isChunked, url_safe);
+disp(code)
+MyTree=[];
+MyTree.Size = 13;
+MyTree.MyString = 'Hello World';
+MyTree.MyImage.ATTRIBUTE.EncodingMIMEType = 'base64';
+MyTree.MyImage.CONTENT = code;   % perform base64 encoding of the binary data
+xml_write('test.xml', MyTree);   % write xml file
+type('test.xml')
+
Q29weXJpZ2h0IChjKSAyMDA3LCBKYXJvc2xhdyBUdXN6eW5za2kKQWxsIHJpZ2h0cyByZXNlcnZl
+ZC4KClJlZGlzdHJpYnV0aW9uIGFuZCB1c2UgaW4gc291cmNlIGFuZCBiaW5hcnkgZm9ybXMsIHdp
+dGggb3Igd2l0aG91dCAKbW9kaWZpY2F0aW9uLCBhcmUgcGVybWl0dGVkIHByb3ZpZGVkIHRoYXQg
+dGhlIGZvbGxvd2luZyBjb25kaXRpb25zIGFyZSAKbWV0OgoKICAgICogUmVkaXN0cmlidXRpb25z
+IG9mIHNvdXJjZSBjb2RlIG11c3QgcmV0YWluIHRoZSBhYm92ZSBjb3B5cmlnaHQgCiAgICAgIG5v
+dGljZSwgdGhpcyBsaXN0IG9mIGNvbmRpdGlvbnMgYW5kIHRoZSBmb2xsb3dpbmcgZGlzY2xhaW1l
+ci4KICAgICogUmVkaXN0cmlidXRpb25zIGluIGJpbmFyeSBmb3JtIG11c3QgcmVwcm9kdWNlIHRo
+ZSBhYm92ZSBjb3B5cmlnaHQgCiAgICAgIG5vdGljZSwgdGhpcyBsaXN0IG9mIGNvbmRpdGlvbnMg
+YW5kIHRoZSBmb2xsb3dpbmcgZGlzY2xhaW1lciBpbiAKICAgICAgdGhlIGRvY3VtZW50YXRpb24g
+YW5kL29yIG90aGVyIG1hdGVyaWFscyBwcm92aWRlZCB3aXRoIHRoZSBkaXN0cmlidXRpb24KICAg
+ICAgClRISVMgU09GVFdBUkUgSVMgUFJPVklERUQgQlkgVEhFIENPUFlSSUdIVCBIT0xERVJTIEFO
+RCBDT05UUklCVVRPUlMgIkFTIElTIiAKQU5EIEFOWSBFWFBSRVNTIE9SIElNUExJRUQgV0FSUkFO
+VElFUywgSU5DTFVESU5HLCBCVVQgTk9UIExJTUlURUQgVE8sIFRIRSAKSU1QTElFRCBXQVJSQU5U
+SUVTIE9GIE1FUkNIQU5UQUJJTElUWSBBTkQgRklUTkVTUyBGT1IgQSBQQVJUSUNVTEFSIFBVUlBP
+U0UgCkFSRSBESVNDTEFJTUVELiBJTiBOTyBFVkVOVCBTSEFMTCBUSEUgQ09QWVJJR0hUIE9XTkVS
+IE9SIENPTlRSSUJVVE9SUyBCRSAKTElBQkxFIEZPUiBBTlkgRElSRUNULCBJTkRJUkVDVCwgSU5D
+SURFTlRBTCwgU1BFQ0lBTCwgRVhFTVBMQVJZLCBPUiAKQ09OU0VRVUVOVElBTCBEQU1BR0VTIChJ
+TkNMVURJTkcsIEJVVCBOT1QgTElNSVRFRCBUTywgUFJPQ1VSRU1FTlQgT0YgClNVQlNUSVRVVEUg
+R09PRFMgT1IgU0VSVklDRVM7IExPU1MgT0YgVVNFLCBEQVRBLCBPUiBQUk9GSVRTOyBPUiBCVVNJ
+TkVTUyAKSU5URVJSVVBUSU9OKSBIT1dFVkVSIENBVVNFRCBBTkQgT04gQU5ZIFRIRU9SWSBPRiBM
+SUFCSUxJVFksIFdIRVRIRVIgSU4gCkNPTlRSQUNULCBTVFJJQ1QgTElBQklMSVRZLCBPUiBUT1JU
+IChJTkNMVURJTkcgTkVHTElHRU5DRSBPUiBPVEhFUldJU0UpIApBUklTSU5HIElOIEFOWSBXQVkg
+T1VUIE9GIFRIRSBVU0UgT0YgVEhJUyBTT0ZUV0FSRSwgRVZFTiBJRiBBRFZJU0VEIE9GIFRIRSAK
+UE9TU0lCSUxJVFkgT0YgU1VDSCBEQU1BR0UuCg==
+
+
+<?xml version="1.0" encoding="utf-8"?>
+<MyTree>
+   <Size>13</Size>
+   <MyString>Hello World</MyString>
+   <MyImage EncodingMIMEType="base64">Q29weXJpZ2h0IChjKSAyMDA3LCBKYXJvc2xhdyBUdXN6eW5za2kKQWxsIHJpZ2h0cyByZXNlcnZl ZC4KClJlZGlzdHJpYnV0aW9uIGFuZCB1c2UgaW4gc291cmNlIGFuZCBiaW5hcnkgZm9ybXMsIHdp dGggb3Igd2l0aG91dCAKbW9kaWZpY2F0aW9uLCBhcmUgcGVybWl0dGVkIHByb3ZpZGVkIHRoYXQg dGhlIGZvbGxvd2luZyBjb25kaXRpb25zIGFyZSAKbWV0OgoKICAgICogUmVkaXN0cmlidXRpb25z IG9mIHNvdXJjZSBjb2RlIG11c3QgcmV0YWluIHRoZSBhYm92ZSBjb3B5cmlnaHQgCiAgICAgIG5v dGljZSwgdGhpcyBsaXN0IG9mIGNvbmRpdGlvbnMgYW5kIHRoZSBmb2xsb3dpbmcgZGlzY2xhaW1l ci4KICAgICogUmVkaXN0cmlidXRpb25zIGluIGJpbmFyeSBmb3JtIG11c3QgcmVwcm9kdWNlIHRo ZSBhYm92ZSBjb3B5cmlnaHQgCiAgICAgIG5vdGljZSwgdGhpcyBsaXN0IG9mIGNvbmRpdGlvbnMg YW5kIHRoZSBmb2xsb3dpbmcgZGlzY2xhaW1lciBpbiAKICAgICAgdGhlIGRvY3VtZW50YXRpb24g YW5kL29yIG90aGVyIG1hdGVyaWFscyBwcm92aWRlZCB3aXRoIHRoZSBkaXN0cmlidXRpb24KICAg ICAgClRISVMgU09GVFdBUkUgSVMgUFJPVklERUQgQlkgVEhFIENPUFlSSUdIVCBIT0xERVJTIEFO RCBDT05UUklCVVRPUlMgIkFTIElTIiAKQU5EIEFOWSBFWFBSRVNTIE9SIElNUExJRUQgV0FSUkFO VElFUywgSU5DTFVESU5HLCBCVVQgTk9UIExJTUlURUQgVE8sIFRIRSAKSU1QTElFRCBXQVJSQU5U SUVTIE9GIE1FUkNIQU5UQUJJTElUWSBBTkQgRklUTkVTUyBGT1IgQSBQQVJUSUNVTEFSIFBVUlBP U0UgCkFSRSBESVNDTEFJTUVELiBJTiBOTyBFVkVOVCBTSEFMTCBUSEUgQ09QWVJJR0hUIE9XTkVS IE9SIENPTlRSSUJVVE9SUyBCRSAKTElBQkxFIEZPUiBBTlkgRElSRUNULCBJTkRJUkVDVCwgSU5D SURFTlRBTCwgU1BFQ0lBTCwgRVhFTVBMQVJZLCBPUiAKQ09OU0VRVUVOVElBTCBEQU1BR0VTIChJ TkNMVURJTkcsIEJVVCBOT1QgTElNSVRFRCBUTywgUFJPQ1VSRU1FTlQgT0YgClNVQlNUSVRVVEUg R09PRFMgT1IgU0VSVklDRVM7IExPU1MgT0YgVVNFLCBEQVRBLCBPUiBQUk9GSVRTOyBPUiBCVVNJ TkVTUyAKSU5URVJSVVBUSU9OKSBIT1dFVkVSIENBVVNFRCBBTkQgT04gQU5ZIFRIRU9SWSBPRiBM SUFCSUxJVFksIFdIRVRIRVIgSU4gCkNPTlRSQUNULCBTVFJJQ1QgTElBQklMSVRZLCBPUiBUT1JU IChJTkNMVURJTkcgTkVHTElHRU5DRSBPUiBPVEhFUldJU0UpIApBUklTSU5HIElOIEFOWSBXQVkg T1VUIE9GIFRIRSBVU0UgT0YgVEhJUyBTT0ZUV0FSRSwgRVZFTiBJRiBBRFZJU0VEIE9GIFRIRSAK UE9TU0lCSUxJVFkgT0YgU1VDSCBEQU1BR0UuCg==</MyImage>
+</MyTree>
+

Read XML file with embedded binary data encoded as Base64 (simpler version using only matlab code

tree = xml_read('test.xml', Pref);         % read xml file
+base64decode(tree.MyImage.CONTENT, 'license2.txt', 'matlab'); % save xml image as raw binary
+type('license2.txt')
+
+Copyright (c) 2007, Jaroslaw Tuszynski
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without 
+modification, are permitted provided that the following conditions are 
+met:
+
+    * Redistributions of source code must retain the above copyright 
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright 
+      notice, this list of conditions and the following disclaimer in 
+      the documentation and/or other materials provided with the distribution
+      
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+POSSIBILITY OF SUCH DAMAGE.
+
+
\ No newline at end of file diff --git a/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/html/xml_tutorial_script.png b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/html/xml_tutorial_script.png new file mode 100644 index 00000000..2f5d8c09 Binary files /dev/null and b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/html/xml_tutorial_script.png differ diff --git a/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/html/xml_tutorial_script_01.png b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/html/xml_tutorial_script_01.png new file mode 100644 index 00000000..d12694fa Binary files /dev/null and b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/html/xml_tutorial_script_01.png differ diff --git a/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/license.txt b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/license.txt new file mode 100644 index 00000000..2a275405 --- /dev/null +++ b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/license.txt @@ -0,0 +1,24 @@ +Copyright (c) 2007, Jaroslaw Tuszynski +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/test_file.xml b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/test_file.xml new file mode 100644 index 00000000..c8f5d6f4 --- /dev/null +++ b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/test_file.xml @@ -0,0 +1,22 @@ + + + + + + + bbb + + ccc + + 5e3+2*i, Inf + NaN, pi + + ee_e + ff-f + ggög + xml tags are treated as ... + ... text + ]]> + + diff --git a/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/xml_read.m b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/xml_read.m new file mode 100644 index 00000000..845efd07 --- /dev/null +++ b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/xml_read.m @@ -0,0 +1,550 @@ +function [tree, RootName, DOMnode] = xml_read(xmlfile, Pref) +%XML_READ reads xml files and converts them into Matlab's struct tree. +% +% DESCRIPTION +% tree = xml_read(xmlfile) reads 'xmlfile' into data structure 'tree' +% +% tree = xml_read(xmlfile, Pref) reads 'xmlfile' into data structure 'tree' +% according to your preferences +% +% [tree, RootName, DOMnode] = xml_read(xmlfile) get additional information +% about XML file +% +% INPUT: +% xmlfile URL or filename of xml file to read +% Pref Preferences: +% Pref.ItemName - default 'item' - name of a special tag used to itemize +% cell arrays +% Pref.ReadAttr - default true - allow reading attributes +% Pref.ReadSpec - default true - allow reading special nodes +% Pref.Str2Num - default 'smart' - convert strings that look like numbers +% to numbers. Options: "always", "never", and "smart" +% Pref.KeepNS - default true - keep or strip namespace info +% Pref.NoCells - default true - force output to have no cell arrays +% Pref.Debug - default false - show mode specific error messages +% Pref.NumLevels- default infinity - how many recursive levels are +% allowed. Can be used to speed up the function by prunning the tree. +% Pref.RootOnly - default true - output variable 'tree' corresponds to +% xml file root element, otherwise it correspond to the whole file. +% Pref.CellItem - default 'true' - leave 'item' nodes in cell notation. +% OUTPUT: +% tree tree of structs and/or cell arrays corresponding to xml file +% RootName XML tag name used for root (top level) node. +% Optionally it can be a string cell array storing: Name of +% root node, document "Processing Instructions" data and +% document "comment" string +% DOMnode output of xmlread +% +% DETAILS: +% Function xml_read first calls MATLAB's xmlread function and than +% converts its output ('Document Object Model' tree of Java objects) +% to tree of MATLAB struct's. The output is in format of nested structs +% and cells. In the output data structure field names are based on +% XML tags, except in cases when tags produce illegal variable names. +% +% Several special xml node types result in special tags for fields of +% 'tree' nodes: +% - node.CONTENT - stores data section of the node if other fields are +% present. Usually data section is stored directly in 'node'. +% - node.ATTRIBUTE.name - stores node's attribute called 'name'. +% - node.COMMENT - stores node's comment section (string). For global +% comments see "RootName" output variable. +% - node.CDATA_SECTION - stores node's CDATA section (string). +% - node.PROCESSING_INSTRUCTIONS - stores "processing instruction" child +% node. For global "processing instructions" see "RootName" output variable. +% - other special node types like: document fragment nodes, document type +% nodes, entity nodes, notation nodes and processing instruction nodes +% will be treated like regular nodes +% +% EXAMPLES: +% MyTree=[]; +% MyTree.MyNumber = 13; +% MyTree.MyString = 'Hello World'; +% xml_write('test.xml', MyTree); +% [tree treeName] = xml_read ('test.xml'); +% disp(treeName) +% gen_object_display() +% % See also xml_examples.m +% +% See also: +% xml_write, xmlread, xmlwrite +% +% Written by Jarek Tuszynski, SAIC, jaroslaw.w.tuszynski_at_saic.com +% References: +% - Function inspired by Example 3 found in xmlread function. +% - Output data structures inspired by xml_toolbox structures. + +%% default preferences +DPref.TableName = {'tr','td'}; % name of a special tags used to itemize 2D cell arrays +DPref.ItemName = 'item'; % name of a special tag used to itemize 1D cell arrays +DPref.CellItem = false; % leave 'item' nodes in cell notation +DPref.ReadAttr = true; % allow reading attributes +DPref.ReadSpec = true; % allow reading special nodes: comments, CData, etc. +DPref.KeepNS = true; % Keep or strip namespace info +DPref.Str2Num = 'smart';% convert strings that look like numbers to numbers +DPref.NoCells = true; % force output to have no cell arrays +DPref.NumLevels = 1e10; % number of recurence levels +DPref.PreserveSpace = false; % Preserve or delete spaces at the beggining and the end of stings? +RootOnly = true; % return root node with no top level special nodes +Debug = false; % show specific errors (true) or general (false)? +tree = []; +RootName = []; + +%% Check Matlab Version +v = ver('MATLAB'); +version = str2double(regexp(v.Version, '\d.\d','match','once')); +if (version<7.1) + error('Your MATLAB version is too old. You need version 7.1 or newer.'); +end + +%% read user preferences +if (nargin>1) + if (isfield(Pref, 'TableName')), DPref.TableName = Pref.TableName; end + if (isfield(Pref, 'ItemName' )), DPref.ItemName = Pref.ItemName; end + if (isfield(Pref, 'CellItem' )), DPref.CellItem = Pref.CellItem; end + if (isfield(Pref, 'Str2Num' )), DPref.Str2Num = Pref.Str2Num ; end + if (isfield(Pref, 'NoCells' )), DPref.NoCells = Pref.NoCells ; end + if (isfield(Pref, 'NumLevels')), DPref.NumLevels = Pref.NumLevels; end + if (isfield(Pref, 'ReadAttr' )), DPref.ReadAttr = Pref.ReadAttr; end + if (isfield(Pref, 'ReadSpec' )), DPref.ReadSpec = Pref.ReadSpec; end + if (isfield(Pref, 'KeepNS' )), DPref.KeepNS = Pref.KeepNS; end + if (isfield(Pref, 'RootOnly' )), RootOnly = Pref.RootOnly; end + if (isfield(Pref, 'Debug' )), Debug = Pref.Debug ; end + if (isfield(Pref, 'PreserveSpace')), DPref.PreserveSpace = Pref.PreserveSpace; end +end +if ischar(DPref.Str2Num), % convert from character description to numbers + DPref.Str2Num = find(strcmpi(DPref.Str2Num, {'never', 'smart', 'always'}))-1; + if isempty(DPref.Str2Num), DPref.Str2Num=1; end % 1-smart by default +end + +%% read xml file using Matlab function +if isa(xmlfile, 'org.apache.xerces.dom.DeferredDocumentImpl'); + % if xmlfile is a DOMnode than skip the call to xmlread + try + try + DOMnode = xmlfile; + catch ME + error('Invalid DOM node: \n%s.', getReport(ME)); + end + catch %#ok catch for mablab versions prior to 7.5 + error('Invalid DOM node. \n'); + end +else % we assume xmlfile is a filename + if (Debug) % in debuging mode crashes are allowed + DOMnode = xmlread(xmlfile); + else % in normal mode crashes are not allowed + try + try + DOMnode = xmlread(xmlfile); + catch ME + error('Failed to read XML file %s: \n%s',xmlfile, getReport(ME)); + end + catch %#ok catch for mablab versions prior to 7.5 + error('Failed to read XML file %s\n',xmlfile); + end + end +end +Node = DOMnode.getFirstChild; + +%% Find the Root node. Also store data from Global Comment and Processing +% Instruction nodes, if any. +GlobalTextNodes = cell(1,3); +GlobalProcInst = []; +GlobalComment = []; +GlobalDocType = []; +while (~isempty(Node)) + if (Node.getNodeType==Node.ELEMENT_NODE) + RootNode=Node; + elseif (Node.getNodeType==Node.PROCESSING_INSTRUCTION_NODE) + data = strtrim(char(Node.getData)); + target = strtrim(char(Node.getTarget)); + GlobalProcInst = [target, ' ', data]; + GlobalTextNodes{2} = GlobalProcInst; + elseif (Node.getNodeType==Node.COMMENT_NODE) + GlobalComment = strtrim(char(Node.getData)); + GlobalTextNodes{3} = GlobalComment; + % elseif (Node.getNodeType==Node.DOCUMENT_TYPE_NODE) + % GlobalTextNodes{4} = GlobalDocType; + end + Node = Node.getNextSibling; +end + +%% parse xml file through calls to recursive DOMnode2struct function +if (Debug) % in debuging mode crashes are allowed + [tree RootName] = DOMnode2struct(RootNode, DPref, 1); +else % in normal mode crashes are not allowed + try + try + [tree RootName] = DOMnode2struct(RootNode, DPref, 1); + catch ME + error('Unable to parse XML file %s: \n %s.',xmlfile, getReport(ME)); + end + catch %#ok catch for mablab versions prior to 7.5 + error('Unable to parse XML file %s.',xmlfile); + end +end + +%% If there were any Global Text nodes than return them +if (~RootOnly) + if (~isempty(GlobalProcInst) && DPref.ReadSpec) + t.PROCESSING_INSTRUCTION = GlobalProcInst; + end + if (~isempty(GlobalComment) && DPref.ReadSpec) + t.COMMENT = GlobalComment; + end + if (~isempty(GlobalDocType) && DPref.ReadSpec) + t.DOCUMENT_TYPE = GlobalDocType; + end + t.(RootName) = tree; + tree=t; +end +if (~isempty(GlobalTextNodes)) + GlobalTextNodes{1} = RootName; + RootName = GlobalTextNodes; +end + + +%% ======================================================================= +% === DOMnode2struct Function =========================================== +% ======================================================================= +function [s TagName LeafNode] = DOMnode2struct(node, Pref, level) + +%% === Step 1: Get node name and check if it is a leaf node ============== +[TagName LeafNode] = NodeName(node, Pref.KeepNS); +s = []; % initialize output structure + +%% === Step 2: Process Leaf Nodes (nodes with no children) =============== +if (LeafNode) + if (LeafNode>1 && ~Pref.ReadSpec), LeafNode=-1; end % tags only so ignore special nodes + if (LeafNode>0) % supported leaf node types + try + try % use try-catch: errors here are often due to VERY large fields (like images) that overflow java memory + s = char(node.getData); + if (isempty(s)), s = ' '; end % make it a string + % for some reason current xmlread 'creates' a lot of empty text + % fields with first chatacter=10 - those will be deleted. + if (~Pref.PreserveSpace || s(1)==10) + if (isspace(s(1)) || isspace(s(end))), s = strtrim(s); end % trim speces is any + end + if (LeafNode==1), s=str2var(s, Pref.Str2Num, 0); end % convert to number(s) if needed + catch ME % catch for mablab versions 7.5 and higher + warning('xml_io_tools:read:LeafRead', ... + 'This leaf node could not be read and was ignored. '); + getReport(ME) + end + catch %#ok catch for mablab versions prior to 7.5 + warning('xml_io_tools:read:LeafRead', ... + 'This leaf node could not be read and was ignored. '); + end + end + if (LeafNode==3) % ProcessingInstructions need special treatment + target = strtrim(char(node.getTarget)); + s = [target, ' ', s]; + end + return % We are done the rest of the function deals with nodes with children +end +if (level>Pref.NumLevels+1), return; end % if Pref.NumLevels is reached than we are done + +%% === Step 3: Process nodes with children =============================== +if (node.hasChildNodes) % children present + Child = node.getChildNodes; % create array of children nodes + nChild = Child.getLength; % number of children + + % --- pass 1: how many children with each name ----------------------- + f = []; + for iChild = 1:nChild % read in each child + [cname cLeaf] = NodeName(Child.item(iChild-1), Pref.KeepNS); + if (cLeaf<0), continue; end % unsupported leaf node types + if (~isfield(f,cname)), + f.(cname)=0; % initialize first time I see this name + end + f.(cname) = f.(cname)+1; % add to the counter + end % end for iChild + % text_nodes become CONTENT & for some reason current xmlread 'creates' a + % lot of empty text fields so f.CONTENT value should not be trusted + if (isfield(f,'CONTENT') && f.CONTENT>2), f.CONTENT=2; end + + % --- pass 2: store all the children as struct of cell arrays ---------- + for iChild = 1:nChild % read in each child + [c cname cLeaf] = DOMnode2struct(Child.item(iChild-1), Pref, level+1); + if (cLeaf && isempty(c)) % if empty leaf node than skip + continue; % usually empty text node or one of unhandled node types + elseif (nChild==1 && cLeaf==1) + s=c; % shortcut for a common case + else % if normal node + if (level>Pref.NumLevels), continue; end + n = f.(cname); % how many of them in the array so far? + if (~isfield(s,cname)) % encountered this name for the first time + if (n==1) % if there will be only one of them ... + s.(cname) = c; % than save it in format it came in + else % if there will be many of them ... + s.(cname) = cell(1,n); + s.(cname){1} = c; % than save as cell array + end + f.(cname) = 1; % initialize the counter + else % already have seen this name + s.(cname){n+1} = c; % add to the array + f.(cname) = n+1; % add to the array counter + end + end + end % for iChild +end % end if (node.hasChildNodes) + +%% === Step 4: Post-process struct's created for nodes with children ===== +if (isstruct(s)) + fields = fieldnames(s); + nField = length(fields); + + % Detect structure that looks like Html table and store it in cell Matrix + if (nField==1 && strcmpi(fields{1},Pref.TableName{1})) + tr = s.(Pref.TableName{1}); + fields2 = fieldnames(tr{1}); + if (length(fields2)==1 && strcmpi(fields2{1},Pref.TableName{2})) + % This seems to be a special structure such that for + % Pref.TableName = {'tr','td'} 's' corresponds to + % M11 M12 + % M12 M22 + % Recognize it as encoding for 2D struct + nr = length(tr); + for r = 1:nr + row = tr{r}.(Pref.TableName{2}); + Table(r,1:length(row)) = row; %#ok + end + s = Table; + end + end + + % --- Post-processing: convert 'struct of cell-arrays' to 'array of structs' + % Example: let say s has 3 fields s.a, s.b & s.c and each field is an + % cell-array with more than one cell-element and all 3 have the same length. + % Then change it to array of structs, each with single cell. + % This way element s.a{1} will be now accessed through s(1).a + vec = zeros(size(fields)); + for i=1:nField, vec(i) = f.(fields{i}); end + if (numel(vec)>1 && vec(1)>1 && var(vec)==0) % convert from struct of + s = cell2struct(struct2cell(s), fields, 1); % arrays to array of struct + end % if anyone knows better way to do above conversion please let me know. + +end + +%% === Step 5: Process nodes with attributes ============================= +if (node.hasAttributes && Pref.ReadAttr) + if (~isstruct(s)), % make into struct if is not already + ss.CONTENT=s; + s=ss; + end + Attr = node.getAttributes; % list of all attributes + for iAttr = 1:Attr.getLength % for each attribute + name = char(Attr.item(iAttr-1).getName); % attribute name + name = str2varName(name, Pref.KeepNS); % fix name if needed + value = char(Attr.item(iAttr-1).getValue); % attribute value + value = str2var(value, Pref.Str2Num, 1); % convert to number if possible + s.ATTRIBUTE.(name) = value; % save again + end % end iAttr loop +end % done with attributes +if (~isstruct(s)), return; end %The rest of the code deals with struct's + +%% === Post-processing: fields of "s" +% convert 'cell-array of structs' to 'arrays of structs' +fields = fieldnames(s); % get field names +nField = length(fields); +for iItem=1:length(s) % for each struct in the array - usually one + for iField=1:length(fields) + field = fields{iField}; % get field name + % if this is an 'item' field and user want to leave those as cells + % than skip this one + if (strcmpi(field, Pref.ItemName) && Pref.CellItem), continue; end + x = s(iItem).(field); + if (iscell(x) && all(cellfun(@isstruct,x(:))) && numel(x)>1) % it's cell-array of structs + % numel(x)>1 check is to keep 1 cell-arrays created when Pref.CellItem=1 + try % this operation fails sometimes + % example: change s(1).a{1}.b='jack'; s(1).a{2}.b='john'; to + % more convinient s(1).a(1).b='jack'; s(1).a(2).b='john'; + s(iItem).(field) = [x{:}]'; %#ok % converted to arrays of structs + catch %#ok + % above operation will fail if s(1).a{1} and s(1).a{2} have + % different fields. If desired, function forceCell2Struct can force + % them to the same field structure by adding empty fields. + if (Pref.NoCells) + s(iItem).(field) = forceCell2Struct(x); %#ok + end + end % end catch + end + end +end + +%% === Step 4: Post-process struct's created for nodes with children ===== + +% --- Post-processing: remove special 'item' tags --------------------- +% many xml writes (including xml_write) use a special keyword to mark +% arrays of nodes (see xml_write for examples). The code below converts +% s.item to s.CONTENT +ItemContent = false; +if (isfield(s,Pref.ItemName)) + s.CONTENT = s.(Pref.ItemName); + s = rmfield(s,Pref.ItemName); + ItemContent = Pref.CellItem; % if CellItem than keep s.CONTENT as cells +end + +% --- Post-processing: clean up CONTENT tags --------------------- +% if s.CONTENT is a cell-array with empty elements at the end than trim +% the length of this cell-array. Also if s.CONTENT is the only field than +% remove .CONTENT part and store it as s. +if (isfield(s,'CONTENT')) + if (iscell(s.CONTENT) && isvector(s.CONTENT)) + x = s.CONTENT; + for i=numel(x):-1:1, if ~isempty(x{i}), break; end; end + if (i==1 && ~ItemContent) + s.CONTENT = x{1}; % delete cell structure + else + s.CONTENT = x(1:i); % delete empty cells + end + end + if (nField==1) + if (ItemContent) + ss = s.CONTENT; % only child: remove a level but ensure output is a cell-array + s=[]; s{1}=ss; + else + s = s.CONTENT; % only child: remove a level + end + end +end + + + +%% ======================================================================= +% === forceCell2Struct Function ========================================= +% ======================================================================= +function s = forceCell2Struct(x) +% Convert cell-array of structs, where not all of structs have the same +% fields, to a single array of structs + +%% Convert 1D cell array of structs to 2D cell array, where each row +% represents item in original array and each column corresponds to a unique +% field name. Array "AllFields" store fieldnames for each column +AllFields = fieldnames(x{1}); % get field names of the first struct +CellMat = cell(length(x), length(AllFields)); +for iItem=1:length(x) + fields = fieldnames(x{iItem}); % get field names of the next struct + for iField=1:length(fields) % inspect all fieldnames and find those + field = fields{iField}; % get field name + col = find(strcmp(field,AllFields),1); + if isempty(col) % no column for such fieldname yet + AllFields = [AllFields; field]; %#ok + col = length(AllFields); % create a new column for it + end + CellMat{iItem,col} = x{iItem}.(field); % store rearanged data + end +end +%% Convert 2D cell array to array of structs +s = cell2struct(CellMat, AllFields, 2); + +%% ======================================================================= +% === str2var Function ================================================== +% ======================================================================= +function val=str2var(str, option, attribute) +% Can this string 'str' be converted to a number? if so than do it. +val = str; +len = numel(str); +if (len==0 || option==0), return; end % Str2Num="never" of empty string -> do not do enything +if (len>10000 && option==1), return; end % Str2Num="smart" and string is very long -> probably base64 encoded binary +digits = '(Inf)|(NaN)|(pi)|[\t\n\d\+\-\*\.ei EI\[\]\;\,]'; +s = regexprep(str, digits, ''); % remove all the digits and other allowed characters +if (~all(~isempty(s))) % if nothing left than this is probably a number + if (~isempty(strfind(str, ' '))), option=2; end %if str has white-spaces assume by default that it is not a date string + if (~isempty(strfind(str, '['))), option=2; end % same with brackets + str(strfind(str, '\n')) = ';';% parse data tables into 2D arrays, if any + if (option==1) % the 'smart' option + try % try to convert to a date, like 2007-12-05 + datenum(str); % if successful than leave it as string + catch %#ok % if this is not a date than ... + option=2; % ... try converting to a number + end + end + if (option==2) + if (attribute) + num = str2double(str); % try converting to a single number using sscanf function + if isnan(num), return; end % So, it wasn't really a number after all + else + num = str2num(str); %#ok % try converting to a single number or array using eval function + end + if(isnumeric(num) && numel(num)>0), val=num; end % if convertion to a single was succesful than save + end +elseif ((str(1)=='[' && str(end)==']') || (str(1)=='{' && str(end)=='}')) % this looks like a (cell) array encoded as a string + try + val = eval(str); + catch %#ok + val = str; + end +elseif (~attribute) % see if it is a boolean array with no [] brackets + str1 = lower(str); + str1 = strrep(str1, 'false', '0'); + str1 = strrep(str1, 'true' , '1'); + s = regexprep(str1, '[01 \;\,]', ''); % remove all 0/1, spaces, commas and semicolons + if (~all(~isempty(s))) % if nothing left than this is probably a boolean array + num = str2num(str1); %#ok + if(isnumeric(num) && numel(num)>0), val = (num>0); end % if convertion was succesful than save as logical + end +end + + +%% ======================================================================= +% === str2varName Function ============================================== +% ======================================================================= +function str = str2varName(str, KeepNS) +% convert a sting to a valid matlab variable name +if(KeepNS) + str = regexprep(str,':','_COLON_', 'once', 'ignorecase'); +else + k = strfind(str,':'); + if (~isempty(k)) + str = str(k+1:end); + end +end +str = regexprep(str,'-','_DASH_' ,'once', 'ignorecase'); +if (~isvarname(str)) && (~iskeyword(str)) + str = genvarname(str); +end + +%% ======================================================================= +% === NodeName Function ================================================= +% ======================================================================= +function [Name LeafNode] = NodeName(node, KeepNS) +% get node name and make sure it is a valid variable name in Matlab. +% also get node type: +% LeafNode=0 - normal element node, +% LeafNode=1 - text node +% LeafNode=2 - supported non-text leaf node, +% LeafNode=3 - supported processing instructions leaf node, +% LeafNode=-1 - unsupported non-text leaf node +switch (node.getNodeType) + case node.ELEMENT_NODE + Name = char(node.getNodeName);% capture name of the node + Name = str2varName(Name, KeepNS); % if Name is not a good variable name - fix it + LeafNode = 0; + case node.TEXT_NODE + Name = 'CONTENT'; + LeafNode = 1; + case node.COMMENT_NODE + Name = 'COMMENT'; + LeafNode = 2; + case node.CDATA_SECTION_NODE + Name = 'CDATA_SECTION'; + LeafNode = 2; + case node.DOCUMENT_TYPE_NODE + Name = 'DOCUMENT_TYPE'; + LeafNode = 2; + case node.PROCESSING_INSTRUCTION_NODE + Name = 'PROCESSING_INSTRUCTION'; + LeafNode = 3; + otherwise + NodeType = {'ELEMENT','ATTRIBUTE','TEXT','CDATA_SECTION', ... + 'ENTITY_REFERENCE', 'ENTITY', 'PROCESSING_INSTRUCTION', 'COMMENT',... + 'DOCUMENT', 'DOCUMENT_TYPE', 'DOCUMENT_FRAGMENT', 'NOTATION'}; + Name = char(node.getNodeName);% capture name of the node + warning('xml_io_tools:read:unkNode', ... + 'Unknown node type encountered: %s_NODE (%s)', NodeType{node.getNodeType}, Name); + LeafNode = -1; +end + + diff --git a/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/xml_tutorial_script.m b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/xml_tutorial_script.m new file mode 100644 index 00000000..3a0d7abe --- /dev/null +++ b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/xml_tutorial_script.m @@ -0,0 +1,914 @@ +%% Tutorial for xml_io_tools Package +% *By Jarek Tuszynski* +% +% Package xml_io_tools can read XML files into MATLAB struct and writes +% MATLAB data types to XML files with help of simple interface to +% MATLAB's xmlwrite and xmlread functions. +% +% Two function to simplify reading and writing XML files from MATLAB: +% +% * Function xml_read first calls MATLAB's xmlread function and than +% converts its output ('Document Object Model' tree of Java objects) +% to tree of MATLAB struct's. The output is in the format of nested +% structs and cells. In the output data structure field names are based on +% XML tags. +% +% * Function xml_write first convert input tree of MATLAB structs and cells +% and other types to tree of 'Document Object Model' nodes, and then writes +% resulting object to XML file using MATLAB's xmlwrite function. . +% +%% This package can: +% * Read most XML files, created inside and outside of MATLAB environment, +% and convert them to MATLAB data structures. +% * Write any MATLAB's struct tree to XML file +% * Handle XML attributes and special XML nodes like comments, processing +% instructions and CDATA sections +% * Supports base64 encoding and decoding to allow handling embeded binary +% data +% * Be studied, modified, customized, rewritten and used in other packages +% without any limitations. All code is included and documented. Software +% is distributed under BSD Licence (included). +% +%% This package does not: +% * Guarantee to recover the same Matlab objects that were saved. If you +% need to be able to recover carbon copy of the structure that was saved +% than you will have to use one of the packages that uses special set of +% tags saved as xml attributes that help to guide the parsing of XML code. +% This package does not use those tags. +% * Guarantee to work with older versions of MATLAB. Functions do not work +% with versions of MATLAB prior to 7.1 (26-Jul-2005). +% +%% Change History +% * 2006-11-06 - original version +% * 2006-11-26 - corrected xml_write to handle writing Matlab's column +% arrays to xml files. Bug discovered and diagnosed by Kalyan Dutta. +% * 2006-11-28 - made changes to handle special node types like: +% COMMENTS and CDATA sections +% * 2007-03-12 - Writing CDATA sections still did not worked. The problem +% was diagnosed and fixed by Alberto Amaro. The fix involved rewriting +% xmlwrite to use Apache Xerces java files directly instead of MATLAB's +% XMLUtils java class. +% * 2007-06-21 - Fixed problem reported by Anna Kelbert in Reviews about +% not writing attributes of ROOT node. Also: added support for Processing +% Instructions, added support for global text nodes: Processing +% Instructions and comments, allowed writing tag names with special +% characters +% * 2007-07-20 - Added tutorial script file. Extended support for global +% text nodes. Added more Preference fields. +% * 2008-01-23 - Fixed problem reported by Anna Krewet of converting dates +% in format '2007-01-01' to numbers. Improved and added warning messages. +% Added detection of old Matlab versions incompatible with the library. +% Expanded documentation. +% * 2008-06-23 - Fixed problem with writing 1D array reported by Mark Neil. +% Extended xml_read's Pref.Num2Str to 3 settings (never, smart and always) +% for better control. Added parameter Pref.KeepNS for keeping or ignoring +% namespace data when reading. Fixed a bug related to writing 2D cell +% arrays brought up by Andrej's Mosat review. +% * 2008-09-11 - Resubmitting last upload - zip file is still old +% * 2009-02-26 - Small changes. More error handling. More robust in case of +% large binary objects. Added support for Base64 encoding/decoding of +% binary objects (using functions by Peter J. Acklam). +% * 2009-06-26 - changes to xml_read: added CellItem parameter to allow +% better control of reading files with 'item' notation (see comment by +% Shlomi); changed try-catch statements so xml_read would work for mablab +% versions prior to 7.5 (see Thomas Pilutti comment) +% * 2009-12-03 - added PreserveSpace parameter for contolling empty string +% handling as suggested by Sebastiaan. Fix suggested by Michael Murphy. +% Fixed number recognition code as suggested by Yuan Ren. +% * 2010-05-04 - implemented fixes suggested by Dylan Reynolds from Airbus. +% * 2010-07-28 - implemented support for 2D arrays of cells and structs +% suggested by Rodney Behn from MIT Lincoln Laboratory. Also attempted +% large scale cleanup of xml_write function +% * 2010-08-18 - minor extension to allow better handling of logical +% scalars and arrays and function handles suggested by Andreas Richter +% and others +% * 2010-09-20 - allow reading and writing of sparse matrices. Improve +% reading of 1D boolean arrays. +% * 2010-11-05 - Fix problem with empty cells reported by Richard Cotton; +% fixed issues with reading boolean arrays reported by Zohar Bar-Yehuda; +% Improved speed of base64 coding and decoding by switching to java based +% code. +%% Licence +% The package is distributed under BSD License +format compact; % viewing preference +clear variables; +type('license.txt') + +%% Write XML file based on a Struct using "xml_write" +% Any MATLAB data struct can be saved to XML file. +MyTree=[]; +MyTree.MyNumber = 13; +MyTree.MyString = 'Hello World'; +xml_write('test.xml', MyTree); +type('test.xml') + +%% Read XML file producing a Struct using "xml_read" +[tree treeName] = xml_read ('test.xml'); +disp([treeName{1} ' =']) +gen_object_display(tree) + +%% "Pref.XmlEngine" flag in "xml_write" +% Occasionaly some operations are performed better by Apache Xerces XML +% engine than default xmlread function. That is why xml_write provide an +% option for choosing the underlaying xml engine. Code below performs the +% same operation as the previous section but using Apache Xerces XML engine. +% Notice that in this case name of root element +% was passed as variable and not extracted from the variable name. +Pref=[]; Pref.XmlEngine = 'Xerces'; % use Xerces xml generator directly +xml_write('test.xml', MyTree, 'TreeOfMine', Pref); +type('test.xml') + +%% Writing Struct with different type MATLAB arrays +MyTree=[]; +MyTree.Empty = []; % Empty variable +MyTree.Num_1x1 = 13; % simple scalar +MyTree.Vec_1x3 = [1 2 3]; % horizontal vector +MyTree.Vec_4x1 = [1; 2; 3; 4]; % vertical vector +MyTree.Mat_2x2 = [1, 2; 3, 4]; % 2D matrix +MyTree.Cube_3D = reshape(1:8,[2 2 2]); % 3D array +MyTree.String1 = '[2003 10 30]'; % number string with [] brackets +MyTree.String2 = ' 2003 10 30 '; % number string without [] brackets +MyTree.Logical_1x1 = false; % single logical +MyTree.Logical_2x2 = [false, true; true, false]; % 2D matrix of logicals +MyTree.Logical_Str = 'False False True True'; +MyTree.Int_2x2 = uint8([1 2;3 4]); % 2D matrix of uint8 integers +MyTree.Complex_1x1 = complex(1, 7); % complex scalar +MyTree.Complex_2x2 = complex([1 2;3 4],[2 2;7 7]); % 2D matrix of complex numbers +MyTree.Sparse_9x9 = sparse(1:9,1:9,1); % sparse 9x9 matrix +MyTree.Function = @sum; % function handle +xml_write('test.xml', MyTree); +type('test.xml') + +%% Read Struct with MATLAB arrays +% Notice that 'Cube_3D' did not preserve original dimentions +[tree treeName] = xml_read ('test.xml'); +disp([treeName{1} ' =']) +gen_object_display(tree) + +%% "Pref.StructItem" flag in "xml_write" (controls 1D arrays of structs) +% *Create a simple structure with 1D array of struct's* +MyTree = []; +MyTree.a(1).b = 'jack'; +MyTree.a(2).b = 'john'; +gen_object_display(MyTree) +%% +% *Write XML with "StructItem = true" (default). Notice single 'a' +% section and multiple 'item' sub-sections. Those subsections are used +% to store array elements* +wPref.StructItem = true; +xml_write('test.xml', MyTree, 'MyTree',wPref); +type('test.xml') +fprintf('\nxml_read output:\n') +gen_object_display(xml_read ('test.xml')) +%% +% *Write XML with "StructItem = false". Notice multiple 'a' sections* +wPref.StructItem = false; +xml_write('test.xml', MyTree, 'MyTree',wPref); +type('test.xml') +fprintf('\nxml_read output:\n') +gen_object_display(xml_read ('test.xml')) +%% +% *Notice that xml_read function produced the same struct when reading both files* +%% +% *Potential problems with "StructItem = true":* +wPref.StructItem = true; +MyTree1 = []; MyTree1.a.b = 'jack'; +MyTree2 = []; MyTree2.a(1).b = 'jack'; +MyTree3 = []; MyTree3.a(2).b = 'jack'; +xml_write('test.xml', MyTree1, [], wPref); type('test.xml'); +xml_write('test.xml', MyTree2, [], wPref); type('test.xml'); +xml_write('test.xml', MyTree3, [], wPref); type('test.xml'); +%% +% *Notice that MyTree1 and MyTree2 produce identical files with no 'items', +% while MyTree2 and MyTree3 produce very different file structures. It was +% pointed out to me that files produced from MyTree2 and MyTree3 can not +% belong to the same schema, which can be a problem. The solution is to use +% cells.* +wPref.CellItem = true; +wPref.NoCells = true; +MyTree2 = []; MyTree2.a{1}.b = 'jack'; +MyTree3 = []; MyTree3.a{2}.b = 'jack'; +xml_write('test.xml', MyTree2, [], wPref); type('test.xml'); +xml_write('test.xml', MyTree3, [], wPref); type('test.xml'); + + +%% "Pref.CellItem" flag in "xml_write" (controls 1D arrays of cells) +% *Create a simple structure with cell arrays* +MyTree = []; +MyTree.a = {'jack', 'john'}; +disp(MyTree) +%% +% *Write XML with "CellItem = true" (default). Notice single 'a' +% section and multiple 'item' sections* +Pref=[]; Pref.CellItem = true; +xml_write('test.xml', MyTree, 'MyTree',Pref); +type('test.xml') +fprintf('\nxml_read output:\n'); +disp(xml_read ('test.xml')) +%% +% *Write XML with "CellItem = false". Notice multiple 'a' sections* +Pref=[]; Pref.CellItem = false; +xml_write('test.xml', MyTree, 'MyTree',Pref); +type('test.xml') +fprintf('\nxml_read output:\n'); +disp(xml_read ('test.xml')) +%% +% *Notice that xml_read function produced the same struct when reading both files* + +%% "Pref.NoCells" flag in "xml_read" +% *Create a cell/struct mixture object* +MyTree = []; +MyTree.a{1}.b = 'jack'; +MyTree.a{2}.b = []; +MyTree.a{2}.c = 'john'; +gen_object_display(MyTree); +%% +% *Save it to xml file* +Pref=[]; Pref.CellItem = false; +xml_write('test.xml', MyTree, 'MyTree',Pref); +type('test.xml') +%% +% *Read above file with "Pref.NoCells=true" (default) - output is quite different then input* +% By default program is trying to convert everything to struct's and arrays +% of structs. In case arrays of structs all the structs in array need to have the +% same fields, and if they are not than MATLAB creates empty fields. +Pref=[]; Pref.NoCells=true; +gen_object_display(xml_read('test.xml', Pref)) +%% +% *Read above file with "Pref.NoCells=false" - now input and output are the same* +% Cell arrays of structs allow structs in array to have different fields. +Pref=[]; Pref.NoCells=false; +gen_object_display(xml_read('test.xml', Pref)) + +%% "Pref.ItemName" flag in "xml_write" (customize 1D arrays of structs and cells) +% *Create a cell/struct mixture object* +MyTree = []; +MyTree.a{1}.b = 'jack'; +MyTree.a{2}.c = 'john'; +gen_object_display(MyTree); +%% +% *Save it to xml file, using 'item' notation but with different name* +Pref=[]; +Pref.CellItem = true; +Pref.ItemName = 'MyItem'; +xml_write('test.xml', MyTree, 'MyTree',Pref); +type('test.xml') + +%% "Pref.ItemName" flag in "xml_read" +% *Read above file with default settings ("Pref.ItemName = 'item'")* +% The results do not match the original structure +Pref=[]; Pref.NoCells = false; +gen_object_display(xml_read('test.xml', Pref)) +%% +% *Read above file with "Pref.ItemName = 'MyItem'" - now saved and read +% MATLAB structures are the same* +Pref=[]; +Pref.ItemName = 'MyItem'; +Pref.NoCells = false; +gen_object_display(xml_read('test.xml', Pref)) + +%% "Pref.CellItem" flag in "xml_read" +% "Pref.ItemName" is used to create xml files with clearly marked arrays +% "Pref.CellItem" flag in "xml_read" ensures that they are always read as +% arrays by forcing output to stay in cell format. In cell format s{1} is +% different than s, while s(1) is indistinguishable from s. +%% +% *Create a test file* +MyTree = []; +MyTree.a1{1}.b = 'jack'; % a1 - single struct +MyTree.a2{1}.b = 'jack'; % a2 - cell array of structs with the same fields +MyTree.a2{2}.b = 'john'; +MyTree.a3{1}.b = 'jack'; % a3 - cell array of structs with the different fields +MyTree.a3{2}.c = 'john'; +Pref=[]; +Pref.CellItem = true; +Pref.Debug = true; +xml_write('test.xml', MyTree, 'MyTree',Pref); +type('test.xml') +%% +% *Read above file with "Pref.CellItem = true" (default)* +% All outputs are in cell format +Pref=[]; +Pref.NoCells = false; % allow cell output +Pref.CellItem = true; % keep 'item' arrays as cells +gen_object_display(xml_read('test.xml', Pref)) +%% +% *Read above file with "Pref.CellItem = false"* +% Outputs format is determined by content +Pref=[]; +Pref.NoCells = false; % allow cell output +Pref.CellItem = false; % allow 'item' arrays to beheave like other fields +gen_object_display(xml_read('test.xml', Pref)) +%% +% *Read above file with "Pref.CellItem = false" and "Pref.NoCells = true"* +% All outputs are in struct format +Pref=[]; +Pref.NoCells = true; % don't allow cell output +Pref.CellItem = false; % allow 'item' arrays to beheave like other fields +gen_object_display(xml_read('test.xml', Pref)) + +%% "Pref.CellTable" flag in "xml_write" (controls 2D arrays of cells) +% *Create a structure with 2D arrays of cells* +MyTree = []; +MyTree.M = {[1,2;3,4], 'M12'; struct('a','jack'), {11, 'N12'; 21, 'N22'}}; +gen_object_display(MyTree) +%% +% *Write XML with "CellTable = 'Html" (default). This option mimics use of +% HTML "tr" and "td" tags to encode 2D tables. Tag names can +% be changed using TableName parameter (see below)* +wPref = []; +wPref.CellTable = 'Html'; +xml_write('test.xml', MyTree, 'MyTree',wPref); +type('test.xml') +fprintf('\nxml_read output:\n') +rPref=[]; rPref.NoCells=false; +gen_object_display(xml_read('test.xml', rPref)) +%% +% *Write XML with "CellTable = 'Vector'".* +% Converts 2D arrays to 1D array and item or regular notation. This option +% is mostly provided for backward compatibility since this was the +% behavior in prior verions of the code +wPref = []; +wPref.CellTable = 'Vector'; +xml_write('test.xml', MyTree, 'MyTree',wPref); +type('test.xml') +fprintf('\nxml_read output:\n') +rPref=[]; rPref.NoCells=false; +gen_object_display(xml_read('test.xml', rPref)) +%% +% *Create a simpler structure without struct's* +MyTree = []; +MyTree.M = {[1,2;3,4], 'M12'; 'M21', {11, 'N12'; 21, 'N22'}}; +gen_object_display(MyTree) +%% +% *Write XML with "CellTable = 'Matlab". This option encodes tables +% consisting of numbers, strings and other cell arrays as MATLAB command +% string. Unlike 'Html' option it does not work if one of the cells is +% a struct* +wPref = []; +wPref.CellTable = 'Matlab'; +xml_write('test.xml', MyTree, 'MyTree',wPref); +type('test.xml') +fprintf('\nxml_read output:\n') +rPref=[]; rPref.NoCells=false; +gen_object_display(xml_read('test.xml', rPref)) + +%% Write 2D cell array in HTML format +MyTree = []; +MyTree.table.ATTRIBUTE.border=1; +MyTree.table.CONTENT = {'Apples', '44%'; 'Bannanas', '23%'; 'Oranges', '13%'; 'Other', '10%'}; +xml_write('html/test.html', MyTree); +type('html/test.html') +%% +% Click on to opened this file with a web brouwser + +%% "Pref.StructTable" flag in "xml_write" (controls 2D arrays of structs) +% *Create a simple structure with arrays of struct's* +MyTree = []; +MyTree.a(1,1).b = 'jack'; +MyTree.a(1,2).b = 'john'; +MyTree.a(2,1).b = 'jim'; +MyTree.a(2,2).b = 'jill'; +gen_object_display(MyTree) +%% +% *Write XML with "StructTable = 'Html" (default). This option mimics use of +% HTML "tr" and "td" tags to encode 2D tables. Tag names can +% be changed using TableName parameter (see below)* +wPref = []; +wPref.StructTable = 'Html'; +xml_write('test.xml', MyTree, 'MyTree',wPref); +type('test.xml') +fprintf('\nxml_read output:\n') +gen_object_display(xml_read ('test.xml')) +%% +% *Write XML with "CellTable = 'Vector'".* +% Converts 2D arrays to 1D array and item or regular notation. This option +% is mostly provided for backward compatibility since this was the +% behavior in prior verions of the code +wPref = []; +wPref.StructTable = 'Vector'; +xml_write('test.xml', MyTree, 'MyTree',wPref); +type('test.xml') +fprintf('\nxml_read output:\n') +gen_object_display(xml_read ('test.xml')) + +%% "Pref.TableName" flag in "xml_write" (controls encoding tags used for 2D arrays) +% *Create a cell object* +MyTree = []; +MyTree.M = {[1,2;3,4], 'M12'; 21, {11, 'N12'; 21, 'N22'}}; +gen_object_display(MyTree); +%% +% *Save it to xml file, using 'Html' notation but with different names for +% rows and cells* +Pref=[]; Pref.TableName = {'row','cell'}; +xml_write('test.xml', MyTree, 'MyTree',Pref); +type('test.xml') + +%% "Pref.TableName" flag in "xml_read" +% *Read above file with default settings ("Pref.TableName = {'tr','td'}")* +% The results do not match the original structure +Pref=[]; Pref.NoCells = false; +gen_object_display(xml_read('test.xml', Pref)) +%% +% *Read above file with "Pref.TableName = {'row','cell'}" - now saved and read +% MATLAB structures are the same* +Pref=[]; +Pref.TableName = {'row','cell'}; +Pref.NoCells = false; +gen_object_display(xml_read('test.xml', Pref)) + +%% "Pref.Str2Num" flag in xml_read (control conversion to numbers while reading) +% *Create a cell/struct mixture object* +MyTree = []; +MyTree.str = 'sphere'; +MyTree.num1 = 123; +MyTree.num2 = '123'; +MyTree.num3 = '[Inf,NaN]'; +MyTree.calc = '1+2+3+4'; +MyTree.func = 'sin(pi)/2'; +MyTree.String1 = '[2003 10 30]'; +MyTree.String2 = '2003 10 30'; % array resembling date +MyTree.ISO8601 = '2003-10-30'; % date in ISO 8601 format +MyTree.US_date = '2003/10/30'; % US style date format +MyTree.complex = '2003i-10e-30'; % complex number resembling a date +gen_object_display(MyTree); +%% +% *Save it to xml file* +xml_write('test.xml', MyTree); +type('test.xml') +%% +% *Read above file with default settings* +% ("Pref.Str2Num = true" or "Pref.Str2Num = 'smart'"). Under this setting all +% strings that look like numbers are converted to numbers, except for +% strings that are recognized by MATLAB 'datenum' function as dates +gen_object_display(xml_read('test.xml')) +%% +% *Note that all the fields of 'MyTree' can be converted to numbers (even +% 'sphere') but by default the function is trying to 'judge' if a string +% should be converted to a number or not* +MyCell = {'sphere','1+2+3+4','sin(pi)/2','2003 10 30','2003-10-30','2003/10/30','2003i-10e-30'}; +cellfun(@str2num, MyCell, 'UniformOutput', false) +%% +% *Read above file with "Pref.Str2Num = false" or "Pref.Str2Num = 'never'" +% to keep all the fields in string format* +Pref=[]; Pref.Str2Num = false; +gen_object_display(xml_read('test.xml', Pref)) +%% +% *Read above file with "Pref.Str2Num = always" +% to convert all strings that look like numbers to numbers* note the likelly +% unintendet conversion of 'ISO8601' +Pref=[]; Pref.Str2Num = 'always'; +gen_object_display(xml_read('test.xml', Pref)) +%% +% *Notice that all three settings will produce the same output for "num1" and +% "num2" and there is no way to reproduce the original "MyTree" structure.* + +%% "Pref.PreserveSpace" flag in xml_write (control handling of strings with leading/trailing spaces) +% *Create a struct with strings* +MyTree=[]; +MyTree.Empty = ''; +MyTree.OneSpace = ' '; +MyTree.TwoSpaces = ' '; +MyTree.String1 = ' Hello World '; +%% +% *Write XML with "PreserveSpace = false" (default).* +Pref=[]; Pref.PreserveSpace = false; % (default setting) +xml_write('test.xml', MyTree, [], Pref); +type('test.xml') +%% +% *Write XML with "PreserveSpace = true".* +Pref=[]; Pref.PreserveSpace = true; +xml_write('test.xml', MyTree, [], Pref); +type('test.xml') + +%% "Pref.PreserveSpace" flag in xml_read +% *Read file while using "PreserveSpace = false" (default).* +Pref=[]; Pref.PreserveSpace = false; % (default setting) +gen_object_display(xml_read('test.xml',Pref)) +%% +% *Read file while using "PreserveSpace = true".* +Pref=[]; Pref.PreserveSpace = true; +gen_object_display(xml_read('test.xml',Pref)) + + +%% Write XML files with ATTRIBUTEs +% In order to add node attributes a special ATTRIBUTE field is used. +% ATTRIBUTEs have to be of simple types like numbers or strings (not +% struct or cells). Attributes are easy to attach to structs nodes like +% MyTree below. +MyTree=[]; +MyTree.MyNumber = 13; +MyTree.MyString = 'Hello World'; % simple case +MyTree.ATTRIBUTE.Num = 2; +xml_write('test.xml', MyTree); +type('test.xml') + +%% +% In case when one needs to attach attributes to nodes which are not +% structs (for example strings, numbers or calls) then special CONTENT +% field needs to be used to make the node a struct node. +MyTree=[]; +MyTree.MyNumber = 13; +MyTree.MyString.CONTENT = 'Hello World'; % simple case +MyTree.MyString.ATTRIBUTE.Num = 2; +xml_write('test.xml', MyTree); +type('test.xml') + +%% "Pref.Str2Num" flag in file with ATTRIBUTEs +% *Create a cell/struct mixture object* +MyTree = []; +MyTree.X.ATTRIBUTE.str = 'sphere'; +MyTree.X.ATTRIBUTE.num1 = 123; +MyTree.X.ATTRIBUTE.num2 = '123'; +MyTree.X.ATTRIBUTE.num3 = '[Inf,NaN]'; +MyTree.X.ATTRIBUTE.calc = '1+2+3+4'; +MyTree.X.ATTRIBUTE.func = 'sin(pi)/2'; +MyTree.X.ATTRIBUTE.String1 = '[2003 10 30]'; +MyTree.X.ATTRIBUTE.String2 = '2003 10 30'; % array resembling date +MyTree.X.ATTRIBUTE.ISO8601 = '2003-10-30'; % date in ISO 8601 format +MyTree.X.ATTRIBUTE.US_date = '2003/10/30'; % US style date format +MyTree.X.ATTRIBUTE.complex = '2003i-10e-30'; % complex number resembling a date +gen_object_display(MyTree); +%% +% *Save it to xml file* +xml_write('test.xml', MyTree); +type('test.xml') +%% +% *Read above file with default settings* +% ("Pref.Str2Num = true" or "Pref.Str2Num = 'smart'"). Under this setting all +% strings that look like numbers are converted to numbers, except for +% strings that are recognized by MATLAB 'datenum' function as dates +gen_object_display(xml_read('test.xml')) + +%% +% *Read above file with "Pref.Str2Num = false" or "Pref.Str2Num = 'never'" +% to keep all the fields in string format* +Pref=[]; Pref.Str2Num = false; +gen_object_display(xml_read('test.xml', Pref)) +%% +% *Read above file with "Pref.Str2Num = always" +% to convert all strings that look like numbers to numbers* +Pref=[]; Pref.Str2Num = 'always'; +gen_object_display(xml_read('test.xml', Pref)) +%% +% *Notice that all three settings will produce the same output for "num1" and +% "num2" and there is no way to reproduce the original "MyTree" structure.* + + +%% Write XML files with COMMENTs +% Insertion of Comments is done with help of special COMMENT field. +% Note that MATLAB's xmlwrite is less readable due to lack of end-of-line +% characters around comment section. +MyTree=[]; +MyTree.COMMENT = 'This is a comment'; +MyTree.MyNumber = 13; +MyTree.MyString.CONTENT = 'Hello World'; +xml_write('test.xml', MyTree); +type('test.xml') + +%% +% *Same operation using Apache Xerces XML engine* +% gives the same result +Pref=[]; Pref.XmlEngine = 'Xerces'; % use Xerces xml generator directly +xml_write('test.xml', MyTree, 'MyTree', Pref); +type('test.xml') + +%% +% *Comments in XML top level (method #1)* +% This method uses cell array +MyTree=[]; +MyTree.MyNumber = 13; +MyTree.MyString = 'Hello World'; +xml_write('test.xml', MyTree, {'MyTree', [], 'This is a global comment'}); +type('test.xml') +%% +% *Same operation using Apache Xerces XML engine* +% gives even nicer results. +Pref=[]; Pref.XmlEngine = 'Xerces'; % use Xerces xml generator directly +xml_write('test.xml', MyTree, {'MyTree', [], 'This is a global comment'}, Pref); +type('test.xml') + +%% +% *Comments in XML top level (method #2)* +% This method adds an extra top layer to the struct 'tree' and sets +% "Pref.RootOnly = false", which informs the function about the extra +% layer. Notice that RootName is also saved as a part of +% the 'tree', and does not have to be passed in separately. +MyTree=[]; +MyTree.COMMENT = 'This is a global comment'; +MyTree.MyTest.MyNumber = 13; +MyTree.MyTest.MyString = 'Hello World'; +Pref=[]; Pref.RootOnly = false; +xml_write('test.xml', MyTree, [], Pref); +type('test.xml') +%% +% *Same operation using Apache Xerces XML engine* +Pref=[]; Pref.XmlEngine = 'Xerces'; % use Xerces xml generator directly +Pref.RootOnly = false; +xml_write('test.xml', MyTree, [], Pref); +type('test.xml') + +%% Write XML files with PROCESSING_INSTRUCTIONs +% Insertion of Processing Instructions is done through use of special +% PROCESSING_INSTRUCTION field, which stores the instruction string. The +% string has to be in 'target data' format separated by space. +MyTree=[]; +MyTree.PROCESSING_INSTRUCTION = 'xml-stylesheet type="a" href="foo"'; +MyTree.MyNumber = 13; +MyTree.MyString = 'Hello World'; +xml_write('test.xml', MyTree); +type('test.xml') + +%% +% *Same operation using Apache Xerces XML engine* +Pref=[]; Pref.XmlEngine = 'Xerces'; % use Xerces xml generator directly +xml_write('test.xml', MyTree, 'MyTree', Pref); +type('test.xml') + +%% +% *PROCESSING_INSTRUCTIONs in XML top level (method #1)* +% This method uses cell array +MyTree=[]; +MyTree.MyNumber = 13; +MyTree.MyString = 'Hello World'; +xml_write('test.xml', MyTree, {'MyTree', 'xml-stylesheet type="a" href="foo"'}); +type('test.xml') +%% +% *Same operation using Apache Xerces XML engine* +Pref=[]; Pref.XmlEngine = 'Xerces'; % use Xerces xml generator directly +xml_write('test.xml', MyTree, {'MyTree', 'xml-stylesheet type="a" href="foo"'}, Pref); +type('test.xml') + +%% +% *PROCESSING_INSTRUCTIONs in XML top level (method #2)* +% This method adds an extra top layer to the struct 'tree' and sets +% pref.RootOnly=false, which informs the function about the extra +% layer. Notice that RootName is also saved as a part of +% the 'tree', and does not have to be passed in separately. +MyTree=[]; +MyTree.PROCESSING_INSTRUCTION = 'xml-stylesheet type="a" href="foo"'; +MyTree.MyTest.MyNumber = 13; +MyTree.MyTest.MyString = 'Hello World'; +Pref=[]; Pref.RootOnly = false; +xml_write('test.xml', MyTree, [], Pref); +type('test.xml') +%% +% *Same operation using Apache Xerces XML engine* +Pref=[]; Pref.XmlEngine = 'Xerces'; % use Xerces xml generator directly +Pref.RootOnly = false; +xml_write('test.xml', MyTree, 'MyTree', Pref); +type('test.xml') + +%% Write XML files with CDATA Sections +% "In an XML document a CDATA (Character DATA) section is a section of +% element content that is marked for the parser to interpret as only +% character data, not markup." (from Wikipedia) +% To insert CDATA Sections one use special CDATA_SECTION field, +% which stores the instruction string. Note that MATLAB's xmlwrite created +% wrong xml code for CDATA section +MyTree=[]; +MyTree.CDATA_SECTION = 'txt'; +MyTree.MyNumber = 13; +MyTree.MyString = 'Hello World'; +xml_write('test.xml', MyTree); +type('test.xml') +%% +% *Same operation using Apache Xerces XML engine produces correct results* +Pref=[]; Pref.XmlEngine = 'Xerces'; % use Xerces xml generator directly +xml_write('test.xml', MyTree, 'MyTree', Pref); +type('test.xml') + +%% Write XML files with special characters in TAG names +% The input to xml_write requires that all tags one wants in XML document +% have to be encoded as field names of MATLAB's struct's. Matlab has a lot +% of restrictions on variable names. This section is about XML tags with +% names not allowed as MATLAB variables, or more specifically with +% characters allowed as xml tag names but not allowed as MATLAB variable +% names. Characters like that can be replaced by their hexadecimal +% representation just as it is done by genvarname function. Alternative way +% of writing the first example is: +MyTree=[]; +MyTree.('MyNumber') = 13; % same as MyTree.MyNumber = 13; +MyTree.MyString.CONTENT = 'Hello World'; +MyTree.MyString.ATTRIBUTE.('Num') = 2; % same as MyTree.MyString.ATTRIBUTE.Num = 2; +xml_write('test.xml', MyTree); +type('test.xml') + +%% +% *This approach fails for some characters like dash '-', colon ':', and +% international characters.* +MyTree=[]; +try + MyTree.('My-Number') = 13; + MyTree.MyString.CONTENT = 'Hello World'; + MyTree.MyString.ATTRIBUTE.('Num_') = 2; +catch %#ok + err = lasterror; %#ok + disp(err.message); +end + +%% +% It can be overcome by replacing offending characters with their +% hexadecimal representation. That can be done manually or with use of +% genvarname function. Note that MATLAB 'type' function does not show +% correctly '' letter in xml file, but opening the file in editor shows +% that it is correct. +MyTree=[]; +MyTree.(genvarname('My-Number')) = 13; +MyTree.MyString.CONTENT = 'Hello World'; +MyTree.MyString.ATTRIBUTE.Num_0xF6 = 2; +gen_object_display(MyTree); +xml_write('test.xml', MyTree); +type('test.xml') + +%% +% *Also two of the characters '-' and ':' can be encoded by a special strings: +% '_DASH_' and '_COLON_' respectively* +MyTree=[]; +MyTree.My_DASH_Number = 13; +MyTree.MyString.CONTENT = 'Hello World'; +MyTree.MyString.ATTRIBUTE.Num0xF6 = 2; +xml_write('test.xml', MyTree); +type('test.xml') + +%% Write XML files with Namespaces +% No extra special fields are needed to define XML namespaces, only colon +% character written using '0x3A' or '_COLON_'. Below is an +% example of a namespace definition +MyTree=[]; +MyTree.f_COLON_child.ATTRIBUTE.xmlns_COLON_f = 'http://www.foo.com'; +MyTree.f_COLON_child.f_COLON_MyNumber = 13; +MyTree.f_COLON_child.f_COLON_MyString = 'Hello World'; +xml_write('test.xml', MyTree, 'MyTree'); +type('test.xml') +%% +% *Same operation using Apache Xerces XML engine* +Pref=[]; Pref.XmlEngine = 'Xerces'; % use Xerces xml generator directly +xml_write('test.xml', MyTree, 'f_COLON_MyTree', Pref); +type('test.xml') + +%% "Pref.KeepNS" flag in "xml_read" +% Thise option allow keeping or exclusion of namespaces in tag names. +% By default the namespace data is kept but it produces much longer field +% names in the output structure. Ignoring namespace will produce more +% readible output. +% Perform default read of file with namespace +tree = xml_read('test.xml'); +gen_object_display(tree); + +%% +% Now the same operation with KeepNS = false. +Pref=[]; Pref.KeepNS = false; % do not read attributes +tree = xml_read('test.xml', Pref); +gen_object_display(tree); + +%% Read XML files with special node types +% Display and read the file, then show the data structure. Note that +% MATLAB 'type' function shows '' letter incorrectly as 'A' in xml file, +% but opening the file in editor shows that it is correct. +fprintf('Test xml file:\n'); +type('test_file.xml') +%% +% Read only the Root Element (default) +[tree GlobalTextNodes] = xml_read('test_file.xml'); +fprintf('Global Data (Root name, Global Processing Instructions and Global Comments):\n'); +disp(GlobalTextNodes') +fprintf('\nStructure read from the file (uncludes COMMENT and CDATA sections):\n'); +gen_object_display(tree); +%% +% Read the whole tree including global Comments and Processing Instructions +Pref=[]; Pref.RootOnly = false; +[tree GlobalTextNodes] = xml_read('test_file.xml', Pref); +fprintf('Global Data (Root name, Global Processing Instructions and Global Comments):\n'); +disp(GlobalTextNodes') +fprintf('\nStructure read from the file (uncludes COMMENT and CDATA sections):\n'); +gen_object_display(tree); + +%% "Pref.ReadAttr" flag in "xml_read" (control handling of nodes with attributes) +% Those option allow exclusion of attributes +Pref=[]; Pref.ReadAttr = false; % do not read attributes +tree = xml_read('test_file.xml', Pref); +gen_object_display(tree); + +%% "Pref.ReadSpec" flag in "xml_read" +% Those option allow exclusion of special nodes, like +% comments, processing instructions, CData sections, etc. +Pref=[]; Pref.ReadSpec = false; % do not read special node types +tree = xml_read('test_file.xml', Pref); +gen_object_display(tree); + +%% "Pref.RootOnly" flag in "xml_read" +% As it was shown in previous examples RootOnly parameter can be used to +% capture global (top level) special nodes (like COMMENTs and +% PROCESSING_INSTRUCTIONs) which are ignored by default +Pref=[]; Pref.RootOnly = false; % do not read special node types +tree = xml_read('test_file.xml', Pref); +gen_object_display(tree); + +%% "Pref.RootOnly" flag in "xml_write" +% Writing previously read tree with default "Pref.RootOnly = true" gives +% wrong output file +Pref=[]; Pref.RootOnly = true; % do not read special node types +xml_write('test.xml', tree, [], Pref); +fprintf('Test xml file:\n'); +type('test.xml') +%% +% Writing the same tree with "Pref.RootOnly = false" gives correct output +Pref=[]; Pref.RootOnly = false; % do not read special node types +xml_write('test.xml', tree, [], Pref); +fprintf('Test xml file:\n'); +type('test.xml') + +%% "Pref.NumLevels" flag in "xml_read" +% This parameter allows user to skip parts of the tree in order to save +% time and memory. Usefull only in a rare case when a small portion of +% large XML file is needed. +% +% Create test tile +MyTree = []; +MyTree.Level1 = 1; +MyTree.Level1_.Level2 = 2; +MyTree.Level1_.Level2_.Level3 = 3; +MyTree.Level1_.Level2_.Level3_.Level4 = 4; +xml_write('test.xml', MyTree); +fprintf('Test xml file:\n'); +type('test.xml') +%% +% *Use Default ("Pref.NumLevels = infinity") setting* +tree = xml_read('test.xml'); +gen_object_display(tree); +%% +% *Limit the read to only 2 levels* +Pref=[]; Pref.NumLevels = 2; +tree = xml_read('test.xml', Pref); +gen_object_display(tree); + + + + +%% Create DOM object based on a Struct using "xml_write" +% *Create Struct tree* +MyTree=[]; +MyTree.MyNumber = 13; +MyTree.MyString = 'Hello World'; +%% +% *Convert Struct to DOM object using xml_write* +DOM = xml_write([], MyTree); +xmlwrite('test.xml', DOM); % Save DOM object using MATLAB function +type('test.xml') + +%% Convert DOM object to Struct using "xml_read" +DOM = xmlread('test.xml'); % Read DOM object using MATLAB function +[tree treeName] = xml_read(DOM); % Convert DOM object to Struct +disp([treeName{1} ' =']) +gen_object_display(tree) + +%% Write XML file based on a DOM using "xml_write_xerces" +xmlwrite_xerces('test.xml', DOM); % Save DOM object using Xerces library +type('test.xml') + +%% Write XML to string instead of a file +DOM = xml_write([], MyTree); +str = xmlwrite(DOM); +disp(str) + +%% Write XML file with embedded binary data encoded as Base64 (using java version) +fid = fopen('football.jpg', 'rb'); +raw1 = uint8(fread(fid, 'uint8')); % read image file as a raw binary +fclose(fid); + +MyTree=[]; +MyTree.Size = 13; +MyTree.MyString = 'Hello World'; % simple case +MyTree.MyImage.ATTRIBUTE.EncodingMIMEType = 'base64'; +MyTree.MyImage.CONTENT = base64encode(raw1,'java');% perform base64 encoding of the binary data +xml_write('test.xml', MyTree); % write xml file + +%% Read XML file with embedded binary data encoded as Base64 (using java version) +tree = xml_read('test.xml', Pref); % read xml file +raw = base64decode(tree.MyImage.CONTENT, '', 'java'); % convert xml image to raw binary +fid = fopen('MyFootball.jpg', 'wb'); +fwrite(fid, raw, 'uint8'); % dumb the raw binary to the hard disk +fclose(fid); +I = imread('MyFootball.jpg'); % read it as an image +imshow(I); + +%% Write XML file with embedded binary data encoded as Base64 (simpler version using only matlab code +% Notice that process of writing to xml stripped all end-of-lie characters +% from base64 code. +isChunked = true; % break into chunks 76 characters long +url_safe = true; % 'base64url' encoding +code = base64encode('license.txt', 'matlab', isChunked, url_safe); +disp(code) +MyTree=[]; +MyTree.Size = 13; +MyTree.MyString = 'Hello World'; +MyTree.MyImage.ATTRIBUTE.EncodingMIMEType = 'base64'; +MyTree.MyImage.CONTENT = code; % perform base64 encoding of the binary data +xml_write('test.xml', MyTree); % write xml file +type('test.xml') + +%% Read XML file with embedded binary data encoded as Base64 (simpler version using only matlab code +tree = xml_read('test.xml', Pref); % read xml file +base64decode(tree.MyImage.CONTENT, 'license2.txt', 'matlab'); % save xml image as raw binary +type('license2.txt') \ No newline at end of file diff --git a/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/xml_write.m b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/xml_write.m new file mode 100644 index 00000000..10a18dea --- /dev/null +++ b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/xml_write.m @@ -0,0 +1,447 @@ +function DOMnode = xml_write(filename, tree, RootName, Pref) +%XML_WRITE Writes Matlab data structures to XML file +% +% DESCRIPTION +% xml_write( filename, tree) Converts Matlab data structure 'tree' containing +% cells, structs, numbers and strings to Document Object Model (DOM) node +% tree, then saves it to XML file 'filename' using Matlab's xmlwrite +% function. Optionally one can also use alternative version of xmlwrite +% function which directly calls JAVA functions for XML writing without +% MATLAB middleware. This function is provided as a patch to existing +% bugs in xmlwrite (in R2006b). +% +% xml_write(filename, tree, RootName, Pref) allows you to specify +% additional preferences about file format +% +% DOMnode = xml_write([], tree) same as above except that DOM node is +% not saved to the file but returned. +% +% INPUT +% filename file name +% tree Matlab structure tree to store in xml file. +% RootName String with XML tag name used for root (top level) node +% Optionally it can be a string cell array storing: Name of +% root node, document "Processing Instructions" data and +% document "comment" string +% Pref Other preferences: +% Pref.ItemName - default 'item' - name of a special tag used to +% itemize cell or struct arrays +% Pref.XmlEngine - let you choose the XML engine. Currently default is +% 'Xerces', which is using directly the apache xerces java file. +% Other option is 'Matlab' which uses MATLAB's xmlwrite and its +% XMLUtils java file. Both options create identical results except in +% case of CDATA sections where xmlwrite fails. +% Pref.CellItem - default 'true' - allow cell arrays to use 'item' +% notation. See below. +% Pref.RootOnly - default true - output variable 'tree' corresponds to +% xml file root element, otherwise it correspond to the whole file. +% Pref.StructItem - default 'true' - allow arrays of structs to use +% 'item' notation. For example "Pref.StructItem = true" gives: +% +% +% ... <\item> +% ... <\item> +% <\b> +% <\a> +% while "Pref.StructItem = false" gives: +% +% ... <\b> +% ... <\b> +% <\a> +% +% +% Several special xml node types can be created if special tags are used +% for field names of 'tree' nodes: +% - node.CONTENT - stores data section of the node if other fields +% (usually ATTRIBUTE are present. Usually data section is stored +% directly in 'node'. +% - node.ATTRIBUTE.name - stores node's attribute called 'name'. +% - node.COMMENT - create comment child node from the string. For global +% comments see "RootName" input variable. +% - node.PROCESSING_INSTRUCTIONS - create "processing instruction" child +% node from the string. For global "processing instructions" see +% "RootName" input variable. +% - node.CDATA_SECTION - stores node's CDATA section (string). Only works +% if Pref.XmlEngine='Xerces'. For more info, see comments of F_xmlwrite. +% - other special node types like: document fragment nodes, document type +% nodes, entity nodes and notation nodes are not being handled by +% 'xml_write' at the moment. +% +% OUTPUT +% DOMnode Document Object Model (DOM) node tree in the format +% required as input to xmlwrite. (optional) +% +% EXAMPLES: +% MyTree=[]; +% MyTree.MyNumber = 13; +% MyTree.MyString = 'Hello World'; +% xml_write('test.xml', MyTree); +% type('test.xml') +% %See also xml_tutorial.m +% +% See also +% xml_read, xmlread, xmlwrite +% +% Written by Jarek Tuszynski, SAIC, jaroslaw.w.tuszynski_at_saic.com + +%% Check Matlab Version +v = ver('MATLAB'); +v = str2double(regexp(v.Version, '\d.\d','match','once')); +if (v<7) + error('Your MATLAB version is too old. You need version 7.0 or newer.'); +end + +%% default preferences +DPref.TableName = {'tr','td'}; % name of a special tags used to itemize 2D cell arrays +DPref.ItemName = 'item'; % name of a special tag used to itemize 1D cell arrays +DPref.StructItem = true; % allow arrays of structs to use 'item' notation +DPref.CellItem = true; % allow cell arrays to use 'item' notation +DPref.StructTable= 'Html'; +DPref.CellTable = 'Html'; +DPref.XmlEngine = 'Matlab'; % use matlab provided XMLUtils +%DPref.XmlEngine = 'Xerces'; % use Xerces xml generator directly +DPref.PreserveSpace = false; % Preserve or delete spaces at the beggining and the end of stings? +RootOnly = true; % Input is root node only +GlobalProcInst = []; +GlobalComment = []; +GlobalDocType = []; + +%% read user preferences +if (nargin>3) + if (isfield(Pref, 'TableName' )), DPref.TableName = Pref.TableName; end + if (isfield(Pref, 'ItemName' )), DPref.ItemName = Pref.ItemName; end + if (isfield(Pref, 'StructItem')), DPref.StructItem = Pref.StructItem; end + if (isfield(Pref, 'CellItem' )), DPref.CellItem = Pref.CellItem; end + if (isfield(Pref, 'CellTable')), DPref.CellTable = Pref.CellTable; end + if (isfield(Pref, 'StructTable')), DPref.StructTable= Pref.StructTable; end + if (isfield(Pref, 'XmlEngine' )), DPref.XmlEngine = Pref.XmlEngine; end + if (isfield(Pref, 'RootOnly' )), RootOnly = Pref.RootOnly; end + if (isfield(Pref, 'PreserveSpace')), DPref.PreserveSpace = Pref.PreserveSpace; end +end +if (nargin<3 || isempty(RootName)), RootName=inputname(2); end +if (isempty(RootName)), RootName='ROOT'; end +if (iscell(RootName)) % RootName also stores global text node data + rName = RootName; + RootName = char(rName{1}); + if (length(rName)>1), GlobalProcInst = char(rName{2}); end + if (length(rName)>2), GlobalComment = char(rName{3}); end + if (length(rName)>3), GlobalDocType = char(rName{4}); end +end +if(~RootOnly && isstruct(tree)) % if struct than deal with each field separatly + fields = fieldnames(tree); + for i=1:length(fields) + field = fields{i}; + x = tree(1).(field); + if (strcmp(field, 'COMMENT')) + GlobalComment = x; + elseif (strcmp(field, 'PROCESSING_INSTRUCTION')) + GlobalProcInst = x; + elseif (strcmp(field, 'DOCUMENT_TYPE')) + GlobalDocType = x; + else + RootName = field; + t = x; + end + end + tree = t; +end + +%% Initialize jave object that will store xml data structure +RootName = varName2str(RootName); +if (~isempty(GlobalDocType)) + % n = strfind(GlobalDocType, ' '); + % if (~isempty(n)) + % dtype = com.mathworks.xml.XMLUtils.createDocumentType(GlobalDocType); + % end + % DOMnode = com.mathworks.xml.XMLUtils.createDocument(RootName, dtype); + warning('xml_io_tools:write:docType', ... + 'DOCUMENT_TYPE node was encountered which is not supported yet. Ignoring.'); +end +DOMnode = com.mathworks.xml.XMLUtils.createDocument(RootName); + + +%% Use recursive function to convert matlab data structure to XML +root = DOMnode.getDocumentElement; +struct2DOMnode(DOMnode, root, tree, DPref.ItemName, DPref); + +%% Remove the only child of the root node +root = DOMnode.getDocumentElement; +Child = root.getChildNodes; % create array of children nodes +nChild = Child.getLength; % number of children +if (nChild==1) + node = root.removeChild(root.getFirstChild); + while(node.hasChildNodes) + root.appendChild(node.removeChild(node.getFirstChild)); + end + while(node.hasAttributes) % copy all attributes + root.setAttributeNode(node.removeAttributeNode(node.getAttributes.item(0))); + end +end + +%% Save exotic Global nodes +if (~isempty(GlobalComment)) + DOMnode.insertBefore(DOMnode.createComment(GlobalComment), DOMnode.getFirstChild()); +end +if (~isempty(GlobalProcInst)) + n = strfind(GlobalProcInst, ' '); + if (~isempty(n)) + proc = DOMnode.createProcessingInstruction(GlobalProcInst(1:(n(1)-1)),... + GlobalProcInst((n(1)+1):end)); + DOMnode.insertBefore(proc, DOMnode.getFirstChild()); + end +end +% Not supported yet as the code below does not work +% if (~isempty(GlobalDocType)) +% n = strfind(GlobalDocType, ' '); +% if (~isempty(n)) +% dtype = DOMnode.createDocumentType(GlobalDocType); +% DOMnode.insertBefore(dtype, DOMnode.getFirstChild()); +% end +% end + +%% save java DOM tree to XML file +if (~isempty(filename)) + if (strcmpi(DPref.XmlEngine, 'Xerces')) + xmlwrite_xerces(filename, DOMnode); + else + xmlwrite(filename, DOMnode); + end +end + + +%% ======================================================================= +% === struct2DOMnode Function =========================================== +% ======================================================================= +function [] = struct2DOMnode(xml, parent, s, TagName, Pref) +% struct2DOMnode is a recursive function that converts matlab's structs to +% DOM nodes. +% INPUTS: +% xml - jave object that will store xml data structure +% parent - parent DOM Element +% s - Matlab data structure to save +% TagName - name to be used in xml tags describing 's' +% Pref - preferenced +% OUTPUT: +% parent - modified 'parent' + +% perform some conversions +if (ischar(s) && min(size(s))>1) % if 2D array of characters + s=cellstr(s); % than convert to cell array +end +% if (strcmp(TagName, 'CONTENT')) +% while (iscell(s) && length(s)==1), s = s{1}; end % unwrap cell arrays of length 1 +% end +TagName = varName2str(TagName); + +%% == node is a 2D cell array == +% convert to some other format prior to further processing +nDim = nnz(size(s)>1); % is it a scalar, vector, 2D array, 3D cube, etc? +if (iscell(s) && nDim==2 && strcmpi(Pref.CellTable, 'Matlab')) + s = var2str(s, Pref.PreserveSpace); +end +if (nDim==2 && (iscell (s) && strcmpi(Pref.CellTable, 'Vector')) || ... + (isstruct(s) && strcmpi(Pref.StructTable, 'Vector'))) + s = s(:); +end +if (nDim>2), s = s(:); end % can not handle this case well +nItem = numel(s); +nDim = nnz(size(s)>1); % is it a scalar, vector, 2D array, 3D cube, etc? + +%% == node is a cell == +if (iscell(s)) % if this is a cell or cell array + if ((nDim==2 && strcmpi(Pref.CellTable,'Html')) || (nDim< 2 && Pref.CellItem)) + % if 2D array of cells than can use HTML-like notation or if 1D array + % than can use item notation + if (strcmp(TagName, 'CONTENT')) % CONTENT nodes already have ... + array2DOMnode(xml, parent, s, Pref.ItemName, Pref ); % recursive call + else + node = xml.createElement(TagName); % ... + array2DOMnode(xml, node, s, Pref.ItemName, Pref ); % recursive call + parent.appendChild(node); + end + else % use ...<\TagName> ...<\TagName> notation + array2DOMnode(xml, parent, s, TagName, Pref ); % recursive call + end +%% == node is a struct == +elseif (isstruct(s)) % if struct than deal with each field separatly + if ((nDim==2 && strcmpi(Pref.StructTable,'Html')) || (nItem>1 && Pref.StructItem)) + % if 2D array of structs than can use HTML-like notation or + % if 1D array of structs than can use 'items' notation + node = xml.createElement(TagName); + array2DOMnode(xml, node, s, Pref.ItemName, Pref ); % recursive call + parent.appendChild(node); + elseif (nItem>1) % use ...<\TagName> ...<\TagName> notation + array2DOMnode(xml, parent, s, TagName, Pref ); % recursive call + else % otherwise save each struct separatelly + fields = fieldnames(s); + node = xml.createElement(TagName); + for i=1:length(fields) % add field by field to the node + field = fields{i}; + x = s.(field); + switch field + case {'COMMENT', 'CDATA_SECTION', 'PROCESSING_INSTRUCTION'} + if iscellstr(x) % cell array of strings -> add them one by one + array2DOMnode(xml, node, x(:), field, Pref ); % recursive call will modify 'node' + elseif ischar(x) % single string -> add it + struct2DOMnode(xml, node, x, field, Pref ); % recursive call will modify 'node' + else % not a string - Ignore + warning('xml_io_tools:write:badSpecialNode', ... + ['Struct field named ',field,' encountered which was not a string. Ignoring.']); + end + case 'ATTRIBUTE' % set attributes of the node + if (isempty(x)), continue; end + if (isstruct(x)) + attName = fieldnames(x); % get names of all the attributes + for k=1:length(attName) % attach them to the node + att = xml.createAttribute(varName2str(attName(k))); + att.setValue(var2str(x.(attName{k}),Pref.PreserveSpace)); + node.setAttributeNode(att); + end + else + warning('xml_io_tools:write:badAttribute', ... + 'Struct field named ATTRIBUTE encountered which was not a struct. Ignoring.'); + end + otherwise % set children of the node + struct2DOMnode(xml, node, x, field, Pref ); % recursive call will modify 'node' + end + end % end for i=1:nFields + parent.appendChild(node); + end +%% == node is a leaf node == +else % if not a struct and not a cell than it is a leaf node + switch TagName % different processing depending on desired type of the node + case 'COMMENT' % create comment node + com = xml.createComment(s); + parent.appendChild(com); + case 'CDATA_SECTION' % create CDATA Section + cdt = xml.createCDATASection(s); + parent.appendChild(cdt); + case 'PROCESSING_INSTRUCTION' % set attributes of the node + OK = false; + if (ischar(s)) + n = strfind(s, ' '); + if (~isempty(n)) + proc = xml.createProcessingInstruction(s(1:(n(1)-1)),s((n(1)+1):end)); + parent.insertBefore(proc, parent.getFirstChild()); + OK = true; + end + end + if (~OK) + warning('xml_io_tools:write:badProcInst', ... + ['Struct field named PROCESSING_INSTRUCTION need to be',... + ' a string, for example: xml-stylesheet type="text/css" ', ... + 'href="myStyleSheet.css". Ignoring.']); + end + case 'CONTENT' % this is text part of already existing node + txt = xml.createTextNode(var2str(s, Pref.PreserveSpace)); % convert to text + parent.appendChild(txt); + otherwise % I guess it is a regular text leaf node + txt = xml.createTextNode(var2str(s, Pref.PreserveSpace)); + node = xml.createElement(TagName); + node.appendChild(txt); + parent.appendChild(node); + end +end % of struct2DOMnode function + +%% ======================================================================= +% === array2DOMnode Function ============================================ +% ======================================================================= +function [] = array2DOMnode(xml, parent, s, TagName, Pref) +% Deal with 1D and 2D arrays of cell or struct. Will modify 'parent'. +nDim = nnz(size(s)>1); % is it a scalar, vector, 2D array, 3D cube, etc? +switch nDim + case 2 % 2D array + for r=1:size(s,1) + subnode = xml.createElement(Pref.TableName{1}); + for c=1:size(s,2) + v = s(r,c); + if iscell(v), v = v{1}; end + struct2DOMnode(xml, subnode, v, Pref.TableName{2}, Pref ); % recursive call + end + parent.appendChild(subnode); + end + case 1 %1D array + for iItem=1:numel(s) + v = s(iItem); + if iscell(v), v = v{1}; end + struct2DOMnode(xml, parent, v, TagName, Pref ); % recursive call + end + case 0 % scalar -> this case should never be called + if ~isempty(s) + if iscell(s), s = s{1}; end + struct2DOMnode(xml, parent, s, TagName, Pref ); + end +end + +%% ======================================================================= +% === var2str Function ================================================== +% ======================================================================= +function str = var2str(object, PreserveSpace) +% convert matlab variables to a string +switch (1) + case isempty(object) + str = ''; + case (isnumeric(object) || islogical(object)) + if ndims(object)>2, object=object(:); end % can't handle arrays with dimention > 2 + str=mat2str(object); % convert matrix to a string + % mark logical scalars with [] (logical arrays already have them) so the xml_read + % recognizes them as MATLAB objects instead of strings. Same with sparse + % matrices + if ((islogical(object) && isscalar(object)) || issparse(object)), + str = ['[' str ']']; + end + if (isinteger(object)), + str = ['[', class(object), '(', str ')]']; + end + case iscell(object) + if ndims(object)>2, object=object(:); end % can't handle cell arrays with dimention > 2 + [nr nc] = size(object); + obj2 = object; + for i=1:length(object(:)) + str = var2str(object{i}, PreserveSpace); + if (ischar(object{i})), object{i} = ['''' object{i} '''']; else object{i}=str; end + obj2{i} = [object{i} ',']; + end + for r = 1:nr, obj2{r,nc} = [object{r,nc} ';']; end + obj2 = obj2.'; + str = ['{' obj2{:} '}']; + case isstruct(object) + str=''; + warning('xml_io_tools:write:var2str', ... + 'Struct was encountered where string was expected. Ignoring.'); + case isa(object, 'function_handle') + str = ['[@' char(object) ']']; + case ischar(object) + str = object; + otherwise + str = char(object); +end + +%% string clean-up +str=str(:); str=str.'; % make sure this is a row vector of char's +if (~isempty(str)) + str(str<32|str==127)=' '; % convert no-printable characters to spaces + if (~PreserveSpace) + str = strtrim(str); % remove spaces from begining and the end + str = regexprep(str,'\s+',' '); % remove multiple spaces + end +end + +%% ======================================================================= +% === var2Namestr Function ============================================== +% ======================================================================= +function str = varName2str(str) +% convert matlab variable names to a sting +str = char(str); +p = strfind(str,'0x'); +if (~isempty(p)) + for i=1:length(p) + before = str( p(i)+(0:3) ); % string to replace + after = char(hex2dec(before(3:4))); % string to replace with + str = regexprep(str,before,after, 'once', 'ignorecase'); + p=p-3; % since 4 characters were replaced with one - compensate + end +end +str = regexprep(str,'_COLON_',':', 'once', 'ignorecase'); +str = regexprep(str,'_DASH_' ,'-', 'once', 'ignorecase'); + diff --git a/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/xmlwrite_xerces.m b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/xmlwrite_xerces.m new file mode 100644 index 00000000..3625c73d --- /dev/null +++ b/matlab_version/AU_training/data extraction/xml_io_tools_2010_11_05/xmlwrite_xerces.m @@ -0,0 +1,109 @@ +function varargout=xmlwrite_xerces(varargin) +%XMLWRITE_XERCES Serialize an XML Document Object Model node using Xerces parser. +% xmlwrite_xerces(FILENAME,DOMNODE) serializes the DOMNODE to file FILENAME. +% +% The function xmlwrite_xerces is very similar the Matlab function xmlwrite +% but works directly with the XERCES java classes (written by Apache XML +% Project) instead of the XMLUtils class created by Mathworks. Xerces files +% are provided in standard MATLAB instalation and live in root\java\jarext +% directory. +% +% Written by A.Amaro (02-22-2007) and generously donated to xml_io_tools. +% This function is needed as a work-around for a bug in XMLUtils library +% which can not write CDATA SECTION nodes correctly. Also Xerces and +% XMLUtils libraries handle namespaces differently. +% +% Examples: +% % See xmlwrite examples this function have almost identical behavior. +% +% Advanced use: +% FILENAME can also be a URN, java.io.OutputStream or java.io.Writer object +% SOURCE can also be a SAX InputSource, JAXP Source, InputStream, or +% Reader object + +returnString = false; +if length(varargin)==1 + returnString = true; + result = java.io.StringWriter; + source = varargin{1}; +else + result = varargin{1}; + if ischar(result) + % Using the XERCES classes directly, is not needed to modify the + % filename string. So I have commented this next line + % result = F_xmlstringinput(result,false); + end + + source = varargin{2}; + if ischar(source) + source = F_xmlstringinput(source,true); + end +end + +% SERIALIZATION OF THE DOM DOCUMENT USING XERCES CLASSES DIRECTLY + +% 1) create the output format according to the document definitions +% and type +objOutputFormat = org.apache.xml.serialize.OutputFormat(source); +set(objOutputFormat,'Indenting','on'); + +% 2) create the output stream. In this case: an XML file +objFile = java.io.File(result); +objOutputStream = java.io.FileOutputStream(objFile); + +% 3) Create the Xerces Serializer object +objSerializer= org.apache.xml.serialize.XMLSerializer(objOutputStream,objOutputFormat); + +% 4) Serialize to the XML files +javaMethod('serialize',objSerializer,source); + +% 5) IMPORTANT! Delete the objects to liberate the XML file created +objOutputStream.close; + +if returnString + varargout{1}=char(result.toString); +end + +%% ======================================================================== + function out = F_xmlstringinput(xString,isFullSearch,varargin) +% The function F_xmlstringinput is a copy of the private function: +% 'xmlstringinput' that the original xmlwrite function uses. + +if isempty(xString) + error('Filename is empty'); +elseif ~isempty(findstr(xString,'://')) + %xString is already a URL, most likely prefaced by file:// or http:// + out = xString; + return; +end + +xPath=fileparts(xString); +if isempty(xPath) + if nargin<2 || isFullSearch + out = which(xString); + if isempty(out) + error('xml:FileNotFound','File %s not found',xString); + end + else + out = fullfile(pwd,xString); + end +else + out = xString; + if (nargin<2 || isFullSearch) && ~exist(xString,'file') + %search to see if xString exists when isFullSearch + error('xml:FileNotFound','File %s not found',xString); + end +end + +%Return as a URN +if strncmp(out,'\\',2) + % SAXON UNC filepaths need to look like file:///\\\server-name\ + out = ['file:///\',out]; +elseif strncmp(out,'/',1) + % SAXON UNIX filepaths need to look like file:///root/dir/dir + out = ['file://',out]; +else + % DOS filepaths need to look like file:///d:/foo/bar + out = ['file:///',strrep(out,'\','/')]; +end + diff --git a/matlab_version/AU_training/experiments/BP4D/Prepare_HOG_AU_data_generic.m b/matlab_version/AU_training/experiments/BP4D/Prepare_HOG_AU_data_generic.m new file mode 100644 index 00000000..1e56805d --- /dev/null +++ b/matlab_version/AU_training/experiments/BP4D/Prepare_HOG_AU_data_generic.m @@ -0,0 +1,110 @@ +function [data_train, labels_train, data_devel, labels_devel, raw_devel, PC, means_norm, stds_norm, valid_ids_test] = ... + Prepare_HOG_AU_data_generic(train_users, devel_users, au_train, bp4d_dir, hog_data_dir, pca_file) + +%% +addpath(genpath('../../data extraction/')); + +au_other = setdiff([1, 2, 4, 6, 7, 10, 12, 14, 15, 17, 23], au_train); +[ labels_other, ~, ~ ] = extract_BP4D_labels(bp4d_dir, train_users, au_other); +labels_other = cat(1, labels_other{:}); + +% First extracting the labels +[ labels_train, valid_ids_train, vid_ids_train ] = extract_BP4D_labels(bp4d_dir, train_users, au_train); + +train_geom_data = Read_geom_files(train_users, hog_data_dir); +% Reading in the HOG data (of only relevant frames) +[train_appearance_data, valid_ids_train_hog, vid_ids_train_string] = Read_HOG_files(train_users, hog_data_dir); +train_appearance_data = cat(2, train_appearance_data, train_geom_data); + +% Subsample the data to make training quicker +labels_train = cat(1, labels_train{:}); +valid_ids_train = logical(cat(1, valid_ids_train{:})); +reduced_inds = false(size(labels_train,1),1); + +if(numel(au_train) == 1) + reduced_inds(labels_train == 1) = true; +else + reduced_inds(:) = true; +end + +% make sure the same number of positive and negative samples is taken +pos_count = sum(labels_train == 1); +neg_count = sum(labels_train == 0); + +num_other = floor(pos_count / (size(labels_other, 2))); + +inds_all = 1:size(labels_train,1); + +if(numel(au_train) == 1) + for i=1:size(labels_other, 2)+1 + + if(i > size(labels_other, 2)) + % fill the rest with a proportion of neutral + inds_other = inds_all(sum(labels_other,2)==0 & ~labels_train ); + num_other_i = min(numel(inds_other), pos_count - sum(labels_train(reduced_inds,:)==0)); + else + % take a proportion of each other AU + inds_other = inds_all(labels_other(:, i) & ~labels_train ); + num_other_i = min(numel(inds_other), num_other); + end + inds_other_to_keep = inds_other(round(linspace(1, numel(inds_other), num_other_i))); + reduced_inds(inds_other_to_keep) = true; + + end +end +% Remove invalid ids based on CLM failing or AU not being labelled +reduced_inds(~valid_ids_train) = false; +reduced_inds(~valid_ids_train_hog) = false; + +% labels_other = labels_other(reduced_inds, :); +labels_train = labels_train(reduced_inds,:); +train_appearance_data = train_appearance_data(reduced_inds,:); +vid_ids_train_string = vid_ids_train_string(reduced_inds,:); + +%% Extract devel data + +% First extracting the labels +[ labels_devel, valid_ids_devel, vid_ids_devel ] = extract_BP4D_labels(bp4d_dir, devel_users, au_train); + +% Reading in the HOG data (of only relevant frames) +devel_geom_data = Read_geom_files(devel_users, hog_data_dir); +[devel_appearance_data, valid_ids_devel_hog, vid_ids_devel_string] = Read_HOG_files(devel_users, hog_data_dir); +devel_appearance_data = cat(2, devel_appearance_data, devel_geom_data); + +labels_devel = cat(1, labels_devel{:}); + +valid_ids_test = valid_ids_devel_hog; + +% Peforming zone specific masking +if(au_train < 8 || au_train == 43 || au_train == 45) % upper face AUs ignore bottom face + % normalise the data + pca_file = '../../pca_generation/generic_face_upper.mat'; + load(pca_file); +elseif(au_train > 9) % lower face AUs ignore upper face and the sides + % normalise the data + pca_file = '../../pca_generation/generic_face_lower.mat'; + load(pca_file); +elseif(au_train == 9) % Central face model + % normalise the data + pca_file = '../../pca_generation/generic_face_rigid.mat'; + load(pca_file); +end + +PC_n = zeros(size(PC)+size(train_geom_data, 2)); +PC_n(1:size(PC,1), 1:size(PC,2)) = PC; +PC_n(size(PC,1)+1:end, size(PC,2)+1:end) = eye(size(train_geom_data, 2)); +PC = PC_n; + +means_norm = cat(2, means_norm, zeros(1, size(train_geom_data,2))); +stds_norm = cat(2, stds_norm, ones(1, size(train_geom_data,2))); + +% Grab all data for validation as want good params for all the data +raw_devel = devel_appearance_data; + +devel_appearance_data = bsxfun(@times, bsxfun(@plus, devel_appearance_data, -means_norm), 1./stds_norm); +train_appearance_data = bsxfun(@times, bsxfun(@plus, train_appearance_data, -means_norm), 1./stds_norm); + +data_train = train_appearance_data * PC; +data_devel = devel_appearance_data * PC; + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/BP4D/Prepare_HOG_AU_data_generic_dynamic.m b/matlab_version/AU_training/experiments/BP4D/Prepare_HOG_AU_data_generic_dynamic.m new file mode 100644 index 00000000..05f3f66e --- /dev/null +++ b/matlab_version/AU_training/experiments/BP4D/Prepare_HOG_AU_data_generic_dynamic.m @@ -0,0 +1,106 @@ +function [data_train, labels_train, data_devel, labels_devel, raw_devel, PC, means_norm, stds_norm, valid_ids_devel] = ... + Prepare_HOG_AU_data_generic_dynamic(train_users, devel_users, au_train, bp4d_dir, hog_data_dir, pca_file) + +%% +addpath(genpath('../../data extraction/')); + +au_other = setdiff([1, 2, 4, 6, 7, 10, 12, 14, 15, 17, 23], au_train); +[ labels_other, ~, ~ ] = extract_BP4D_labels(bp4d_dir, train_users, au_other); +labels_other = cat(1, labels_other{:}); + +% First extracting the labels +[ labels_train, valid_ids_train, vid_ids_train ] = extract_BP4D_labels(bp4d_dir, train_users, au_train); + +train_geom_data = Read_geom_files_dynamic(train_users, hog_data_dir); + +% Reading in the HOG data (of only relevant frames) +[train_appearance_data, valid_ids_train_hog, vid_ids_train_string] = Read_HOG_files_dynamic_pp(train_users, hog_data_dir); + +train_appearance_data = cat(2, train_appearance_data, train_geom_data); + +% Subsample the data to make training quicker +labels_train = cat(1, labels_train{:}); +valid_ids_train = logical(cat(1, valid_ids_train{:})); + +reduced_inds = false(size(labels_train,1),1); +reduced_inds(labels_train == 1) = true; + +% make sure the same number of positive and negative samples is taken +pos_count = sum(labels_train == 1); +neg_count = sum(labels_train == 0); + +num_other = floor(pos_count / (size(labels_other, 2))); + +inds_all = 1:size(labels_train,1); + +for i=1:size(labels_other, 2)+1 + + if(i > size(labels_other, 2)) + % fill the rest with a proportion of neutral + inds_other = inds_all(sum(labels_other,2)==0 & ~labels_train ); + num_other_i = min(numel(inds_other), pos_count - sum(labels_train(reduced_inds,:)==0)); + else + % take a proportion of each other AU + inds_other = inds_all(labels_other(:, i) & ~labels_train ); + num_other_i = min(numel(inds_other), num_other); + end + inds_other_to_keep = inds_other(round(linspace(1, numel(inds_other), num_other_i))); + reduced_inds(inds_other_to_keep) = true; + +end + +% Remove invalid ids based on CLM failing or AU not being labelled +reduced_inds(~valid_ids_train) = false; +reduced_inds(~valid_ids_train_hog) = false; + +labels_other = labels_other(reduced_inds, :); +labels_train = labels_train(reduced_inds,:); +train_appearance_data = train_appearance_data(reduced_inds,:); +vid_ids_train_string = vid_ids_train_string(reduced_inds,:); + +%% Extract devel data + +% First extracting the labels +[ labels_devel, valid_ids_devel, vid_ids_devel ] = extract_BP4D_labels(bp4d_dir, devel_users, au_train); +labels_devel = cat(1, labels_devel{:}); + +% Reading in the HOG data (of only relevant frames) +devel_geom_data = Read_geom_files_dynamic(devel_users, hog_data_dir); +[devel_appearance_data, valid_ids_devel_hog, vid_ids_devel_string] = Read_HOG_files_dynamic_pp(devel_users, hog_data_dir); +devel_appearance_data = cat(2, devel_appearance_data, devel_geom_data); + +valid_ids_devel = valid_ids_devel_hog; + +% Peforming zone specific masking +if(au_train < 8 || au_train == 43 || au_train == 45) % upper face AUs ignore bottom face + % normalise the data + pca_file = '../../pca_generation/generic_face_upper.mat'; + load(pca_file); +elseif(au_train > 9) % lower face AUs ignore upper face and the sides + % normalise the data + pca_file = '../../pca_generation/generic_face_lower.mat'; + load(pca_file); +elseif(au_train == 9) % Central face model + % normalise the data + pca_file = '../../pca_generation/generic_face_rigid.mat'; + load(pca_file); +end + +PC_n = zeros(size(PC)+size(train_geom_data, 2)); +PC_n(1:size(PC,1), 1:size(PC,2)) = PC; +PC_n(size(PC,1)+1:end, size(PC,2)+1:end) = eye(size(train_geom_data, 2)); +PC = PC_n; + +means_norm = cat(2, means_norm, zeros(1, size(train_geom_data,2))); +stds_norm = cat(2, stds_norm, ones(1, size(train_geom_data,2))); + +% Grab all data for validation as want good params for all the data +raw_devel = devel_appearance_data; + +devel_appearance_data = bsxfun(@times, bsxfun(@plus, devel_appearance_data, -means_norm), 1./stds_norm); +train_appearance_data = bsxfun(@times, bsxfun(@plus, train_appearance_data, -means_norm), 1./stds_norm); + +data_train = train_appearance_data * PC; +data_devel = devel_appearance_data * PC; + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/BP4D/Prepare_HOG_AU_data_generic_intensity.m b/matlab_version/AU_training/experiments/BP4D/Prepare_HOG_AU_data_generic_intensity.m new file mode 100644 index 00000000..dae8fbae --- /dev/null +++ b/matlab_version/AU_training/experiments/BP4D/Prepare_HOG_AU_data_generic_intensity.m @@ -0,0 +1,115 @@ +function [data_train, labels_train, vid_ids_train_string, data_devel, labels_devel, vid_ids_devel_string, raw_devel, PC, means_norm, stds_norm, success_devel] = ... + Prepare_HOG_AU_data_generic_intensity(train_users, devel_users, au_train, bp4d_dir, hog_data_dir) + +%% +addpath(genpath('../data extraction/')); + +% First extracting the labels +[ labels_train, valid_ids_train, vid_ids_train ] = extract_BP4D_labels_intensity(bp4d_dir, train_users, au_train); +au_other = setdiff([6, 10, 12, 14, 17], au_train); +[ labels_other, ~, ~ ] = extract_BP4D_labels_intensity(bp4d_dir, train_users, au_other); +labels_other = cat(1, labels_other{:}); + +train_geom_data = Read_geom_files(train_users, hog_data_dir); + +% Reading in the HOG data (of only relevant frames) +[train_appearance_data, valid_ids_train_hog, vid_ids_train_string] = Read_HOG_files(train_users, hog_data_dir); +train_appearance_data = cat(2, train_appearance_data, train_geom_data); + +% Subsample the data to make training quicker +labels_train = cat(1, labels_train{:}); +valid_ids_train = logical(cat(1, valid_ids_train{:})); + +reduced_inds = false(size(labels_train,1),1); +reduced_inds(labels_train > 0) = true; + +% make sure the same number of positive and negative samples is taken +pos_count = sum(labels_train > 0); +neg_count = sum(labels_train == 0); + +num_other = floor(pos_count / (size(labels_other, 2))); + +inds_all = 1:size(labels_train,1); + +if(numel(train_users) > 0) + if(numel(au_train) == 1) + for i=1:size(labels_other, 2)+1 + + if(i > size(labels_other, 2)) + % fill the rest with a proportion of neutral + inds_other = inds_all(sum(labels_other,2)==0 & ~labels_train ); + num_other_i = min(numel(inds_other), pos_count - sum(labels_train(reduced_inds,:)==0)); + else + % take a proportion of each other AU + inds_other = inds_all(labels_other(:, i) & ~labels_train ); + num_other_i = min(numel(inds_other), num_other); + end + inds_other_to_keep = inds_other(round(linspace(1, numel(inds_other), num_other_i))); + reduced_inds(inds_other_to_keep) = true; + + end + end + % Remove invalid ids based on CLM failing or AU not being labelled + reduced_inds(~valid_ids_train) = false; + reduced_inds(~valid_ids_train_hog) = false; + + labels_other = labels_other(reduced_inds, :); + labels_train = labels_train(reduced_inds,:); + train_appearance_data = train_appearance_data(reduced_inds,:); + vid_ids_train_string = vid_ids_train_string(reduced_inds,:); + +end + +%% Extract devel data + +% First extracting the labels +[ labels_devel, valid_ids_devel, vid_ids_devel ] = extract_BP4D_labels_intensity(bp4d_dir, devel_users, au_train); + +devel_geom_data = Read_geom_files(devel_users, hog_data_dir); +% Reading in the HOG data (of only relevant frames) +[devel_appearance_data, valid_ids_devel_hog, vid_ids_devel_string] = Read_HOG_files(devel_users, hog_data_dir); +devel_appearance_data = cat(2, devel_appearance_data, devel_geom_data); + +valid_ids_devel = logical(cat(1, valid_ids_devel{:})); + +labels_devel = cat(1, labels_devel{:}); + +success_devel = valid_ids_devel; + +% Peforming zone specific masking +if(au_train < 8 || au_train == 43 || au_train == 45) % upper face AUs ignore bottom face + % normalise the data + pca_file = '../../pca_generation/generic_face_upper.mat'; + load(pca_file); +elseif(au_train > 9) % lower face AUs ignore upper face and the sides + % normalise the data + pca_file = '../../pca_generation/generic_face_lower.mat'; + load(pca_file); +elseif(au_train == 9) % Central face model + % normalise the data + pca_file = '../../pca_generation/generic_face_rigid.mat'; + load(pca_file); +end + +PC_n = zeros(size(PC)+size(devel_geom_data, 2)); +PC_n(1:size(PC,1), 1:size(PC,2)) = PC; +PC_n(size(PC,1)+1:end, size(PC,2)+1:end) = eye(size(devel_geom_data, 2)); +PC = PC_n; + +means_norm = cat(2, means_norm, zeros(1, size(devel_geom_data,2))); +stds_norm = cat(2, stds_norm, ones(1, size(devel_geom_data,2))); + +% Grab all data for validation as want good params for all the data +raw_devel = devel_appearance_data; + +devel_appearance_data = bsxfun(@times, bsxfun(@plus, devel_appearance_data, -means_norm), 1./stds_norm); +data_devel = devel_appearance_data * PC; + +if(numel(train_users) > 0) + train_appearance_data = bsxfun(@times, bsxfun(@plus, train_appearance_data, -means_norm), 1./stds_norm); + data_train = train_appearance_data * PC; +else + data_train = []; +end + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/BP4D/Prepare_HOG_AU_data_generic_intensity_dynamic.m b/matlab_version/AU_training/experiments/BP4D/Prepare_HOG_AU_data_generic_intensity_dynamic.m new file mode 100644 index 00000000..8dc4ca7b --- /dev/null +++ b/matlab_version/AU_training/experiments/BP4D/Prepare_HOG_AU_data_generic_intensity_dynamic.m @@ -0,0 +1,115 @@ +function [data_train, labels_train, vid_ids_train_string, data_devel, labels_devel, vid_ids_devel_string, raw_devel, PC, means_norm, stds_norm, success_devel] = ... + Prepare_HOG_AU_data_generic_intensity_dynamic(train_users, devel_users, au_train, bp4d_dir, hog_data_dir) + +%% +addpath(genpath('../data extraction/')); + +% First extracting the labels +[ labels_train, valid_ids_train, vid_ids_train ] = extract_BP4D_labels_intensity(bp4d_dir, train_users, au_train); +au_other = setdiff([6, 10, 12, 14, 17], au_train); +[ labels_other, ~, ~ ] = extract_BP4D_labels_intensity(bp4d_dir, train_users, au_other); +labels_other = cat(1, labels_other{:}); + +train_geom_data = Read_geom_files_dynamic(train_users, hog_data_dir); + +% Reading in the HOG data (of only relevant frames) +[train_appearance_data, valid_ids_train_hog, vid_ids_train_string] = Read_HOG_files_dynamic_pp(train_users, hog_data_dir); +train_appearance_data = cat(2, train_appearance_data, train_geom_data); + +% Subsample the data to make training quicker +labels_train = cat(1, labels_train{:}); +valid_ids_train = logical(cat(1, valid_ids_train{:})); + +reduced_inds = false(size(labels_train,1),1); +reduced_inds(labels_train > 0) = true; + +% make sure the same number of positive and negative samples is taken +pos_count = sum(labels_train > 0); +neg_count = sum(labels_train == 0); + +num_other = floor(pos_count / (size(labels_other, 2))); + +inds_all = 1:size(labels_train,1); + +if(numel(train_users) > 0) + if(numel(au_train) == 1) + for i=1:size(labels_other, 2)+1 + + if(i > size(labels_other, 2)) + % fill the rest with a proportion of neutral + inds_other = inds_all(sum(labels_other,2)==0 & ~labels_train ); + num_other_i = min(numel(inds_other), pos_count - sum(labels_train(reduced_inds,:)==0)); + else + % take a proportion of each other AU + inds_other = inds_all(labels_other(:, i) & ~labels_train ); + num_other_i = min(numel(inds_other), num_other); + end + inds_other_to_keep = inds_other(round(linspace(1, numel(inds_other), num_other_i))); + reduced_inds(inds_other_to_keep) = true; + + end + end + % Remove invalid ids based on CLM failing or AU not being labelled + reduced_inds(~valid_ids_train) = false; + reduced_inds(~valid_ids_train_hog) = false; + + labels_other = labels_other(reduced_inds, :); + labels_train = labels_train(reduced_inds,:); + train_appearance_data = train_appearance_data(reduced_inds,:); + vid_ids_train_string = vid_ids_train_string(reduced_inds,:); + +end + +%% Extract devel data + +% First extracting the labels +[ labels_devel, valid_ids_devel, vid_ids_devel ] = extract_BP4D_labels_intensity(bp4d_dir, devel_users, au_train); + +devel_geom_data = Read_geom_files_dynamic(devel_users, hog_data_dir); +% Reading in the HOG data (of only relevant frames) +[devel_appearance_data, valid_ids_devel_hog, vid_ids_devel_string] = Read_HOG_files_dynamic_pp(devel_users, hog_data_dir); +devel_appearance_data = cat(2, devel_appearance_data, devel_geom_data); + +valid_ids_devel = logical(cat(1, valid_ids_devel{:})); + +labels_devel = cat(1, labels_devel{:}); + +success_devel = valid_ids_devel; + +% Peforming zone specific masking +if(au_train < 8 || au_train == 43 || au_train == 45) % upper face AUs ignore bottom face + % normalise the data + pca_file = '../../pca_generation/generic_face_upper.mat'; + load(pca_file); +elseif(au_train > 9) % lower face AUs ignore upper face and the sides + % normalise the data + pca_file = '../../pca_generation/generic_face_lower.mat'; + load(pca_file); +elseif(au_train == 9) % Central face model + % normalise the data + pca_file = '../../pca_generation/generic_face_rigid.mat'; + load(pca_file); +end + +PC_n = zeros(size(PC)+size(devel_geom_data, 2)); +PC_n(1:size(PC,1), 1:size(PC,2)) = PC; +PC_n(size(PC,1)+1:end, size(PC,2)+1:end) = eye(size(devel_geom_data, 2)); +PC = PC_n; + +means_norm = cat(2, means_norm, zeros(1, size(devel_geom_data,2))); +stds_norm = cat(2, stds_norm, ones(1, size(devel_geom_data,2))); + +% Grab all data for validation as want good params for all the data +raw_devel = devel_appearance_data; + +devel_appearance_data = bsxfun(@times, bsxfun(@plus, devel_appearance_data, -means_norm), 1./stds_norm); +data_devel = devel_appearance_data * PC; + +if(numel(train_users) > 0) + train_appearance_data = bsxfun(@times, bsxfun(@plus, train_appearance_data, -means_norm), 1./stds_norm); + data_train = train_appearance_data * PC; +else + data_train = []; +end + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/BP4D/Read_HOG_files.m b/matlab_version/AU_training/experiments/BP4D/Read_HOG_files.m new file mode 100644 index 00000000..b4f1d78d --- /dev/null +++ b/matlab_version/AU_training/experiments/BP4D/Read_HOG_files.m @@ -0,0 +1,93 @@ +function [hog_data, valid_inds, vid_id] = Read_HOG_files(users, hog_data_dir) + + hog_data = []; + vid_id = {}; + valid_inds = []; + + feats_filled = 0; + + for i=1:numel(users) + + hog_files = dir([hog_data_dir, '/train/' users{i} '*.hog']); + hog_dir = [hog_data_dir, '/train/']; + if(isempty(hog_files)) + hog_files = dir([hog_data_dir, '/devel/' users{i} '*.hog']); + hog_dir = [hog_data_dir, '/devel/']; + end + + for h=1:numel(hog_files) + hog_file = [hog_dir, hog_files(h).name]; + f = fopen(hog_file, 'r'); + + curr_data = []; + curr_ind = 0; + + while(~feof(f)) + + if(curr_ind == 0) + num_cols = fread(f, 1, 'int32'); + if(isempty(num_cols)) + break; + end + + num_rows = fread(f, 1, 'int32'); + num_chan = fread(f, 1, 'int32'); + + curr_ind = curr_ind + 1; + + % preallocate some space + if(curr_ind == 1) + curr_data = zeros(1000, 1 + num_rows * num_cols * num_chan); + num_feats = 1 + num_rows * num_cols * num_chan; + end + + if(curr_ind > size(curr_data,1)) + curr_data = cat(1, curr_data, zeros(1000, 1 + num_rows * num_cols * num_chan)); + end + feature_vec = fread(f, [1, 1 + num_rows * num_cols * num_chan], 'float32'); + curr_data(curr_ind, :) = feature_vec; + else + + % Reading in batches of 5000 + + feature_vec = fread(f, [4 + num_rows * num_cols * num_chan, 5000], 'float32'); + feature_vec = feature_vec(4:end,:)'; + + num_rows_read = size(feature_vec,1); + + curr_data(curr_ind+1:curr_ind+num_rows_read,:) = feature_vec; + + curr_ind = curr_ind + size(feature_vec,1); + + end + + end + + fclose(f); + + curr_data = curr_data(1:curr_ind,:); + vid_id_curr = cell(curr_ind,1); + vid_id_curr(:) = users(i); + + vid_id = cat(1, vid_id, vid_id_curr); + + % Assume same number of frames per video + if(i==1 && h == 1) + hog_data = zeros(curr_ind * numel(users) * 8, num_feats); + end + + if(size(hog_data,1) < feats_filled+curr_ind) + hog_data = cat(1, hog_data, zeros(size(hog_data,1), num_feats)); + end + + hog_data(feats_filled+1:feats_filled+curr_ind,:) = curr_data; + + feats_filled = feats_filled + curr_ind; + end + end + + if(~isempty(hog_data)) + valid_inds = hog_data(1:feats_filled,1); + hog_data = hog_data(1:feats_filled,2:end); + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/BP4D/Read_HOG_files_dynamic_pp.m b/matlab_version/AU_training/experiments/BP4D/Read_HOG_files_dynamic_pp.m new file mode 100644 index 00000000..0b5e38a8 --- /dev/null +++ b/matlab_version/AU_training/experiments/BP4D/Read_HOG_files_dynamic_pp.m @@ -0,0 +1,101 @@ +function [hog_data, valid_inds, vid_id] = Read_HOG_files_dynamic_pp(users, hog_data_dir) + + hog_data = []; + vid_id = {}; + valid_inds = []; + + feats_filled = 0; + + for i=1:numel(users) + + start_person_ind = feats_filled + 1; + + hog_files = dir([hog_data_dir, '/train/' users{i} '*.hog']); + hog_dir = [hog_data_dir, '/train/']; + if(isempty(hog_files)) + hog_files = dir([hog_data_dir, '/devel/' users{i} '*.hog']); + hog_dir = [hog_data_dir, '/devel/']; + end + + for h=1:numel(hog_files) + hog_file = [hog_dir, hog_files(h).name]; + f = fopen(hog_file, 'r'); + + curr_data = []; + curr_ind = 0; + + while(~feof(f)) + + if(curr_ind == 0) + num_cols = fread(f, 1, 'int32'); + if(isempty(num_cols)) + break; + end + + num_rows = fread(f, 1, 'int32'); + num_chan = fread(f, 1, 'int32'); + + curr_ind = curr_ind + 1; + + % preallocate some space + if(curr_ind == 1) + curr_data = zeros(1000, 1 + num_rows * num_cols * num_chan); + num_feats = 1 + num_rows * num_cols * num_chan; + end + + if(curr_ind > size(curr_data,1)) + curr_data = cat(1, curr_data, zeros(1000, 1 + num_rows * num_cols * num_chan)); + end + feature_vec = fread(f, [1, 1 + num_rows * num_cols * num_chan], 'float32'); + curr_data(curr_ind, :) = feature_vec; + else + + % Reading in batches of 5000 + + feature_vec = fread(f, [4 + num_rows * num_cols * num_chan, 5000], 'float32'); + feature_vec = feature_vec(4:end,:)'; + + num_rows_read = size(feature_vec,1); + + curr_data(curr_ind+1:curr_ind+num_rows_read,:) = feature_vec; + + curr_ind = curr_ind + size(feature_vec,1); + + end + + end + + fclose(f); + + curr_data = curr_data(1:curr_ind,:); + vid_id_curr = cell(curr_ind,1); + vid_id_curr(:) = users(i); + + vid_id = cat(1, vid_id, vid_id_curr); + + % Assume same number of frames per video + if(i==1 && h == 1) + hog_data = zeros(curr_ind * numel(users) * 8, num_feats); + end + + if(size(hog_data,1) < feats_filled+curr_ind) + hog_data = cat(1, hog_data, zeros(size(hog_data,1), num_feats)); + end + + + hog_data(feats_filled+1:feats_filled+curr_ind,:) = curr_data; + + feats_filled = feats_filled + curr_ind; + end + + person_ids = start_person_ind:feats_filled; + % Do the median normalisation per person here + hog_data(person_ids,2:end) = bsxfun(@plus, hog_data(person_ids,2:end), -median(hog_data(person_ids,2:end))); + + end + + if(~isempty(hog_data)) + valid_inds = hog_data(1:feats_filled,1); + hog_data = hog_data(1:feats_filled,2:end); + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/BP4D/Read_geom_files.m b/matlab_version/AU_training/experiments/BP4D/Read_geom_files.m new file mode 100644 index 00000000..9e59c44e --- /dev/null +++ b/matlab_version/AU_training/experiments/BP4D/Read_geom_files.m @@ -0,0 +1,41 @@ +function [geom_data, valid_ids] = Read_geom_files(users, hog_data_dir) + + geom_data = []; + valid_ids = []; + + load('../../pca_generation/pdm_68_aligned_wild.mat'); + + for i=1:numel(users) + + geom_files = dir([hog_data_dir, '/train/', users{i} '*.params.txt']); + geom_dir = [hog_data_dir, '/train/']; + if(isempty(geom_files)) + geom_files = dir([hog_data_dir, '/devel/', users{i} '*.params.txt']); + geom_dir = [hog_data_dir, '/devel/']; + end + + for h=1:numel(geom_files) + geom_file = [geom_dir, geom_files(h).name]; + [~, nm, ~] = fileparts(geom_file); + m_file = [geom_dir, '/' nm '.params.mat']; + + if(~exist(m_file, 'file')) + res = dlmread(geom_file, ',', 1, 0); + save(m_file, 'res'); + else + load(m_file); + end + + valid = res(:, 4); + res = res(:, 11:end); + + actual_locs = res * V'; + res = cat(2, actual_locs, res); + + valid_ids = cat(1, valid_ids, valid); + + geom_data = cat(1, geom_data, res); + + end + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/BP4D/Read_geom_files_dynamic.m b/matlab_version/AU_training/experiments/BP4D/Read_geom_files_dynamic.m new file mode 100644 index 00000000..1ccb9708 --- /dev/null +++ b/matlab_version/AU_training/experiments/BP4D/Read_geom_files_dynamic.m @@ -0,0 +1,46 @@ +function [geom_data, valid_ids] = Read_geom_files_dynamic(users, hog_data_dir) + + geom_data = []; + valid_ids = []; + + load('../../pca_generation/pdm_68_aligned_wild.mat'); + + for i=1:numel(users) + + geom_files = dir([hog_data_dir, '/train/', users{i} '*.params.txt']); + geom_dir = [hog_data_dir, '/train/']; + if(isempty(geom_files)) + geom_files = dir([hog_data_dir, '/devel/', users{i} '*.params.txt']); + geom_dir = [hog_data_dir, '/devel/']; + end + + geom_data_curr = []; + for h=1:numel(geom_files) + geom_file = [geom_dir, geom_files(h).name]; + + [~, nm, ~] = fileparts(geom_file); + m_file = [geom_dir, '/' nm '.params.mat']; + + if(~exist(m_file, 'file')) + res = dlmread(geom_file, ',', 1, 0); + save(m_file, 'res'); + else + load(m_file); + end + + valid = res(:, 4); + res = res(:, 11:end); + + actual_locs = res * V'; + res = cat(2, actual_locs, res); + + valid_ids = cat(1, valid_ids, valid); + + geom_data_curr = cat(1, geom_data_curr, res); + end + geom_data_curr = bsxfun(@plus, geom_data_curr, -median(geom_data_curr)); + + geom_data = cat(1, geom_data, geom_data_curr); + + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/BP4D/Script_HOG_SVM_dynamic.m b/matlab_version/AU_training/experiments/BP4D/Script_HOG_SVM_dynamic.m new file mode 100644 index 00000000..5cfd4d98 --- /dev/null +++ b/matlab_version/AU_training/experiments/BP4D/Script_HOG_SVM_dynamic.m @@ -0,0 +1,64 @@ +% Change to your downloaded location +clear +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); +%% load shared definitions and AU data +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-7:0.5:1); +hyperparams.e = 10.^(-3); + +hyperparams.validate_params = {'c', 'e'}; + +% Set the training function +svm_train = @svm_train_linear; + +% Set the test function (the first output will be used for validation) +svm_test = @svm_test_linear; + +pca_loc = '../../pca_generation/generic_face_rigid.mat'; + +hog_data_dir_BP4D = hog_data_dir; + +aus = [1, 2, 4, 6, 7, 10, 12, 14, 15, 17, 23]; +%% +for a=1:numel(aus) + + au = aus(a); + + rest_aus = setdiff(all_aus, au); + + % load the training and testing data for the current fold + [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling] = Prepare_HOG_AU_data_generic_dynamic(train_recs, devel_recs, au, BP4D_dir, hog_data_dir_BP4D, pca_loc); + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + + %% Cross-validate here + [ best_params, ~ ] = validate_grid_search_no_par(svm_train, svm_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + model = svm_train(train_labels, train_samples, best_params); + + [~, predictions_all] = svm_test(valid_labels, valid_samples, model); + + name = sprintf('results_BP4D_devel/AU_%d_dynamic.mat', au); + + [ accuracies, F1s, corrs, ccc, rms, classes ] = evaluate_regression_results( predictions_all, valid_labels ); + + save(name, 'model', 'F1s', 'accuracies', 'predictions_all', 'valid_labels'); + + % Write out the model + name = sprintf('models/AU_%d_dynamic.dat', au); + + pos_lbl = model.Label(1); + neg_lbl = model.Label(2); + + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + write_lin_dyn_svm(name, means, svs, b, pos_lbl, neg_lbl); +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/BP4D/Script_HOG_SVM_static.m b/matlab_version/AU_training/experiments/BP4D/Script_HOG_SVM_static.m new file mode 100644 index 00000000..85905429 --- /dev/null +++ b/matlab_version/AU_training/experiments/BP4D/Script_HOG_SVM_static.m @@ -0,0 +1,66 @@ +% Change to your downloaded location +clear +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); +%% load shared definitions and AU data +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-7:0.5:1); +hyperparams.e = 10.^(-3); + +hyperparams.validate_params = {'c', 'e'}; + +% Set the training function +svm_train = @svm_train_linear; + +% Set the test function (the first output will be used for validation) +svm_test = @svm_test_linear; + +pca_loc = '../../pca_generation/generic_face_rigid.mat'; + +hog_data_dir_BP4D = hog_data_dir; + +aus = [1, 2, 4, 6, 7, 10, 12, 14, 15, 17, 23]; +%% +for a=1:numel(aus) + + au = aus(a); + + rest_aus = setdiff(all_aus, au); + + % load the training and testing data for the current fold + [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling] = Prepare_HOG_AU_data_generic(train_recs, devel_recs, au, BP4D_dir, hog_data_dir_BP4D, pca_loc); + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + + %% Cross-validate here + [ best_params, ~ ] = validate_grid_search_no_par(svm_train, svm_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + model = svm_train(train_labels, train_samples, best_params); + + [~, predictions_all] = svm_test(valid_labels, valid_samples, model); + + name = sprintf('results_BP4D_devel/AU_%d_static.mat', au); + + [ accuracies, F1s, corrs, ccc, rms, classes ] = evaluate_regression_results( predictions_all, valid_labels ); + + save(name, 'model', 'F1s', 'accuracies', 'predictions_all', 'valid_labels'); + + % Write out the model + name = sprintf('models/AU_%d_static.dat', au); + + pos_lbl = model.Label(1); + neg_lbl = model.Label(2); + + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + write_lin_svm(name, means, svs, b, pos_lbl, neg_lbl); +end + + diff --git a/matlab_version/AU_training/experiments/BP4D/Script_HOG_SVR_dynamic_shift.m b/matlab_version/AU_training/experiments/BP4D/Script_HOG_SVR_dynamic_shift.m new file mode 100644 index 00000000..06aa8822 --- /dev/null +++ b/matlab_version/AU_training/experiments/BP4D/Script_HOG_SVR_dynamic_shift.m @@ -0,0 +1,83 @@ +%% load shared definitions and AU data +clear + +addpath('../../data extraction/'); +addpath('../utilities/'); +addpath('../training_code/'); + +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-7:1:4); +hyperparams.p = 10.^(-2); + +hyperparams.validate_params = {'c', 'p'}; + +% Set the training function +svr_train = @svr_train_linear_shift; + +% Set the test function (the first output will be used for validation) +svr_test = @svr_test_linear_shift; + +pca_loc = '../../pca_generation/generic_face_rigid.mat'; + +hog_data_dir_BP4D = hog_data_dir; + +aus = [6, 10, 12, 14, 17]; +%% +for a=1:numel(aus) + + predictions_all = []; + test_labels_all = []; + + au = aus(a); + + rest_aus = setdiff(all_aus, au); + + % load the training and testing data for the current fold + [train_samples, train_labels, ~, valid_samples, valid_labels, vid_ids_devel, ~, PC, means, scaling, success_devel] = Prepare_HOG_AU_data_generic_intensity(train_recs, devel_recs, au, BP4D_dir_int, hog_data_dir_BP4D, pca_loc); + + ignore = valid_labels == 9; + + valid_samples = valid_samples(~ignore, :); + valid_labels = valid_labels(~ignore); + vid_ids_devel = vid_ids_devel(~ignore); + success_devel = success_devel(~ignore); + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + + hyperparams.success = success_devel; + hyperparams.valid_samples = valid_samples; + hyperparams.valid_labels = valid_labels; + hyperparams.vid_ids = vid_ids_devel; + + %% Cross-validate here + [ best_params, ~ ] = validate_grid_search_no_par(svr_train, svr_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + model = svr_train(train_labels, train_samples, best_params); + + clear 'train_samples' + + %% Now test the model + model.vid_ids = vid_ids_devel; + + [~, prediction] = svr_test(valid_labels, valid_samples, model); + + name = sprintf('results_BP4D_devel/AU_%d_static_intensity_shift.mat', au); + + [ accuracies, F1s, corrs, ccc, rms, classes ] = evaluate_regression_results( prediction, valid_labels ); + + save(name, 'model', 'F1s', 'corrs', 'accuracies', 'ccc', 'rms', 'prediction', 'valid_labels'); + + % Go from raw data to the prediction + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + name = sprintf('models/AU_%d_static_intensity_shift.dat', au); + + write_lin_svr(name, means, svs, b); + +end + diff --git a/matlab_version/AU_training/experiments/BP4D/Script_HOG_SVR_static.m b/matlab_version/AU_training/experiments/BP4D/Script_HOG_SVR_static.m new file mode 100644 index 00000000..a0c50bff --- /dev/null +++ b/matlab_version/AU_training/experiments/BP4D/Script_HOG_SVR_static.m @@ -0,0 +1,78 @@ +%% load shared definitions and AU data +clear + +addpath('../../data extraction/'); +addpath('../utilities/'); +addpath('../training_code/'); + +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-7:1:4); +hyperparams.p = 10.^(-2); + +hyperparams.validate_params = {'c', 'p'}; + +% Set the training function +svr_train = @svr_train_linear; + +% Set the test function (the first output will be used for validation) +svr_test = @svr_test_linear; + +hog_data_dir_BP4D = hog_data_dir; + +aus = [6, 10, 12, 14, 17]; +%% +for a=1:numel(aus) + + predictions_all = []; + test_labels_all = []; + + au = aus(a); + + rest_aus = setdiff(all_aus, au); + + % load the training and testing data for the current fold + [train_samples, train_labels, ~, valid_samples, valid_labels, vid_ids_devel, ~, PC, means, scaling, success_devel] = Prepare_HOG_AU_data_generic_intensity(train_recs, devel_recs, au, BP4D_dir_int, hog_data_dir_BP4D); + + ignore = valid_labels == 9; + + valid_samples = valid_samples(~ignore, :); + valid_labels = valid_labels(~ignore); + vid_ids_devel = vid_ids_devel(~ignore); + success_devel = success_devel(~ignore); + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + + hyperparams.success = success_devel; + + %% Cross-validate here + [ best_params, ~ ] = validate_grid_search_no_par(svr_train, svr_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + model = svr_train(train_labels, train_samples, best_params); + + clear 'train_samples' + + %% Now test the model + model.vid_ids = vid_ids_devel; + + [~, prediction] = svr_test(valid_labels, valid_samples, model); + + name = sprintf('results_BP4D_devel/AU_%d_static_intensity.mat', au); + + [ accuracies, F1s, corrs, ccc, rms, classes ] = evaluate_regression_results( prediction, valid_labels ); + + save(name, 'model', 'F1s', 'corrs', 'accuracies', 'ccc', 'rms', 'prediction', 'valid_labels'); + + % Go from raw data to the prediction + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + name = sprintf('models/AU_%d_static_intensity.dat', au); + + write_lin_svr(name, means, svs, b); + +end + diff --git a/matlab_version/AU_training/experiments/BP4D/Script_HOG_SVR_static_shift.m b/matlab_version/AU_training/experiments/BP4D/Script_HOG_SVR_static_shift.m new file mode 100644 index 00000000..06aa8822 --- /dev/null +++ b/matlab_version/AU_training/experiments/BP4D/Script_HOG_SVR_static_shift.m @@ -0,0 +1,83 @@ +%% load shared definitions and AU data +clear + +addpath('../../data extraction/'); +addpath('../utilities/'); +addpath('../training_code/'); + +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-7:1:4); +hyperparams.p = 10.^(-2); + +hyperparams.validate_params = {'c', 'p'}; + +% Set the training function +svr_train = @svr_train_linear_shift; + +% Set the test function (the first output will be used for validation) +svr_test = @svr_test_linear_shift; + +pca_loc = '../../pca_generation/generic_face_rigid.mat'; + +hog_data_dir_BP4D = hog_data_dir; + +aus = [6, 10, 12, 14, 17]; +%% +for a=1:numel(aus) + + predictions_all = []; + test_labels_all = []; + + au = aus(a); + + rest_aus = setdiff(all_aus, au); + + % load the training and testing data for the current fold + [train_samples, train_labels, ~, valid_samples, valid_labels, vid_ids_devel, ~, PC, means, scaling, success_devel] = Prepare_HOG_AU_data_generic_intensity(train_recs, devel_recs, au, BP4D_dir_int, hog_data_dir_BP4D, pca_loc); + + ignore = valid_labels == 9; + + valid_samples = valid_samples(~ignore, :); + valid_labels = valid_labels(~ignore); + vid_ids_devel = vid_ids_devel(~ignore); + success_devel = success_devel(~ignore); + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + + hyperparams.success = success_devel; + hyperparams.valid_samples = valid_samples; + hyperparams.valid_labels = valid_labels; + hyperparams.vid_ids = vid_ids_devel; + + %% Cross-validate here + [ best_params, ~ ] = validate_grid_search_no_par(svr_train, svr_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + model = svr_train(train_labels, train_samples, best_params); + + clear 'train_samples' + + %% Now test the model + model.vid_ids = vid_ids_devel; + + [~, prediction] = svr_test(valid_labels, valid_samples, model); + + name = sprintf('results_BP4D_devel/AU_%d_static_intensity_shift.mat', au); + + [ accuracies, F1s, corrs, ccc, rms, classes ] = evaluate_regression_results( prediction, valid_labels ); + + save(name, 'model', 'F1s', 'corrs', 'accuracies', 'ccc', 'rms', 'prediction', 'valid_labels'); + + % Go from raw data to the prediction + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + name = sprintf('models/AU_%d_static_intensity_shift.dat', au); + + write_lin_svr(name, means, svs, b); + +end + diff --git a/matlab_version/AU_training/experiments/BP4D/get_balanced_fold.m b/matlab_version/AU_training/experiments/BP4D/get_balanced_fold.m new file mode 100644 index 00000000..521b96de --- /dev/null +++ b/matlab_version/AU_training/experiments/BP4D/get_balanced_fold.m @@ -0,0 +1,21 @@ +function [train_users, dev_users] = get_balanced_fold(BP4D_dir, users, au, prop_test) + + % Extracting the labels + [labels, valid_ids, vid_ids, filenames] = extract_BP4D_labels(BP4D_dir, users, au); + + % the grouping should be done per person + + for f=1:numel(filenames) + filenames{f} = filenames{f}(1:4); + end + + counts = zeros(numel(users),1); + for k=1:numel(users) + counts(k) = sum(cat(1, labels{strcmp(filenames, users{k})})); + end + + [sorted, inds] = sort(counts); + + dev_users = users(inds(1:round(1/prop_test):end)); + train_users = setdiff(users, dev_users); +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_10_dynamic.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_10_dynamic.dat new file mode 100644 index 00000000..2b023a13 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_10_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_10_static.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_10_static.dat new file mode 100644 index 00000000..6ea1e528 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_10_static.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_10_static_intensity.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_10_static_intensity.dat new file mode 100644 index 00000000..381143d1 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_10_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_10_static_intensity_shift.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_10_static_intensity_shift.dat new file mode 100644 index 00000000..381143d1 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_10_static_intensity_shift.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_12_dynamic.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_12_dynamic.dat new file mode 100644 index 00000000..3c340db7 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_12_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_12_static.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_12_static.dat new file mode 100644 index 00000000..a7d47be0 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_12_static.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_12_static_intensity.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_12_static_intensity.dat new file mode 100644 index 00000000..322b3f7b Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_12_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_12_static_intensity_shift.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_12_static_intensity_shift.dat new file mode 100644 index 00000000..322b3f7b Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_12_static_intensity_shift.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_14_dynamic.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_14_dynamic.dat new file mode 100644 index 00000000..6a0b383f Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_14_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_14_static.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_14_static.dat new file mode 100644 index 00000000..ec09ccde Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_14_static.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_14_static_intensity.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_14_static_intensity.dat new file mode 100644 index 00000000..c2a8662c Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_14_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_14_static_intensity_shift.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_14_static_intensity_shift.dat new file mode 100644 index 00000000..c2a8662c Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_14_static_intensity_shift.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_15_dynamic.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_15_dynamic.dat new file mode 100644 index 00000000..59105322 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_15_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_15_static.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_15_static.dat new file mode 100644 index 00000000..71722446 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_15_static.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_17_dynamic.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_17_dynamic.dat new file mode 100644 index 00000000..7a544b14 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_17_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_17_static.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_17_static.dat new file mode 100644 index 00000000..40e5a192 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_17_static.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_17_static_intensity.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_17_static_intensity.dat new file mode 100644 index 00000000..c4a77fdd Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_17_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_17_static_intensity_shift.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_17_static_intensity_shift.dat new file mode 100644 index 00000000..1c6516ab Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_17_static_intensity_shift.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_1_dynamic.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_1_dynamic.dat new file mode 100644 index 00000000..a1c064c6 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_1_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_1_static.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_1_static.dat new file mode 100644 index 00000000..f7da0d28 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_1_static.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_23_dynamic.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_23_dynamic.dat new file mode 100644 index 00000000..f4069928 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_23_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_23_static.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_23_static.dat new file mode 100644 index 00000000..a8b5abbb Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_23_static.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_2_dynamic.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_2_dynamic.dat new file mode 100644 index 00000000..288db4fc Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_2_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_2_static.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_2_static.dat new file mode 100644 index 00000000..f6e94fa6 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_2_static.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_4_dynamic.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_4_dynamic.dat new file mode 100644 index 00000000..67af3a38 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_4_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_4_static.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_4_static.dat new file mode 100644 index 00000000..95bcef64 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_4_static.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_6_dynamic.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_6_dynamic.dat new file mode 100644 index 00000000..d5bf4d30 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_6_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_6_static.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_6_static.dat new file mode 100644 index 00000000..646f107d Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_6_static.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_6_static_intensity.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_6_static_intensity.dat new file mode 100644 index 00000000..4e1a5163 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_6_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_6_static_intensity_shift.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_6_static_intensity_shift.dat new file mode 100644 index 00000000..12ef667d Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_6_static_intensity_shift.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_7_dynamic.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_7_dynamic.dat new file mode 100644 index 00000000..7ea2d0d0 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_7_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/models/AU_7_static.dat b/matlab_version/AU_training/experiments/BP4D/models/AU_7_static.dat new file mode 100644 index 00000000..76da8d3d Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/models/AU_7_static.dat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_10_dynamic.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_10_dynamic.mat new file mode 100644 index 00000000..e6643b15 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_10_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_10_static.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_10_static.mat new file mode 100644 index 00000000..8c13724f Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_10_static.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_10_static_intensity.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_10_static_intensity.mat new file mode 100644 index 00000000..c91740c3 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_10_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_10_static_intensity_shift.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_10_static_intensity_shift.mat new file mode 100644 index 00000000..a541ec70 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_10_static_intensity_shift.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_12_dynamic.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_12_dynamic.mat new file mode 100644 index 00000000..509564f6 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_12_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_12_static.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_12_static.mat new file mode 100644 index 00000000..279b1df2 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_12_static.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_12_static_intensity.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_12_static_intensity.mat new file mode 100644 index 00000000..71c19cf3 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_12_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_12_static_intensity_shift.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_12_static_intensity_shift.mat new file mode 100644 index 00000000..f6cfd460 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_12_static_intensity_shift.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_14_dynamic.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_14_dynamic.mat new file mode 100644 index 00000000..668cfce2 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_14_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_14_static.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_14_static.mat new file mode 100644 index 00000000..eed2cf86 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_14_static.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_14_static_intensity.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_14_static_intensity.mat new file mode 100644 index 00000000..ace61ea2 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_14_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_14_static_intensity_shift.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_14_static_intensity_shift.mat new file mode 100644 index 00000000..a82d591a Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_14_static_intensity_shift.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_15_dynamic.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_15_dynamic.mat new file mode 100644 index 00000000..c97bdae2 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_15_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_15_static.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_15_static.mat new file mode 100644 index 00000000..b3c037c0 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_15_static.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_17_dynamic.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_17_dynamic.mat new file mode 100644 index 00000000..6675737e Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_17_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_17_static.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_17_static.mat new file mode 100644 index 00000000..3f798c22 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_17_static.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_17_static_intensity.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_17_static_intensity.mat new file mode 100644 index 00000000..6f150156 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_17_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_17_static_intensity_shift.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_17_static_intensity_shift.mat new file mode 100644 index 00000000..d9c968cb Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_17_static_intensity_shift.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_1_dynamic.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_1_dynamic.mat new file mode 100644 index 00000000..ce868f85 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_1_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_1_static.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_1_static.mat new file mode 100644 index 00000000..71d39d59 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_1_static.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_23_dynamic.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_23_dynamic.mat new file mode 100644 index 00000000..2fc079b8 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_23_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_23_static.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_23_static.mat new file mode 100644 index 00000000..d03acaba Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_23_static.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_2_dynamic.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_2_dynamic.mat new file mode 100644 index 00000000..5a6b0189 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_2_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_2_static.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_2_static.mat new file mode 100644 index 00000000..eac486ec Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_2_static.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_4_dynamic.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_4_dynamic.mat new file mode 100644 index 00000000..df9cb6cc Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_4_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_4_static.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_4_static.mat new file mode 100644 index 00000000..4a37097b Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_4_static.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_6_dynamic.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_6_dynamic.mat new file mode 100644 index 00000000..b325e1f4 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_6_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_6_static.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_6_static.mat new file mode 100644 index 00000000..8d10da27 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_6_static.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_6_static_intensity.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_6_static_intensity.mat new file mode 100644 index 00000000..851e7255 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_6_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_6_static_intensity_shift.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_6_static_intensity_shift.mat new file mode 100644 index 00000000..d620ca1a Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_6_static_intensity_shift.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_7_dynamic.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_7_dynamic.mat new file mode 100644 index 00000000..5776b1e0 Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_7_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_7_static.mat b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_7_static.mat new file mode 100644 index 00000000..9ce775db Binary files /dev/null and b/matlab_version/AU_training/experiments/BP4D/results_BP4D_devel/AU_7_static.mat differ diff --git a/matlab_version/AU_training/experiments/BP4D/shared_defs.m b/matlab_version/AU_training/experiments/BP4D/shared_defs.m new file mode 100644 index 00000000..15871e7e --- /dev/null +++ b/matlab_version/AU_training/experiments/BP4D/shared_defs.m @@ -0,0 +1,36 @@ +% this is data defined across the experiments (to make sure all of them have same user conventions) + +% Defining which AU's we are extracting (all corrs above 0.5) +all_aus = [1, 2, 4, 6, 7, 10, 12, 14, 15, 17, 23]; +aus = [1, 2, 4, 6, 7, 10, 12, 14, 15, 17, 23]; + +all_aus_int = [6, 10, 12, 14, 17]; + +% load all of the data together (for efficiency) +% it will be split up accordingly at later stages +if(exist('C:\tadas\face_datasets\fera_2015\bp4d\AUCoding/', 'file')) + BP4D_dir = 'C:\tadas\face_datasets\fera_2015\bp4d\AUCoding/'; + BP4D_dir_int = 'C:\tadas\face_datasets\fera_2015\bp4d\AU Intensity Codes3.0/'; +elseif(exist('E:\datasets\FERA_2015\BP4D\AUCoding/', 'file')) + BP4D_dir = 'E:\datasets\FERA_2015\BP4D\AUCoding/'; + BP4D_dir_int = 'E:\datasets\FERA_2015\BP4D\AU Intensity Codes3.0/'; +elseif(exist('D:\datasets\face_datasets\fera_2015\bp4d\AUCoding/','file')) + BP4D_dir = 'D:\datasets\face_datasets\fera_2015\bp4d\AUCoding/'; + BP4D_dir_int = 'D:\datasets\face_datasets\fera_2015\bp4d\AU Intensity Codes3.0/'; +elseif(exist('D:\Datasets\FERA_2015\BP4D\AUCoding/','file')) + BP4D_dir = 'D:\Datasets\FERA_2015\BP4D\AUCoding/'; + BP4D_dir_int = 'D:\Datasets\FERA_2015\BP4D\AU Intensity Codes3.0/'; +elseif(exist('I:\datasets\FERA_2015\BP4D\AUCoding/', 'file')) + BP4D_dir = 'I:\datasets\FERA_2015\BP4D\AUCoding/'; + BP4D_dir_int = 'I:\datasets\FERA_2015\BP4D\AU Intensity Codes3.0/'; +else + fprintf('BP4D location not found (or not defined)\n'); +end + +if(exist('BP4D_dir', 'var')) + hog_data_dir = [BP4D_dir, '../processed_data/']; +end + +train_recs = {'F001', 'F003', 'F005', 'F007', 'F009', 'F011', 'F013', 'F015', 'F017', 'F019', 'F021', 'F023', 'M001', 'M003', 'M005', 'M007', 'M009', 'M011', 'M013', 'M015' 'M017'}; +devel_recs = {'F002', 'F004', 'F006', 'F008', 'F010', 'F012', 'F014', 'F016', 'F018', 'F020', 'F022', 'M002', 'M004', 'M006', 'M008', 'M010', 'M012', 'M014', 'M016', 'M018'}; + diff --git a/matlab_version/AU_training/experiments/Bosphorus/Prepare_HOG_AU_data.m b/matlab_version/AU_training/experiments/Bosphorus/Prepare_HOG_AU_data.m new file mode 100644 index 00000000..a8c4e83b --- /dev/null +++ b/matlab_version/AU_training/experiments/Bosphorus/Prepare_HOG_AU_data.m @@ -0,0 +1,119 @@ +function [data_train, labels_train, data_devel, labels_devel, raw_devel, PC, means_norm, stds_norm, devel_ids, devel_success] = ... + Prepare_HOG_AU_data(train_users, devel_users, au_train, rest_aus, Bosphorus_dir, hog_data_dir) + +%% +addpath(genpath('../data extraction/')); + +% First extracting the labels +[ labels_train, valid_ids_train, filenames ] = extract_Bosphorus_labels(Bosphorus_dir, train_users, au_train); + +[ labels_other, ~, ~ ] = extract_Bosphorus_labels(Bosphorus_dir, train_users, rest_aus); + +% Reading in the HOG data (of only relevant frames) +[train_appearance_data, valid_ids_train_hog, vid_ids_train_string] = Read_HOG_files(filenames, [hog_data_dir, '/hog_aligned_rigid_b']); + +params_data_dir = [hog_data_dir, '/model_params_b']; +[train_geom_data] = Read_geom_files(filenames, params_data_dir); + +% Subsample the data to rebalance it +if(numel(train_users) > 0) + reduced_inds = false(size(labels_train,1),1); + reduced_inds(labels_train > 0) = true; + + % make sure the same number of positive and negative samples is taken + pos_count = sum(labels_train > 0); + neg_count = sum(labels_train == 0); + + num_other = floor( pos_count / (size(labels_other, 2))); + + inds_all = 1:size(labels_train,1); + + for i=1:size(labels_other, 2)+1 + + if(i > size(labels_other, 2)) + % fill the rest with a proportion of neutral + inds_other = inds_all(sum(labels_other,2)==0 & ~labels_train ); + num_other_i = min(numel(inds_other), pos_count - sum(labels_train(reduced_inds,:)==0)); + else + % take a proportion of each other AU + inds_other = inds_all(labels_other(:, i) & ~labels_train ); + num_other_i = min(numel(inds_other), num_other); + end + inds_other_to_keep = inds_other(round(linspace(1, numel(inds_other), num_other_i))); + reduced_inds(inds_other_to_keep) = true; + + end + + % Remove invalid ids based on CLM failing or AU not being labelled + reduced_inds(~valid_ids_train) = false; + reduced_inds(~valid_ids_train_hog) = false; + + labels_other = labels_other(reduced_inds, :); + labels_train = labels_train(reduced_inds,:); + train_appearance_data = train_appearance_data(reduced_inds,:); + train_geom_data = train_geom_data(reduced_inds,:); + vid_ids_train_string = vid_ids_train_string(reduced_inds,:); +end +%% Extract devel data + +% First extracting the labels +[ labels_devel, valid_ids_devel, filenames_devel ] = extract_Bosphorus_labels(Bosphorus_dir, devel_users, au_train); + +% Reading in the HOG data (of only relevant frames) +[devel_appearance_data, valid_ids_devel_hog, vid_ids_devel_string] = Read_HOG_files(filenames_devel, [hog_data_dir, '/hog_aligned_rigid_b']); +devel_success = valid_ids_devel_hog; +devel_ids = vid_ids_devel_string; + +[devel_geom_data] = Read_geom_files(filenames_devel, params_data_dir); + +% Peforming zone specific masking +if(au_train < 8 || au_train == 43 || au_train == 45) % upper face AUs ignore bottom face + % normalise the data + pca_file = '../../pca_generation/generic_face_upper.mat'; + load(pca_file); +elseif(au_train > 9) % lower face AUs ignore upper face and the sides + % normalise the data + pca_file = '../../pca_generation/generic_face_lower.mat'; + load(pca_file); +elseif(au_train == 9) % Central face model + % normalise the data + pca_file = '../../pca_generation/generic_face_rigid.mat'; + load(pca_file); +end + +% Grab all data for validation as want good params for all the data +raw_devel = cat(2, devel_appearance_data, devel_geom_data); + +devel_appearance_data = bsxfun(@times, bsxfun(@plus, devel_appearance_data, -means_norm), 1./stds_norm); + +data_devel = devel_appearance_data * PC; + +data_devel = cat(2, data_devel, devel_geom_data); + +valid_ids_devel = valid_ids_devel & devel_success; +data_devel = data_devel(valid_ids_devel,:); +labels_devel = labels_devel(valid_ids_devel,:); +raw_devel = raw_devel(valid_ids_devel,:); +devel_success = devel_success(valid_ids_devel,:); +devel_ids = devel_ids(valid_ids_devel); + +if(numel(train_users) > 0) + train_appearance_data = bsxfun(@times, bsxfun(@plus, train_appearance_data, -means_norm), 1./stds_norm); + + data_train = train_appearance_data * PC; + data_train = cat(2, data_train, train_geom_data); +else + data_train = []; +end + +geom_size = max(size(train_geom_data, 2), size(devel_geom_data, 2)); + +PC_n = zeros(size(PC)+geom_size); +PC_n(1:size(PC,1), 1:size(PC,2)) = PC; +PC_n(size(PC,1)+1:end, size(PC,2)+1:end) = eye(geom_size); +PC = PC_n; + +means_norm = cat(2, means_norm, zeros(1, geom_size)); +stds_norm = cat(2, stds_norm, ones(1, geom_size)); + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/Bosphorus/Prepare_HOG_AU_data_dynamic.m b/matlab_version/AU_training/experiments/Bosphorus/Prepare_HOG_AU_data_dynamic.m new file mode 100644 index 00000000..a6a877ee --- /dev/null +++ b/matlab_version/AU_training/experiments/Bosphorus/Prepare_HOG_AU_data_dynamic.m @@ -0,0 +1,118 @@ +function [data_train, labels_train, data_devel, labels_devel, raw_devel, PC, means_norm, stds_norm, devel_ids, devel_success] = ... + Prepare_HOG_AU_data_dynamic(train_users, devel_users, au_train, rest_aus, Bosphorus_dir, hog_data_dir) + +%% +addpath(genpath('../data extraction/')); + +% First extracting the labels +[ labels_train, valid_ids_train, filenames ] = extract_Bosphorus_labels(Bosphorus_dir, train_users, au_train); + +[ labels_other, ~, ~ ] = extract_Bosphorus_labels(Bosphorus_dir, train_users, rest_aus); + +% Reading in the HOG data (of only relevant frames) +[train_appearance_data, valid_ids_train_hog, vid_ids_train_string] = Read_HOG_files_dynamic(filenames, [hog_data_dir, '/hog_aligned_rigid_b']); + +params_data_dir = [hog_data_dir, '/model_params_b']; +[train_geom_data] = Read_geom_files_dynamic(filenames, params_data_dir); + +if(numel(train_users) > 0) + reduced_inds = false(size(labels_train,1),1); + reduced_inds(labels_train > 0) = true; + + % make sure the same number of positive and negative samples is taken + pos_count = sum(labels_train > 0); + neg_count = sum(labels_train == 0); + + num_other = floor( pos_count / (size(labels_other, 2))); + + inds_all = 1:size(labels_train,1); + + for i=1:size(labels_other, 2)+1 + + if(i > size(labels_other, 2)) + % fill the rest with a proportion of neutral + inds_other = inds_all(sum(labels_other,2)==0 & ~labels_train ); + num_other_i = min(numel(inds_other), pos_count - sum(labels_train(reduced_inds,:)==0)); + else + % take a proportion of each other AU + inds_other = inds_all(labels_other(:, i) & ~labels_train ); + num_other_i = min(numel(inds_other), num_other); + end + inds_other_to_keep = inds_other(round(linspace(1, numel(inds_other), num_other_i))); + reduced_inds(inds_other_to_keep) = true; + + end + + % Remove invalid ids based on CLM failing or AU not being labelled + reduced_inds(~valid_ids_train) = false; + reduced_inds(~valid_ids_train_hog) = false; + + labels_other = labels_other(reduced_inds, :); + labels_train = labels_train(reduced_inds,:); + train_appearance_data = train_appearance_data(reduced_inds,:); + train_geom_data = train_geom_data(reduced_inds,:); + vid_ids_train_string = vid_ids_train_string(reduced_inds,:); +end +%% Extract devel data + +% First extracting the labels +[ labels_devel, valid_ids_devel, devel_files ] = extract_Bosphorus_labels(Bosphorus_dir, devel_users, au_train); + +% Reading in the HOG data (of only relevant frames) +[devel_appearance_data, valid_ids_devel_hog, vid_ids_devel_string] = Read_HOG_files_dynamic(devel_files, [hog_data_dir, '/hog_aligned_rigid_b']); +devel_success = valid_ids_devel_hog; +devel_ids = vid_ids_devel_string; + +[devel_geom_data] = Read_geom_files_dynamic(devel_files, params_data_dir); + +% Peforming zone specific masking +if(au_train < 8 || au_train == 43 || au_train == 45) % upper face AUs ignore bottom face + % normalise the data + pca_file = '../../pca_generation/generic_face_upper.mat'; + load(pca_file); +elseif(au_train > 9) % lower face AUs ignore upper face and the sides + % normalise the data + pca_file = '../../pca_generation/generic_face_lower.mat'; + load(pca_file); +elseif(au_train == 9) % Central face model + % normalise the data + pca_file = '../../pca_generation/generic_face_rigid.mat'; + load(pca_file); +end + +% Grab all data for validation as want good params for all the data +raw_devel = cat(2, devel_appearance_data, devel_geom_data); + +devel_appearance_data = bsxfun(@times, bsxfun(@plus, devel_appearance_data, -means_norm), 1./stds_norm); + +data_devel = devel_appearance_data * PC; + +data_devel = cat(2, data_devel, devel_geom_data); + +valid_ids_devel = valid_ids_devel & devel_success; +data_devel = data_devel(valid_ids_devel,:); +labels_devel = labels_devel(valid_ids_devel,:); +raw_devel = raw_devel(valid_ids_devel,:); +devel_success = devel_success(valid_ids_devel,:); +devel_ids = devel_ids(valid_ids_devel); + +if(numel(train_users) > 0) + train_appearance_data = bsxfun(@times, bsxfun(@plus, train_appearance_data, -means_norm), 1./stds_norm); + + data_train = train_appearance_data * PC; + data_train = cat(2, data_train, train_geom_data); +else + data_train = []; +end + +geom_size = max(size(train_geom_data, 2), size(devel_geom_data, 2)); + +PC_n = zeros(size(PC)+geom_size); +PC_n(1:size(PC,1), 1:size(PC,2)) = PC; +PC_n(size(PC,1)+1:end, size(PC,2)+1:end) = eye(geom_size); +PC = PC_n; + +means_norm = cat(2, means_norm, zeros(1, geom_size)); +stds_norm = cat(2, stds_norm, ones(1, geom_size)); + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/Bosphorus/Read_HOG_files.m b/matlab_version/AU_training/experiments/Bosphorus/Read_HOG_files.m new file mode 100644 index 00000000..3d9acc76 --- /dev/null +++ b/matlab_version/AU_training/experiments/Bosphorus/Read_HOG_files.m @@ -0,0 +1,89 @@ +function [hog_data, valid_data, vid_id] = Read_HOG_files(users, hog_data_dir) + + + hog_data = []; + vid_id = {}; + valid_data = []; + + feats_filled = 0; + + for i=1:numel(users) + + hog_file =[hog_data_dir, '/' users{i} '.hog']; + + f = fopen(hog_file, 'r'); + + curr_data = []; + curr_ind = 0; + + while(~feof(f)) + + if(curr_ind == 0) + num_cols = fread(f, 1, 'int32'); + if(isempty(num_cols)) + break; + end + + num_rows = fread(f, 1, 'int32'); + num_chan = fread(f, 1, 'int32'); + + curr_ind = curr_ind + 1; + + % preallocate some space + if(curr_ind == 1) + curr_data = zeros(5000, 1 + num_rows * num_cols * num_chan); + num_feats = 1 + num_rows * num_cols * num_chan; + end + + if(curr_ind > size(curr_data,1)) + curr_data = cat(1, curr_data, zeros(6000, 1 + num_rows * num_cols * num_chan)); + end + feature_vec = fread(f, [1, 1 + num_rows * num_cols * num_chan], 'float32'); + curr_data(curr_ind, :) = feature_vec; + else + + % Reading in batches of 5000 + feature_vec = fread(f, [4 + num_rows * num_cols * num_chan, 5000], 'float32'); + feature_vec = feature_vec(4:end,:)'; + + if(isempty(feature_vec)) + continue + end + + num_rows_read = size(feature_vec,1); + + curr_data(curr_ind+1:curr_ind+num_rows_read,:) = feature_vec; + + curr_ind = curr_ind + size(feature_vec,1); + + end + end + fclose(f); + + curr_data = curr_data(1:curr_ind,:); + vid_id_curr = cell(curr_ind,1); + vid_id_curr(:) = users(i); + + vid_id = cat(1, vid_id, vid_id_curr); + + % Assume same number of frames per video + if(i==1) + hog_data = zeros(curr_ind*numel(users), num_feats); + end + + if(size(hog_data,1) < feats_filled+curr_ind) + hog_data = cat(1, hog_data, zeros(size(hog_data,1), num_feats)); + end + + hog_data(feats_filled+1:feats_filled+curr_ind,:) = curr_data; + + feats_filled = feats_filled + curr_ind; + + end + + if(numel(users) > 0) + valid_data = hog_data(1:feats_filled,1) > 0; + hog_data = hog_data(1:feats_filled,2:end); + end + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/Bosphorus/Read_HOG_files_dynamic.m b/matlab_version/AU_training/experiments/Bosphorus/Read_HOG_files_dynamic.m new file mode 100644 index 00000000..0e0182f8 --- /dev/null +++ b/matlab_version/AU_training/experiments/Bosphorus/Read_HOG_files_dynamic.m @@ -0,0 +1,101 @@ +function [hog_data, valid_data, vid_id] = Read_HOG_files_dynamic(users, hog_data_dir) + + + hog_data = []; + vid_id = {}; + valid_data = []; + + user_files = []; + + feats_filled = 0; + + for i=1:numel(users) + + hog_file = [hog_data_dir, '/' users{i} '.hog']; + + user_files = cat(1, user_files, str2num(users{i}(3:5))); + + f = fopen(hog_file, 'r'); + + curr_data = []; + curr_ind = 0; + + while(~feof(f)) + + if(curr_ind == 0) + num_cols = fread(f, 1, 'int32'); + if(isempty(num_cols)) + break; + end + + num_rows = fread(f, 1, 'int32'); + num_chan = fread(f, 1, 'int32'); + + curr_ind = curr_ind + 1; + + % preallocate some space + if(curr_ind == 1) + curr_data = zeros(5000, 1 + num_rows * num_cols * num_chan); + num_feats = 1 + num_rows * num_cols * num_chan; + end + + if(curr_ind > size(curr_data,1)) + curr_data = cat(1, curr_data, zeros(6000, 1 + num_rows * num_cols * num_chan)); + end + feature_vec = fread(f, [1, 1 + num_rows * num_cols * num_chan], 'float32'); + curr_data(curr_ind, :) = feature_vec; + else + + % Reading in batches of 5000 + + feature_vec = fread(f, [4 + num_rows * num_cols * num_chan, 5000], 'float32'); + feature_vec = feature_vec(4:end,:)'; + + if(isempty(feature_vec)) + continue; + end + + num_rows_read = size(feature_vec,1); + + curr_data(curr_ind+1:curr_ind+num_rows_read,:) = feature_vec; + + curr_ind = curr_ind + size(feature_vec,1); + + end + + end + + fclose(f); + + curr_data = curr_data(1:curr_ind,:); + vid_id_curr = cell(curr_ind,1); + vid_id_curr(:) = users(i); + + vid_id = cat(1, vid_id, vid_id_curr); + + % Assume same number of frames per video + if(i==1) + hog_data = zeros(curr_ind*numel(users), num_feats); + end + + if(size(hog_data,1) < feats_filled+curr_ind) + hog_data = cat(1, hog_data, zeros(size(hog_data,1), num_feats)); + end + + hog_data(feats_filled+1:feats_filled+curr_ind,:) = curr_data; + + feats_filled = feats_filled + curr_ind; + + end + + if(numel(users) > 0) + valid_data = hog_data(:,1) > 0; + hog_data = hog_data(:,2:end); + + uq_ids = unique(user_files)'; + + for u=uq_ids + hog_data(user_files==u,:) = bsxfun(@plus, hog_data(user_files==u,:), -median( hog_data(valid_data & user_files==u,:))); + end + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/Bosphorus/Read_geom_files.m b/matlab_version/AU_training/experiments/Bosphorus/Read_geom_files.m new file mode 100644 index 00000000..902f203e --- /dev/null +++ b/matlab_version/AU_training/experiments/Bosphorus/Read_geom_files.m @@ -0,0 +1,25 @@ +function [geom_data, valid_ids] = Read_geom_files(users, model_param_data_dir) + + geom_data = []; + valid_ids = []; + + load('../../pca_generation/pdm_68_aligned_wild.mat'); + + for i=1:numel(users) + + geom_file = [model_param_data_dir, '/' users{i} '.txt']; + + res = dlmread(geom_file, ',', 1, 0); + + valid = res(:, 4); + res = res(:, 11:end); + + actual_locs = res * V'; + res = cat(2, actual_locs, res); + + valid_ids = cat(1, valid_ids, valid); + + geom_data = cat(1, geom_data, res); + + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/Bosphorus/Read_geom_files_dynamic.m b/matlab_version/AU_training/experiments/Bosphorus/Read_geom_files_dynamic.m new file mode 100644 index 00000000..d4062833 --- /dev/null +++ b/matlab_version/AU_training/experiments/Bosphorus/Read_geom_files_dynamic.m @@ -0,0 +1,42 @@ +function [geom_data, valid_ids] = Read_geom_files_dynamic(users, model_param_data_dir) + + geom_data = []; + valid_ids = []; + + load('../../pca_generation/pdm_68_aligned_wild.mat'); + + user_files = []; + + for i=1:numel(users) + + geom_file = [model_param_data_dir, '/' users{i} '.txt']; + + user_files = cat(1, user_files, str2num(users{i}(3:5))); + + m_file = [model_param_data_dir, '/', users{i}, '.mat']; + + res = dlmread(geom_file, ',', 1, 0); + + valid = res(:, 4); + res = res(:, 11:end); + + actual_locs = res * V'; + res = cat(2, actual_locs, res); + + valid_ids = cat(1, valid_ids, valid); + + geom_data_curr_p = res; + + geom_data = cat(1, geom_data, geom_data_curr_p); + + end + + if(numel(users) > 0) + uq_ids = unique(user_files)'; + + for u=uq_ids + geom_data(user_files==u,:) = bsxfun(@plus, geom_data(user_files==u,:), -median( geom_data(valid_ids & user_files==u,:))); + end + end + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/Bosphorus/Script_HOG_SVM_train.m b/matlab_version/AU_training/experiments/Bosphorus/Script_HOG_SVM_train.m new file mode 100644 index 00000000..735e0a77 --- /dev/null +++ b/matlab_version/AU_training/experiments/Bosphorus/Script_HOG_SVM_train.m @@ -0,0 +1,80 @@ +function Script_HOG_SVM_train() + +% Change to your downloaded location +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); +%% load shared definitions and AU data +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-9:0.5:1); +hyperparams.e = 10.^(-3); + +hyperparams.validate_params = {'c', 'e'}; + +% Set the training function +svm_train = @svm_train_linear; + +% Set the test function (the first output will be used for validation) +svm_test = @svm_test_linear; + +%% +for a=1:numel(aus) + + au = aus(a); + + rest_aus = setdiff(all_aus, au); + + [users_train, users_valid] = get_balanced_fold(Bosphorus_dir, all_recs, au, 1/3, 1); + + % load the training and testing data for the current fold + [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling] = Prepare_HOG_AU_data(users_train, users_valid, au, rest_aus, Bosphorus_dir, hog_data_dir); + + % Binarizing the data + train_labels(train_labels > 1) = 1; + valid_labels(valid_labels > 1) = 1; + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + + %% Cross-validate here + [ best_params, ~ ] = validate_grid_search_no_par(svm_train, svm_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + + model = svm_train(train_labels, train_samples, best_params); + + [prediction, a, actual_vals] = predict(valid_labels, valid_samples, model); + + % Go from raw data to the prediction + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + name = sprintf('models/AU_%d_static.dat', au); + + pos_lbl = model.Label(1); + neg_lbl = model.Label(2); + + write_lin_svm(name, means, svs, b, pos_lbl, neg_lbl); + + name = sprintf('results_Bosphorus_devel/AU_%d_static.mat', au); + + tp = sum(valid_labels == 1 & prediction == 1); + fp = sum(valid_labels == 0 & prediction == 1); + fn = sum(valid_labels == 1 & prediction == 0); + tn = sum(valid_labels == 0 & prediction == 0); + + precision = tp/(tp+fp); + recall = tp/(tp+fn); + + f1 = 2 * precision * recall / (precision + recall); + + save(name, 'model', 'f1', 'precision', 'recall', 'best_params', 'valid_labels', 'prediction', 'users_valid'); + +end + +end + + diff --git a/matlab_version/AU_training/experiments/Bosphorus/Script_HOG_SVM_train_dyn.m b/matlab_version/AU_training/experiments/Bosphorus/Script_HOG_SVM_train_dyn.m new file mode 100644 index 00000000..507bd5d0 --- /dev/null +++ b/matlab_version/AU_training/experiments/Bosphorus/Script_HOG_SVM_train_dyn.m @@ -0,0 +1,83 @@ +function Script_HOG_SVM_train_dyn() + +% Change to your downloaded location +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); + +%% load shared definitions and AU data +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-9:0.5:1); +hyperparams.e = 10.^(-3); + +hyperparams.validate_params = {'c', 'e'}; + +% Set the training function +svm_train = @svm_train_linear; + +% Set the test function (the first output will be used for validation) +svm_test = @svm_test_linear; + +pca_loc = '../../pca_generation/generic_face_rigid.mat'; + +%% +for a=1:numel(aus) + + au = aus(a); + + rest_aus = setdiff(all_aus, au); + + [users_train, users_valid] = get_balanced_fold(Bosphorus_dir, all_recs, au, 1/3, 1); + + % load the training and testing data for the current fold + [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling] = Prepare_HOG_AU_data_dynamic(users_train, users_valid, au, rest_aus, Bosphorus_dir, hog_data_dir); + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + + % Binarizing the data + train_labels(train_labels > 1) = 1; + valid_labels(valid_labels > 1) = 1; + + %% Cross-validate here + [ best_params, ~ ] = validate_grid_search_no_par(svm_train, svm_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + + model = svm_train(train_labels, train_samples, best_params); + + [prediction, a, actual_vals] = predict(valid_labels, valid_samples, model); + + % Go from raw data to the prediction + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + name = sprintf('models/AU_%d_dyn.dat', au); + + pos_lbl = model.Label(1); + neg_lbl = model.Label(2); + + write_lin_dyn_svm(name, means, svs, b, pos_lbl, neg_lbl); + + name = sprintf('results_Bosphorus_devel/AU_%d_dyn.mat', au); + + tp = sum(valid_labels == 1 & prediction == 1); + fp = sum(valid_labels == 0 & prediction == 1); + fn = sum(valid_labels == 1 & prediction == 0); + tn = sum(valid_labels == 0 & prediction == 0); + + precision = tp/(tp+fp); + recall = tp/(tp+fn); + + f1 = 2 * precision * recall / (precision + recall); + + save(name, 'model', 'f1', 'precision', 'recall', 'best_params', 'valid_labels', 'prediction', 'users_valid'); + +end + +end + + diff --git a/matlab_version/AU_training/experiments/Bosphorus/Script_HOG_SVR_train.m b/matlab_version/AU_training/experiments/Bosphorus/Script_HOG_SVR_train.m new file mode 100644 index 00000000..efde2c63 --- /dev/null +++ b/matlab_version/AU_training/experiments/Bosphorus/Script_HOG_SVR_train.m @@ -0,0 +1,68 @@ +function Script_HOG_SVR_train() + +% Change to your downloaded location +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); + +%% load shared definitions and AU data +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-7:1:4); +hyperparams.p = 10.^(-2); + +hyperparams.validate_params = {'c', 'p'}; + +% Set the training function +svr_train = @svr_train_linear; + +% Set the test function (the first output will be used for validation) +svr_test = @svr_test_linear; + +%% +for a=1:numel(aus) + + au = aus(a); + + rest_aus = setdiff(all_aus, au); + + [users_train, users_valid] = get_balanced_fold(Bosphorus_dir, all_recs, au, 1/3, 1); + + % load the training and testing data for the current fold + [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data(users_train, users_valid, au, rest_aus, Bosphorus_dir, hog_data_dir); + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + + hyperparams.success = valid_success; + + %% Cross-validate here + [ best_params, ~ ] = validate_grid_search_no_par(svr_train, svr_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + + model = svr_train(train_labels, train_samples, best_params); + + [~, prediction] = svr_test(valid_labels, valid_samples, model); + + % Go from raw data to the prediction + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + name = sprintf('models/AU_%d_static_intensity.dat', au); + + write_lin_svr(name, means, svs, b); + + name = sprintf('results_Bosphorus_devel/AU_%d_static_intensity.mat', au); + + [ accuracies, F1s, corrs, ccc, rms, classes ] = evaluate_regression_results( prediction, valid_labels ); + + save(name, 'model', 'F1s', 'corrs', 'accuracies', 'ccc', 'rms', 'prediction', 'valid_labels', 'users_valid'); + +end + +end + + diff --git a/matlab_version/AU_training/experiments/Bosphorus/Script_HOG_SVR_train_dyn.m b/matlab_version/AU_training/experiments/Bosphorus/Script_HOG_SVR_train_dyn.m new file mode 100644 index 00000000..287a8e5b --- /dev/null +++ b/matlab_version/AU_training/experiments/Bosphorus/Script_HOG_SVR_train_dyn.m @@ -0,0 +1,68 @@ +function Script_HOG_SVR_train_dyn() + +% Change to your downloaded location +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); + +%% load shared definitions and AU data +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-7:1:4); +hyperparams.p = 10.^(-2); + +hyperparams.validate_params = {'c', 'p'}; + +% Set the training function +svr_train = @svr_train_linear; + +% Set the test function (the first output will be used for validation) +svr_test = @svr_test_linear; + +%% +for a=1:numel(aus) + + au = aus(a); + + rest_aus = setdiff(all_aus, au); + + [users_train, users_valid] = get_balanced_fold(Bosphorus_dir, all_recs, au, 1/3, 1); + + % load the training and testing data for the current fold + [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data_dynamic(users_train, users_valid, au, rest_aus, Bosphorus_dir, hog_data_dir); + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + + hyperparams.success = valid_success; + + %% Cross-validate here + [ best_params, ~ ] = validate_grid_search_no_par(svr_train, svr_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + + model = svr_train(train_labels, train_samples, best_params); + + [~, prediction] = svr_test(valid_labels, valid_samples, model); + + % Go from raw data to the prediction + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + name = sprintf('models/AU_%d_dyn_intensity.dat', au); + + write_lin_dyn_svr(name, means, svs, b); + + name = sprintf('results_Bosphorus_devel/AU_%d_dyn_intensity.mat', au); + + [ accuracies, F1s, corrs, ccc, rms, classes ] = evaluate_regression_results( prediction, valid_labels ); + + save(name, 'model', 'F1s', 'corrs', 'accuracies', 'ccc', 'rms', 'prediction', 'valid_labels', 'users_valid'); + +end + +end + + diff --git a/matlab_version/AU_training/experiments/Bosphorus/get_balanced_fold.m b/matlab_version/AU_training/experiments/Bosphorus/get_balanced_fold.m new file mode 100644 index 00000000..a7b6be24 --- /dev/null +++ b/matlab_version/AU_training/experiments/Bosphorus/get_balanced_fold.m @@ -0,0 +1,35 @@ +function [train_users, dev_users] = get_balanced_fold(Bosphorus_dir, users, au, prop_test, offset) + + + [ labels_train, valid_ids_train, filenames ] = extract_Bosphorus_labels(Bosphorus_dir, users, au); + + labels_train = labels_train(valid_ids_train,:); + filenames = filenames(valid_ids_train); + + % Shorten the filenames to reflect user id + for i=1:numel(filenames) + filenames{i} = filenames{i}(1:5); + end + + counts = zeros(numel(users),1); + for k=1:numel(users) + counts(k) = sum(labels_train(strcmp(filenames, users{k}))>0); + end + + [sorted, inds] = sort(counts); + + dev_users = users(inds(offset:round(1/prop_test):end)); + train_users = setdiff(users, dev_users); + + count_dev = 0; + count_train = 0; + for k=1:numel(users) + if(any(strcmp(dev_users, users{k}))) + count_dev = count_dev + counts(k); + else + count_train = count_train + counts(k); + end + + end + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_10_dyn.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_10_dyn.dat new file mode 100644 index 00000000..dda21333 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_10_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_10_dyn_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_10_dyn_intensity.dat new file mode 100644 index 00000000..b8759d03 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_10_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_10_static.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_10_static.dat new file mode 100644 index 00000000..851cfe8e Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_10_static.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_10_static_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_10_static_intensity.dat new file mode 100644 index 00000000..92d7e79c Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_10_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_12_dyn.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_12_dyn.dat new file mode 100644 index 00000000..ffec6b38 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_12_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_12_dyn_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_12_dyn_intensity.dat new file mode 100644 index 00000000..abb8a8b2 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_12_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_12_static.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_12_static.dat new file mode 100644 index 00000000..421c79a9 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_12_static.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_12_static_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_12_static_intensity.dat new file mode 100644 index 00000000..c2b9901b Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_12_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_14_dyn.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_14_dyn.dat new file mode 100644 index 00000000..f9697e5f Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_14_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_14_dyn_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_14_dyn_intensity.dat new file mode 100644 index 00000000..fada0498 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_14_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_14_static.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_14_static.dat new file mode 100644 index 00000000..cfb1bbf6 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_14_static.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_14_static_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_14_static_intensity.dat new file mode 100644 index 00000000..66937e8b Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_14_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_15_dyn.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_15_dyn.dat new file mode 100644 index 00000000..b40f5def Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_15_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_15_dyn_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_15_dyn_intensity.dat new file mode 100644 index 00000000..96af31b6 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_15_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_15_static.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_15_static.dat new file mode 100644 index 00000000..ed03a93b Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_15_static.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_15_static_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_15_static_intensity.dat new file mode 100644 index 00000000..8bccef8e Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_15_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_17_dyn.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_17_dyn.dat new file mode 100644 index 00000000..6e457e15 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_17_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_17_dyn_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_17_dyn_intensity.dat new file mode 100644 index 00000000..48a468ec Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_17_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_17_static.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_17_static.dat new file mode 100644 index 00000000..7960d9fa Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_17_static.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_17_static_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_17_static_intensity.dat new file mode 100644 index 00000000..69f406f6 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_17_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_1_dyn.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_1_dyn.dat new file mode 100644 index 00000000..22d20530 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_1_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_1_dyn_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_1_dyn_intensity.dat new file mode 100644 index 00000000..842f8c1e Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_1_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_1_static.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_1_static.dat new file mode 100644 index 00000000..9317afaa Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_1_static.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_1_static_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_1_static_intensity.dat new file mode 100644 index 00000000..15704c72 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_1_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_20_dyn.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_20_dyn.dat new file mode 100644 index 00000000..18664c1b Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_20_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_20_dyn_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_20_dyn_intensity.dat new file mode 100644 index 00000000..683d191b Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_20_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_20_static.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_20_static.dat new file mode 100644 index 00000000..bc17be61 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_20_static.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_20_static_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_20_static_intensity.dat new file mode 100644 index 00000000..657b5fbc Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_20_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_23_dyn.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_23_dyn.dat new file mode 100644 index 00000000..86bd1686 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_23_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_23_dyn_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_23_dyn_intensity.dat new file mode 100644 index 00000000..1e03fb6f Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_23_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_23_static.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_23_static.dat new file mode 100644 index 00000000..b9243ff3 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_23_static.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_23_static_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_23_static_intensity.dat new file mode 100644 index 00000000..646d5e07 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_23_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_25_dyn.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_25_dyn.dat new file mode 100644 index 00000000..ccaf6512 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_25_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_25_dyn_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_25_dyn_intensity.dat new file mode 100644 index 00000000..623e84db Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_25_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_25_static.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_25_static.dat new file mode 100644 index 00000000..47c8c5e5 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_25_static.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_25_static_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_25_static_intensity.dat new file mode 100644 index 00000000..0fe52b38 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_25_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_26_dyn.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_26_dyn.dat new file mode 100644 index 00000000..d3473255 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_26_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_26_dyn_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_26_dyn_intensity.dat new file mode 100644 index 00000000..dc390cd3 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_26_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_26_static.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_26_static.dat new file mode 100644 index 00000000..6f5e9504 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_26_static.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_26_static_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_26_static_intensity.dat new file mode 100644 index 00000000..3e7e2963 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_26_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_2_dyn.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_2_dyn.dat new file mode 100644 index 00000000..53fd6e99 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_2_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_2_dyn_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_2_dyn_intensity.dat new file mode 100644 index 00000000..e4465730 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_2_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_2_static.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_2_static.dat new file mode 100644 index 00000000..5f255442 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_2_static.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_2_static_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_2_static_intensity.dat new file mode 100644 index 00000000..6ca52c7a Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_2_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_43_dyn.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_43_dyn.dat new file mode 100644 index 00000000..14b25da8 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_43_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_43_dyn_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_43_dyn_intensity.dat new file mode 100644 index 00000000..df4a186a Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_43_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_43_static.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_43_static.dat new file mode 100644 index 00000000..f0a02388 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_43_static.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_43_static_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_43_static_intensity.dat new file mode 100644 index 00000000..2d759bec Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_43_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_4_dyn.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_4_dyn.dat new file mode 100644 index 00000000..fe867f8a Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_4_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_4_dyn_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_4_dyn_intensity.dat new file mode 100644 index 00000000..93493207 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_4_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_4_static.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_4_static.dat new file mode 100644 index 00000000..a87867a2 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_4_static.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_4_static_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_4_static_intensity.dat new file mode 100644 index 00000000..6a66f2b8 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_4_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_5_dyn.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_5_dyn.dat new file mode 100644 index 00000000..0db88685 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_5_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_5_dyn_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_5_dyn_intensity.dat new file mode 100644 index 00000000..cf7c9c48 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_5_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_5_static.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_5_static.dat new file mode 100644 index 00000000..edebec7d Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_5_static.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_5_static_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_5_static_intensity.dat new file mode 100644 index 00000000..2e7fd691 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_5_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_6_dyn.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_6_dyn.dat new file mode 100644 index 00000000..404302b6 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_6_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_6_dyn_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_6_dyn_intensity.dat new file mode 100644 index 00000000..407be27c Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_6_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_6_static.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_6_static.dat new file mode 100644 index 00000000..a751f561 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_6_static.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_6_static_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_6_static_intensity.dat new file mode 100644 index 00000000..87835730 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_6_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_7_dyn.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_7_dyn.dat new file mode 100644 index 00000000..e0b81510 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_7_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_7_dyn_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_7_dyn_intensity.dat new file mode 100644 index 00000000..150d0b35 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_7_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_7_static.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_7_static.dat new file mode 100644 index 00000000..e9a42ec3 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_7_static.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_7_static_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_7_static_intensity.dat new file mode 100644 index 00000000..edc7bcc5 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_7_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_9_dyn.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_9_dyn.dat new file mode 100644 index 00000000..16271be6 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_9_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_9_dyn_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_9_dyn_intensity.dat new file mode 100644 index 00000000..c7d64ac2 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_9_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_9_static.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_9_static.dat new file mode 100644 index 00000000..0004015a Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_9_static.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/models/AU_9_static_intensity.dat b/matlab_version/AU_training/experiments/Bosphorus/models/AU_9_static_intensity.dat new file mode 100644 index 00000000..46a63ba8 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/models/AU_9_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_10_dyn.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_10_dyn.mat new file mode 100644 index 00000000..3e47b42d Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_10_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_10_dyn_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_10_dyn_intensity.mat new file mode 100644 index 00000000..d97a19d5 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_10_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_10_static.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_10_static.mat new file mode 100644 index 00000000..1bb9c2bd Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_10_static.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_10_static_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_10_static_intensity.mat new file mode 100644 index 00000000..da7475fa Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_10_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_12_dyn.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_12_dyn.mat new file mode 100644 index 00000000..f317e7af Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_12_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_12_dyn_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_12_dyn_intensity.mat new file mode 100644 index 00000000..f246c416 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_12_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_12_static.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_12_static.mat new file mode 100644 index 00000000..9572ee40 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_12_static.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_12_static_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_12_static_intensity.mat new file mode 100644 index 00000000..ddca8c66 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_12_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_14_dyn.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_14_dyn.mat new file mode 100644 index 00000000..79de7760 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_14_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_14_dyn_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_14_dyn_intensity.mat new file mode 100644 index 00000000..6ff98427 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_14_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_14_static.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_14_static.mat new file mode 100644 index 00000000..ff7050df Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_14_static.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_14_static_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_14_static_intensity.mat new file mode 100644 index 00000000..3a9c64ec Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_14_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_15_dyn.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_15_dyn.mat new file mode 100644 index 00000000..da80d45c Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_15_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_15_dyn_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_15_dyn_intensity.mat new file mode 100644 index 00000000..ddf6f632 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_15_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_15_static.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_15_static.mat new file mode 100644 index 00000000..5a1e1a65 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_15_static.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_15_static_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_15_static_intensity.mat new file mode 100644 index 00000000..2d827acf Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_15_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_17_dyn.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_17_dyn.mat new file mode 100644 index 00000000..921a438e Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_17_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_17_dyn_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_17_dyn_intensity.mat new file mode 100644 index 00000000..55feffd5 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_17_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_17_static.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_17_static.mat new file mode 100644 index 00000000..b0de5365 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_17_static.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_17_static_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_17_static_intensity.mat new file mode 100644 index 00000000..7d40dbe7 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_17_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_1_dyn.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_1_dyn.mat new file mode 100644 index 00000000..3a16e35b Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_1_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_1_dyn_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_1_dyn_intensity.mat new file mode 100644 index 00000000..7bcb8009 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_1_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_1_static.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_1_static.mat new file mode 100644 index 00000000..8d19660d Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_1_static.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_1_static_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_1_static_intensity.mat new file mode 100644 index 00000000..630f7be7 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_1_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_20_dyn.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_20_dyn.mat new file mode 100644 index 00000000..b9eb5af3 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_20_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_20_dyn_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_20_dyn_intensity.mat new file mode 100644 index 00000000..72c9da97 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_20_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_20_static.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_20_static.mat new file mode 100644 index 00000000..a3096e37 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_20_static.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_20_static_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_20_static_intensity.mat new file mode 100644 index 00000000..4c5dffed Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_20_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_23_dyn.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_23_dyn.mat new file mode 100644 index 00000000..d70a417b Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_23_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_23_dyn_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_23_dyn_intensity.mat new file mode 100644 index 00000000..baaf24e9 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_23_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_23_static.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_23_static.mat new file mode 100644 index 00000000..cc542b9a Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_23_static.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_23_static_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_23_static_intensity.mat new file mode 100644 index 00000000..6e84a8f1 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_23_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_25_dyn.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_25_dyn.mat new file mode 100644 index 00000000..24943be7 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_25_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_25_dyn_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_25_dyn_intensity.mat new file mode 100644 index 00000000..5d548040 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_25_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_25_static.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_25_static.mat new file mode 100644 index 00000000..816ae279 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_25_static.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_25_static_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_25_static_intensity.mat new file mode 100644 index 00000000..9e6ce098 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_25_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_26_dyn.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_26_dyn.mat new file mode 100644 index 00000000..834a296b Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_26_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_26_dyn_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_26_dyn_intensity.mat new file mode 100644 index 00000000..b1b77b46 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_26_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_26_static.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_26_static.mat new file mode 100644 index 00000000..0b1290f4 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_26_static.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_26_static_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_26_static_intensity.mat new file mode 100644 index 00000000..db1a2eee Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_26_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_2_dyn.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_2_dyn.mat new file mode 100644 index 00000000..0b62d1e5 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_2_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_2_dyn_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_2_dyn_intensity.mat new file mode 100644 index 00000000..82920f9a Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_2_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_2_static.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_2_static.mat new file mode 100644 index 00000000..fb54b2df Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_2_static.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_2_static_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_2_static_intensity.mat new file mode 100644 index 00000000..90dc17f8 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_2_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_43_dyn.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_43_dyn.mat new file mode 100644 index 00000000..1562c618 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_43_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_43_dyn_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_43_dyn_intensity.mat new file mode 100644 index 00000000..7dbc7a6e Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_43_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_43_static.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_43_static.mat new file mode 100644 index 00000000..b220a8c4 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_43_static.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_43_static_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_43_static_intensity.mat new file mode 100644 index 00000000..33a0413f Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_43_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_4_dyn.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_4_dyn.mat new file mode 100644 index 00000000..f76c0b3a Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_4_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_4_dyn_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_4_dyn_intensity.mat new file mode 100644 index 00000000..55bf470b Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_4_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_4_static.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_4_static.mat new file mode 100644 index 00000000..c29fadf8 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_4_static.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_4_static_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_4_static_intensity.mat new file mode 100644 index 00000000..65f69bf8 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_4_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_5_dyn.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_5_dyn.mat new file mode 100644 index 00000000..1b973fe9 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_5_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_5_dyn_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_5_dyn_intensity.mat new file mode 100644 index 00000000..20916ab3 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_5_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_5_static.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_5_static.mat new file mode 100644 index 00000000..eb69398f Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_5_static.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_5_static_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_5_static_intensity.mat new file mode 100644 index 00000000..9f465f82 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_5_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_6_dyn.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_6_dyn.mat new file mode 100644 index 00000000..690c0665 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_6_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_6_dyn_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_6_dyn_intensity.mat new file mode 100644 index 00000000..70a57e91 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_6_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_6_static.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_6_static.mat new file mode 100644 index 00000000..a8959cc0 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_6_static.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_6_static_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_6_static_intensity.mat new file mode 100644 index 00000000..4a6f7a13 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_6_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_7_dyn.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_7_dyn.mat new file mode 100644 index 00000000..bb2fa720 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_7_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_7_dyn_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_7_dyn_intensity.mat new file mode 100644 index 00000000..f37e5280 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_7_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_7_static.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_7_static.mat new file mode 100644 index 00000000..ace7fc57 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_7_static.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_7_static_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_7_static_intensity.mat new file mode 100644 index 00000000..dc7ecf14 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_7_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_9_dyn.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_9_dyn.mat new file mode 100644 index 00000000..5ac9d6d8 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_9_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_9_dyn_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_9_dyn_intensity.mat new file mode 100644 index 00000000..41fb543b Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_9_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_9_static.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_9_static.mat new file mode 100644 index 00000000..c23acd9d Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_9_static.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_9_static_intensity.mat b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_9_static_intensity.mat new file mode 100644 index 00000000..6707ddc5 Binary files /dev/null and b/matlab_version/AU_training/experiments/Bosphorus/results_Bosphorus_devel/AU_9_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/Bosphorus/shared_defs.m b/matlab_version/AU_training/experiments/Bosphorus/shared_defs.m new file mode 100644 index 00000000..92becc5a --- /dev/null +++ b/matlab_version/AU_training/experiments/Bosphorus/shared_defs.m @@ -0,0 +1,9 @@ +% this is data defined across the experiments (to make sure all of them have same user conventions) + +all_aus = [1, 2, 4, 5, 6, 7, 9, 10, 12, 14, 15, 17, 20, 23, 25, 26, 43]; +aus = [1, 2, 4, 5, 6, 7, 9, 10, 12, 14, 15, 17, 20, 23, 25, 26, 43]; + +addpath('../../data extraction/'); + +find_Bosphorus; + diff --git a/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_12_dyn_shift.mat b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_12_dyn_shift.mat new file mode 100644 index 00000000..cbe7aeac Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_12_dyn_shift.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_15_dyn_shift.mat b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_15_dyn_shift.mat new file mode 100644 index 00000000..6528cd79 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_15_dyn_shift.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_17_dyn_shift.mat b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_17_dyn_shift.mat new file mode 100644 index 00000000..65d56b33 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_17_dyn_shift.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_1_dyn_shift.mat b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_1_dyn_shift.mat new file mode 100644 index 00000000..4b9a5b74 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_1_dyn_shift.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_20_dyn_shift.mat b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_20_dyn_shift.mat new file mode 100644 index 00000000..be89c18a Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_20_dyn_shift.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_25_dyn_shift.mat b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_25_dyn_shift.mat new file mode 100644 index 00000000..b4fd6e06 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_25_dyn_shift.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_26_dyn_shift.mat b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_26_dyn_shift.mat new file mode 100644 index 00000000..f70c1911 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_26_dyn_shift.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_2_dyn_shift.mat b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_2_dyn_shift.mat new file mode 100644 index 00000000..b3e0f92e Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_2_dyn_shift.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_4_dyn_shift.mat b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_4_dyn_shift.mat new file mode 100644 index 00000000..4341e1d7 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_4_dyn_shift.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_5_dyn_shift.mat b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_5_dyn_shift.mat new file mode 100644 index 00000000..c1c69dd5 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_5_dyn_shift.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_6_dyn_shift.mat b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_6_dyn_shift.mat new file mode 100644 index 00000000..cdd67625 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_6_dyn_shift.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_9_dyn_shift.mat b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_9_dyn_shift.mat new file mode 100644 index 00000000..4dfd27a4 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/5_fold_shift/AU_9_dyn_shift.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/Prepare_HOG_AU_data_generic.m b/matlab_version/AU_training/experiments/DISFA/Prepare_HOG_AU_data_generic.m new file mode 100644 index 00000000..cc1213b8 --- /dev/null +++ b/matlab_version/AU_training/experiments/DISFA/Prepare_HOG_AU_data_generic.m @@ -0,0 +1,121 @@ +function [data_train, labels_train, data_test, labels_test, raw_test, PC, means_norm, stds_norm, vid_ids_test, success_test] = ... + Prepare_HOG_AU_data_generic(train_users, test_users, au_train, rest_aus, hog_data_dir) + +%% This should be a separate function? + +input_train_label_files = cell(numel(train_users),1); +input_test_label_files = cell(numel(test_users),1); + +root = [hog_data_dir, '/../']; + +% This is for loading the labels +for i=1:numel(train_users) + input_train_label_files{i} = [root, '/ActionUnit_Labels/', train_users{i}, '/', train_users{i}]; +end + +% This is for loading the labels +for i=1:numel(test_users) + input_test_label_files{i} = [root, '/ActionUnit_Labels/', test_users{i}, '/', test_users{i}]; +end + +% First extracting the labels +[train_geom_data] = Read_geom_files(train_users, hog_data_dir); +[test_geom_data] = Read_geom_files(test_users, hog_data_dir); + +% Reading in the HOG data +[train_data, tracked_inds_hog, vid_ids_train] = Read_HOG_files(train_users, hog_data_dir); +[test_data, success_test, vid_ids_test] = Read_HOG_files(test_users, hog_data_dir); + +train_data = cat(2, train_data, train_geom_data); +raw_test = cat(2, test_data, test_geom_data); + +% Extracting the labels +labels_train = extract_au_labels(input_train_label_files, au_train); +labels_test = extract_au_labels(input_test_label_files, au_train); + +labels_other = zeros(size(labels_train,1), numel(rest_aus)); + +% This is used to pick up activity of other AUs for a more 'interesting' +% data split and not only neutral expressions for negative samples +if(numel(input_train_label_files) > 0) + for i=1:numel(rest_aus) + labels_other(:,i) = extract_au_labels(input_train_label_files, rest_aus(i)); + end + + % can now extract the needed training labels (do not rebalance validation + % data) + + % make sure the same number of positive and negative samples is taken + reduced_inds = false(size(labels_train,1),1); + reduced_inds(labels_train > 0) = true; + + % make sure the same number of positive and negative samples is taken + pos_count = sum(labels_train > 0); + neg_count = sum(labels_train == 0); + + % pos_count = pos_count * 8; + + num_other = floor(pos_count / (size(labels_other, 2))); + + inds_all = 1:size(labels_train,1); + + for i=1:size(labels_other, 2)+1 + + if(i > size(labels_other, 2)) + % fill the rest with a proportion of neutral + inds_other = inds_all(sum(labels_other,2)==0 & ~labels_train); + num_other_i = min(numel(inds_other), pos_count - sum(labels_train(reduced_inds,:)==0)); + else + % take a proportion of each other AU + inds_other = inds_all(labels_other(:, i) & ~labels_train); + num_other_i = min(numel(inds_other), num_other); + end + inds_other_to_keep = inds_other(round(linspace(1, numel(inds_other), num_other_i))); + reduced_inds(inds_other_to_keep) = true; + + end + + % Remove invalid ids based on CLM failing or AU not being labelled + reduced_inds(~tracked_inds_hog) = false; + + labels_train = labels_train(reduced_inds); + train_data = train_data(reduced_inds,:); + +end + +geom_size = max(size(train_geom_data,2), size(test_geom_data,2)); + +% Peforming zone specific masking +if(au_train < 8 || au_train == 43 || au_train == 45) % upper face AUs ignore bottom face + % normalise the data + pca_file = '../../pca_generation/generic_face_upper.mat'; + load(pca_file); +elseif(au_train > 9) % lower face AUs ignore upper face and the sides + % normalise the data + pca_file = '../../pca_generation/generic_face_lower.mat'; + load(pca_file); +elseif(au_train == 9) % Central face model + % normalise the data + pca_file = '../../pca_generation/generic_face_rigid.mat'; + load(pca_file); +end + +PC_n = zeros(size(PC)+geom_size); +PC_n(1:size(PC,1), 1:size(PC,2)) = PC; +PC_n(size(PC,1)+1:end, size(PC,2)+1:end) = eye(geom_size); +PC = PC_n; + +means_norm = cat(2, means_norm, zeros(1, geom_size)); +stds_norm = cat(2, stds_norm, ones(1, geom_size)); + +data_test = bsxfun(@times, bsxfun(@plus, raw_test, -means_norm), 1./stds_norm); +data_test = data_test * PC; + +if(numel(train_data > 0)) + data_train = bsxfun(@times, bsxfun(@plus, train_data, -means_norm), 1./stds_norm); + data_train = data_train * PC; +else + data_train = []; +end + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/DISFA/Prepare_HOG_AU_data_generic_dynamic.m b/matlab_version/AU_training/experiments/DISFA/Prepare_HOG_AU_data_generic_dynamic.m new file mode 100644 index 00000000..39e655bd --- /dev/null +++ b/matlab_version/AU_training/experiments/DISFA/Prepare_HOG_AU_data_generic_dynamic.m @@ -0,0 +1,121 @@ +function [data_train, labels_train, data_test, labels_test, raw_test, PC, means_norm, stds_norm, vid_ids_test, success_test] = ... + Prepare_HOG_AU_data_generic_dynamic(train_users, test_users, au_train, rest_aus, hog_data_dir) + +%% This should be a separate function? + +input_train_label_files = cell(numel(train_users),1); +input_test_label_files = cell(numel(test_users),1); + +root = [hog_data_dir, '/../']; + +% This is for loading the labels +for i=1:numel(train_users) + input_train_label_files{i} = [root, '/ActionUnit_Labels/', train_users{i}, '/', train_users{i}]; +end + +% This is for loading the labels +for i=1:numel(test_users) + input_test_label_files{i} = [root, '/ActionUnit_Labels/', test_users{i}, '/', test_users{i}]; +end + +% First extracting the labels +[train_geom_data] = Read_geom_files_dynamic(train_users, hog_data_dir); +[test_geom_data] = Read_geom_files_dynamic(test_users, hog_data_dir); + +% Reading in the HOG data +[train_data, tracked_inds_hog, vid_ids_train] = Read_HOG_files_dynamic(train_users, hog_data_dir); +[test_data, success_test, vid_ids_test] = Read_HOG_files_dynamic(test_users, hog_data_dir); + +train_data = cat(2, train_data, train_geom_data); +raw_test = cat(2, test_data, test_geom_data); + +% Extracting the labels +labels_train = extract_au_labels(input_train_label_files, au_train); +labels_test = extract_au_labels(input_test_label_files, au_train); + +labels_other = zeros(size(labels_train,1), numel(rest_aus)); + +% This is used to pick up activity of other AUs for a more 'interesting' +% data split and not only neutral expressions for negative samples +if(numel(input_train_label_files) > 0) + for i=1:numel(rest_aus) + labels_other(:,i) = extract_au_labels(input_train_label_files, rest_aus(i)); + end + + % can now extract the needed training labels (do not rebalance validation + % data) + + % make sure the same number of positive and negative samples is taken + reduced_inds = false(size(labels_train,1),1); + reduced_inds(labels_train > 0) = true; + + % make sure the same number of positive and negative samples is taken + pos_count = sum(labels_train > 0); + neg_count = sum(labels_train == 0); + + % pos_count = pos_count * 8; + + num_other = floor(pos_count / (size(labels_other, 2))); + + inds_all = 1:size(labels_train,1); + + for i=1:size(labels_other, 2)+1 + + if(i > size(labels_other, 2)) + % fill the rest with a proportion of neutral + inds_other = inds_all(sum(labels_other,2)==0 & ~labels_train); + num_other_i = min(numel(inds_other), pos_count - sum(labels_train(reduced_inds,:)==0)); + else + % take a proportion of each other AU + inds_other = inds_all(labels_other(:, i) & ~labels_train); + num_other_i = min(numel(inds_other), num_other); + end + inds_other_to_keep = inds_other(round(linspace(1, numel(inds_other), num_other_i))); + reduced_inds(inds_other_to_keep) = true; + + end + + % Remove invalid ids based on CLM failing or AU not being labelled + reduced_inds(~tracked_inds_hog) = false; + + labels_train = labels_train(reduced_inds); + train_data = train_data(reduced_inds,:); + +end + +geom_size = max(size(train_geom_data,2), size(test_geom_data,2)); + +% Peforming zone specific masking +if(au_train < 8 || au_train == 43 || au_train == 45) % upper face AUs ignore bottom face + % normalise the data + pca_file = '../../pca_generation/generic_face_upper.mat'; + load(pca_file); +elseif(au_train > 9) % lower face AUs ignore upper face and the sides + % normalise the data + pca_file = '../../pca_generation/generic_face_lower.mat'; + load(pca_file); +elseif(au_train == 9) % Central face model + % normalise the data + pca_file = '../../pca_generation/generic_face_rigid.mat'; + load(pca_file); +end + +PC_n = zeros(size(PC)+geom_size); +PC_n(1:size(PC,1), 1:size(PC,2)) = PC; +PC_n(size(PC,1)+1:end, size(PC,2)+1:end) = eye(geom_size); +PC = PC_n; + +means_norm = cat(2, means_norm, zeros(1, geom_size)); +stds_norm = cat(2, stds_norm, ones(1, geom_size)); + +data_test = bsxfun(@times, bsxfun(@plus, raw_test, -means_norm), 1./stds_norm); +data_test = data_test * PC; + +if(numel(train_data > 0)) + data_train = bsxfun(@times, bsxfun(@plus, train_data, -means_norm), 1./stds_norm); + data_train = data_train * PC; +else + data_train = []; +end + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/DISFA/Read_HOG_files.m b/matlab_version/AU_training/experiments/DISFA/Read_HOG_files.m new file mode 100644 index 00000000..2e870a64 --- /dev/null +++ b/matlab_version/AU_training/experiments/DISFA/Read_HOG_files.m @@ -0,0 +1,87 @@ +function [hog_data, valid_data, vid_id] = Read_HOG_files(users, hog_data_dir) + + hog_data = []; + vid_id = {}; + valid_data = []; + + feats_filled = 0; + + for i=1:numel(users) + + hog_file = [hog_data_dir, 'LeftVideo' users{i} '_comp.hog']; + + f = fopen(hog_file, 'r'); + + curr_data = []; + curr_ind = 0; + + while(~feof(f)) + + if(curr_ind == 0) + num_cols = fread(f, 1, 'int32'); + if(isempty(num_cols)) + break; + end + + num_rows = fread(f, 1, 'int32'); + num_chan = fread(f, 1, 'int32'); + + curr_ind = curr_ind + 1; + + % preallocate some space + if(curr_ind == 1) + curr_data = zeros(5000, 1 + num_rows * num_cols * num_chan); + num_feats = 1 + num_rows * num_cols * num_chan; + end + + if(curr_ind > size(curr_data,1)) + curr_data = cat(1, curr_data, zeros(6000, 1 + num_rows * num_cols * num_chan)); + end + feature_vec = fread(f, [1, 1 + num_rows * num_cols * num_chan], 'float32'); + curr_data(curr_ind, :) = feature_vec; + else + + % Reading in batches of 5000 + + feature_vec = fread(f, [4 + num_rows * num_cols * num_chan, 5000], 'float32'); + feature_vec = feature_vec(4:end,:)'; + + num_rows_read = size(feature_vec,1); + + curr_data(curr_ind+1:curr_ind+num_rows_read,:) = feature_vec; + + curr_ind = curr_ind + size(feature_vec,1); + + end + + end + + fclose(f); + + curr_data = curr_data(1:curr_ind,:); + + vid_id_curr = cell(curr_ind,1); + vid_id_curr(:) = users(i); + + vid_id = cat(1, vid_id, vid_id_curr); + + % Assume same number of frames per video + if(i==1) + hog_data = zeros(curr_ind*numel(users), num_feats); + end + + if(size(hog_data,1) < feats_filled+curr_ind) + hog_data = cat(1, hog_data, zeros(size(hog_data,1), num_feats)); + end + + hog_data(feats_filled+1:feats_filled+curr_ind,:) = curr_data; + + feats_filled = feats_filled + curr_ind; + + end + + if(numel(users) > 0) + valid_data = hog_data(1:feats_filled,1) > 0; + hog_data = hog_data(1:feats_filled,2:end); + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/DISFA/Read_HOG_files_dynamic.m b/matlab_version/AU_training/experiments/DISFA/Read_HOG_files_dynamic.m new file mode 100644 index 00000000..50ea49a8 --- /dev/null +++ b/matlab_version/AU_training/experiments/DISFA/Read_HOG_files_dynamic.m @@ -0,0 +1,91 @@ +function [hog_data, valid_data, vid_id] = Read_HOG_files_dynamic(users, hog_data_dir) + + hog_data = []; + vid_id = {}; + valid_data = []; + + feats_filled = 0; + + for i=1:numel(users) + + hog_file = [hog_data_dir, 'LeftVideo' users{i} '_comp.hog']; + + f = fopen(hog_file, 'r'); + + curr_data = []; + curr_ind = 0; + + while(~feof(f)) + + if(curr_ind == 0) + num_cols = fread(f, 1, 'int32'); + if(isempty(num_cols)) + break; + end + + num_rows = fread(f, 1, 'int32'); + num_chan = fread(f, 1, 'int32'); + + curr_ind = curr_ind + 1; + + % preallocate some space + if(curr_ind == 1) + curr_data = zeros(5000, 1 + num_rows * num_cols * num_chan); + num_feats = 1 + num_rows * num_cols * num_chan; + end + + if(curr_ind > size(curr_data,1)) + curr_data = cat(1, curr_data, zeros(6000, 1 + num_rows * num_cols * num_chan)); + end + feature_vec = fread(f, [1, 1 + num_rows * num_cols * num_chan], 'float32'); + curr_data(curr_ind, :) = feature_vec; + else + + % Reading in batches of 5000 + + feature_vec = fread(f, [4 + num_rows * num_cols * num_chan, 5000], 'float32'); + feature_vec = feature_vec(4:end,:)'; + + num_rows_read = size(feature_vec,1); + + curr_data(curr_ind+1:curr_ind+num_rows_read,:) = feature_vec; + + curr_ind = curr_ind + size(feature_vec,1); + + end + + end + + fclose(f); + + curr_data = curr_data(1:curr_ind,:); + + valid = logical(curr_data(:, 1)); + + curr_data(:, 2:end) = bsxfun(@plus, curr_data(:, 2:end), -median(curr_data(valid, 2:end))); + + vid_id_curr = cell(curr_ind,1); + vid_id_curr(:) = users(i); + + vid_id = cat(1, vid_id, vid_id_curr); + + % Assume same number of frames per video + if(i==1) + hog_data = zeros(curr_ind*numel(users), num_feats); + end + + if(size(hog_data,1) < feats_filled+curr_ind) + hog_data = cat(1, hog_data, zeros(size(hog_data,1), num_feats)); + end + + hog_data(feats_filled+1:feats_filled+curr_ind,:) = curr_data; + + feats_filled = feats_filled + curr_ind; + + end + + if(numel(users) > 0) + valid_data = hog_data(1:feats_filled,1) > 0; + hog_data = hog_data(1:feats_filled,2:end); + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/DISFA/Read_geom_files.m b/matlab_version/AU_training/experiments/DISFA/Read_geom_files.m new file mode 100644 index 00000000..12c3d555 --- /dev/null +++ b/matlab_version/AU_training/experiments/DISFA/Read_geom_files.m @@ -0,0 +1,24 @@ +function [geom_data] = Read_geom_files(users, hog_data_dir) + + geom_data = []; + + load('../../pca_generation/pdm_68_aligned_wild.mat'); + + for i=1:numel(users) + + geom_file = [hog_data_dir, '/../model_params/LeftVideo' users{i} '_comp.txt']; + + res = dlmread(geom_file, ',', 1, 0); + valid = logical(res(:,4)); + + %res_rot = res(:,6:8); + + res = res(:,11:end); + + actual_locs = res * V'; + res = cat(2, actual_locs, res); + + geom_data = cat(1, geom_data, res); + + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/DISFA/Read_geom_files_dynamic.m b/matlab_version/AU_training/experiments/DISFA/Read_geom_files_dynamic.m new file mode 100644 index 00000000..6689f41f --- /dev/null +++ b/matlab_version/AU_training/experiments/DISFA/Read_geom_files_dynamic.m @@ -0,0 +1,26 @@ +function [geom_data] = Read_geom_files_dynamic(users, hog_data_dir) + + geom_data = []; + + load('../../pca_generation/pdm_68_aligned_wild.mat'); + + for i=1:numel(users) + + geom_file = [hog_data_dir, '/../model_params/LeftVideo' users{i} '_comp.txt']; + + res = dlmread(geom_file, ',', 1, 0); + valid = logical(res(:,4)); + + %res_rot = res(:,6:8); + + res = res(:,11:end); + + actual_locs = res * V'; + res = cat(2, actual_locs, res); + + res = bsxfun(@plus, res, -median(res(valid,:))); + + geom_data = cat(1, geom_data, res); + + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/DISFA/Script_HOG_SVM_train_dyn.m b/matlab_version/AU_training/experiments/DISFA/Script_HOG_SVM_train_dyn.m new file mode 100644 index 00000000..60887f9c --- /dev/null +++ b/matlab_version/AU_training/experiments/DISFA/Script_HOG_SVM_train_dyn.m @@ -0,0 +1,56 @@ +% Change to your downloaded location +clear +addpath('C:\liblinear\matlab') +addpath('../training_code') +addpath('../utilities') + +%% load shared definitions and AU data +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-7:1:1); +hyperparams.e = 10.^(-3); + +hyperparams.validate_params = {'c', 'e'}; + +% Set the training function +svr_train = @svm_train_linear; + +% Set the test function (the first output will be used for validation) +svr_test = @svm_test_linear; + +%% +for a=1:numel(aus) + + au = aus(a); + + rest_aus = setdiff(all_aus, au); + + % make sure validation data's labels are balanced + [users_train, users_valid] = get_balanced_fold(DISFA_dir, users, au, 1/3, 1); + + % need to split the rest + [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data_generic_dynamic(users_train, users_valid, au, rest_aus, hog_data_dir); + + train_labels(train_labels > 1) = 1; + valid_labels(valid_labels > 1) = 1; + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + + %% Validate here + hyperparams.success = valid_success; + + [ best_params, ~ ] = validate_grid_search_no_par(svr_train, svr_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + + model = svr_train(train_labels, train_samples, best_params); + + [~, prediction] = svr_test(valid_labels, valid_samples, model); + + name = sprintf('classifiers/AU_%d_dyn.mat', au); + + [ accuracies, F1s, corrs, ccc, rms, classes ] = evaluate_regression_results( prediction, valid_labels ); + + save(name, 'model', 'accuracies', 'F1s', 'corrs', 'rms', 'ccc', 'prediction', 'valid_labels'); + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/DISFA/Script_HOG_SVM_train_stat.m b/matlab_version/AU_training/experiments/DISFA/Script_HOG_SVM_train_stat.m new file mode 100644 index 00000000..638c6d3f --- /dev/null +++ b/matlab_version/AU_training/experiments/DISFA/Script_HOG_SVM_train_stat.m @@ -0,0 +1,56 @@ +% Change to your downloaded location +clear +addpath('C:\liblinear\matlab') +addpath('../training_code') +addpath('../utilities') + +%% load shared definitions and AU data +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-7:1:1); +hyperparams.e = 10.^(-3); + +hyperparams.validate_params = {'c', 'e'}; + +% Set the training function +svr_train = @svm_train_linear; + +% Set the test function (the first output will be used for validation) +svr_test = @svm_test_linear; + +%% +for a=1:numel(aus) + + au = aus(a); + + rest_aus = setdiff(all_aus, au); + + % make sure validation data's labels are balanced + [users_train, users_valid] = get_balanced_fold(DISFA_dir, users, au, 1/3, 1); + + % need to split the rest + [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data_generic(users_train, users_valid, au, rest_aus, hog_data_dir); + + train_labels(train_labels > 1) = 1; + valid_labels(valid_labels > 1) = 1; + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + + %% Validate here + hyperparams.success = valid_success; + + [ best_params, ~ ] = validate_grid_search_no_par(svr_train, svr_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + + model = svr_train(train_labels, train_samples, best_params); + + [~, prediction] = svr_test(valid_labels, valid_samples, model); + + name = sprintf('classifiers/AU_%d_stat.mat', au); + + [ accuracies, F1s, corrs, ccc, rms, classes ] = evaluate_regression_results( prediction, valid_labels ); + + save(name, 'model', 'accuracies', 'F1s', 'corrs', 'rms', 'ccc', 'prediction', 'valid_labels'); + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/DISFA/Script_HOG_SVR_train_dyn_5_fold_shift.m b/matlab_version/AU_training/experiments/DISFA/Script_HOG_SVR_train_dyn_5_fold_shift.m new file mode 100644 index 00000000..6a3603d0 --- /dev/null +++ b/matlab_version/AU_training/experiments/DISFA/Script_HOG_SVR_train_dyn_5_fold_shift.m @@ -0,0 +1,83 @@ +% Change to your downloaded location +addpath('C:\liblinear\matlab') +addpath('../training_code') +addpath('../utilities') + +num_test_folds = 5; + +%% load shared definitions and AU data +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-7:1:3); +hyperparams.p = 10.^(-2); + +hyperparams.validate_params = {'c', 'p'}; + +% Set the training function +svr_train = @svr_train_linear_shift; + +% Set the test function (the first output will be used for validation) +svr_test = @svr_test_linear_shift; + +test_folds = get_test_folds(num_test_folds, users); + +%% +for a=1:numel(aus) + + au = aus(a); + + prediction_all = []; + test_all = []; + fprintf('Training AU%d ', au); + + for t=1:num_test_folds + + rest_aus = setdiff(all_aus, au); + + % load the training and testing data for the current fold + [~, ~, test_samples, test_labels, ~, ~, ~, ~, test_ids, test_success] = Prepare_HOG_AU_data_generic_dynamic({}, test_folds{t}, au, rest_aus, hog_data_dir); + + % create the training and validation data + users_train = setdiff(users, unique(test_ids)); + % make sure validation data's labels are balanced + [users_train, users_valid] = get_balanced_fold(DISFA_dir, users_train, au, 1/4, 1); + + % need to split the rest + [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data_generic_dynamic(users_train, users_valid, au, rest_aus, hog_data_dir); + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + test_samples = sparse(test_samples); + + %% Cross-validate here + hyperparams.success = valid_success; + hyperparams.valid_samples = valid_samples; + hyperparams.valid_labels = valid_labels; + hyperparams.vid_ids = valid_ids; + + [ best_params, ~ ] = validate_grid_search_no_par(svr_train, svr_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + + model = svr_train(train_labels, train_samples, best_params); + model.success = test_success; + model.success = test_success; + model.vid_ids = test_ids; + + [~, prediction] = svr_test(test_labels, test_samples, model); + + prediction_all = cat(1, prediction_all, prediction); + test_all = cat(1, test_all, test_labels); + fprintf('done fold %d ', t); + end + + fprintf('\n'); + + name = sprintf('5_fold_shift/AU_%d_dyn_shift.mat', au); + + [ accuracies, F1s, corrs, ccc, rms, classes ] = evaluate_regression_results( prediction_all, test_all ); + + save(name, 'model', 'accuracies', 'F1s', 'corrs', 'rms', 'ccc', 'prediction_all', 'test_all'); + +end + + diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_12_dyn.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_12_dyn.mat new file mode 100644 index 00000000..84eba1e0 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_12_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_12_stat.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_12_stat.mat new file mode 100644 index 00000000..41fd362d Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_12_stat.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_15_dyn.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_15_dyn.mat new file mode 100644 index 00000000..78c25433 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_15_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_15_stat.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_15_stat.mat new file mode 100644 index 00000000..1fe9bd57 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_15_stat.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_17_dyn.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_17_dyn.mat new file mode 100644 index 00000000..7a705ac0 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_17_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_17_stat.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_17_stat.mat new file mode 100644 index 00000000..9fe50e9f Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_17_stat.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_1_dyn.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_1_dyn.mat new file mode 100644 index 00000000..5db9f4f0 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_1_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_1_stat.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_1_stat.mat new file mode 100644 index 00000000..6b03f1c0 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_1_stat.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_20_dyn.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_20_dyn.mat new file mode 100644 index 00000000..a35c818b Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_20_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_20_stat.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_20_stat.mat new file mode 100644 index 00000000..b7fb4a4b Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_20_stat.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_25_dyn.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_25_dyn.mat new file mode 100644 index 00000000..10547b50 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_25_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_25_stat.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_25_stat.mat new file mode 100644 index 00000000..cea4d5a6 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_25_stat.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_26_dyn.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_26_dyn.mat new file mode 100644 index 00000000..27c77d10 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_26_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_26_stat.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_26_stat.mat new file mode 100644 index 00000000..e91f6f55 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_26_stat.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_2_dyn.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_2_dyn.mat new file mode 100644 index 00000000..742020bc Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_2_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_2_stat.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_2_stat.mat new file mode 100644 index 00000000..30f14b8a Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_2_stat.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_4_dyn.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_4_dyn.mat new file mode 100644 index 00000000..f81e3931 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_4_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_4_stat.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_4_stat.mat new file mode 100644 index 00000000..76215e02 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_4_stat.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_5_dyn.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_5_dyn.mat new file mode 100644 index 00000000..f69b0632 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_5_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_5_stat.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_5_stat.mat new file mode 100644 index 00000000..e6214c60 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_5_stat.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_6_dyn.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_6_dyn.mat new file mode 100644 index 00000000..629047a3 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_6_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_6_stat.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_6_stat.mat new file mode 100644 index 00000000..81ae18d3 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_6_stat.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_9_dyn.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_9_dyn.mat new file mode 100644 index 00000000..76f1046c Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_9_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/classifiers/AU_9_stat.mat b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_9_stat.mat new file mode 100644 index 00000000..f436d981 Binary files /dev/null and b/matlab_version/AU_training/experiments/DISFA/classifiers/AU_9_stat.mat differ diff --git a/matlab_version/AU_training/experiments/DISFA/extract_au_labels.m b/matlab_version/AU_training/experiments/DISFA/extract_au_labels.m new file mode 100644 index 00000000..19968b16 --- /dev/null +++ b/matlab_version/AU_training/experiments/DISFA/extract_au_labels.m @@ -0,0 +1,16 @@ +function [ labels ] = extract_au_labels( input_folders, au_id) +%EXTRACT_AU_LABELS Summary of this function goes here +% Detailed explanation goes here + + labels = []; + for i=1:numel(input_folders) + + in_file = sprintf('%s_au%d.txt', input_folders{i}, au_id); + + A = dlmread(in_file, ','); + + labels = cat(1, labels, A(:,2)); + end + +end + diff --git a/matlab_version/AU_training/experiments/DISFA/get_balanced_fold.m b/matlab_version/AU_training/experiments/DISFA/get_balanced_fold.m new file mode 100644 index 00000000..1c0359a4 --- /dev/null +++ b/matlab_version/AU_training/experiments/DISFA/get_balanced_fold.m @@ -0,0 +1,31 @@ +function [train_users, dev_users] = get_balanced_fold(DISFA_dir, users, au, prop_test, offset) + + % This is for loading the labels + for i=1:numel(users) + input_train_label_files{i} = [DISFA_dir, '/ActionUnit_Labels/', users{i}, '/', users{i}]; + end + + % Extracting the labels + labels_train = extract_au_labels(input_train_label_files, au); + + counts = zeros(numel(users),1); + for k=1:numel(users) + counts(k) = sum(labels_train((k-1)*4844+1:k*4844)); + end + + [sorted, inds] = sort(counts); + + dev_users = users(inds(offset:round(1/prop_test):end)); + train_users = setdiff(users, dev_users); + + count_dev = 0; + count_train = 0; + for k=1:numel(users) + if(any(strcmp(dev_users, users{k}))) + count_dev = count_dev + counts(k); + else + count_train = count_train + counts(k); + end + + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/DISFA/get_test_folds.m b/matlab_version/AU_training/experiments/DISFA/get_test_folds.m new file mode 100644 index 00000000..482be039 --- /dev/null +++ b/matlab_version/AU_training/experiments/DISFA/get_test_folds.m @@ -0,0 +1,14 @@ +function [ test_folds ] = get_test_folds( num_folds, users ) +%GET_TEST_FOLDS Summary of this function goes here +% Detailed explanation goes here + +test_folds = cell(num_folds,1); +rng(0); +randomise_users = randperm(27); +spacing = round(linspace(0, 27, num_folds+1)); +for i=1:num_folds + test_folds{i} = users(randomise_users((spacing(i)+1):spacing(i+1))); +end + +end + diff --git a/matlab_version/AU_training/experiments/DISFA/shared_defs.m b/matlab_version/AU_training/experiments/DISFA/shared_defs.m new file mode 100644 index 00000000..5580dd8a --- /dev/null +++ b/matlab_version/AU_training/experiments/DISFA/shared_defs.m @@ -0,0 +1,55 @@ +% this is data defined across the experiments (to make sure all of them have same user conventions) + +% Defining which AU's we are extracting (all corrs above 0.5) +all_aus = [1,2,4,5,6,9,12,15,17,20,25,26]; +aus = [1,2,4,5,6,9,12,15,17,20,25,26]; + +% load all of the data together (for efficiency) +% it will be split up accordingly at later stages +if(exist('F:/datasets/DISFA/', 'file')) + DISFA_dir = 'F:/datasets/DISFA/'; +elseif(exist('D:/Databases/DISFA/', 'file')) + DISFA_dir = 'D:/Databases/DISFA/'; +elseif(exist('D:\datasets\face_datasets\DISFA/', 'file')) + DISFA_dir = 'D:\datasets\face_datasets\DISFA/'; +elseif(exist('D:\Datasets\DISFA/', 'file')) + DISFA_dir = 'D:\Datasets\DISFA/'; +elseif(exist('Z:/datasets/DISFA/', 'file')) + DISFA_dir = 'Z:/Databases/DISFA/'; +elseif(exist('E:/datasets/DISFA/', 'file')) + DISFA_dir = 'E:/datasets/DISFA/'; +elseif(exist('C:/tadas/DISFA/', 'file')) + DISFA_dir = 'C:/tadas/DISFA/'; +else + fprintf('DISFA location not found (or not defined)\n'); +end + +hog_data_dir = [DISFA_dir, '/hog_aligned_rigid/']; + +users = {'SN001'; + 'SN002'; + 'SN003'; + 'SN004'; + 'SN005'; + 'SN006'; + 'SN007'; + 'SN008'; + 'SN009'; + 'SN010'; + 'SN011'; + 'SN012'; + 'SN016'; + 'SN017'; + 'SN018'; + 'SN021'; + 'SN023'; + 'SN024'; + 'SN025'; + 'SN026'; + 'SN027'; + 'SN028'; + 'SN029'; + 'SN030'; + 'SN031'; + 'SN032'; + 'SN013'}; diff --git a/matlab_version/AU_training/experiments/FERA2011/Prepare_HOG_AU_data_generic.m b/matlab_version/AU_training/experiments/FERA2011/Prepare_HOG_AU_data_generic.m new file mode 100644 index 00000000..bf59c1bd --- /dev/null +++ b/matlab_version/AU_training/experiments/FERA2011/Prepare_HOG_AU_data_generic.m @@ -0,0 +1,106 @@ +function [data_train, labels_train, data_devel, labels_devel, raw_devel, PC, means_norm, stds_norm, vid_ids_devel_string, valid_ids_devel] = ... + Prepare_HOG_AU_data_generic(train_users, devel_users, au_train, rest_aus, unbc_dir, hog_data_dir) + +%% +addpath(genpath('../../data extraction/')); + +% First extracting the labels +[ labels_train, valid_ids_train, filenames ] = extract_FERA2011_labels(unbc_dir, train_users, au_train); + +[ labels_other, ~, ~ ] = extract_FERA2011_labels(unbc_dir, train_users, rest_aus); +labels_other = cat(1, labels_other{:}); + +% Reading in the HOG data (of only relevant frames) +[train_appearance_data, valid_ids_train_hog, vid_ids_train_string] = Read_HOG_files(train_users, hog_data_dir); + +[train_geom_data] = Read_geom_files(train_users, [hog_data_dir, '/../model_params']); + +% Subsample the data to make training quicker +labels_train = cat(1, labels_train{:}); +valid_ids_train = logical(cat(1, valid_ids_train{:})); + +reduced_inds = false(size(labels_train,1),1); +reduced_inds(labels_train == 1) = true; + +% make sure the same number of positive and negative samples is taken +pos_count = sum(labels_train == 1); +neg_count = sum(labels_train == 0); + +num_other = floor(pos_count / (size(labels_other, 2))); + +inds_all = 1:size(labels_train,1); + +for i=1:size(labels_other, 2)+1 + + if(i > size(labels_other, 2)) + % fill the rest with a proportion of neutral + inds_other = inds_all(sum(labels_other,2)==0 & ~labels_train ); + num_other_i = min(numel(inds_other), pos_count - sum(labels_train(reduced_inds,:)==0)); + else + % take a proportion of each other AU + inds_other = inds_all(labels_other(:, i) & ~labels_train ); + num_other_i = min(numel(inds_other), num_other); + end + inds_other_to_keep = inds_other(round(linspace(1, numel(inds_other), num_other_i))); + reduced_inds(inds_other_to_keep) = true; + +end + +% Remove invalid ids based on CLM failing or AU not being labelled +reduced_inds(~valid_ids_train) = false; +reduced_inds(~valid_ids_train_hog) = false; + +labels_other = labels_other(reduced_inds, :); +labels_train = labels_train(reduced_inds,:); +train_appearance_data = train_appearance_data(reduced_inds,:); +train_geom_data = train_geom_data(reduced_inds,:); +vid_ids_train_string = vid_ids_train_string(reduced_inds,:); + +%% Extract devel data + +% First extracting the labels +[ labels_devel, valid_ids_devel, filenames_devel ] = extract_FERA2011_labels(unbc_dir, devel_users, au_train); + +% Reading in the HOG data (of only relevant frames) +[devel_appearance_data, valid_ids_devel_hog, vid_ids_devel_string] = Read_HOG_files(devel_users, hog_data_dir); + +[devel_geom_data] = Read_geom_files(devel_users, [hog_data_dir, '/../model_params']); + +labels_devel = cat(1, labels_devel{:}); + +% Peforming zone specific masking +if(au_train < 8 || au_train == 43 || au_train == 45) % upper face AUs ignore bottom face + % normalise the data + pca_file = '../../pca_generation/generic_face_upper.mat'; + load(pca_file); +elseif(au_train > 9) % lower face AUs ignore upper face and the sides + % normalise the data + pca_file = '../../pca_generation/generic_face_lower.mat'; + load(pca_file); +elseif(au_train == 9) % Central face model + % normalise the data + pca_file = '../../pca_generation/generic_face_rigid.mat'; + load(pca_file); +end + +% Grab all data for validation as want good params for all the data +raw_devel = cat(2, devel_appearance_data, devel_geom_data); + +devel_appearance_data = bsxfun(@times, bsxfun(@plus, devel_appearance_data, -means_norm), 1./stds_norm); +train_appearance_data = bsxfun(@times, bsxfun(@plus, train_appearance_data, -means_norm), 1./stds_norm); + +data_train = train_appearance_data * PC; +data_devel = devel_appearance_data * PC; + +data_train = cat(2, data_train, train_geom_data); +data_devel = cat(2, data_devel, devel_geom_data); + +PC_n = zeros(size(PC)+size(train_geom_data, 2)); +PC_n(1:size(PC,1), 1:size(PC,2)) = PC; +PC_n(size(PC,1)+1:end, size(PC,2)+1:end) = eye(size(train_geom_data, 2)); +PC = PC_n; + +means_norm = cat(2, means_norm, zeros(1, size(train_geom_data,2))); +stds_norm = cat(2, stds_norm, ones(1, size(train_geom_data,2))); + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/FERA2011/Prepare_HOG_AU_data_generic_dynamic.m b/matlab_version/AU_training/experiments/FERA2011/Prepare_HOG_AU_data_generic_dynamic.m new file mode 100644 index 00000000..7f8f49e6 --- /dev/null +++ b/matlab_version/AU_training/experiments/FERA2011/Prepare_HOG_AU_data_generic_dynamic.m @@ -0,0 +1,106 @@ +function [data_train, labels_train, data_devel, labels_devel, raw_devel, PC, means_norm, stds_norm, vid_ids_devel_string] = ... + Prepare_HOG_AU_data_generic_dynamic(train_users, devel_users, au_train, rest_aus, semaine_dir, hog_data_dir) + +%% +addpath(genpath('../../data extraction/')); + +% First extracting the labels +[ labels_train, filenames, vid_ids_train ] = extract_FERA2011_labels(semaine_dir, train_users, au_train); + +[ labels_other, ~, ~ ] = extract_FERA2011_labels(semaine_dir, train_users, rest_aus); +labels_other = cat(1, labels_other{:}); + +% Reading in the HOG data (of only relevant frames) +[train_appearance_data, valid_ids_train_hog, vid_ids_train_string] = Read_HOG_files_dynamic(train_users, hog_data_dir); + +[train_geom_data] = Read_geom_files_dynamic(train_users, [hog_data_dir, '/../model_params']); + +% Subsample the data to make training quicker +labels_train = cat(1, labels_train{:}); +filenames = logical(cat(1, filenames{:})); + +reduced_inds = false(size(labels_train,1),1); +reduced_inds(labels_train == 1) = true; + +% make sure the same number of positive and negative samples is taken +pos_count = sum(labels_train == 1); +neg_count = sum(labels_train == 0); + +num_other = floor(pos_count / (size(labels_other, 2))); + +inds_all = 1:size(labels_train,1); + +for i=1:size(labels_other, 2)+1 + + if(i > size(labels_other, 2)) + % fill the rest with a proportion of neutral + inds_other = inds_all(sum(labels_other,2)==0 & ~labels_train ); + num_other_i = min(numel(inds_other), pos_count - sum(labels_train(reduced_inds,:)==0)); + else + % take a proportion of each other AU + inds_other = inds_all(labels_other(:, i) & ~labels_train ); + num_other_i = min(numel(inds_other), num_other); + end + inds_other_to_keep = inds_other(round(linspace(1, numel(inds_other), num_other_i))); + reduced_inds(inds_other_to_keep) = true; + +end + +% Remove invalid ids based on CLM failing or AU not being labelled +reduced_inds(~filenames) = false; +reduced_inds(~valid_ids_train_hog) = false; + +labels_other = labels_other(reduced_inds, :); +labels_train = labels_train(reduced_inds,:); +train_appearance_data = train_appearance_data(reduced_inds,:); +train_geom_data = train_geom_data(reduced_inds,:); +vid_ids_train_string = vid_ids_train_string(reduced_inds,:); + +%% Extract devel data + +% First extracting the labels +[ labels_devel, valid_ids_devel, vid_ids_devel ] = extract_FERA2011_labels(semaine_dir, devel_users, au_train); + +% Reading in the HOG data (of only relevant frames) +[devel_appearance_data, valid_ids_devel_hog, vid_ids_devel_string] = Read_HOG_files_dynamic(devel_users, hog_data_dir); + +[devel_geom_data] = Read_geom_files_dynamic(devel_users, [hog_data_dir, '/../model_params']); + +labels_devel = cat(1, labels_devel{:}); + +% Peforming zone specific masking +if(au_train < 8 || au_train == 43 || au_train == 45) % upper face AUs ignore bottom face + % normalise the data + pca_file = '../../pca_generation/generic_face_upper.mat'; + load(pca_file); +elseif(au_train > 9) % lower face AUs ignore upper face and the sides + % normalise the data + pca_file = '../../pca_generation/generic_face_lower.mat'; + load(pca_file); +elseif(au_train == 9) % Central face model + % normalise the data + pca_file = '../../pca_generation/generic_face_rigid.mat'; + load(pca_file); +end + +% Grab all data for validation as want good params for all the data +raw_devel = cat(2, devel_appearance_data, devel_geom_data); + +devel_appearance_data = bsxfun(@times, bsxfun(@plus, devel_appearance_data, -means_norm), 1./stds_norm); +train_appearance_data = bsxfun(@times, bsxfun(@plus, train_appearance_data, -means_norm), 1./stds_norm); + +data_train = train_appearance_data * PC; +data_devel = devel_appearance_data * PC; + +data_train = cat(2, data_train, train_geom_data); +data_devel = cat(2, data_devel, devel_geom_data); + +PC_n = zeros(size(PC)+size(train_geom_data, 2)); +PC_n(1:size(PC,1), 1:size(PC,2)) = PC; +PC_n(size(PC,1)+1:end, size(PC,2)+1:end) = eye(size(train_geom_data, 2)); +PC = PC_n; + +means_norm = cat(2, means_norm, zeros(1, size(train_geom_data,2))); +stds_norm = cat(2, stds_norm, ones(1, size(train_geom_data,2))); + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/FERA2011/Read_HOG_files.m b/matlab_version/AU_training/experiments/FERA2011/Read_HOG_files.m new file mode 100644 index 00000000..5fc7d726 --- /dev/null +++ b/matlab_version/AU_training/experiments/FERA2011/Read_HOG_files.m @@ -0,0 +1,86 @@ +function [hog_data, valid_data, vid_id] = Read_HOG_files(users, hog_data_dir) + + hog_data = []; + vid_id = {}; + valid_data = []; + + feats_filled = 0; + + for i=1:numel(users) + + hog_file = [hog_data_dir, '/au_training_', users{i} '.hog']; + + f = fopen(hog_file, 'r'); + + curr_data = []; + curr_ind = 0; + + while(~feof(f)) + + if(curr_ind == 0) + num_cols = fread(f, 1, 'int32'); + if(isempty(num_cols)) + break; + end + + num_rows = fread(f, 1, 'int32'); + num_chan = fread(f, 1, 'int32'); + + curr_ind = curr_ind + 1; + + % preallocate some space + if(curr_ind == 1) + curr_data = zeros(5000, 1 + num_rows * num_cols * num_chan); + num_feats = 1 + num_rows * num_cols * num_chan; + end + + if(curr_ind > size(curr_data,1)) + curr_data = cat(1, curr_data, zeros(6000, 1 + num_rows * num_cols * num_chan)); + end + feature_vec = fread(f, [1, 1 + num_rows * num_cols * num_chan], 'float32'); + curr_data(curr_ind, :) = feature_vec; + else + + % Reading in batches of 5000 + + feature_vec = fread(f, [4 + num_rows * num_cols * num_chan, 5000], 'float32'); + feature_vec = feature_vec(4:end,:)'; + + num_rows_read = size(feature_vec,1); + + curr_data(curr_ind+1:curr_ind+num_rows_read,:) = feature_vec; + + curr_ind = curr_ind + size(feature_vec,1); + + end + + end + + fclose(f); + + curr_data = curr_data(1:curr_ind,:); + vid_id_curr = cell(curr_ind,1); + vid_id_curr(:) = users(i); + + vid_id = cat(1, vid_id, vid_id_curr); + + % Assume same number of frames per video + if(i==1) + hog_data = zeros(curr_ind*numel(users), num_feats); + end + + if(size(hog_data,1) < feats_filled+curr_ind) + hog_data = cat(1, hog_data, zeros(size(hog_data,1), num_feats)); + end + + hog_data(feats_filled+1:feats_filled+curr_ind,:) = curr_data; + + feats_filled = feats_filled + curr_ind; + + end + if(numel(users) > 0) + valid_data = hog_data(1:feats_filled,1) > 0; + hog_data = hog_data(1:feats_filled,2:end); + end + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/FERA2011/Read_HOG_files_dynamic.m b/matlab_version/AU_training/experiments/FERA2011/Read_HOG_files_dynamic.m new file mode 100644 index 00000000..1d40dcc0 --- /dev/null +++ b/matlab_version/AU_training/experiments/FERA2011/Read_HOG_files_dynamic.m @@ -0,0 +1,133 @@ +function [hog_data, valid_data, vid_id] = Read_HOG_files_dynamic(users, hog_data_dir) + + hog_data = []; + vid_id = {}; + valid_data = []; + + feats_filled = 0; + + user1 = {'train_001', 'train_002', 'train_003', 'train_004', 'train_005',... + 'train_006', 'train_007', 'train_008', 'train_009', 'train_010',... + 'train_011', 'train_012', 'train_013', 'train_014', 'train_015',... + 'train_016', 'train_017', 'train_018'}; + + user2 = {'train_019', 'train_020', 'train_021', 'train_022', 'train_023',... + 'train_024', 'train_025', 'train_026', 'train_027', 'train_028',... + 'train_029', 'train_030', 'train_031', 'train_032'}; + + user3 = {'train_033', 'train_034', 'train_035', 'train_036', 'train_037',... + 'train_038', 'train_039', 'train_040', 'train_041'}; + + user4 = {'train_042', 'train_043', 'train_044', 'train_045', 'train_046',... + 'train_047', 'train_048', 'train_049', 'train_050', 'train_051',... + 'train_052', 'train_053', 'train_054', 'train_055', 'train_056'}; + + user5 = {'train_057', 'train_058', 'train_059', 'train_060', 'train_061',... + 'train_062', 'train_063'}; + + user6 = {'train_064', 'train_065', 'train_066', 'train_067', 'train_068',... + 'train_069', 'train_070', 'train_071', 'train_072', 'train_073',... + 'train_074', 'train_075', 'train_076', 'train_077', 'train_078', 'train_079'}; + + user7 = {'train_080', 'train_081', 'train_082', 'train_083', 'train_084',... + 'train_085', 'train_086', 'train_087'}; + + users_group = cat(1, {user1}, {user2}, {user3}, {user4}, {user5}, {user6}, {user7}); + user_inds = []; + + for i=1:numel(users) + + hog_file = [hog_data_dir, '/au_training_', users{i} '.hog']; + + f = fopen(hog_file, 'r'); + + curr_data = []; + curr_ind = 0; + + while(~feof(f)) + + if(curr_ind == 0) + num_cols = fread(f, 1, 'int32'); + if(isempty(num_cols)) + break; + end + + num_rows = fread(f, 1, 'int32'); + num_chan = fread(f, 1, 'int32'); + + curr_ind = curr_ind + 1; + + % preallocate some space + if(curr_ind == 1) + curr_data = zeros(5000, 1 + num_rows * num_cols * num_chan); + num_feats = 1 + num_rows * num_cols * num_chan; + end + + if(curr_ind > size(curr_data,1)) + curr_data = cat(1, curr_data, zeros(6000, 1 + num_rows * num_cols * num_chan)); + end + feature_vec = fread(f, [1, 1 + num_rows * num_cols * num_chan], 'float32'); + curr_data(curr_ind, :) = feature_vec; + else + + % Reading in batches of 5000 + + feature_vec = fread(f, [4 + num_rows * num_cols * num_chan, 5000], 'float32'); + feature_vec = feature_vec(4:end,:)'; + + num_rows_read = size(feature_vec,1); + + curr_data(curr_ind+1:curr_ind+num_rows_read,:) = feature_vec; + + curr_ind = curr_ind + size(feature_vec,1); + + end + + end + + fclose(f); + + curr_data = curr_data(1:curr_ind,:); + + for k=1:numel(users_group) + if(~isempty(strmatch(users{i}, users_group{k}))) + user_inds = cat(1, user_inds, k * ones(curr_ind,1)); + end + end + + valid = logical(curr_data(:, 1)); + + vid_id_curr = cell(curr_ind,1); + vid_id_curr(:) = users(i); + + vid_id = cat(1, vid_id, vid_id_curr); + + % Assume same number of frames per video + if(i==1) + hog_data = zeros(curr_ind*numel(users), num_feats); + end + + if(size(hog_data,1) < feats_filled+curr_ind) + hog_data = cat(1, hog_data, zeros(size(hog_data,1), num_feats)); + end + + hog_data(feats_filled+1:feats_filled+curr_ind,:) = curr_data; + + feats_filled = feats_filled + curr_ind; + + end + + if(numel(users) > 0) + + % Perform normalization here + u_id = unique(user_inds)'; + + valid_data = hog_data(1:feats_filled,1) > 0; + + for u=u_id + hog_data(user_inds==u, 2:end) = bsxfun(@plus, hog_data(user_inds==u, 2:end), -median(hog_data(user_inds==u & valid_data, 2:end))); + end + + hog_data = hog_data(1:feats_filled,2:end); + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/FERA2011/Read_geom_files.m b/matlab_version/AU_training/experiments/FERA2011/Read_geom_files.m new file mode 100644 index 00000000..879b1e18 --- /dev/null +++ b/matlab_version/AU_training/experiments/FERA2011/Read_geom_files.m @@ -0,0 +1,31 @@ +function [geom_data, valid_ids] = Read_geom_files(users, params_data_dir) + + geom_data = []; + valid_ids = []; + + load('../../pca_generation/pdm_68_aligned_wild.mat'); + + for i=1:numel(users) + + geom_file = [params_data_dir, '/au_training_' users{i} '.txt']; + m_file = [params_data_dir, '/au_training_' users{i} '.params.mat']; + + if(~exist(m_file, 'file')) + res = dlmread(geom_file, ',', 1, 0); + save(m_file, 'res'); + else + load(m_file); + end + + valid = res(:, 4); + res = res(:, 11:end); + + actual_locs = res * V'; + res = cat(2, actual_locs, res); + + valid_ids = cat(1, valid_ids, valid); + + geom_data = cat(1, geom_data, res); + + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/FERA2011/Read_geom_files_dynamic.m b/matlab_version/AU_training/experiments/FERA2011/Read_geom_files_dynamic.m new file mode 100644 index 00000000..c340ca01 --- /dev/null +++ b/matlab_version/AU_training/experiments/FERA2011/Read_geom_files_dynamic.m @@ -0,0 +1,77 @@ +function [geom_data, valid_ids] = Read_geom_files_dynamic(users, params_data_dir) + + geom_data = []; + valid_ids = []; + + load('../../pca_generation/pdm_68_aligned_wild.mat'); + + user1 = {'train_001', 'train_002', 'train_003', 'train_004', 'train_005',... + 'train_006', 'train_007', 'train_008', 'train_009', 'train_010',... + 'train_011', 'train_012', 'train_013', 'train_014', 'train_015',... + 'train_016', 'train_017', 'train_018'}; + + user2 = {'train_019', 'train_020', 'train_021', 'train_022', 'train_023',... + 'train_024', 'train_025', 'train_026', 'train_027', 'train_028',... + 'train_029', 'train_030', 'train_031', 'train_032'}; + + user3 = {'train_033', 'train_034', 'train_035', 'train_036', 'train_037',... + 'train_038', 'train_039', 'train_040', 'train_041'}; + + user4 = {'train_042', 'train_043', 'train_044', 'train_045', 'train_046',... + 'train_047', 'train_048', 'train_049', 'train_050', 'train_051',... + 'train_052', 'train_053', 'train_054', 'train_055', 'train_056'}; + + user5 = {'train_057', 'train_058', 'train_059', 'train_060', 'train_061',... + 'train_062', 'train_063'}; + + user6 = {'train_064', 'train_065', 'train_066', 'train_067', 'train_068',... + 'train_069', 'train_070', 'train_071', 'train_072', 'train_073',... + 'train_074', 'train_075', 'train_076', 'train_077', 'train_078', 'train_079'}; + + user7 = {'train_080', 'train_081', 'train_082', 'train_083', 'train_084',... + 'train_085', 'train_086', 'train_087'}; + + users_group = cat(1, {user1}, {user2}, {user3}, {user4}, {user5}, {user6}, {user7}); + user_inds = []; + + for i=1:numel(users) + + geom_file = [params_data_dir, '/au_training_' users{i} '.txt']; + m_file = [params_data_dir, '/au_training_' users{i} '.params.mat']; + + if(~exist(m_file, 'file')) + res = dlmread(geom_file, ',', 1, 0); + save(m_file, 'res'); + else + load(m_file); + end + + valid = res(:, 4); + res = res(:, 11:end); + + for k=1:numel(users_group) + if(~isempty(strmatch(users{i}, users_group{k}))) + user_inds = cat(1, user_inds, k * ones(size(valid,1),1)); + end + end + + actual_locs = res * V'; + res = cat(2, actual_locs, res); + + valid_ids = cat(1, valid_ids, valid); + + + geom_data = cat(1, geom_data, res); + + end + + if(numel(users) > 0) + + % Perform normalization here + u_id = unique(user_inds)'; + for u=u_id + geom_data(user_inds==u, :) = bsxfun(@plus, geom_data(user_inds==u, :), -median(geom_data(user_inds==u & valid_ids, :))); + end + end + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/FERA2011/Script_HOG_SVM_train.m b/matlab_version/AU_training/experiments/FERA2011/Script_HOG_SVM_train.m new file mode 100644 index 00000000..ab9a13c7 --- /dev/null +++ b/matlab_version/AU_training/experiments/FERA2011/Script_HOG_SVM_train.m @@ -0,0 +1,78 @@ +function Script_HOG_SVM_train() + +% Change to your downloaded location +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); + +%% load shared definitions and AU data +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-9:0.5:1); +hyperparams.e = 10.^(-3); + +hyperparams.validate_params = {'c', 'e'}; + +% Set the training function +svm_train = @svm_train_linear; + +% Set the test function (the first output will be used for validation) +svm_test = @svm_test_linear; + +all_recs = cat(2, train_recs, devel_recs); + +%% +for a=1:numel(all_aus) + + au = all_aus(a); + + rest_aus = setdiff(all_aus, au); + [train_recs, devel_recs] = get_balanced_fold(FERA2011_dir, all_recs, au, 1/3, 1); + + % load the training and testing data for the current fold + [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling] = Prepare_HOG_AU_data_generic(train_recs, devel_recs, au, rest_aus, FERA2011_dir, hog_data_dir); + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + + %% Cross-validate here + [ best_params, ~ ] = validate_grid_search_no_par(svm_train, svm_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + + model = svm_train(train_labels, train_samples, best_params); + + [~, prediction] = svm_test(valid_labels, valid_samples, model); + + % Go from raw data to the prediction + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + name = sprintf('models/AU_%d_static.dat', au); + + pos_lbl = model.Label(1); + neg_lbl = model.Label(2); + + write_lin_svm(name, means, svs, b, pos_lbl, neg_lbl); + + name = sprintf('results_FERA2011_devel/AU_%d_static.mat', au); + + tp = sum(valid_labels == 1 & prediction == 1); + fp = sum(valid_labels == 0 & prediction == 1); + fn = sum(valid_labels == 1 & prediction == 0); + tn = sum(valid_labels == 0 & prediction == 0); + + precision = tp/(tp+fp); + recall = tp/(tp+fn); + + f1 = 2 * precision * recall / (precision + recall); + + save(name, 'model', 'f1', 'precision', 'recall', 'best_params', 'valid_labels', 'prediction'); + +end + +end + + diff --git a/matlab_version/AU_training/experiments/FERA2011/Script_HOG_SVM_train_dyn.m b/matlab_version/AU_training/experiments/FERA2011/Script_HOG_SVM_train_dyn.m new file mode 100644 index 00000000..fa464623 --- /dev/null +++ b/matlab_version/AU_training/experiments/FERA2011/Script_HOG_SVM_train_dyn.m @@ -0,0 +1,79 @@ +function Script_HOG_SVM_train_dyn() + +% Change to your downloaded location +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); + +%% load shared definitions and AU data +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-9:0.5:1); +hyperparams.e = 10.^(-3); + +hyperparams.validate_params = {'c', 'e'}; + +% Set the training function +svm_train = @svm_train_linear; + +% Set the test function (the first output will be used for validation) +svm_test = @svm_test_linear; + +all_recs = cat(2, train_recs, devel_recs); + +%% +for a=1:numel(all_aus) + + au = all_aus(a); + + rest_aus = setdiff(all_aus, au); + + [train_recs, devel_recs] = get_balanced_fold(FERA2011_dir, all_recs, au, 1/3, 1); + + % load the training and testing data for the current fold + [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling] = Prepare_HOG_AU_data_generic_dynamic(train_recs, devel_recs, au, rest_aus, FERA2011_dir, hog_data_dir); + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + + %% Cross-validate here + [ best_params, ~ ] = validate_grid_search_no_par(svm_train, svm_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + + model = svm_train(train_labels, train_samples, best_params); + + [~, prediction] = svm_test(valid_labels, valid_samples, model); + + % Go from raw data to the prediction + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + name = sprintf('models/AU_%d_dyn.dat', au); + + pos_lbl = model.Label(1); + neg_lbl = model.Label(2); + + write_lin_dyn_svm(name, means, svs, b, pos_lbl, neg_lbl); + + name = sprintf('results_FERA2011_devel/AU_%d_dyn.mat', au); + + tp = sum(valid_labels == 1 & prediction == 1); + fp = sum(valid_labels == 0 & prediction == 1); + fn = sum(valid_labels == 1 & prediction == 0); + tn = sum(valid_labels == 0 & prediction == 0); + + precision = tp/(tp+fp); + recall = tp/(tp+fn); + + f1 = 2 * precision * recall / (precision + recall); + + save(name, 'model', 'f1', 'precision', 'recall', 'best_params', 'valid_labels', 'prediction'); + +end + +end + + diff --git a/matlab_version/AU_training/experiments/FERA2011/get_balanced_fold.m b/matlab_version/AU_training/experiments/FERA2011/get_balanced_fold.m new file mode 100644 index 00000000..dfe87f36 --- /dev/null +++ b/matlab_version/AU_training/experiments/FERA2011/get_balanced_fold.m @@ -0,0 +1,56 @@ +function [train_users, dev_users] = get_balanced_fold(FERA_dir, users, au, prop_test, offset) + + + [ labels_train, valid_ids_train, filenames ] = extract_FERA2011_labels(FERA_dir, users, au); + + % Make sure the folds are user independent + user1 = {'train_001', 'train_002', 'train_003', 'train_004', 'train_005',... + 'train_006', 'train_007', 'train_008', 'train_009', 'train_010',... + 'train_011', 'train_012', 'train_013', 'train_014', 'train_015',... + 'train_016', 'train_017', 'train_018'}; + + user2 = {'train_019', 'train_020', 'train_021', 'train_022', 'train_023',... + 'train_024', 'train_025', 'train_026', 'train_027', 'train_028',... + 'train_029', 'train_030', 'train_031', 'train_032'}; + + user3 = {'train_033', 'train_034', 'train_035', 'train_036', 'train_037',... + 'train_038', 'train_039', 'train_040', 'train_041'}; + + user4 = {'train_042', 'train_043', 'train_044', 'train_045', 'train_046',... + 'train_047', 'train_048', 'train_049', 'train_050', 'train_051',... + 'train_052', 'train_053', 'train_054', 'train_055', 'train_056'}; + + user5 = {'train_057', 'train_058', 'train_059', 'train_060', 'train_061',... + 'train_062', 'train_063'}; + + user6 = {'train_064', 'train_065', 'train_066', 'train_067', 'train_068',... + 'train_069', 'train_070', 'train_071', 'train_072', 'train_073',... + 'train_074', 'train_075', 'train_076', 'train_077', 'train_078', 'train_079'}; + + user7 = {'train_080', 'train_081', 'train_082', 'train_083', 'train_084',... + 'train_085', 'train_086', 'train_087'}; + + users_group = cat(1, {user1}, {user2}, {user3}, {user4}, {user5}, {user6}, {user7}); + + counts = zeros(numel(users_group),1); + for k=1:numel(users_group) + for f=1:numel(filenames) + if(~isempty(strmatch(filenames{f}(1:9), users_group{k}))) + counts(k) = counts(k) + sum(labels_train{f}); + end + end + end + + % Now group them together by users + + [sorted, inds] = sort(counts); + dev_inds = inds(offset:round(1/prop_test):end); + train_inds = setdiff(inds, dev_inds); + + dev_users = users_group(dev_inds); + dev_users = cat(2, dev_users{:})'; + + train_users = users_group(train_inds); + train_users = cat(2, train_users{:})'; + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_10_dyn.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_10_dyn.dat new file mode 100644 index 00000000..25a255f8 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_10_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_10_static.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_10_static.dat new file mode 100644 index 00000000..2bebe0ff Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_10_static.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_12_dyn.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_12_dyn.dat new file mode 100644 index 00000000..9f366721 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_12_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_12_static.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_12_static.dat new file mode 100644 index 00000000..77eef418 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_12_static.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_15_dyn.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_15_dyn.dat new file mode 100644 index 00000000..e9d188cf Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_15_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_15_static.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_15_static.dat new file mode 100644 index 00000000..212ed989 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_15_static.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_17_dyn.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_17_dyn.dat new file mode 100644 index 00000000..148b7cdd Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_17_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_17_static.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_17_static.dat new file mode 100644 index 00000000..ba82851a Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_17_static.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_18_dyn.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_18_dyn.dat new file mode 100644 index 00000000..3de891a9 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_18_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_18_static.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_18_static.dat new file mode 100644 index 00000000..0032a445 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_18_static.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_1_dyn.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_1_dyn.dat new file mode 100644 index 00000000..f686beb7 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_1_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_1_static.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_1_static.dat new file mode 100644 index 00000000..a9e547b6 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_1_static.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_25_dyn.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_25_dyn.dat new file mode 100644 index 00000000..e1bd0955 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_25_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_25_static.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_25_static.dat new file mode 100644 index 00000000..deb9d945 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_25_static.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_26_dyn.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_26_dyn.dat new file mode 100644 index 00000000..60badc9c Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_26_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_26_static.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_26_static.dat new file mode 100644 index 00000000..b06d5c9f Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_26_static.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_2_dyn.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_2_dyn.dat new file mode 100644 index 00000000..59875986 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_2_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_2_static.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_2_static.dat new file mode 100644 index 00000000..56c26cb6 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_2_static.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_4_dyn.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_4_dyn.dat new file mode 100644 index 00000000..e81b1624 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_4_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_4_static.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_4_static.dat new file mode 100644 index 00000000..a44a3825 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_4_static.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_6_dyn.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_6_dyn.dat new file mode 100644 index 00000000..6f64468e Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_6_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_6_static.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_6_static.dat new file mode 100644 index 00000000..ede5505f Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_6_static.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_7_dyn.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_7_dyn.dat new file mode 100644 index 00000000..8d7c6587 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_7_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/models/AU_7_static.dat b/matlab_version/AU_training/experiments/FERA2011/models/AU_7_static.dat new file mode 100644 index 00000000..83bf942a Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/models/AU_7_static.dat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_10_dyn.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_10_dyn.mat new file mode 100644 index 00000000..68214502 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_10_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_10_static.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_10_static.mat new file mode 100644 index 00000000..bb7f5a7e Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_10_static.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_12_dyn.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_12_dyn.mat new file mode 100644 index 00000000..3af13d44 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_12_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_12_static.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_12_static.mat new file mode 100644 index 00000000..e32103b0 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_12_static.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_15_dyn.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_15_dyn.mat new file mode 100644 index 00000000..72e0168d Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_15_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_15_static.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_15_static.mat new file mode 100644 index 00000000..053128be Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_15_static.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_17_dyn.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_17_dyn.mat new file mode 100644 index 00000000..ca16c549 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_17_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_17_static.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_17_static.mat new file mode 100644 index 00000000..35b1033b Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_17_static.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_18_dyn.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_18_dyn.mat new file mode 100644 index 00000000..6bae36e9 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_18_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_18_static.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_18_static.mat new file mode 100644 index 00000000..2b1aa53f Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_18_static.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_1_dyn.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_1_dyn.mat new file mode 100644 index 00000000..0b557cbe Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_1_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_1_static.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_1_static.mat new file mode 100644 index 00000000..5d5114e3 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_1_static.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_25_dyn.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_25_dyn.mat new file mode 100644 index 00000000..50193ca3 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_25_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_25_static.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_25_static.mat new file mode 100644 index 00000000..3a369cde Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_25_static.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_26_dyn.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_26_dyn.mat new file mode 100644 index 00000000..e11f7e53 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_26_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_26_static.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_26_static.mat new file mode 100644 index 00000000..96dd1558 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_26_static.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_2_dyn.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_2_dyn.mat new file mode 100644 index 00000000..f11c8081 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_2_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_2_static.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_2_static.mat new file mode 100644 index 00000000..5d5a2468 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_2_static.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_4_dyn.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_4_dyn.mat new file mode 100644 index 00000000..f1954f37 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_4_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_4_static.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_4_static.mat new file mode 100644 index 00000000..2dff07a3 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_4_static.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_6_dyn.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_6_dyn.mat new file mode 100644 index 00000000..c7fe26d7 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_6_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_6_static.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_6_static.mat new file mode 100644 index 00000000..dd631ce1 Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_6_static.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_7_dyn.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_7_dyn.mat new file mode 100644 index 00000000..df7fa1aa Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_7_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_7_static.mat b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_7_static.mat new file mode 100644 index 00000000..906e206f Binary files /dev/null and b/matlab_version/AU_training/experiments/FERA2011/results_FERA2011_devel/AU_7_static.mat differ diff --git a/matlab_version/AU_training/experiments/FERA2011/shared_defs.m b/matlab_version/AU_training/experiments/FERA2011/shared_defs.m new file mode 100644 index 00000000..33ae7e48 --- /dev/null +++ b/matlab_version/AU_training/experiments/FERA2011/shared_defs.m @@ -0,0 +1,9 @@ +% this is data defined across the experiments (to make sure all of them have same user conventions) + +% Defining which AU's we are extracting +all_aus = [1, 2, 4, 6, 7, 10, 12, 15, 17, 18, 25, 26]; + +addpath('../../data extraction/'); + +find_FERA2011; + diff --git a/matlab_version/AU_training/experiments/SEMAINE/Prepare_HOG_AU_data_generic.m b/matlab_version/AU_training/experiments/SEMAINE/Prepare_HOG_AU_data_generic.m new file mode 100644 index 00000000..bb1c6740 --- /dev/null +++ b/matlab_version/AU_training/experiments/SEMAINE/Prepare_HOG_AU_data_generic.m @@ -0,0 +1,106 @@ +function [data_train, labels_train, data_devel, labels_devel, raw_devel, PC, means_norm, stds_norm, vid_ids_devel_string] = ... + Prepare_HOG_AU_data_generic(train_users, devel_users, au_train, rest_aus, semaine_dir, hog_data_dir, pca_file) + +%% +addpath(genpath('../data extraction/')); + +% First extracting the labels +[ labels_train, valid_ids_train, vid_ids_train ] = extract_SEMAINE_labels(semaine_dir, train_users, au_train); + +[ labels_other, ~, ~ ] = extract_SEMAINE_labels(semaine_dir, train_users, rest_aus); +labels_other = cat(1, labels_other{:}); + +% Reading in the HOG data (of only relevant frames) +[train_appearance_data, valid_ids_train_hog, vid_ids_train_string] = Read_HOG_files(train_users, vid_ids_train, hog_data_dir); + +[train_geom_data] = Read_geom_files(train_users, vid_ids_train, hog_data_dir); + +% Subsample the data to make training quicker +labels_train = cat(1, labels_train{:}); +valid_ids_train = logical(cat(1, valid_ids_train{:})); + +reduced_inds = false(size(labels_train,1),1); +reduced_inds(labels_train == 1) = true; + +% make sure the same number of positive and negative samples is taken +pos_count = sum(labels_train == 1); +neg_count = sum(labels_train == 0); + +num_other = floor(pos_count / (size(labels_other, 2))); + +inds_all = 1:size(labels_train,1); + +for i=1:size(labels_other, 2)+1 + + if(i > size(labels_other, 2)) + % fill the rest with a proportion of neutral + inds_other = inds_all(sum(labels_other,2)==0 & ~labels_train ); + num_other_i = min(numel(inds_other), pos_count - sum(labels_train(reduced_inds,:)==0)); + else + % take a proportion of each other AU + inds_other = inds_all(labels_other(:, i) & ~labels_train ); + num_other_i = min(numel(inds_other), num_other); + end + inds_other_to_keep = inds_other(round(linspace(1, numel(inds_other), num_other_i))); + reduced_inds(inds_other_to_keep) = true; + +end + +% Remove invalid ids based on CLM failing or AU not being labelled +reduced_inds(~valid_ids_train) = false; +reduced_inds(~valid_ids_train_hog) = false; + +labels_other = labels_other(reduced_inds, :); +labels_train = labels_train(reduced_inds,:); +train_appearance_data = train_appearance_data(reduced_inds,:); +train_geom_data = train_geom_data(reduced_inds,:); +vid_ids_train_string = vid_ids_train_string(reduced_inds,:); + +%% Extract devel data + +% First extracting the labels +[ labels_devel, valid_ids_devel, vid_ids_devel ] = extract_SEMAINE_labels(semaine_dir, devel_users, au_train); + +% Reading in the HOG data (of only relevant frames) +[devel_appearance_data, valid_ids_devel_hog, vid_ids_devel_string] = Read_HOG_files(devel_users, vid_ids_devel, hog_data_dir); + +[devel_geom_data] = Read_geom_files(devel_users, vid_ids_devel, hog_data_dir); + +labels_devel = cat(1, labels_devel{:}); + +% Peforming zone specific masking +if(au_train < 8 || au_train == 43 || au_train == 45) % upper face AUs ignore bottom face + % normalise the data + pca_file = '../../pca_generation/generic_face_upper.mat'; + load(pca_file); +elseif(au_train > 9) % lower face AUs ignore upper face and the sides + % normalise the data + pca_file = '../../pca_generation/generic_face_lower.mat'; + load(pca_file); +elseif(au_train == 9) % Central face model + % normalise the data + pca_file = '../../pca_generation/generic_face_rigid.mat'; + load(pca_file); +end + +% Grab all data for validation as want good params for all the data +raw_devel = cat(2, devel_appearance_data, devel_geom_data); + +devel_appearance_data = bsxfun(@times, bsxfun(@plus, devel_appearance_data, -means_norm), 1./stds_norm); +train_appearance_data = bsxfun(@times, bsxfun(@plus, train_appearance_data, -means_norm), 1./stds_norm); + +data_train = train_appearance_data * PC; +data_devel = devel_appearance_data * PC; + +data_train = cat(2, data_train, train_geom_data); +data_devel = cat(2, data_devel, devel_geom_data); + +PC_n = zeros(size(PC)+size(train_geom_data, 2)); +PC_n(1:size(PC,1), 1:size(PC,2)) = PC; +PC_n(size(PC,1)+1:end, size(PC,2)+1:end) = eye(size(train_geom_data, 2)); +PC = PC_n; + +means_norm = cat(2, means_norm, zeros(1, size(train_geom_data,2))); +stds_norm = cat(2, stds_norm, ones(1, size(train_geom_data,2))); + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/SEMAINE/Prepare_HOG_AU_data_generic_dynamic.m b/matlab_version/AU_training/experiments/SEMAINE/Prepare_HOG_AU_data_generic_dynamic.m new file mode 100644 index 00000000..4f90a631 --- /dev/null +++ b/matlab_version/AU_training/experiments/SEMAINE/Prepare_HOG_AU_data_generic_dynamic.m @@ -0,0 +1,106 @@ +function [data_train, labels_train, data_devel, labels_devel, raw_devel, PC, means_norm, stds_norm, vid_ids_devel_string] = ... + Prepare_HOG_AU_data_generic_dynamic(train_users, devel_users, au_train, rest_aus, semaine_dir, hog_data_dir, pca_file) + +%% +addpath(genpath('../data extraction/')); + +% First extracting the labels +[ labels_train, valid_ids_train, vid_ids_train ] = extract_SEMAINE_labels(semaine_dir, train_users, au_train); + +[ labels_other, ~, ~ ] = extract_SEMAINE_labels(semaine_dir, train_users, rest_aus); +labels_other = cat(1, labels_other{:}); + +% Reading in the HOG data (of only relevant frames) +[train_appearance_data, valid_ids_train_hog, vid_ids_train_string] = Read_HOG_files_dynamic(train_users, vid_ids_train, hog_data_dir); + +[train_geom_data] = Read_geom_files_dynamic(train_users, vid_ids_train, hog_data_dir); + +% Subsample the data to make training quicker +labels_train = cat(1, labels_train{:}); +valid_ids_train = logical(cat(1, valid_ids_train{:})); + +reduced_inds = false(size(labels_train,1),1); +reduced_inds(labels_train == 1) = true; + +% make sure the same number of positive and negative samples is taken +pos_count = sum(labels_train == 1); +neg_count = sum(labels_train == 0); + +num_other = floor(pos_count / (size(labels_other, 2))); + +inds_all = 1:size(labels_train,1); + +for i=1:size(labels_other, 2)+1 + + if(i > size(labels_other, 2)) + % fill the rest with a proportion of neutral + inds_other = inds_all(sum(labels_other,2)==0 & ~labels_train ); + num_other_i = min(numel(inds_other), pos_count - sum(labels_train(reduced_inds,:)==0)); + else + % take a proportion of each other AU + inds_other = inds_all(labels_other(:, i) & ~labels_train ); + num_other_i = min(numel(inds_other), num_other); + end + inds_other_to_keep = inds_other(round(linspace(1, numel(inds_other), num_other_i))); + reduced_inds(inds_other_to_keep) = true; + +end + +% Remove invalid ids based on CLM failing or AU not being labelled +reduced_inds(~valid_ids_train) = false; +reduced_inds(~valid_ids_train_hog) = false; + +labels_other = labels_other(reduced_inds, :); +labels_train = labels_train(reduced_inds,:); +train_appearance_data = train_appearance_data(reduced_inds,:); +train_geom_data = train_geom_data(reduced_inds,:); +vid_ids_train_string = vid_ids_train_string(reduced_inds,:); + +%% Extract devel data + +% First extracting the labels +[ labels_devel, valid_ids_devel, vid_ids_devel ] = extract_SEMAINE_labels(semaine_dir, devel_users, au_train); + +% Reading in the HOG data (of only relevant frames) +[devel_appearance_data, valid_ids_devel_hog, vid_ids_devel_string] = Read_HOG_files_dynamic(devel_users, vid_ids_devel, hog_data_dir); + +[devel_geom_data] = Read_geom_files_dynamic(devel_users, vid_ids_devel, hog_data_dir); + +labels_devel = cat(1, labels_devel{:}); + +% Peforming zone specific masking +if(au_train < 8 || au_train == 43 || au_train == 45) % upper face AUs ignore bottom face + % normalise the data + pca_file = '../../pca_generation/generic_face_upper.mat'; + load(pca_file); +elseif(au_train > 9) % lower face AUs ignore upper face and the sides + % normalise the data + pca_file = '../../pca_generation/generic_face_lower.mat'; + load(pca_file); +elseif(au_train == 9) % Central face model + % normalise the data + pca_file = '../../pca_generation/generic_face_rigid.mat'; + load(pca_file); +end + +% Grab all data for validation as want good params for all the data +raw_devel = cat(2, devel_appearance_data, devel_geom_data); + +devel_appearance_data = bsxfun(@times, bsxfun(@plus, devel_appearance_data, -means_norm), 1./stds_norm); +train_appearance_data = bsxfun(@times, bsxfun(@plus, train_appearance_data, -means_norm), 1./stds_norm); + +data_train = train_appearance_data * PC; +data_devel = devel_appearance_data * PC; + +data_train = cat(2, data_train, train_geom_data); +data_devel = cat(2, data_devel, devel_geom_data); + +PC_n = zeros(size(PC)+size(train_geom_data, 2)); +PC_n(1:size(PC,1), 1:size(PC,2)) = PC; +PC_n(size(PC,1)+1:end, size(PC,2)+1:end) = eye(size(train_geom_data, 2)); +PC = PC_n; + +means_norm = cat(2, means_norm, zeros(1, size(train_geom_data,2))); +stds_norm = cat(2, stds_norm, ones(1, size(train_geom_data,2))); + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/SEMAINE/Read_HOG_files.m b/matlab_version/AU_training/experiments/SEMAINE/Read_HOG_files.m new file mode 100644 index 00000000..ec48a36a --- /dev/null +++ b/matlab_version/AU_training/experiments/SEMAINE/Read_HOG_files.m @@ -0,0 +1,57 @@ +function [hog_data, valid_inds, vid_id] = Read_HOG_files(users, vid_ids, hog_data_dir) + + hog_data = []; + vid_id = {}; + + feats_filled = 0; + + for i=1:numel(users) + + hog_file = [hog_data_dir, '/train/' users{i} '.hog']; + if(~exist(hog_file, 'file')) + hog_file = [hog_data_dir, '/devel/' users{i} '.hog']; + end + + f = fopen(hog_file, 'r'); + + num_cols = fread(f, 1, 'int32'); + if(isempty(num_cols)) + break; + end + + num_rows = fread(f, 1, 'int32'); + num_chan = fread(f, 1, 'int32'); + num_feats = num_rows * num_cols * num_chan + 1; + + % go to the beginning + fseek(f, 0, 'bof'); + + % Read only the relevant bits + + % Skip to the right start element (1 indexed) + fseek(f, 4*(4+num_rows*num_rows*num_chan)*(vid_ids(i,1)-1), 'bof'); + + feature_vec = fread(f, [4 + num_rows * num_cols * num_chan, vid_ids(i,2) - vid_ids(i,1)], 'float32'); + fclose(f); + + curr_data = feature_vec(4:end,:)'; + curr_ind = size(curr_data,1); + + vid_id_curr = cell(size(curr_data,1),1); + vid_id_curr(:) = users(i); + + vid_id = cat(1, vid_id, vid_id_curr); + + % Assume same number of frames per video + if(i==1) + hog_data = zeros(sum(vid_ids(:,2)-vid_ids(:,1)), num_feats); + end + + hog_data(feats_filled+1:feats_filled+curr_ind,:) = curr_data; + + feats_filled = feats_filled + curr_ind; + + end + valid_inds = hog_data(:,1) > 0; + hog_data = hog_data(:,2:end); +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/SEMAINE/Read_HOG_files_dynamic.m b/matlab_version/AU_training/experiments/SEMAINE/Read_HOG_files_dynamic.m new file mode 100644 index 00000000..febf0697 --- /dev/null +++ b/matlab_version/AU_training/experiments/SEMAINE/Read_HOG_files_dynamic.m @@ -0,0 +1,59 @@ +function [hog_data, valid_inds, vid_id] = Read_HOG_files_dynamic(users, vid_ids, hog_data_dir) + + hog_data = []; + vid_id = {}; + + feats_filled = 0; + + for i=1:numel(users) + + hog_file = [hog_data_dir, '/train/' users{i} '.hog']; + if(~exist(hog_file, 'file')) + hog_file = [hog_data_dir, '/devel/' users{i} '.hog']; + end + + f = fopen(hog_file, 'r'); + + num_cols = fread(f, 1, 'int32'); + if(isempty(num_cols)) + break; + end + + num_rows = fread(f, 1, 'int32'); + num_chan = fread(f, 1, 'int32'); + num_feats = num_rows * num_cols * num_chan + 1; + + % go to the beginning + fseek(f, 0, 'bof'); + + % Read only the relevant bits + + % Skip to the right start element (1 indexed) + fseek(f, 4*(4+num_rows*num_rows*num_chan)*(vid_ids(i,1)-1), 'bof'); + + feature_vec = fread(f, [4 + num_rows * num_cols * num_chan, vid_ids(i,2) - vid_ids(i,1)], 'float32'); + fclose(f); + + curr_data = feature_vec(4:end,:)'; + curr_ind = size(curr_data,1); + + vid_id_curr = cell(size(curr_data,1),1); + vid_id_curr(:) = users(i); + + vid_id = cat(1, vid_id, vid_id_curr); + + % Assume same number of frames per video + if(i==1) + hog_data = zeros(sum(vid_ids(:,2)-vid_ids(:,1)), num_feats); + end + + curr_data(:,2:end) = bsxfun(@plus, curr_data(:,2:end), -median(curr_data(:,2:end))); + + hog_data(feats_filled+1:feats_filled+curr_ind,:) = curr_data; + + feats_filled = feats_filled + curr_ind; + + end + valid_inds = hog_data(:,1) > 0; + hog_data = hog_data(:,2:end); +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/SEMAINE/Read_geom_files.m b/matlab_version/AU_training/experiments/SEMAINE/Read_geom_files.m new file mode 100644 index 00000000..1556e5e3 --- /dev/null +++ b/matlab_version/AU_training/experiments/SEMAINE/Read_geom_files.m @@ -0,0 +1,36 @@ +function [geom_data, valid_ids] = Read_geom_files(users, vid_ids, hog_data_dir) + + geom_data = []; + valid_ids = []; + + load('../../pca_generation/pdm_68_aligned_wild.mat'); + + for i=1:numel(users) + + geom_file = [hog_data_dir, '/train/' users{i} '.params.txt']; + m_file = [hog_data_dir, '/train/' users{i} '.params.mat']; + if(~exist(geom_file, 'file')) + geom_file = [hog_data_dir, '/devel/' users{i} '.params.txt']; + m_file = [hog_data_dir, '/devel/' users{i} '.params.mat']; + end + + if(~exist(m_file, 'file')) + res = dlmread(geom_file, ',', 1, 0); + res = res(vid_ids(i,1)+1:vid_ids(i,2),:); + save(m_file, 'res'); + else + load(m_file); + end + + valid = res(:, 4); + res = res(:, 11:end); + + actual_locs = res * V'; + res = cat(2, actual_locs, res); + + valid_ids = cat(1, valid_ids, valid); + + geom_data = cat(1, geom_data, res); + + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/SEMAINE/Read_geom_files_dynamic.m b/matlab_version/AU_training/experiments/SEMAINE/Read_geom_files_dynamic.m new file mode 100644 index 00000000..dd6dd82e --- /dev/null +++ b/matlab_version/AU_training/experiments/SEMAINE/Read_geom_files_dynamic.m @@ -0,0 +1,39 @@ +function [geom_data, valid_ids] = Read_geom_files_dynamic(users, vid_ids, hog_data_dir) + + geom_data = []; + valid_ids = []; + + load('../../pca_generation/pdm_68_aligned_wild.mat'); + + for i=1:numel(users) + + geom_file = [hog_data_dir, '/train/' users{i} '.params.txt']; + m_file = [hog_data_dir, '/train/' users{i} '.params.mat']; + if(~exist(geom_file, 'file')) + geom_file = [hog_data_dir, '/devel/' users{i} '.params.txt']; + m_file = [hog_data_dir, '/devel/' users{i} '.params.mat']; + end + + if(~exist(m_file, 'file')) + res = dlmread(geom_file, ',', 1, 0); + res = res(vid_ids(i,1)+1:vid_ids(i,2),:); + save(m_file, 'res'); + else + load(m_file); + end + + valid = res(:, 4); + res = res(:, 11:end); + + + actual_locs = res * V'; + res = cat(2, actual_locs, res); + + valid_ids = cat(1, valid_ids, valid); + + res = bsxfun(@plus, res, -median(res)); + + geom_data = cat(1, geom_data, res); + + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/SEMAINE/Script_HOG_SVM_train.m b/matlab_version/AU_training/experiments/SEMAINE/Script_HOG_SVM_train.m new file mode 100644 index 00000000..5da14194 --- /dev/null +++ b/matlab_version/AU_training/experiments/SEMAINE/Script_HOG_SVM_train.m @@ -0,0 +1,77 @@ +function Script_HOG_SVM_train() + +% Change to your downloaded location +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); + +%% load shared definitions and AU data +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-9:0.5:1); +hyperparams.e = 10.^(-3); + +hyperparams.validate_params = {'c', 'e'}; + +% Set the training function +svm_train = @svm_train_linear; + +% Set the test function (the first output will be used for validation) +svm_test = @svm_test_linear; + +pca_loc = '../../pca_generation/generic_face_rigid.mat'; + +%% +for a=1:numel(aus) + + au = aus(a); + + rest_aus = setdiff(all_aus, au); + + % load the training and testing data for the current fold + [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling] = Prepare_HOG_AU_data_generic(train_recs, devel_recs, au, rest_aus, SEMAINE_dir, hog_data_dir, pca_loc); + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + + %% Cross-validate here + [ best_params, ~ ] = validate_grid_search_no_par(svm_train, svm_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + + model = svm_train(train_labels, train_samples, best_params); + + [prediction, a, actual_vals] = predict(valid_labels, valid_samples, model); + + % Go from raw data to the prediction + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + name = sprintf('models/AU_%d_static.dat', au); + + pos_lbl = model.Label(1); + neg_lbl = model.Label(2); + + write_lin_svm(name, means, svs, b, pos_lbl, neg_lbl); + + name = sprintf('results_SEMAINE_devel/AU_%d_static.mat', au); + + tp = sum(valid_labels == 1 & prediction == 1); + fp = sum(valid_labels == 0 & prediction == 1); + fn = sum(valid_labels == 1 & prediction == 0); + tn = sum(valid_labels == 0 & prediction == 0); + + precision = tp/(tp+fp); + recall = tp/(tp+fn); + + f1 = 2 * precision * recall / (precision + recall); + + save(name, 'model', 'f1', 'precision', 'recall', 'best_params', 'valid_labels', 'prediction'); + +end + +end + + diff --git a/matlab_version/AU_training/experiments/SEMAINE/Script_HOG_SVM_train_dyn.m b/matlab_version/AU_training/experiments/SEMAINE/Script_HOG_SVM_train_dyn.m new file mode 100644 index 00000000..7fe9d5e1 --- /dev/null +++ b/matlab_version/AU_training/experiments/SEMAINE/Script_HOG_SVM_train_dyn.m @@ -0,0 +1,74 @@ +function Script_HOG_SVM_train_dyn() + +% Change to your downloaded location +addpath('C:\liblinear\matlab') + +%% load shared definitions and AU data +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-9:0.5:1); +hyperparams.e = 10.^(-3); + +hyperparams.validate_params = {'c', 'e'}; + +% Set the training function +svm_train = @svm_train_linear; + +% Set the test function (the first output will be used for validation) +svm_test = @svm_test_linear; + +pca_loc = '../../pca_generation/generic_face_rigid.mat'; + +%% +for a=1:numel(aus) + + au = aus(a); + + rest_aus = setdiff(all_aus, au); + + % load the training and testing data for the current fold + [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling] = Prepare_HOG_AU_data_generic_dynamic(train_recs, devel_recs, au, rest_aus, SEMAINE_dir, hog_data_dir, pca_loc); + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + + %% Cross-validate here + [ best_params, ~ ] = validate_grid_search_no_par(svm_train, svm_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + + model = svm_train(train_labels, train_samples, best_params); + + [prediction, a, actual_vals] = predict(valid_labels, valid_samples, model); + + % Go from raw data to the prediction + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + name = sprintf('models/AU_%d_dyn.dat', au); + + pos_lbl = model.Label(1); + neg_lbl = model.Label(2); + + write_lin_dyn_svm(name, means, svs, b, pos_lbl, neg_lbl); + + name = sprintf('results_SEMAINE_devel/AU_%d_dyn.mat', au); + + tp = sum(valid_labels == 1 & prediction == 1); + fp = sum(valid_labels == 0 & prediction == 1); + fn = sum(valid_labels == 1 & prediction == 0); + tn = sum(valid_labels == 0 & prediction == 0); + + precision = tp/(tp+fp); + recall = tp/(tp+fn); + + f1 = 2 * precision * recall / (precision + recall); + + save(name, 'model', 'f1', 'precision', 'recall', 'best_params', 'valid_labels', 'prediction'); + +end + +end + + diff --git a/matlab_version/AU_training/experiments/SEMAINE/models/AU_12_dyn.dat b/matlab_version/AU_training/experiments/SEMAINE/models/AU_12_dyn.dat new file mode 100644 index 00000000..bfaa9894 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/models/AU_12_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/models/AU_12_dyn_shift.dat b/matlab_version/AU_training/experiments/SEMAINE/models/AU_12_dyn_shift.dat new file mode 100644 index 00000000..13f44ca9 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/models/AU_12_dyn_shift.dat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/models/AU_12_static.dat b/matlab_version/AU_training/experiments/SEMAINE/models/AU_12_static.dat new file mode 100644 index 00000000..26235d6d Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/models/AU_12_static.dat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/models/AU_17_dyn.dat b/matlab_version/AU_training/experiments/SEMAINE/models/AU_17_dyn.dat new file mode 100644 index 00000000..275df3c0 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/models/AU_17_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/models/AU_17_dyn_shift.dat b/matlab_version/AU_training/experiments/SEMAINE/models/AU_17_dyn_shift.dat new file mode 100644 index 00000000..903cb40d Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/models/AU_17_dyn_shift.dat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/models/AU_17_static.dat b/matlab_version/AU_training/experiments/SEMAINE/models/AU_17_static.dat new file mode 100644 index 00000000..32ae98ef Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/models/AU_17_static.dat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/models/AU_25_dyn.dat b/matlab_version/AU_training/experiments/SEMAINE/models/AU_25_dyn.dat new file mode 100644 index 00000000..3dd8401b Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/models/AU_25_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/models/AU_25_dyn_shift.dat b/matlab_version/AU_training/experiments/SEMAINE/models/AU_25_dyn_shift.dat new file mode 100644 index 00000000..c2808315 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/models/AU_25_dyn_shift.dat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/models/AU_25_static.dat b/matlab_version/AU_training/experiments/SEMAINE/models/AU_25_static.dat new file mode 100644 index 00000000..1977f940 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/models/AU_25_static.dat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/models/AU_28_dyn.dat b/matlab_version/AU_training/experiments/SEMAINE/models/AU_28_dyn.dat new file mode 100644 index 00000000..d53c4c23 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/models/AU_28_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/models/AU_28_dyn_shift.dat b/matlab_version/AU_training/experiments/SEMAINE/models/AU_28_dyn_shift.dat new file mode 100644 index 00000000..b193447d Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/models/AU_28_dyn_shift.dat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/models/AU_28_static.dat b/matlab_version/AU_training/experiments/SEMAINE/models/AU_28_static.dat new file mode 100644 index 00000000..97fed7e4 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/models/AU_28_static.dat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/models/AU_2_dyn.dat b/matlab_version/AU_training/experiments/SEMAINE/models/AU_2_dyn.dat new file mode 100644 index 00000000..827a2204 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/models/AU_2_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/models/AU_2_dyn_shift.dat b/matlab_version/AU_training/experiments/SEMAINE/models/AU_2_dyn_shift.dat new file mode 100644 index 00000000..e216dc1f Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/models/AU_2_dyn_shift.dat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/models/AU_2_static.dat b/matlab_version/AU_training/experiments/SEMAINE/models/AU_2_static.dat new file mode 100644 index 00000000..f90ec886 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/models/AU_2_static.dat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/models/AU_45_dyn.dat b/matlab_version/AU_training/experiments/SEMAINE/models/AU_45_dyn.dat new file mode 100644 index 00000000..2e92ca2e Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/models/AU_45_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/models/AU_45_dyn_shift.dat b/matlab_version/AU_training/experiments/SEMAINE/models/AU_45_dyn_shift.dat new file mode 100644 index 00000000..3a8ddbf5 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/models/AU_45_dyn_shift.dat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/models/AU_45_static.dat b/matlab_version/AU_training/experiments/SEMAINE/models/AU_45_static.dat new file mode 100644 index 00000000..dc010488 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/models/AU_45_static.dat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_12_dyn.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_12_dyn.mat new file mode 100644 index 00000000..834ed4f0 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_12_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_12_static.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_12_static.mat new file mode 100644 index 00000000..a3139a1d Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_12_static.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_17_dyn.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_17_dyn.mat new file mode 100644 index 00000000..c943dcd3 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_17_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_17_static.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_17_static.mat new file mode 100644 index 00000000..92e44773 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_17_static.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_25_dyn.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_25_dyn.mat new file mode 100644 index 00000000..4a1ee7ae Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_25_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_25_static.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_25_static.mat new file mode 100644 index 00000000..f83b4c55 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_25_static.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_28_dyn.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_28_dyn.mat new file mode 100644 index 00000000..33a2e292 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_28_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_28_static.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_28_static.mat new file mode 100644 index 00000000..9b54ed61 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_28_static.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_2_dyn.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_2_dyn.mat new file mode 100644 index 00000000..dbdec3ea Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_2_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_2_static.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_2_static.mat new file mode 100644 index 00000000..6b76c411 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_2_static.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_45_dyn.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_45_dyn.mat new file mode 100644 index 00000000..2c60954f Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_45_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_45_static.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_45_static.mat new file mode 100644 index 00000000..f5dbd843 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel/AU_45_static.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_12_dyn.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_12_dyn.mat new file mode 100644 index 00000000..a5dcc997 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_12_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_12_static.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_12_static.mat new file mode 100644 index 00000000..69b06c41 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_12_static.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_17_dyn.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_17_dyn.mat new file mode 100644 index 00000000..ff99ac09 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_17_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_17_static.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_17_static.mat new file mode 100644 index 00000000..ef347cb3 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_17_static.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_25_dyn.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_25_dyn.mat new file mode 100644 index 00000000..51a7fcee Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_25_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_25_static.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_25_static.mat new file mode 100644 index 00000000..01aa51f0 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_25_static.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_28_dyn.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_28_dyn.mat new file mode 100644 index 00000000..1122954e Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_28_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_28_static.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_28_static.mat new file mode 100644 index 00000000..42bbaa45 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_28_static.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_2_dyn.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_2_dyn.mat new file mode 100644 index 00000000..8fc81e7c Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_2_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_2_static.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_2_static.mat new file mode 100644 index 00000000..33e3fec3 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_2_static.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_45_dyn.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_45_dyn.mat new file mode 100644 index 00000000..1d885028 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_45_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_45_static.mat b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_45_static.mat new file mode 100644 index 00000000..a4867b30 Binary files /dev/null and b/matlab_version/AU_training/experiments/SEMAINE/results_SEMAINE_devel_back/AU_45_static.mat differ diff --git a/matlab_version/AU_training/experiments/SEMAINE/shared_defs.m b/matlab_version/AU_training/experiments/SEMAINE/shared_defs.m new file mode 100644 index 00000000..1e7fd00c --- /dev/null +++ b/matlab_version/AU_training/experiments/SEMAINE/shared_defs.m @@ -0,0 +1,10 @@ +% this is data defined across the experiments (to make sure all of them have same user conventions) + +% Defining which AU's we are extracting (all corrs above 0.5) +all_aus = [2 12 17 25 28 45]; +aus = [2 12 17 25 28 45]; + +addpath('../../data extraction/'); + +find_SEMAINE + diff --git a/matlab_version/AU_training/experiments/UNBC/Prepare_HOG_AU_data.m b/matlab_version/AU_training/experiments/UNBC/Prepare_HOG_AU_data.m new file mode 100644 index 00000000..6ada1757 --- /dev/null +++ b/matlab_version/AU_training/experiments/UNBC/Prepare_HOG_AU_data.m @@ -0,0 +1,118 @@ +function [data_train, labels_train, data_devel, labels_devel, raw_devel, PC, means_norm, stds_norm, devel_ids, devel_success] = ... + Prepare_HOG_AU_data(train_users, devel_users, au_train, rest_aus, UNBC_dir, hog_data_dir) + +%% +addpath(genpath('../data extraction/')); + +% First extracting the labels +[ labels_train, valid_ids_train, filenames ] = extract_UNBC_labels(UNBC_dir, train_users, au_train); + +[ labels_other, ~, ~ ] = extract_UNBC_labels(UNBC_dir, train_users, rest_aus); +labels_other = cat(1, labels_other{:}); + +% Reading in the HOG data (of only relevant frames) +[train_appearance_data, valid_ids_train_hog, vid_ids_train_string] = Read_HOG_files(train_users, hog_data_dir); + +clm_data_dir = [hog_data_dir, '/../model_params']; +[train_geom_data] = Read_geom_files(train_users, clm_data_dir); + +% Subsample the data to make training quicker +labels_train = cat(1, labels_train{:}); +valid_ids_train = logical(cat(1, valid_ids_train{:})); + +if(numel(train_users) > 0) + reduced_inds = false(size(labels_train,1),1); + reduced_inds(labels_train > 0) = true; + + % make sure the same number of positive and negative samples is taken + pos_count = sum(labels_train > 0); + neg_count = sum(labels_train == 0); + + num_other = floor(pos_count / (size(labels_other, 2))); + + inds_all = 1:size(labels_train,1); + + for i=1:size(labels_other, 2)+1 + + if(i > size(labels_other, 2)) + % fill the rest with a proportion of neutral + inds_other = inds_all(sum(labels_other,2)==0 & ~labels_train ); + num_other_i = min(numel(inds_other), pos_count - sum(labels_train(reduced_inds,:)==0)); + else + % take a proportion of each other AU + inds_other = inds_all(labels_other(:, i) & ~labels_train ); + num_other_i = min(numel(inds_other), num_other); + end + inds_other_to_keep = inds_other(round(linspace(1, numel(inds_other), num_other_i))); + reduced_inds(inds_other_to_keep) = true; + + end + + % Remove invalid ids based on CLM failing or AU not being labelled + reduced_inds(~valid_ids_train) = false; + reduced_inds(~valid_ids_train_hog) = false; + + labels_other = labels_other(reduced_inds, :); + labels_train = labels_train(reduced_inds,:); + train_appearance_data = train_appearance_data(reduced_inds,:); + train_geom_data = train_geom_data(reduced_inds,:); + vid_ids_train_string = vid_ids_train_string(reduced_inds,:); +end +%% Extract devel data + +% First extracting the labels +[ labels_devel, valid_ids_devel, vid_ids_devel ] = extract_UNBC_labels(UNBC_dir, devel_users, au_train); + +% Reading in the HOG data (of only relevant frames) +[devel_appearance_data, valid_ids_devel_hog, vid_ids_devel_string] = Read_HOG_files(devel_users, hog_data_dir); +devel_success = valid_ids_devel_hog; +devel_ids = vid_ids_devel_string; + +[devel_geom_data] = Read_geom_files(devel_users, clm_data_dir); + +labels_devel = cat(1, labels_devel{:}); + +% Peforming zone specific masking +if(au_train < 8 || au_train == 43 || au_train == 45) % upper face AUs ignore bottom face + % normalise the data + pca_file = '../../pca_generation/generic_face_upper.mat'; + load(pca_file); +elseif(au_train > 9) % lower face AUs ignore upper face and the sides + % normalise the data + pca_file = '../../pca_generation/generic_face_lower.mat'; + load(pca_file); +elseif(au_train == 9) % Central face model + % normalise the data + pca_file = '../../pca_generation/generic_face_rigid.mat'; + load(pca_file); +end + +% Grab all data for validation as want good params for all the data +raw_devel = cat(2, devel_appearance_data, devel_geom_data); + +devel_appearance_data = bsxfun(@times, bsxfun(@plus, devel_appearance_data, -means_norm), 1./stds_norm); + +data_devel = devel_appearance_data * PC; + +data_devel = cat(2, data_devel, devel_geom_data); + +if(numel(train_users) > 0) + train_appearance_data = bsxfun(@times, bsxfun(@plus, train_appearance_data, -means_norm), 1./stds_norm); + + data_train = train_appearance_data * PC; + data_train = cat(2, data_train, train_geom_data); +else + data_train = []; +end + +geom_size = max(size(train_geom_data, 2), size(devel_geom_data, 2)); + +PC_n = zeros(size(PC)+geom_size); +PC_n(1:size(PC,1), 1:size(PC,2)) = PC; +PC_n(size(PC,1)+1:end, size(PC,2)+1:end) = eye(geom_size); +PC = PC_n; + +means_norm = cat(2, means_norm, zeros(1, geom_size)); +stds_norm = cat(2, stds_norm, ones(1, geom_size)); + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/UNBC/Prepare_HOG_AU_data_dynamic.m b/matlab_version/AU_training/experiments/UNBC/Prepare_HOG_AU_data_dynamic.m new file mode 100644 index 00000000..1c5e231b --- /dev/null +++ b/matlab_version/AU_training/experiments/UNBC/Prepare_HOG_AU_data_dynamic.m @@ -0,0 +1,118 @@ +function [data_train, labels_train, data_devel, labels_devel, raw_devel, PC, means_norm, stds_norm, devel_ids, devel_success] = ... + Prepare_HOG_AU_data_dynamic(train_users, devel_users, au_train, rest_aus, UNBC_dir, hog_data_dir) + +%% +addpath(genpath('../data extraction/')); + +% First extracting the labels +[ labels_train, valid_ids_train, filenames ] = extract_UNBC_labels(UNBC_dir, train_users, au_train); + +[ labels_other, ~, ~ ] = extract_UNBC_labels(UNBC_dir, train_users, rest_aus); +labels_other = cat(1, labels_other{:}); + +% Reading in the HOG data (of only relevant frames) +[train_appearance_data, valid_ids_train_hog, vid_ids_train_string] = Read_HOG_files_dynamic(train_users, hog_data_dir); + +clm_data_dir = [hog_data_dir, '/../model_params']; +[train_geom_data] = Read_geom_files_dynamic(train_users, clm_data_dir); + +% Subsample the data to make training quicker +labels_train = cat(1, labels_train{:}); +valid_ids_train = logical(cat(1, valid_ids_train{:})); + +if(numel(train_users) > 0) + reduced_inds = false(size(labels_train,1),1); + reduced_inds(labels_train > 0) = true; + + % make sure the same number of positive and negative samples is taken + pos_count = sum(labels_train > 0); + neg_count = sum(labels_train == 0); + + num_other = floor(pos_count / (size(labels_other, 2))); + + inds_all = 1:size(labels_train,1); + + for i=1:size(labels_other, 2)+1 + + if(i > size(labels_other, 2)) + % fill the rest with a proportion of neutral + inds_other = inds_all(sum(labels_other,2)==0 & ~labels_train ); + num_other_i = min(numel(inds_other), pos_count - sum(labels_train(reduced_inds,:)==0)); + else + % take a proportion of each other AU + inds_other = inds_all(labels_other(:, i) & ~labels_train ); + num_other_i = min(numel(inds_other), num_other); + end + inds_other_to_keep = inds_other(round(linspace(1, numel(inds_other), num_other_i))); + reduced_inds(inds_other_to_keep) = true; + + end + + % Remove invalid ids based on CLM failing or AU not being labelled + reduced_inds(~valid_ids_train) = false; + reduced_inds(~valid_ids_train_hog) = false; + + labels_other = labels_other(reduced_inds, :); + labels_train = labels_train(reduced_inds,:); + train_appearance_data = train_appearance_data(reduced_inds,:); + train_geom_data = train_geom_data(reduced_inds,:); + vid_ids_train_string = vid_ids_train_string(reduced_inds,:); +end +%% Extract devel data + +% First extracting the labels +[ labels_devel, valid_ids_devel, vid_ids_devel ] = extract_UNBC_labels(UNBC_dir, devel_users, au_train); + +% Reading in the HOG data (of only relevant frames) +[devel_appearance_data, valid_ids_devel_hog, vid_ids_devel_string] = Read_HOG_files_dynamic(devel_users, hog_data_dir); +devel_success = valid_ids_devel_hog; +devel_ids = vid_ids_devel_string; + +[devel_geom_data] = Read_geom_files_dynamic(devel_users, clm_data_dir); + +labels_devel = cat(1, labels_devel{:}); + +% Peforming zone specific masking +if(au_train < 8 || au_train == 43 || au_train == 45) % upper face AUs ignore bottom face + % normalise the data + pca_file = '../../pca_generation/generic_face_upper.mat'; + load(pca_file); +elseif(au_train > 9) % lower face AUs ignore upper face and the sides + % normalise the data + pca_file = '../../pca_generation/generic_face_lower.mat'; + load(pca_file); +elseif(au_train == 9) % Central face model + % normalise the data + pca_file = '../../pca_generation/generic_face_rigid.mat'; + load(pca_file); +end + +% Grab all data for validation as want good params for all the data +raw_devel = cat(2, devel_appearance_data, devel_geom_data); + +devel_appearance_data = bsxfun(@times, bsxfun(@plus, devel_appearance_data, -means_norm), 1./stds_norm); + +data_devel = devel_appearance_data * PC; + +data_devel = cat(2, data_devel, devel_geom_data); + +if(numel(train_users) > 0) + train_appearance_data = bsxfun(@times, bsxfun(@plus, train_appearance_data, -means_norm), 1./stds_norm); + + data_train = train_appearance_data * PC; + data_train = cat(2, data_train, train_geom_data); +else + data_train = []; +end + +geom_size = max(size(train_geom_data, 2), size(devel_geom_data, 2)); + +PC_n = zeros(size(PC)+geom_size); +PC_n(1:size(PC,1), 1:size(PC,2)) = PC; +PC_n(size(PC,1)+1:end, size(PC,2)+1:end) = eye(geom_size); +PC = PC_n; + +means_norm = cat(2, means_norm, zeros(1, geom_size)); +stds_norm = cat(2, stds_norm, ones(1, geom_size)); + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/UNBC/Read_HOG_files.m b/matlab_version/AU_training/experiments/UNBC/Read_HOG_files.m new file mode 100644 index 00000000..fcab4a6f --- /dev/null +++ b/matlab_version/AU_training/experiments/UNBC/Read_HOG_files.m @@ -0,0 +1,89 @@ +function [hog_data, valid_data, vid_id] = Read_HOG_files(users, hog_data_dir) + + + hog_data = []; + vid_id = {}; + valid_data = []; + + feats_filled = 0; + + for i=1:numel(users) + + hog_files = dir([hog_data_dir, '/' users{i} '*.hog']); + + for f_num=1:numel(hog_files) + f = fopen([hog_data_dir, '/', hog_files(f_num).name], 'r'); + + curr_data = []; + curr_ind = 0; + + while(~feof(f)) + + if(curr_ind == 0) + num_cols = fread(f, 1, 'int32'); + if(isempty(num_cols)) + break; + end + + num_rows = fread(f, 1, 'int32'); + num_chan = fread(f, 1, 'int32'); + + curr_ind = curr_ind + 1; + + % preallocate some space + if(curr_ind == 1) + curr_data = zeros(5000, 1 + num_rows * num_cols * num_chan); + num_feats = 1 + num_rows * num_cols * num_chan; + end + + if(curr_ind > size(curr_data,1)) + curr_data = cat(1, curr_data, zeros(6000, 1 + num_rows * num_cols * num_chan)); + end + feature_vec = fread(f, [1, 1 + num_rows * num_cols * num_chan], 'float32'); + curr_data(curr_ind, :) = feature_vec; + else + + % Reading in batches of 5000 + + feature_vec = fread(f, [4 + num_rows * num_cols * num_chan, 5000], 'float32'); + feature_vec = feature_vec(4:end,:)'; + + num_rows_read = size(feature_vec,1); + + curr_data(curr_ind+1:curr_ind+num_rows_read,:) = feature_vec; + + curr_ind = curr_ind + size(feature_vec,1); + + end + + end + + fclose(f); + + curr_data = curr_data(1:curr_ind,:); + vid_id_curr = cell(curr_ind,1); + vid_id_curr(:) = users(i); + + vid_id = cat(1, vid_id, vid_id_curr); + + % Assume same number of frames per video + if(i==1) + hog_data = zeros(curr_ind*numel(users), num_feats); + end + + if(size(hog_data,1) < feats_filled+curr_ind) + hog_data = cat(1, hog_data, zeros(size(hog_data,1), num_feats)); + end + + hog_data(feats_filled+1:feats_filled+curr_ind,:) = curr_data; + + feats_filled = feats_filled + curr_ind; + end + end + + if(numel(users) > 0) + valid_data = hog_data(1:feats_filled,1) > 0; + hog_data = hog_data(1:feats_filled,2:end); + end + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/UNBC/Read_HOG_files_dynamic.m b/matlab_version/AU_training/experiments/UNBC/Read_HOG_files_dynamic.m new file mode 100644 index 00000000..aabe493e --- /dev/null +++ b/matlab_version/AU_training/experiments/UNBC/Read_HOG_files_dynamic.m @@ -0,0 +1,93 @@ +function [hog_data, valid_data, vid_id] = Read_HOG_files_dynamic(users, hog_data_dir) + + + hog_data = []; + vid_id = {}; + valid_data = []; + + for i=1:numel(users) + + hog_files = dir([hog_data_dir, '/' users{i} '*.hog']); + + hog_data_curr_p = []; + feats_filled = 0; + + for f_num=1:numel(hog_files) + f = fopen([hog_data_dir, '/', hog_files(f_num).name], 'r'); + + curr_data = []; + curr_ind = 0; + + while(~feof(f)) + + if(curr_ind == 0) + num_cols = fread(f, 1, 'int32'); + if(isempty(num_cols)) + break; + end + + num_rows = fread(f, 1, 'int32'); + num_chan = fread(f, 1, 'int32'); + + curr_ind = curr_ind + 1; + + % preallocate some space + if(curr_ind == 1) + curr_data = zeros(5000, 1 + num_rows * num_cols * num_chan); + num_feats = 1 + num_rows * num_cols * num_chan; + end + + if(curr_ind > size(curr_data,1)) + curr_data = cat(1, curr_data, zeros(6000, 1 + num_rows * num_cols * num_chan)); + end + feature_vec = fread(f, [1, 1 + num_rows * num_cols * num_chan], 'float32'); + curr_data(curr_ind, :) = feature_vec; + else + + % Reading in batches of 5000 + + feature_vec = fread(f, [4 + num_rows * num_cols * num_chan, 5000], 'float32'); + feature_vec = feature_vec(4:end,:)'; + + num_rows_read = size(feature_vec,1); + + curr_data(curr_ind+1:curr_ind+num_rows_read,:) = feature_vec; + + curr_ind = curr_ind + size(feature_vec,1); + + end + + end + + fclose(f); + + curr_data = curr_data(1:curr_ind,:); + vid_id_curr = cell(curr_ind,1); + vid_id_curr(:) = users(i); + + vid_id = cat(1, vid_id, vid_id_curr); + + % Assume same number of frames per video + if(f_num==1) + hog_data_curr_p = zeros(curr_ind*numel(users), num_feats); + end + + if(size(hog_data_curr_p,1) < feats_filled+curr_ind) + hog_data_curr_p = cat(1, hog_data_curr_p, zeros(size(hog_data_curr_p,1), num_feats)); + end + + hog_data_curr_p(feats_filled+1:feats_filled+curr_ind,:) = curr_data; + + feats_filled = feats_filled + curr_ind; + end + + hog_data_curr_p(1:feats_filled,2:end) = bsxfun(@plus, hog_data_curr_p(1:feats_filled,2:end), -median(hog_data_curr_p(1:feats_filled,2:end))); + hog_data = cat(1, hog_data, hog_data_curr_p(1:feats_filled,:)); + + end + + if(numel(users) > 0) + valid_data = hog_data(:,1) > 0; + hog_data = hog_data(:,2:end); + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/UNBC/Read_geom_files.m b/matlab_version/AU_training/experiments/UNBC/Read_geom_files.m new file mode 100644 index 00000000..9d57c717 --- /dev/null +++ b/matlab_version/AU_training/experiments/UNBC/Read_geom_files.m @@ -0,0 +1,34 @@ +function [geom_data, valid_ids] = Read_geom_files(users, model_param_data_dir) + + geom_data = []; + valid_ids = []; + + load('../../pca_generation/pdm_68_aligned_wild.mat'); + + for i=1:numel(users) + + geom_files = dir([model_param_data_dir, '/' users{i} '*.txt']); + + for g=1:numel(geom_files) + + m_file = [model_param_data_dir, '/', geom_files(g).name, '.mat']; + + if(~exist(m_file, 'file')) + res = dlmread([model_param_data_dir, '/', geom_files(g).name], ',', 1, 0); + save(m_file, 'res'); + else + load(m_file); + end + + valid = res(:, 4); + res = res(:, 11:end); + + actual_locs = res * V'; + res = cat(2, actual_locs, res); + + valid_ids = cat(1, valid_ids, valid); + + geom_data = cat(1, geom_data, res); + end + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/UNBC/Read_geom_files_dynamic.m b/matlab_version/AU_training/experiments/UNBC/Read_geom_files_dynamic.m new file mode 100644 index 00000000..44cc3bf1 --- /dev/null +++ b/matlab_version/AU_training/experiments/UNBC/Read_geom_files_dynamic.m @@ -0,0 +1,39 @@ +function [geom_data, valid_ids] = Read_geom_files_dynamic(users, model_param_data_dir) + + geom_data = []; + valid_ids = []; + + load('../../pca_generation/pdm_68_aligned_wild.mat'); + + for i=1:numel(users) + + geom_files = dir([model_param_data_dir, '/' users{i} '*.txt']); + + geom_data_curr_p = []; + + for g=1:numel(geom_files) + m_file = [model_param_data_dir, '/', geom_files(g).name, '.mat']; + + if(~exist(m_file, 'file')) + res = dlmread([model_param_data_dir, '/', geom_files(g).name], ',', 1, 0); + save(m_file, 'res'); + else + load(m_file); + end + + valid = res(:, 4); + res = res(:, 11:end); + + actual_locs = res * V'; + res = cat(2, actual_locs, res); + + valid_ids = cat(1, valid_ids, valid); + + geom_data_curr_p = cat(1, geom_data_curr_p, res); + end + geom_data_curr_p = bsxfun(@plus, geom_data_curr_p, -median(geom_data_curr_p)); + + geom_data = cat(1, geom_data, geom_data_curr_p); + + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/UNBC/Script_HOG_SVM_train.m b/matlab_version/AU_training/experiments/UNBC/Script_HOG_SVM_train.m new file mode 100644 index 00000000..2875a924 --- /dev/null +++ b/matlab_version/AU_training/experiments/UNBC/Script_HOG_SVM_train.m @@ -0,0 +1,83 @@ +function Script_HOG_SVM_train() + +% Change to your downloaded location +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); + +%% load shared definitions and AU data +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-9:0.5:1); +hyperparams.e = 10.^(-3); + +hyperparams.validate_params = {'c', 'e'}; + +% Set the training function +svm_train = @svm_train_linear; + +% Set the test function (the first output will be used for validation) +svm_test = @svm_test_linear; + +all_recs = cat(2, train_recs, devel_recs); + +%% +for a=1:numel(aus) + + au = aus(a); + + rest_aus = setdiff(all_aus, au); + + [users_train, users_valid] = get_balanced_fold(UNBC_dir, all_recs, au, 1/3, 1); + + % load the training and testing data for the current fold + [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling] = Prepare_HOG_AU_data(users_train, users_valid, au, rest_aus, UNBC_dir, hog_data_dir); + + % Binarizing the data + train_labels(train_labels > 1) = 1; + valid_labels(valid_labels > 1) = 1; + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + + %% Cross-validate here + [ best_params, ~ ] = validate_grid_search_no_par(svm_train, svm_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + + model = svm_train(train_labels, train_samples, best_params); + + [prediction, a, actual_vals] = predict(valid_labels, valid_samples, model); + + % Go from raw data to the prediction + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + name = sprintf('models/AU_%d_static.dat', au); + + pos_lbl = model.Label(1); + neg_lbl = model.Label(2); + + write_lin_svm(name, means, svs, b, pos_lbl, neg_lbl); + + name = sprintf('results_UNBC_devel/AU_%d_static.mat', au); + + tp = sum(valid_labels == 1 & prediction == 1); + fp = sum(valid_labels == 0 & prediction == 1); + fn = sum(valid_labels == 1 & prediction == 0); + tn = sum(valid_labels == 0 & prediction == 0); + + precision = tp/(tp+fp); + recall = tp/(tp+fn); + + f1 = 2 * precision * recall / (precision + recall); + + save(name, 'model', 'f1', 'precision', 'recall', 'best_params', 'valid_labels', 'prediction', 'users_valid'); + +end + +end + + diff --git a/matlab_version/AU_training/experiments/UNBC/Script_HOG_SVM_train_dyn.m b/matlab_version/AU_training/experiments/UNBC/Script_HOG_SVM_train_dyn.m new file mode 100644 index 00000000..00a9bd2f --- /dev/null +++ b/matlab_version/AU_training/experiments/UNBC/Script_HOG_SVM_train_dyn.m @@ -0,0 +1,83 @@ +function Script_HOG_SVM_train_dyn() + +% Change to your downloaded location +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); + +%% load shared definitions and AU data +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-9:0.5:1); +hyperparams.e = 10.^(-3); + +hyperparams.validate_params = {'c', 'e'}; + +% Set the training function +svm_train = @svm_train_linear; + +% Set the test function (the first output will be used for validation) +svm_test = @svm_test_linear; + +all_recs = cat(2, train_recs, devel_recs); + +%% +for a=1:numel(aus) + + au = aus(a); + + rest_aus = setdiff(all_aus, au); + + [users_train, users_valid] = get_balanced_fold(UNBC_dir, all_recs, au, 1/3, 1); + + % load the training and testing data for the current fold + [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling] = Prepare_HOG_AU_data_dynamic(users_train, users_valid, au, rest_aus, UNBC_dir, hog_data_dir); + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + + % Binarizing the data + train_labels(train_labels > 1) = 1; + valid_labels(valid_labels > 1) = 1; + + %% Cross-validate here + [ best_params, ~ ] = validate_grid_search_no_par(svm_train, svm_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + + model = svm_train(train_labels, train_samples, best_params); + + [prediction, a, actual_vals] = predict(valid_labels, valid_samples, model); + + % Go from raw data to the prediction + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + name = sprintf('models/AU_%d_dyn.dat', au); + + pos_lbl = model.Label(1); + neg_lbl = model.Label(2); + + write_lin_dyn_svm(name, means, svs, b, pos_lbl, neg_lbl); + + name = sprintf('results_UNBC_devel/AU_%d_dyn.mat', au); + + tp = sum(valid_labels == 1 & prediction == 1); + fp = sum(valid_labels == 0 & prediction == 1); + fn = sum(valid_labels == 1 & prediction == 0); + tn = sum(valid_labels == 0 & prediction == 0); + + precision = tp/(tp+fp); + recall = tp/(tp+fn); + + f1 = 2 * precision * recall / (precision + recall); + + save(name, 'model', 'f1', 'precision', 'recall', 'best_params', 'valid_labels', 'prediction', 'users_valid'); + +end + +end + + diff --git a/matlab_version/AU_training/experiments/UNBC/Script_HOG_SVR_train.m b/matlab_version/AU_training/experiments/UNBC/Script_HOG_SVR_train.m new file mode 100644 index 00000000..bc6e73e9 --- /dev/null +++ b/matlab_version/AU_training/experiments/UNBC/Script_HOG_SVR_train.m @@ -0,0 +1,70 @@ +function Script_HOG_SVR_train() + +% Change to your downloaded location +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); + +%% load shared definitions and AU data +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-7:1:4); +hyperparams.p = 10.^(-2); + +hyperparams.validate_params = {'c', 'p'}; + +% Set the training function +svr_train = @svr_train_linear; + +% Set the test function (the first output will be used for validation) +svr_test = @svr_test_linear; + +all_recs = cat(2, train_recs, devel_recs); + +%% +for a=1:numel(aus) + + au = aus(a); + + rest_aus = setdiff(all_aus, au); + + [users_train, users_valid] = get_balanced_fold(UNBC_dir, all_recs, au, 1/3, 1); + + % load the training and testing data for the current fold + [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data(users_train, users_valid, au, rest_aus, UNBC_dir, hog_data_dir); + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + + hyperparams.success = valid_success; + + %% Cross-validate here + [ best_params, ~ ] = validate_grid_search_no_par(svr_train, svr_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + + model = svr_train(train_labels, train_samples, best_params); + + [~, prediction] = svr_test(valid_labels, valid_samples, model); + + % Go from raw data to the prediction + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + name = sprintf('models/AU_%d_static_intensity.dat', au); + + write_lin_svr(name, means, svs, b); + + name = sprintf('results_UNBC_devel/AU_%d_static_intensity.mat', au); + + [ accuracies, F1s, corrs, ccc, rms, classes ] = evaluate_regression_results( prediction, valid_labels ); + + save(name, 'model', 'F1s', 'corrs', 'accuracies', 'ccc', 'rms', 'prediction', 'valid_labels', 'users_valid'); + +end + +end + + diff --git a/matlab_version/AU_training/experiments/UNBC/Script_HOG_SVR_train_dyn.m b/matlab_version/AU_training/experiments/UNBC/Script_HOG_SVR_train_dyn.m new file mode 100644 index 00000000..a51a7ddc --- /dev/null +++ b/matlab_version/AU_training/experiments/UNBC/Script_HOG_SVR_train_dyn.m @@ -0,0 +1,70 @@ +function Script_HOG_SVR_train_dyn() + +% Change to your downloaded location +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); + +%% load shared definitions and AU data +shared_defs; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-7:1:4); +hyperparams.p = 10.^(-2); + +hyperparams.validate_params = {'c', 'p'}; + +% Set the training function +svr_train = @svr_train_linear; + +% Set the test function (the first output will be used for validation) +svr_test = @svr_test_linear; + +all_recs = cat(2, train_recs, devel_recs); + +%% +for a=1:numel(aus) + + au = aus(a); + + rest_aus = setdiff(all_aus, au); + + [users_train, users_valid] = get_balanced_fold(UNBC_dir, all_recs, au, 1/3, 1); + + % load the training and testing data for the current fold + [train_samples, train_labels, valid_samples, valid_labels, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data_dynamic(users_train, users_valid, au, rest_aus, UNBC_dir, hog_data_dir); + + train_samples = sparse(train_samples); + valid_samples = sparse(valid_samples); + + hyperparams.success = valid_success; + + %% Cross-validate here + [ best_params, ~ ] = validate_grid_search_no_par(svr_train, svr_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + + model = svr_train(train_labels, train_samples, best_params); + + [~, prediction] = svr_test(valid_labels, valid_samples, model); + + % Go from raw data to the prediction + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + name = sprintf('models/AU_%d_dyn_intensity.dat', au); + + write_lin_dyn_svr(name, means, svs, b); + + name = sprintf('results_UNBC_devel/AU_%d_dyn_intensity.mat', au); + + [ accuracies, F1s, corrs, ccc, rms, classes ] = evaluate_regression_results( prediction, valid_labels ); + + save(name, 'model', 'F1s', 'corrs', 'accuracies', 'ccc', 'rms', 'prediction', 'valid_labels', 'users_valid'); + +end + +end + + diff --git a/matlab_version/AU_training/experiments/UNBC/get_balanced_fold.m b/matlab_version/AU_training/experiments/UNBC/get_balanced_fold.m new file mode 100644 index 00000000..dcae75c2 --- /dev/null +++ b/matlab_version/AU_training/experiments/UNBC/get_balanced_fold.m @@ -0,0 +1,33 @@ +function [train_users, dev_users] = get_balanced_fold(UNBC_dir, users, au, prop_test, offset) + + + [ labels_train, valid_ids_train, filenames ] = extract_UNBC_labels(UNBC_dir, users, au); + + % trimming the filenames a bit + for f=1:numel(filenames) + filenames{f} = filenames{f}(1:5); + end + + counts = zeros(numel(users),1); + for k=1:numel(users) + counts(k) = sum(cat(1, labels_train{strcmp(filenames, users{k}(5:end))})); + end + + [sorted, inds] = sort(counts); + + dev_users = users(inds(offset:round(1/prop_test):end)); + train_users = setdiff(users, dev_users); + + count_dev = 0; + count_train = 0; + for k=1:numel(users) + if(any(strcmp(dev_users, users{k}))) + count_dev = count_dev + counts(k); + else + count_train = count_train + counts(k); + end + + end + fprintf('Mean train %.2f, mean test %.2f\n', count_train / numel(train_users), count_dev / numel(dev_users)); + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_10_dyn.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_10_dyn.dat new file mode 100644 index 00000000..03fcbebd Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_10_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_10_dyn_intensity.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_10_dyn_intensity.dat new file mode 100644 index 00000000..ce8a3d4a Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_10_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_10_static.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_10_static.dat new file mode 100644 index 00000000..51396688 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_10_static.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_10_static_intensity.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_10_static_intensity.dat new file mode 100644 index 00000000..6653c6d0 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_10_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_12_dyn.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_12_dyn.dat new file mode 100644 index 00000000..8a7cc724 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_12_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_12_dyn_intensity.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_12_dyn_intensity.dat new file mode 100644 index 00000000..cf171746 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_12_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_12_static.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_12_static.dat new file mode 100644 index 00000000..25b74954 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_12_static.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_12_static_intensity.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_12_static_intensity.dat new file mode 100644 index 00000000..afed975a Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_12_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_25_dyn.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_25_dyn.dat new file mode 100644 index 00000000..3237f480 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_25_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_25_dyn_intensity.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_25_dyn_intensity.dat new file mode 100644 index 00000000..601c5952 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_25_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_25_static.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_25_static.dat new file mode 100644 index 00000000..7491a0be Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_25_static.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_25_static_intensity.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_25_static_intensity.dat new file mode 100644 index 00000000..7dd79fa4 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_25_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_26_dyn.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_26_dyn.dat new file mode 100644 index 00000000..88b92f01 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_26_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_26_dyn_intensity.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_26_dyn_intensity.dat new file mode 100644 index 00000000..a68e4f2b Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_26_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_26_static.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_26_static.dat new file mode 100644 index 00000000..2171137c Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_26_static.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_26_static_intensity.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_26_static_intensity.dat new file mode 100644 index 00000000..dfafbbf7 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_26_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_6_dyn.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_6_dyn.dat new file mode 100644 index 00000000..14e1323e Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_6_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_6_dyn_intensity.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_6_dyn_intensity.dat new file mode 100644 index 00000000..0695a0d2 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_6_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_6_static.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_6_static.dat new file mode 100644 index 00000000..5ba6355d Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_6_static.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_6_static_intensity.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_6_static_intensity.dat new file mode 100644 index 00000000..77489d3f Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_6_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_7_dyn.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_7_dyn.dat new file mode 100644 index 00000000..4f3b8f2c Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_7_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_7_dyn_intensity.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_7_dyn_intensity.dat new file mode 100644 index 00000000..62a4128c Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_7_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_7_static.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_7_static.dat new file mode 100644 index 00000000..47231d68 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_7_static.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_7_static_intensity.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_7_static_intensity.dat new file mode 100644 index 00000000..b7489f3c Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_7_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_9_dyn.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_9_dyn.dat new file mode 100644 index 00000000..d0d47900 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_9_dyn.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_9_dyn_intensity.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_9_dyn_intensity.dat new file mode 100644 index 00000000..3da026d8 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_9_dyn_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_9_static.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_9_static.dat new file mode 100644 index 00000000..269c5441 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_9_static.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/models/AU_9_static_intensity.dat b/matlab_version/AU_training/experiments/UNBC/models/AU_9_static_intensity.dat new file mode 100644 index 00000000..22e17cda Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/models/AU_9_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_10_dyn.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_10_dyn.mat new file mode 100644 index 00000000..9ccad009 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_10_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_10_dyn_intensity.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_10_dyn_intensity.mat new file mode 100644 index 00000000..f854cb90 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_10_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_10_static.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_10_static.mat new file mode 100644 index 00000000..cbcf2024 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_10_static.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_10_static_intensity.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_10_static_intensity.mat new file mode 100644 index 00000000..bc78d692 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_10_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_12_dyn.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_12_dyn.mat new file mode 100644 index 00000000..162dc7fe Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_12_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_12_dyn_intensity.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_12_dyn_intensity.mat new file mode 100644 index 00000000..2319e1ec Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_12_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_12_static.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_12_static.mat new file mode 100644 index 00000000..4d9f1969 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_12_static.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_12_static_intensity.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_12_static_intensity.mat new file mode 100644 index 00000000..8fa0a93e Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_12_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_25_dyn.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_25_dyn.mat new file mode 100644 index 00000000..af8c2f23 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_25_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_25_dyn_intensity.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_25_dyn_intensity.mat new file mode 100644 index 00000000..4f90cb71 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_25_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_25_static.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_25_static.mat new file mode 100644 index 00000000..6d0e5a7c Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_25_static.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_25_static_intensity.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_25_static_intensity.mat new file mode 100644 index 00000000..10823332 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_25_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_26_dyn.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_26_dyn.mat new file mode 100644 index 00000000..bd2c0db8 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_26_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_26_dyn_intensity.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_26_dyn_intensity.mat new file mode 100644 index 00000000..e86585c2 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_26_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_26_static.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_26_static.mat new file mode 100644 index 00000000..e15633b7 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_26_static.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_26_static_intensity.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_26_static_intensity.mat new file mode 100644 index 00000000..6ee38bdc Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_26_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_6_dyn.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_6_dyn.mat new file mode 100644 index 00000000..cb241d3b Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_6_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_6_dyn_intensity.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_6_dyn_intensity.mat new file mode 100644 index 00000000..646f75f2 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_6_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_6_static.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_6_static.mat new file mode 100644 index 00000000..0322f0d0 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_6_static.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_6_static_intensity.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_6_static_intensity.mat new file mode 100644 index 00000000..790830e3 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_6_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_7_dyn.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_7_dyn.mat new file mode 100644 index 00000000..65f636df Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_7_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_7_dyn_intensity.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_7_dyn_intensity.mat new file mode 100644 index 00000000..7412075f Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_7_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_7_static.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_7_static.mat new file mode 100644 index 00000000..bc0a56c1 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_7_static.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_7_static_intensity.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_7_static_intensity.mat new file mode 100644 index 00000000..63b92ae5 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_7_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_9_dyn.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_9_dyn.mat new file mode 100644 index 00000000..b55a6a93 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_9_dyn.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_9_dyn_intensity.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_9_dyn_intensity.mat new file mode 100644 index 00000000..d5e4cd73 Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_9_dyn_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_9_static.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_9_static.mat new file mode 100644 index 00000000..87d402bb Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_9_static.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_9_static_intensity.mat b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_9_static_intensity.mat new file mode 100644 index 00000000..d05cc2fc Binary files /dev/null and b/matlab_version/AU_training/experiments/UNBC/results_UNBC_devel/AU_9_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/UNBC/shared_defs.m b/matlab_version/AU_training/experiments/UNBC/shared_defs.m new file mode 100644 index 00000000..a423e055 --- /dev/null +++ b/matlab_version/AU_training/experiments/UNBC/shared_defs.m @@ -0,0 +1,10 @@ +% this is data defined across the experiments (to make sure all of them have same user conventions) + +% Defining which AU's we are extracting (all corrs above 0.5) +all_aus = [6, 7, 9, 10, 12, 25, 26]; +aus = [6, 7, 9, 10, 12, 25, 26]; + +addpath('../../data extraction/'); + +find_UNBC; + diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_10_dynamic.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_10_dynamic.dat new file mode 100644 index 00000000..169a5b8a Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_10_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_10_static.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_10_static.dat new file mode 100644 index 00000000..149fcf35 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_10_static.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_12_dynamic.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_12_dynamic.dat new file mode 100644 index 00000000..2f36f6fd Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_12_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_12_static.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_12_static.dat new file mode 100644 index 00000000..2b0c3ab5 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_12_static.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_14_dynamic.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_14_dynamic.dat new file mode 100644 index 00000000..c31894a1 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_14_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_14_static.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_14_static.dat new file mode 100644 index 00000000..e067b63d Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_14_static.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_15_dynamic.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_15_dynamic.dat new file mode 100644 index 00000000..886c0d14 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_15_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_15_static.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_15_static.dat new file mode 100644 index 00000000..4e8c136f Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_15_static.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_17_dynamic.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_17_dynamic.dat new file mode 100644 index 00000000..8764e93d Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_17_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_17_static.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_17_static.dat new file mode 100644 index 00000000..4a44b6b1 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_17_static.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_1_dynamic.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_1_dynamic.dat new file mode 100644 index 00000000..8da47385 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_1_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_1_static.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_1_static.dat new file mode 100644 index 00000000..4a93caf7 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_1_static.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_20_dynamic.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_20_dynamic.dat new file mode 100644 index 00000000..3b2eb5ae Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_20_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_20_static.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_20_static.dat new file mode 100644 index 00000000..64f27b30 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_20_static.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_23_dynamic.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_23_dynamic.dat new file mode 100644 index 00000000..8c8f7c8a Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_23_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_23_static.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_23_static.dat new file mode 100644 index 00000000..12ec7fde Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_23_static.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_25_dynamic.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_25_dynamic.dat new file mode 100644 index 00000000..ee7f6eea Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_25_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_25_static.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_25_static.dat new file mode 100644 index 00000000..c0a3226b Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_25_static.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_26_dynamic.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_26_dynamic.dat new file mode 100644 index 00000000..2b04a5ae Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_26_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_26_static.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_26_static.dat new file mode 100644 index 00000000..fbc41322 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_26_static.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_28_dynamic.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_28_dynamic.dat new file mode 100644 index 00000000..5f84b18b Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_28_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_28_static.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_28_static.dat new file mode 100644 index 00000000..a9af4fdd Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_28_static.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_2_dynamic.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_2_dynamic.dat new file mode 100644 index 00000000..8f9cb984 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_2_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_2_static.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_2_static.dat new file mode 100644 index 00000000..288634e9 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_2_static.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_45_dynamic.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_45_dynamic.dat new file mode 100644 index 00000000..b58b9277 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_45_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_45_static.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_45_static.dat new file mode 100644 index 00000000..830aee7d Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_45_static.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_4_dynamic.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_4_dynamic.dat new file mode 100644 index 00000000..e56d1b20 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_4_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_4_static.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_4_static.dat new file mode 100644 index 00000000..08e875a6 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_4_static.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_5_dynamic.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_5_dynamic.dat new file mode 100644 index 00000000..fc0beebb Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_5_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_5_static.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_5_static.dat new file mode 100644 index 00000000..c6dd7e18 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_5_static.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_6_dynamic.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_6_dynamic.dat new file mode 100644 index 00000000..e5dd4469 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_6_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_6_static.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_6_static.dat new file mode 100644 index 00000000..c53afee7 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_6_static.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_7_dynamic.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_7_dynamic.dat new file mode 100644 index 00000000..55ea2ee8 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_7_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_7_static.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_7_static.dat new file mode 100644 index 00000000..ec665e2d Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_7_static.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_9_dynamic.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_9_dynamic.dat new file mode 100644 index 00000000..aa120df4 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_9_dynamic.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_9_static.dat b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_9_static.dat new file mode 100644 index 00000000..0c460579 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/classifiers/AU_9_static.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/evaluate_best_models_DISFA_dyn.m b/matlab_version/AU_training/experiments/full_model_training/evaluate_best_models_DISFA_dyn.m new file mode 100644 index 00000000..14e6bc06 --- /dev/null +++ b/matlab_version/AU_training/experiments/full_model_training/evaluate_best_models_DISFA_dyn.m @@ -0,0 +1,55 @@ +% Change to your downloaded location +clear +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); + +DISFA_aus = [1, 2, 4, 5, 6, 9, 12, 15, 17, 20, 25, 26]; + +au = DISFA_aus(1); + +op = cd('../DISFA/'); +rest_aus = setdiff(DISFA_aus, au); +shared_defs; +users = users(1); + +% need to split the rest +[~, ~, test_samples, test_labels, raw_data, PC, means, scaling, vid_ids, success] = Prepare_HOG_AU_data_generic_dynamic([], users, au, rest_aus, hog_data_dir); + +test_samples = sparse(test_samples); + +%% +root = [hog_data_dir, '/../']; +for i=1:numel(users) + input_train_label_files{i} = [root, '/ActionUnit_Labels/', users{i}, '/', users{i}]; +end +labels_gt_test = []; +for a=1:numel(DISFA_aus) + labels_gt_test = cat(2, labels_gt_test, extract_au_labels(input_train_label_files, DISFA_aus(a))); +end +cd(op); +% labels_gt_test(labels_gt_test > 1) = 1; + +%% +for a=1:1%numel(DISFA_aus) + + name = sprintf('mat_models/AU_%d_dynamic_intensity_comb.mat', DISFA_aus(a)); + load(name); + svr_test = @svr_test_linear_shift; + + model.eval_ids = ones(size(labels_gt_test,1),1); + model.vid_ids = vid_ids; + model.success = success; + + svs = bsxfun(@times, PC, 1./scaling') * model.w(1:end-1)'; +% model.cutoff = -1; + + [~, predictions_all] = svr_test(labels_gt_test(:,a), test_samples, model); + + [ ~, ~, ~, ccc, ~, ~ ] = evaluate_regression_results( predictions_all, labels_gt_test(:,a)); + + fprintf('AU%d, CCC - %.3f\n', DISFA_aus(a), ccc); +end + + diff --git a/matlab_version/AU_training/experiments/full_model_training/evaluate_best_models_DISFA_static.m b/matlab_version/AU_training/experiments/full_model_training/evaluate_best_models_DISFA_static.m new file mode 100644 index 00000000..b76487d4 --- /dev/null +++ b/matlab_version/AU_training/experiments/full_model_training/evaluate_best_models_DISFA_static.m @@ -0,0 +1,49 @@ +% Change to your downloaded location +clear +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); + +DISFA_aus = [1, 2, 4, 5, 6, 9, 12, 15, 17, 20, 25, 26]; + +au = DISFA_aus(1); + +op = cd('../DISFA/'); +rest_aus = setdiff(DISFA_aus, au); +shared_defs; + +% need to split the rest +[~, ~, test_samples, test_labels, raw_test, PC, means, scaling, vid_ids, success] = Prepare_HOG_AU_data_generic([], users, au, rest_aus, hog_data_dir); + +test_samples = sparse(test_samples); + +%% +root = [hog_data_dir, '/../']; +for i=1:numel(users) + input_train_label_files{i} = [root, '/ActionUnit_Labels/', users{i}, '/', users{i}]; +end +labels_gt_test = []; +for a=1:numel(DISFA_aus) + labels_gt_test = cat(2, labels_gt_test, extract_au_labels(input_train_label_files, DISFA_aus(a))); +end +cd(op); + +%% +for a=1:4%numel(DISFA_aus) + + name = sprintf('mat_models/AU_%d_static_intensity.mat', DISFA_aus(a)); + load(name); + svr_test = @svr_test_linear; + + model.eval_ids = ones(size(labels_gt_test,1),1); + model.vid_ids = vid_ids; + model.success = success; + [~, predictions_all] = svr_test(labels_gt_test(:,a), test_samples, model); + + [ ~, ~, ~, ccc, ~, ~ ] = evaluate_regression_results( predictions_all, labels_gt_test(:,a)); + + fprintf('AU%d, CCC - %.3f\n', DISFA_aus(a), ccc); +end + + diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_10_dynamic.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_10_dynamic.mat new file mode 100644 index 00000000..45356d6e Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_10_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_10_dynamic_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_10_dynamic_intensity.mat new file mode 100644 index 00000000..9af95dba Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_10_dynamic_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_10_dynamic_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_10_dynamic_intensity_comb.mat new file mode 100644 index 00000000..2dd78414 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_10_dynamic_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_10_static.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_10_static.mat new file mode 100644 index 00000000..11408646 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_10_static.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_10_static_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_10_static_intensity.mat new file mode 100644 index 00000000..e31fe3c5 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_10_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_10_static_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_10_static_intensity_comb.mat new file mode 100644 index 00000000..0da73b61 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_10_static_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_12_dynamic.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_12_dynamic.mat new file mode 100644 index 00000000..e32b877e Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_12_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_12_dynamic_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_12_dynamic_intensity.mat new file mode 100644 index 00000000..d689c488 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_12_dynamic_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_12_dynamic_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_12_dynamic_intensity_comb.mat new file mode 100644 index 00000000..4a17759f Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_12_dynamic_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_12_static.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_12_static.mat new file mode 100644 index 00000000..2c2cd8f2 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_12_static.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_12_static_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_12_static_intensity.mat new file mode 100644 index 00000000..c3109e35 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_12_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_12_static_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_12_static_intensity_comb.mat new file mode 100644 index 00000000..7ea294af Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_12_static_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_14_dynamic.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_14_dynamic.mat new file mode 100644 index 00000000..6852dfad Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_14_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_14_dynamic_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_14_dynamic_intensity.mat new file mode 100644 index 00000000..0c42700a Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_14_dynamic_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_14_static.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_14_static.mat new file mode 100644 index 00000000..6294fdfc Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_14_static.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_14_static_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_14_static_intensity.mat new file mode 100644 index 00000000..a465cd6c Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_14_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_15_dynamic.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_15_dynamic.mat new file mode 100644 index 00000000..5293cb3d Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_15_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_15_dynamic_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_15_dynamic_intensity.mat new file mode 100644 index 00000000..ccdb4695 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_15_dynamic_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_15_dynamic_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_15_dynamic_intensity_comb.mat new file mode 100644 index 00000000..91d3bcb0 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_15_dynamic_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_15_static.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_15_static.mat new file mode 100644 index 00000000..65c86e9d Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_15_static.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_15_static_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_15_static_intensity.mat new file mode 100644 index 00000000..a4401858 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_15_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_15_static_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_15_static_intensity_comb.mat new file mode 100644 index 00000000..427e8ad7 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_15_static_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_17_dynamic.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_17_dynamic.mat new file mode 100644 index 00000000..77967b6f Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_17_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_17_dynamic_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_17_dynamic_intensity.mat new file mode 100644 index 00000000..22def917 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_17_dynamic_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_17_dynamic_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_17_dynamic_intensity_comb.mat new file mode 100644 index 00000000..f4303d89 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_17_dynamic_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_17_static.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_17_static.mat new file mode 100644 index 00000000..a4f11079 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_17_static.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_17_static_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_17_static_intensity.mat new file mode 100644 index 00000000..56d9d615 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_17_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_17_static_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_17_static_intensity_comb.mat new file mode 100644 index 00000000..3268166c Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_17_static_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_1_dynamic.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_1_dynamic.mat new file mode 100644 index 00000000..e6d8838b Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_1_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_1_dynamic_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_1_dynamic_intensity.mat new file mode 100644 index 00000000..0e0caec0 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_1_dynamic_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_1_dynamic_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_1_dynamic_intensity_comb.mat new file mode 100644 index 00000000..51cfa191 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_1_dynamic_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_1_static.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_1_static.mat new file mode 100644 index 00000000..e73448bf Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_1_static.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_1_static_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_1_static_intensity.mat new file mode 100644 index 00000000..eda562d4 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_1_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_1_static_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_1_static_intensity_comb.mat new file mode 100644 index 00000000..11d11378 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_1_static_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_20_dynamic.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_20_dynamic.mat new file mode 100644 index 00000000..f0d546ff Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_20_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_20_dynamic_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_20_dynamic_intensity.mat new file mode 100644 index 00000000..de83425f Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_20_dynamic_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_20_static.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_20_static.mat new file mode 100644 index 00000000..dd5bdb86 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_20_static.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_20_static_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_20_static_intensity.mat new file mode 100644 index 00000000..81bca509 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_20_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_23_dynamic.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_23_dynamic.mat new file mode 100644 index 00000000..04bc4114 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_23_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_23_dynamic_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_23_dynamic_intensity.mat new file mode 100644 index 00000000..8775c912 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_23_dynamic_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_23_dynamic_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_23_dynamic_intensity_comb.mat new file mode 100644 index 00000000..51bae919 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_23_dynamic_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_23_static.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_23_static.mat new file mode 100644 index 00000000..7faed42a Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_23_static.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_23_static_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_23_static_intensity.mat new file mode 100644 index 00000000..f69dda36 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_23_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_23_static_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_23_static_intensity_comb.mat new file mode 100644 index 00000000..12209e31 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_23_static_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_25_dynamic.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_25_dynamic.mat new file mode 100644 index 00000000..733b3604 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_25_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_25_dynamic_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_25_dynamic_intensity.mat new file mode 100644 index 00000000..9eab9649 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_25_dynamic_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_25_dynamic_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_25_dynamic_intensity_comb.mat new file mode 100644 index 00000000..d5246526 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_25_dynamic_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_25_static.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_25_static.mat new file mode 100644 index 00000000..9bbd2d8e Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_25_static.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_25_static_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_25_static_intensity.mat new file mode 100644 index 00000000..2e4ebdcc Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_25_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_25_static_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_25_static_intensity_comb.mat new file mode 100644 index 00000000..cb4fd924 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_25_static_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_26_dynamic.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_26_dynamic.mat new file mode 100644 index 00000000..14c951ad Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_26_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_26_dynamic_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_26_dynamic_intensity.mat new file mode 100644 index 00000000..4bdaa900 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_26_dynamic_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_26_dynamic_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_26_dynamic_intensity_comb.mat new file mode 100644 index 00000000..a479a71a Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_26_dynamic_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_26_static.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_26_static.mat new file mode 100644 index 00000000..a575e0e6 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_26_static.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_26_static_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_26_static_intensity.mat new file mode 100644 index 00000000..9284bae1 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_26_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_26_static_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_26_static_intensity_comb.mat new file mode 100644 index 00000000..00f914bd Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_26_static_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_28_dynamic.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_28_dynamic.mat new file mode 100644 index 00000000..b6594e87 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_28_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_28_static.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_28_static.mat new file mode 100644 index 00000000..a41e835e Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_28_static.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_2_dynamic.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_2_dynamic.mat new file mode 100644 index 00000000..ad269846 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_2_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_2_dynamic_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_2_dynamic_intensity.mat new file mode 100644 index 00000000..2c713516 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_2_dynamic_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_2_dynamic_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_2_dynamic_intensity_comb.mat new file mode 100644 index 00000000..00e7ae35 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_2_dynamic_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_2_static.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_2_static.mat new file mode 100644 index 00000000..526b29cf Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_2_static.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_2_static_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_2_static_intensity.mat new file mode 100644 index 00000000..89ca6629 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_2_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_2_static_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_2_static_intensity_comb.mat new file mode 100644 index 00000000..23e2af9f Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_2_static_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_45_dynamic.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_45_dynamic.mat new file mode 100644 index 00000000..640dfdfd Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_45_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_45_dynamic_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_45_dynamic_intensity.mat new file mode 100644 index 00000000..20960be9 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_45_dynamic_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_45_dynamic_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_45_dynamic_intensity_comb.mat new file mode 100644 index 00000000..e9d35ba9 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_45_dynamic_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_45_static.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_45_static.mat new file mode 100644 index 00000000..82bc298b Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_45_static.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_45_static_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_45_static_intensity.mat new file mode 100644 index 00000000..a0ed805d Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_45_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_45_static_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_45_static_intensity_comb.mat new file mode 100644 index 00000000..fbbfbf84 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_45_static_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_4_dynamic.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_4_dynamic.mat new file mode 100644 index 00000000..1e869153 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_4_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_4_dynamic_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_4_dynamic_intensity.mat new file mode 100644 index 00000000..1d2f3908 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_4_dynamic_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_4_dynamic_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_4_dynamic_intensity_comb.mat new file mode 100644 index 00000000..22f9a0a0 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_4_dynamic_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_4_static.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_4_static.mat new file mode 100644 index 00000000..ab755c69 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_4_static.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_4_static_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_4_static_intensity.mat new file mode 100644 index 00000000..68e2edd7 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_4_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_4_static_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_4_static_intensity_comb.mat new file mode 100644 index 00000000..b7f272d6 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_4_static_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_5_dynamic.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_5_dynamic.mat new file mode 100644 index 00000000..c21da056 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_5_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_5_dynamic_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_5_dynamic_intensity.mat new file mode 100644 index 00000000..caf5644c Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_5_dynamic_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_5_static.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_5_static.mat new file mode 100644 index 00000000..1b2f4c43 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_5_static.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_5_static_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_5_static_intensity.mat new file mode 100644 index 00000000..986fda51 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_5_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_6_dynamic.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_6_dynamic.mat new file mode 100644 index 00000000..b86b300c Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_6_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_6_dynamic_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_6_dynamic_intensity.mat new file mode 100644 index 00000000..2a4b810b Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_6_dynamic_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_6_dynamic_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_6_dynamic_intensity_comb.mat new file mode 100644 index 00000000..f5331b32 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_6_dynamic_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_6_static.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_6_static.mat new file mode 100644 index 00000000..ee25eb80 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_6_static.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_6_static_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_6_static_intensity.mat new file mode 100644 index 00000000..f282f27c Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_6_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_6_static_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_6_static_intensity_comb.mat new file mode 100644 index 00000000..dac6d3dd Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_6_static_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_7_dynamic.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_7_dynamic.mat new file mode 100644 index 00000000..d14f28ab Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_7_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_7_dynamic_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_7_dynamic_intensity.mat new file mode 100644 index 00000000..20b734dd Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_7_dynamic_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_7_dynamic_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_7_dynamic_intensity_comb.mat new file mode 100644 index 00000000..b8808ed1 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_7_dynamic_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_7_static.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_7_static.mat new file mode 100644 index 00000000..677e2847 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_7_static.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_7_static_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_7_static_intensity.mat new file mode 100644 index 00000000..ad2a20c2 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_7_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_7_static_intensity_comb.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_7_static_intensity_comb.mat new file mode 100644 index 00000000..0704ce2c Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_7_static_intensity_comb.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_9_dynamic.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_9_dynamic.mat new file mode 100644 index 00000000..021f572c Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_9_dynamic.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_9_dynamic_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_9_dynamic_intensity.mat new file mode 100644 index 00000000..85d838e8 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_9_dynamic_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_9_static.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_9_static.mat new file mode 100644 index 00000000..52472752 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_9_static.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_9_static_intensity.mat b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_9_static_intensity.mat new file mode 100644 index 00000000..b2695713 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/mat_models/AU_9_static_intensity.mat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_10_dynamic_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_10_dynamic_intensity.dat new file mode 100644 index 00000000..241f61e0 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_10_dynamic_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_10_dynamic_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_10_dynamic_intensity_comb.dat new file mode 100644 index 00000000..fe9ce795 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_10_dynamic_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_10_static_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_10_static_intensity.dat new file mode 100644 index 00000000..c3888555 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_10_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_10_static_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_10_static_intensity_comb.dat new file mode 100644 index 00000000..624731e3 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_10_static_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_12_dynamic_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_12_dynamic_intensity.dat new file mode 100644 index 00000000..ebb8053c Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_12_dynamic_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_12_dynamic_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_12_dynamic_intensity_comb.dat new file mode 100644 index 00000000..491f94d0 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_12_dynamic_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_12_static_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_12_static_intensity.dat new file mode 100644 index 00000000..b74a655d Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_12_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_12_static_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_12_static_intensity_comb.dat new file mode 100644 index 00000000..406fd810 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_12_static_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_14_dynamic_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_14_dynamic_intensity.dat new file mode 100644 index 00000000..706d585e Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_14_dynamic_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_14_static_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_14_static_intensity.dat new file mode 100644 index 00000000..83c864ee Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_14_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_15_dynamic_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_15_dynamic_intensity.dat new file mode 100644 index 00000000..42de54ac Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_15_dynamic_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_15_dynamic_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_15_dynamic_intensity_comb.dat new file mode 100644 index 00000000..00f802cf Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_15_dynamic_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_15_static_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_15_static_intensity.dat new file mode 100644 index 00000000..472a768d Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_15_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_15_static_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_15_static_intensity_comb.dat new file mode 100644 index 00000000..3a22f41a Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_15_static_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_17_dynamic_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_17_dynamic_intensity.dat new file mode 100644 index 00000000..649dec0f Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_17_dynamic_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_17_dynamic_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_17_dynamic_intensity_comb.dat new file mode 100644 index 00000000..8e5c2389 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_17_dynamic_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_17_static_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_17_static_intensity.dat new file mode 100644 index 00000000..362dd687 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_17_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_17_static_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_17_static_intensity_comb.dat new file mode 100644 index 00000000..109c7740 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_17_static_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_1_dynamic_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_1_dynamic_intensity.dat new file mode 100644 index 00000000..67a80a5d Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_1_dynamic_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_1_dynamic_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_1_dynamic_intensity_comb.dat new file mode 100644 index 00000000..db183754 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_1_dynamic_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_1_static_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_1_static_intensity.dat new file mode 100644 index 00000000..065b1c52 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_1_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_1_static_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_1_static_intensity_comb.dat new file mode 100644 index 00000000..d85541b9 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_1_static_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_20_dynamic_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_20_dynamic_intensity.dat new file mode 100644 index 00000000..554df8c7 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_20_dynamic_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_20_static_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_20_static_intensity.dat new file mode 100644 index 00000000..eb78b669 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_20_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_23_dynamic_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_23_dynamic_intensity.dat new file mode 100644 index 00000000..2afaa3f0 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_23_dynamic_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_23_dynamic_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_23_dynamic_intensity_comb.dat new file mode 100644 index 00000000..a6f437a7 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_23_dynamic_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_23_static_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_23_static_intensity.dat new file mode 100644 index 00000000..335d7c7b Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_23_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_23_static_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_23_static_intensity_comb.dat new file mode 100644 index 00000000..bd03fe24 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_23_static_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_25_dynamic_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_25_dynamic_intensity.dat new file mode 100644 index 00000000..a6679646 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_25_dynamic_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_25_dynamic_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_25_dynamic_intensity_comb.dat new file mode 100644 index 00000000..f161ad8c Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_25_dynamic_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_25_static_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_25_static_intensity.dat new file mode 100644 index 00000000..411670da Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_25_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_25_static_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_25_static_intensity_comb.dat new file mode 100644 index 00000000..254f819c Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_25_static_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_26_dynamic_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_26_dynamic_intensity.dat new file mode 100644 index 00000000..a9939992 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_26_dynamic_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_26_dynamic_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_26_dynamic_intensity_comb.dat new file mode 100644 index 00000000..c5b2597e Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_26_dynamic_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_26_static_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_26_static_intensity.dat new file mode 100644 index 00000000..39c61b9a Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_26_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_26_static_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_26_static_intensity_comb.dat new file mode 100644 index 00000000..3119305f Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_26_static_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_2_dynamic_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_2_dynamic_intensity.dat new file mode 100644 index 00000000..b384ad37 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_2_dynamic_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_2_dynamic_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_2_dynamic_intensity_comb.dat new file mode 100644 index 00000000..89391784 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_2_dynamic_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_2_static_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_2_static_intensity.dat new file mode 100644 index 00000000..eb9ae935 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_2_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_2_static_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_2_static_intensity_comb.dat new file mode 100644 index 00000000..12f7ce84 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_2_static_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_45_dynamic_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_45_dynamic_intensity.dat new file mode 100644 index 00000000..0da415b7 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_45_dynamic_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_45_dynamic_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_45_dynamic_intensity_comb.dat new file mode 100644 index 00000000..2f6c0b54 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_45_dynamic_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_45_static_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_45_static_intensity.dat new file mode 100644 index 00000000..fb3b9d32 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_45_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_45_static_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_45_static_intensity_comb.dat new file mode 100644 index 00000000..28bce9a0 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_45_static_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_4_dynamic_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_4_dynamic_intensity.dat new file mode 100644 index 00000000..67598c08 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_4_dynamic_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_4_dynamic_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_4_dynamic_intensity_comb.dat new file mode 100644 index 00000000..c5c8edaf Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_4_dynamic_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_4_static_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_4_static_intensity.dat new file mode 100644 index 00000000..7ee65b02 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_4_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_4_static_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_4_static_intensity_comb.dat new file mode 100644 index 00000000..8204a879 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_4_static_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_5_dynamic_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_5_dynamic_intensity.dat new file mode 100644 index 00000000..14f43f53 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_5_dynamic_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_5_static_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_5_static_intensity.dat new file mode 100644 index 00000000..5c3481b5 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_5_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_6_dynamic_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_6_dynamic_intensity.dat new file mode 100644 index 00000000..afbc2670 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_6_dynamic_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_6_dynamic_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_6_dynamic_intensity_comb.dat new file mode 100644 index 00000000..58727998 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_6_dynamic_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_6_static_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_6_static_intensity.dat new file mode 100644 index 00000000..5c33712c Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_6_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_6_static_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_6_static_intensity_comb.dat new file mode 100644 index 00000000..69c3005d Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_6_static_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_7_dynamic_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_7_dynamic_intensity.dat new file mode 100644 index 00000000..221c6d21 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_7_dynamic_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_7_dynamic_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_7_dynamic_intensity_comb.dat new file mode 100644 index 00000000..f13ba04d Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_7_dynamic_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_7_static_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_7_static_intensity.dat new file mode 100644 index 00000000..785ccc74 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_7_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_7_static_intensity_comb.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_7_static_intensity_comb.dat new file mode 100644 index 00000000..04b4a112 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_7_static_intensity_comb.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_9_dynamic_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_9_dynamic_intensity.dat new file mode 100644 index 00000000..c809ddcd Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_9_dynamic_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/regressors/AU_9_static_intensity.dat b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_9_static_intensity.dat new file mode 100644 index 00000000..7cdfc5d6 Binary files /dev/null and b/matlab_version/AU_training/experiments/full_model_training/regressors/AU_9_static_intensity.dat differ diff --git a/matlab_version/AU_training/experiments/full_model_training/train_dynamic_classifiers.m b/matlab_version/AU_training/experiments/full_model_training/train_dynamic_classifiers.m new file mode 100644 index 00000000..979717d8 --- /dev/null +++ b/matlab_version/AU_training/experiments/full_model_training/train_dynamic_classifiers.m @@ -0,0 +1,266 @@ +% Change to your downloaded location +clear +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); + +%% load shared definitions and AU data +all_dataset_aus = [1, 2, 4, 5, 6, 7, 9, 10, 12, 14, 15, 17, 20, 23, 25, 26, 28, 45]; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-7:0.5:1); +hyperparams.e = 10.^(-3); + +hyperparams.validate_params = {'c', 'e'}; + +% Set the training function +svm_train = @svm_train_linear; + +% Set the test function (the first output will be used for validation) +svm_test = @svm_test_linear; + +BP4D_aus = [1, 2, 4, 6, 7, 10, 12, 14, 15, 17, 23]; +SEMAINE_aus = [2, 12, 17, 25, 28, 45]; +FERA2011_aus = [1, 2, 4, 6, 7, 10, 12, 15, 17, 25, 26]; +UNBC_aus = [6, 7, 9, 12, 25, 26]; +DISFA_aus = [1, 2, 4, 5, 6, 9, 12, 15, 17, 20, 25, 26]; +Bosphorus_aus = [1, 2, 4, 5, 6, 7, 9, 10, 12, 14, 15, 17, 20, 23, 25, 26, 45]; + +for a=1:numel(all_dataset_aus) + + au = all_dataset_aus(a); + + train_samples = []; + valid_samples = []; + + train_labels = []; + valid_labels = []; + + % Keeping track which validation sample came from which dataset, as we + % will be validating based on which hyperparam leads to best + % performance on all datasets (mean F1) + eval_ids = []; + dataset_ids = {}; + + if(~isempty(find(BP4D_aus == au, 1))) + op = cd('../BP4D/'); + rest_aus = setdiff(BP4D_aus, au); + shared_defs; + % load the training and testing data for the current fold + [train_samples_bp4d, train_labels_bp4d, valid_samples_bp4d, valid_labels_bp4d, ~, PC, means, scaling] = Prepare_HOG_AU_data_generic_dynamic(train_recs, devel_recs, au, BP4D_dir, hog_data_dir); + + train_samples = cat(1, train_samples, train_samples_bp4d); + valid_samples = cat(1, valid_samples, valid_samples_bp4d); + + train_labels = cat(1, train_labels, train_labels_bp4d); + valid_labels = cat(1, valid_labels, valid_labels_bp4d); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_bp4d,1), 1); + end + + clear 'train_samples_bp4d' 'train_labels_bp4d' 'valid_samples_bp4d' 'valid_labels_bp4d' + + dataset_ids = cat(1, dataset_ids, {'BP4D'}); + + cd(op); + + end + + if(~isempty(find(FERA2011_aus == au, 1))) + op = cd('../FERA2011/'); + rest_aus = setdiff(FERA2011_aus, au); + shared_defs; + all_recs = cat(2, train_recs, devel_recs); + [users_train, users_valid_fera] = get_balanced_fold(FERA2011_dir, all_recs, au, 1/3, 1); + + % load the training and testing data for the current fold + [train_samples_f2011, train_labels_f2011, valid_samples_f2011, valid_labels_f2011, ~, PC, means, scaling] = Prepare_HOG_AU_data_generic_dynamic(users_train, users_valid_fera, au, rest_aus, FERA2011_dir, hog_data_dir); + + train_samples = cat(1, train_samples, train_samples_f2011); + valid_samples = cat(1, valid_samples, valid_samples_f2011); + + train_labels = cat(1, train_labels, train_labels_f2011); + valid_labels = cat(1, valid_labels, valid_labels_f2011); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_f2011,1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_f2011,1), 1)); + end + + clear 'train_samples_f2011' 'train_labels_f2011' 'valid_samples_f2011' 'valid_labels_bp4d' + + dataset_ids = cat(1, dataset_ids, {'FERA2011'}); + + cd(op); + + end + + if(~isempty(find(SEMAINE_aus == au, 1))) + op = cd('../SEMAINE/'); + rest_aus = setdiff(SEMAINE_aus, au); + shared_defs; + % load the training and testing data for the current fold + [train_samples_sem, train_labels_sem, valid_samples_sem, valid_labels_sem, ~, PC, means, scaling] = Prepare_HOG_AU_data_generic_dynamic(train_recs, devel_recs, au, rest_aus, SEMAINE_dir, hog_data_dir); + + train_samples = cat(1, train_samples, train_samples_sem); + valid_samples = cat(1, valid_samples, valid_samples_sem); + + train_labels = cat(1, train_labels, train_labels_sem); + valid_labels = cat(1, valid_labels, valid_labels_sem); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_sem,1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_sem,1), 1)); + end + + clear 'train_samples_sem' 'train_labels_sem' 'valid_samples_sem' 'valid_labels_sem' + dataset_ids = cat(1, dataset_ids, {'SEMAINE'}); + cd(op); + + end + + if(~isempty(find(Bosphorus_aus == au, 1))) + op = cd('../Bosphorus/'); + rest_aus = setdiff(DISFA_aus, au); + shared_defs; + + % make sure validation data's labels are balanced + [users_train, users_valid_bosph] = get_balanced_fold(Bosphorus_dir, all_recs, au, 1/3, 1); + + % need to split the rest + [train_samples_bosph, train_labels_bosph, valid_samples_bosph, valid_labels_bosph, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data_dynamic(users_train, users_valid_bosph, au, rest_aus, Bosphorus_dir, hog_data_dir); + + train_labels_bosph(train_labels_bosph > 1) = 1; + valid_labels_bosph(valid_labels_bosph > 1) = 1; + + % As there are only a few Bosphorus images (it being an image dataset) + % we oversample it quite a bit + train_samples_bosph = repmat(train_samples_bosph, 10, 1); + train_labels_bosph = repmat(train_labels_bosph, 10, 1); + + train_samples = cat(1, train_samples, train_samples_bosph); + valid_samples = cat(1, valid_samples, valid_samples_bosph); + + train_labels = cat(1, train_labels, train_labels_bosph); + valid_labels = cat(1, valid_labels, valid_labels_bosph); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_bosph, 1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_bosph, 1), 1)); + end + + clear 'train_samples_bosph' 'train_labels_bosph' 'valid_samples_bosph' 'valid_labels_bosph' + dataset_ids = cat(1, dataset_ids, {'Bosphorus'}); + cd(op); + + end + + if(~isempty(find(DISFA_aus == au, 1))) + op = cd('../DISFA/'); + rest_aus = setdiff(DISFA_aus, au); + shared_defs; + + % make sure validation data's labels are balanced + [users_train, users_valid_disfa] = get_balanced_fold(DISFA_dir, users, au, 1/3, 1); + + % need to split the rest + [train_samples_disf, train_labels_disf, valid_samples_disf, valid_labels_disf, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data_generic_dynamic(users_train, users_valid_disfa, au, rest_aus, hog_data_dir); + + train_labels_disf(train_labels_disf > 1) = 1; + valid_labels_disf(valid_labels_disf > 1) = 1; + + train_samples = cat(1, train_samples, train_samples_disf); + valid_samples = cat(1, valid_samples, valid_samples_disf); + + train_labels = cat(1, train_labels, train_labels_disf); + valid_labels = cat(1, valid_labels, valid_labels_disf); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_disf,1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_disf,1), 1)); + end + + clear 'train_samples_disf' 'train_labels_disf' 'valid_samples_disf' 'valid_labels_disf' + dataset_ids = cat(1, dataset_ids, {'DISFA'}); + cd(op); + + end + + if(~isempty(find(UNBC_aus == au, 1))) + op = cd('../UNBC/'); + rest_aus = setdiff(UNBC_aus, au); + shared_defs; + + [users_train, users_valid_unbc] = get_balanced_fold(UNBC_dir, all_recs, au, 1/3, 1); + + % load the training and testing data for the current fold + [train_samples_unbc, train_labels_unbc, valid_samples_unbc, valid_labels_unbc, ~, PC, means, scaling] = Prepare_HOG_AU_data_dynamic(users_train, users_valid_unbc, au, rest_aus, UNBC_dir, hog_data_dir); + + % Binarizing the data + train_labels_unbc(train_labels_unbc > 1) = 1; + valid_labels_unbc(valid_labels_unbc > 1) = 1; + + train_samples = cat(1, train_samples, train_samples_unbc); + valid_samples = cat(1, valid_samples, valid_samples_unbc); + + train_labels = cat(1, train_labels, train_labels_unbc); + valid_labels = cat(1, valid_labels, valid_labels_unbc); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_unbc,1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_unbc,1), 1)); + end + + clear 'train_samples_unbc' 'train_labels_unbc' 'valid_samples_unbc' 'valid_labels_unbc' + dataset_ids = cat(1, dataset_ids, {'UNBC'}); + cd(op); + + end + + train_samples = sparse(train_samples); + dataset_ids + %% Cross-validate here + hyperparams.eval_ids = eval_ids; + [ best_params, ~ ] = validate_grid_search_no_par(svm_train, svm_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + model = svm_train(train_labels, train_samples, best_params); + + model.eval_ids = eval_ids; + + [~, predictions_all] = svm_test(valid_labels, valid_samples, model); + + name = sprintf('mat_models/AU_%d_dynamic.mat', au); + + eval_ids_uq = unique(eval_ids)'; + F1s = []; + for i=eval_ids_uq + F1s = cat(2, F1s, compute_F1(valid_labels(eval_ids==i), predictions_all(eval_ids==i))); + end + + meanF1 = mean(F1s); + + save(name, 'model', 'F1s', 'meanF1', 'predictions_all', 'valid_labels', 'eval_ids', 'dataset_ids'); + + % Write out the model + name = sprintf('classifiers/AU_%d_dynamic.dat', au); + + pos_lbl = model.Label(1); + neg_lbl = model.Label(2); + + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + write_lin_dyn_svm(name, means, svs, b, pos_lbl, neg_lbl); + + clear 'train_samples' 'train_labels' 'valid_samples' 'valid_labels' +end + + diff --git a/matlab_version/AU_training/experiments/full_model_training/train_dynamic_regressors.m b/matlab_version/AU_training/experiments/full_model_training/train_dynamic_regressors.m new file mode 100644 index 00000000..a69b453a --- /dev/null +++ b/matlab_version/AU_training/experiments/full_model_training/train_dynamic_regressors.m @@ -0,0 +1,233 @@ +% Change to your downloaded location +clear +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); + +%% load shared definitions and AU data +all_dataset_aus = [1, 2, 4, 5, 6, 7, 9, 10, 12, 14, 15, 17, 20, 23, 25, 26, 45]; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-7:1:4); +hyperparams.p = 10.^(-2); + +hyperparams.validate_params = {'c', 'p'}; + +% Set the training function +svr_train = @svr_train_linear_shift; + +% Set the test function (the first output will be used for validation) +svr_test = @svr_test_linear_shift; + +BP4D_aus = [6, 10, 12, 14, 17]; +UNBC_aus = [6, 7, 9, 12, 25, 26]; +DISFA_aus = [1, 2, 4, 5, 6, 9, 12, 15, 17, 20, 25, 26]; +Bosphorus_aus = [1, 2, 4, 5, 6, 7, 9, 10, 12, 14, 15, 17, 20, 23, 25, 26, 45]; + +for a=1:numel(all_dataset_aus) + + au = all_dataset_aus(a); + + train_samples = []; + valid_samples = []; + + train_labels = []; + valid_labels = []; + + % Keeping track which validation sample came from which dataset, as we + % will be validating based on which hyperparam leads to best + % performance on all datasets (mean F1) + eval_ids = []; + dataset_ids = {}; + vid_ids = {}; + success = []; + + if(~isempty(find(BP4D_aus == au, 1))) + op = cd('../BP4D/'); + rest_aus = setdiff(BP4D_aus, au); + shared_defs; + % load the training and testing data for the current fold + [train_samples_bp4d, train_labels_bp4d, ~, valid_samples_bp4d, valid_labels_bp4d, vid_ids_bp4d, ~, PC, means, scaling, success_devel] = Prepare_HOG_AU_data_generic_intensity_dynamic(train_recs, devel_recs, au, BP4D_dir_int, hog_data_dir); + + ignore = valid_labels_bp4d == 9; + + valid_samples_bp4d = valid_samples_bp4d(~ignore, :); + valid_labels_bp4d = valid_labels_bp4d(~ignore); + vid_ids_bp4d = vid_ids_bp4d(~ignore); + success_devel = success_devel(~ignore); + + train_samples = cat(1, train_samples, train_samples_bp4d); + valid_samples = cat(1, valid_samples, valid_samples_bp4d); + + train_labels = cat(1, train_labels, train_labels_bp4d); + valid_labels = cat(1, valid_labels, valid_labels_bp4d); + vid_ids = cat(1, vid_ids, vid_ids_bp4d); + + success = cat(1, success, success_devel); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_bp4d,1), 1); + end + + clear 'train_samples_bp4d' 'train_labels_bp4d' 'valid_samples_bp4d' 'valid_labels_bp4d' + + dataset_ids = cat(1, dataset_ids, {'BP4D'}); + + cd(op); + + end + + if(~isempty(find(Bosphorus_aus == au, 1))) + op = cd('../Bosphorus/'); + rest_aus = setdiff(DISFA_aus, au); + shared_defs; + + % make sure validation data's labels are balanced + [users_train, users_valid_bosph] = get_balanced_fold(Bosphorus_dir, all_recs, au, 1/3, 1); + + % need to split the rest + [train_samples_bosph, train_labels_bosph, valid_samples_bosph, valid_labels_bosph, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data_dynamic(users_train, users_valid_bosph, au, rest_aus, Bosphorus_dir, hog_data_dir); + + % Shortening the filenames to make it more like a video so that it + % would work with normalization + for v=1:numel(valid_ids) + valid_ids{v} = valid_ids{v}(1:5); + end + + % As there are only a few Bosphorus images (it being an image dataset) + % we oversample it quite a bit + train_samples_bosph = repmat(train_samples_bosph, 10, 1); + train_labels_bosph = repmat(train_labels_bosph, 10, 1); + + train_samples = cat(1, train_samples, train_samples_bosph); + valid_samples = cat(1, valid_samples, valid_samples_bosph); + + train_labels = cat(1, train_labels, train_labels_bosph); + valid_labels = cat(1, valid_labels, valid_labels_bosph); + + vid_ids = cat(1, vid_ids, valid_ids); + + success = cat(1, success, valid_success); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_bosph, 1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_bosph, 1), 1)); + end + + clear 'train_samples_bosph' 'train_labels_bosph' 'valid_samples_bosph' 'valid_labels_bosph' + dataset_ids = cat(1, dataset_ids, {'Bosphorus'}); + cd(op); + + end + + if(~isempty(find(DISFA_aus == au, 1))) + op = cd('../DISFA/'); + rest_aus = setdiff(DISFA_aus, au); + shared_defs; + + % make sure validation data's labels are balanced + [users_train, users_valid_disfa] = get_balanced_fold(DISFA_dir, users, au, 1/3, 1); + + % need to split the rest + [train_samples_disf, train_labels_disf, valid_samples_disf, valid_labels_disf, raw_disfa, PC, means, scaling, vid_ids_disfa, valid_success] = Prepare_HOG_AU_data_generic_dynamic(users_train, users_valid_disfa, au, rest_aus, hog_data_dir); + + train_samples = cat(1, train_samples, train_samples_disf); + valid_samples = cat(1, valid_samples, valid_samples_disf); + + train_labels = cat(1, train_labels, train_labels_disf); + valid_labels = cat(1, valid_labels, valid_labels_disf); + + vid_ids = cat(1, vid_ids, vid_ids_disfa); + + success = cat(1, success, valid_success); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_disf,1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_disf,1), 1)); + end + + clear 'train_samples_disf' 'train_labels_disf' 'valid_samples_disf' 'valid_labels_disf' + dataset_ids = cat(1, dataset_ids, {'DISFA'}); + cd(op); + + end + + if(~isempty(find(UNBC_aus == au, 1))) + op = cd('../UNBC/'); + rest_aus = setdiff(UNBC_aus, au); + shared_defs; + + [users_train, users_valid_unbc] = get_balanced_fold(UNBC_dir, all_recs, au, 1/3, 1); + + % load the training and testing data for the current fold + [train_samples_unbc, train_labels_unbc, valid_samples_unbc, valid_labels_unbc, ~, PC, means, scaling, vid_ids_unbc, success_devel] = Prepare_HOG_AU_data_dynamic(users_train, users_valid_unbc, au, rest_aus, UNBC_dir, hog_data_dir); + + train_samples = cat(1, train_samples, train_samples_unbc); + valid_samples = cat(1, valid_samples, valid_samples_unbc); + + train_labels = cat(1, train_labels, train_labels_unbc); + valid_labels = cat(1, valid_labels, valid_labels_unbc); + + vid_ids = cat(1, vid_ids, vid_ids_unbc); + + success = cat(1, success, success_devel); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_unbc,1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_unbc,1), 1)); + end + + clear 'train_samples_unbc' 'train_labels_unbc' 'valid_samples_unbc' 'valid_labels_unbc' + dataset_ids = cat(1, dataset_ids, {'UNBC'}); + cd(op); + + end + + train_samples = sparse(train_samples); + dataset_ids + %% Cross-validate here + hyperparams.eval_ids = eval_ids; + hyperparams.vid_ids = vid_ids; + hyperparams.valid_samples = valid_samples; + hyperparams.success = success; + hyperparams.valid_labels = valid_labels; + + [ best_params, ~ ] = validate_grid_search_no_par(svr_train, svr_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + model = svr_train(train_labels, train_samples, best_params); + + model.eval_ids = eval_ids; + model.vid_ids = vid_ids; + + [~, predictions_all] = svr_test(valid_labels, valid_samples, model); + + name = sprintf('mat_models/AU_%d_dynamic_intensity.mat', au); + + eval_ids_uq = unique(eval_ids)'; + cccs = []; + for i=eval_ids_uq + [ ~, ~, ~, ccc_c, ~, ~ ] = evaluate_regression_results( predictions_all(eval_ids==i), valid_labels(eval_ids==i)); + cccs = cat(2, cccs, ccc_c); + end + + mean_ccc = mean(cccs); + + save(name, 'model', 'mean_ccc', 'mean_ccc', 'cccs', 'predictions_all', 'valid_labels', 'eval_ids', 'dataset_ids'); + + % Write out the model + name = sprintf('regressors/AU_%d_dynamic_intensity.dat', au); + + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + write_lin_dyn_svr(name, means, svs, b, model.cutoff); + + clear 'train_samples' 'train_labels' 'valid_samples' 'valid_labels' +end + + diff --git a/matlab_version/AU_training/experiments/full_model_training/train_dynamic_regressors_with_classifiers.m b/matlab_version/AU_training/experiments/full_model_training/train_dynamic_regressors_with_classifiers.m new file mode 100644 index 00000000..ec996ea6 --- /dev/null +++ b/matlab_version/AU_training/experiments/full_model_training/train_dynamic_regressors_with_classifiers.m @@ -0,0 +1,255 @@ +% Change to your downloaded location +clear +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); + +%% load shared definitions and AU data +all_dataset_aus = [1, 2, 4, 6, 7, 10, 12, 15, 17, 23, 25, 26, 45]; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-8:0.5:4); +hyperparams.p = 10.^(-2); + +hyperparams.validate_params = {'c', 'p'}; + +% Set the training function +svr_train = @svr_train_linear_shift; + +% Set the test function (the first output will be used for validation) +svr_test = @svr_test_linear_shift; + +BP4D_aus = [6, 10, 12, 14, 17]; +UNBC_aus = [6, 7, 9, 12, 25, 26]; +DISFA_aus = [1, 2, 4, 5, 6, 9, 12, 15, 17, 20, 25, 26]; +Bosphorus_aus = [1, 2, 4, 5, 6, 7, 9, 10, 12, 14, 15, 17, 20, 23, 25, 26, 45]; + +for a=1:numel(all_dataset_aus) + + au = all_dataset_aus(a); + + train_samples = []; + valid_samples = []; + + train_labels = []; + valid_labels = []; + + % Keeping track which validation sample came from which dataset, as we + % will be validating based on which hyperparam leads to best + % performance on all datasets (mean F1) + eval_ids = []; + dataset_ids = {}; + vid_ids = {}; + success = []; + + if(~isempty(find(BP4D_aus == au, 1))) + op = cd('../BP4D/'); + rest_aus = setdiff(BP4D_aus, au); + shared_defs; + % load the training and testing data for the current fold + [train_samples_bp4d, train_labels_bp4d, ~, valid_samples_bp4d, valid_labels_bp4d, vid_ids_bp4d, ~, PC, means, scaling, success_devel] = Prepare_HOG_AU_data_generic_intensity_dynamic(train_recs, devel_recs, au, BP4D_dir_int, hog_data_dir); + + ignore = valid_labels_bp4d == 9; + + valid_samples_bp4d = valid_samples_bp4d(~ignore, :); + valid_labels_bp4d = valid_labels_bp4d(~ignore); + vid_ids_bp4d = vid_ids_bp4d(~ignore); + success_devel = success_devel(~ignore); + + train_samples = cat(1, train_samples, train_samples_bp4d); + valid_samples = cat(1, valid_samples, valid_samples_bp4d); + + train_labels = cat(1, train_labels, train_labels_bp4d); + valid_labels = cat(1, valid_labels, valid_labels_bp4d); + vid_ids = cat(1, vid_ids, vid_ids_bp4d); + + success = cat(1, success, success_devel); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_bp4d,1), 1); + end + + clear 'train_samples_bp4d' 'train_labels_bp4d' 'valid_samples_bp4d' 'valid_labels_bp4d' + + dataset_ids = cat(1, dataset_ids, {'BP4D'}); + + cd(op); + + end + + if(~isempty(find(Bosphorus_aus == au, 1))) + op = cd('../Bosphorus/'); + rest_aus = setdiff(DISFA_aus, au); + shared_defs; + + % make sure validation data's labels are balanced + [users_train, users_valid_bosph] = get_balanced_fold(Bosphorus_dir, all_recs, au, 1/3, 1); + + % need to split the rest + [train_samples_bosph, train_labels_bosph, valid_samples_bosph, valid_labels_bosph, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data_dynamic(users_train, users_valid_bosph, au, rest_aus, Bosphorus_dir, hog_data_dir); + + % Shortening the filenames to make it more like a video so that it + % would work with normalization + for v=1:numel(valid_ids) + valid_ids{v} = valid_ids{v}(1:5); + end + + % As there are only a few Bosphorus images (it being an image dataset) + % we oversample it quite a bit + train_samples_bosph = repmat(train_samples_bosph, 10, 1); + train_labels_bosph = repmat(train_labels_bosph, 10, 1); + + train_samples = cat(1, train_samples, train_samples_bosph); + valid_samples = cat(1, valid_samples, valid_samples_bosph); + + train_labels = cat(1, train_labels, train_labels_bosph); + valid_labels = cat(1, valid_labels, valid_labels_bosph); + + vid_ids = cat(1, vid_ids, valid_ids); + + success = cat(1, success, valid_success); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_bosph, 1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_bosph, 1), 1)); + end + + clear 'train_samples_bosph' 'train_labels_bosph' 'valid_samples_bosph' 'valid_labels_bosph' + dataset_ids = cat(1, dataset_ids, {'Bosphorus'}); + cd(op); + + end + + if(~isempty(find(DISFA_aus == au, 1))) + op = cd('../DISFA/'); + rest_aus = setdiff(DISFA_aus, au); + shared_defs; + + % make sure validation data's labels are balanced + [users_train, users_valid_disfa] = get_balanced_fold(DISFA_dir, users, au, 1/3, 1); + + % need to split the rest + [train_samples_disf, train_labels_disf, valid_samples_disf, valid_labels_disf, raw_disfa, PC, means, scaling, vid_ids_disfa, valid_success] = Prepare_HOG_AU_data_generic_dynamic(users_train, users_valid_disfa, au, rest_aus, hog_data_dir); + + train_samples = cat(1, train_samples, train_samples_disf); + valid_samples = cat(1, valid_samples, valid_samples_disf); + + train_labels = cat(1, train_labels, train_labels_disf); + valid_labels = cat(1, valid_labels, valid_labels_disf); + + vid_ids = cat(1, vid_ids, vid_ids_disfa); + + success = cat(1, success, valid_success); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_disf,1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_disf,1), 1)); + end + + clear 'train_samples_disf' 'train_labels_disf' 'valid_samples_disf' 'valid_labels_disf' + dataset_ids = cat(1, dataset_ids, {'DISFA'}); + cd(op); + + end + + if(~isempty(find(UNBC_aus == au, 1))) + op = cd('../UNBC/'); + rest_aus = setdiff(UNBC_aus, au); + shared_defs; + + [users_train, users_valid_unbc] = get_balanced_fold(UNBC_dir, all_recs, au, 1/3, 1); + + % load the training and testing data for the current fold + [train_samples_unbc, train_labels_unbc, valid_samples_unbc, valid_labels_unbc, ~, PC, means, scaling, vid_ids_unbc, success_devel] = Prepare_HOG_AU_data_dynamic(users_train, users_valid_unbc, au, rest_aus, UNBC_dir, hog_data_dir); + + train_samples = cat(1, train_samples, train_samples_unbc); + valid_samples = cat(1, valid_samples, valid_samples_unbc); + + train_labels = cat(1, train_labels, train_labels_unbc); + valid_labels = cat(1, valid_labels, valid_labels_unbc); + + vid_ids = cat(1, vid_ids, vid_ids_unbc); + + success = cat(1, success, success_devel); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_unbc,1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_unbc,1), 1)); + end + + clear 'train_samples_unbc' 'train_labels_unbc' 'valid_samples_unbc' 'valid_labels_unbc' + dataset_ids = cat(1, dataset_ids, {'UNBC'}); + cd(op); + + end + + train_samples = sparse(train_samples); + dataset_ids + %% Cross-validate here + + name = sprintf('mat_models/AU_%d_dynamic_intensity.mat', au); + load(name, 'model'); + model_reg = model; + + valid_all_reg = valid_samples * model_reg.w(1:end-1)' + model_reg.w(end); + train_all_reg = train_samples * model_reg.w(1:end-1)' + model_reg.w(end); + + name = sprintf('mat_models/AU_%d_dynamic.mat', au); + load(name, 'model'); + model_class = model; + valid_all_class = valid_samples * model_class.w(1:end-1)' + model_class.w(end); + train_all_class = train_samples * model_class.w(1:end-1)' + model_class.w(end); + + valid_samples_p = cat(2, valid_all_reg, valid_all_class); + train_samples_p = sparse(cat(2, train_all_reg, train_all_class)); + + %% + hyperparams.eval_ids = eval_ids; + hyperparams.vid_ids = vid_ids; + hyperparams.valid_samples = valid_samples_p; + hyperparams.success = success; + hyperparams.valid_labels = valid_labels; + + [ best_params, ~ ] = validate_grid_search_no_par(svr_train, svr_test, false, train_samples_p, train_labels, valid_samples_p, valid_labels, hyperparams); + model_fuse = svr_train(train_labels, train_samples_p, best_params); + + % Fust the regressor and classifier based on their corresponding + % weights + p = model_fuse.w; + model = model_reg; + model.w = model_reg.w * p(1) + model_class.w * p(2); + model.w(end) = model.w(end) + p(3); + %% + name = sprintf('mat_models/AU_%d_dynamic_intensity_comb.mat', au); + + [~, predictions_all] = svr_test(valid_labels, valid_samples, model); + + eval_ids_uq = unique(eval_ids)'; + cccs = []; + for i=eval_ids_uq + [ ~, ~, ~, ccc_c, ~, ~ ] = evaluate_regression_results( predictions_all(eval_ids==i), valid_labels(eval_ids==i)); + cccs = cat(2, cccs, ccc_c); + end + + mean_ccc = mean(cccs); + %% + save(name, 'model', 'mean_ccc', 'mean_ccc', 'cccs', 'predictions_all', 'valid_labels', 'eval_ids', 'dataset_ids'); + + % Write out the model + name = sprintf('regressors/AU_%d_dynamic_intensity_comb.dat', au); + + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + write_lin_dyn_svr(name, means, svs, b, model.cutoff); + + clear 'train_samples' 'train_labels' 'valid_samples' 'valid_labels' +end + + diff --git a/matlab_version/AU_training/experiments/full_model_training/train_static_classifiers.m b/matlab_version/AU_training/experiments/full_model_training/train_static_classifiers.m new file mode 100644 index 00000000..fa8f9f2c --- /dev/null +++ b/matlab_version/AU_training/experiments/full_model_training/train_static_classifiers.m @@ -0,0 +1,266 @@ +% Change to your downloaded location +clear +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); + +%% load shared definitions and AU data +all_dataset_aus = [1, 2, 4, 5, 6, 7, 9, 10, 12, 14, 15, 17, 20, 23, 25, 26, 28, 45]; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-7:0.5:1); +hyperparams.e = 10.^(-3); + +hyperparams.validate_params = {'c', 'e'}; + +% Set the training function +svm_train = @svm_train_linear; + +% Set the test function (the first output will be used for validation) +svm_test = @svm_test_linear; + +BP4D_aus = [1, 2, 4, 6, 7, 10, 12, 14, 15, 17, 23]; +SEMAINE_aus = [2, 12, 17, 25, 28, 45]; +FERA2011_aus = [1, 2, 4, 6, 7, 10, 12, 15, 17, 25, 26]; +UNBC_aus = [6, 7, 9, 12, 25, 26]; +DISFA_aus = [1, 2, 4, 5, 6, 9, 12, 15, 17, 20, 25, 26]; +Bosphorus_aus = [1, 2, 4, 5, 6, 7, 9, 10, 12, 14, 15, 17, 20, 23, 25, 26, 45]; + +for a=1:numel(all_dataset_aus) + + au = all_dataset_aus(a); + + train_samples = []; + valid_samples = []; + + train_labels = []; + valid_labels = []; + + % Keeping track which validation sample came from which dataset, as we + % will be validating based on which hyperparam leads to best + % performance on all datasets (mean F1) + eval_ids = []; + dataset_ids = {}; + + if(~isempty(find(BP4D_aus == au, 1))) + op = cd('../BP4D/'); + rest_aus = setdiff(BP4D_aus, au); + shared_defs; + % load the training and testing data for the current fold + [train_samples_bp4d, train_labels_bp4d, valid_samples_bp4d, valid_labels_bp4d, ~, PC, means, scaling] = Prepare_HOG_AU_data_generic(train_recs, devel_recs, au, BP4D_dir, hog_data_dir); + + train_samples = cat(1, train_samples, train_samples_bp4d); + valid_samples = cat(1, valid_samples, valid_samples_bp4d); + + train_labels = cat(1, train_labels, train_labels_bp4d); + valid_labels = cat(1, valid_labels, valid_labels_bp4d); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_bp4d,1), 1); + end + + clear 'train_samples_bp4d' 'train_labels_bp4d' 'valid_samples_bp4d' 'valid_labels_bp4d' + + dataset_ids = cat(1, dataset_ids, {'BP4D'}); + + cd(op); + + end + + if(~isempty(find(FERA2011_aus == au, 1))) + op = cd('../FERA2011/'); + rest_aus = setdiff(FERA2011_aus, au); + shared_defs; + all_recs = cat(2, train_recs, devel_recs); + [users_train, users_valid_fera] = get_balanced_fold(FERA2011_dir, all_recs, au, 1/3, 1); + + % load the training and testing data for the current fold + [train_samples_f2011, train_labels_f2011, valid_samples_f2011, valid_labels_f2011, ~, PC, means, scaling] = Prepare_HOG_AU_data_generic(users_train, users_valid_fera, au, rest_aus, FERA2011_dir, hog_data_dir); + + train_samples = cat(1, train_samples, train_samples_f2011); + valid_samples = cat(1, valid_samples, valid_samples_f2011); + + train_labels = cat(1, train_labels, train_labels_f2011); + valid_labels = cat(1, valid_labels, valid_labels_f2011); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_f2011,1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_f2011,1), 1)); + end + + clear 'train_samples_f2011' 'train_labels_f2011' 'valid_samples_f2011' 'valid_labels_bp4d' + + dataset_ids = cat(1, dataset_ids, {'FERA2011'}); + + cd(op); + + end + + if(~isempty(find(SEMAINE_aus == au, 1))) + op = cd('../SEMAINE/'); + rest_aus = setdiff(SEMAINE_aus, au); + shared_defs; + % load the training and testing data for the current fold + [train_samples_sem, train_labels_sem, valid_samples_sem, valid_labels_sem, ~, PC, means, scaling] = Prepare_HOG_AU_data_generic(train_recs, devel_recs, au, rest_aus, SEMAINE_dir, hog_data_dir); + + train_samples = cat(1, train_samples, train_samples_sem); + valid_samples = cat(1, valid_samples, valid_samples_sem); + + train_labels = cat(1, train_labels, train_labels_sem); + valid_labels = cat(1, valid_labels, valid_labels_sem); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_sem,1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_sem,1), 1)); + end + + clear 'train_samples_sem' 'train_labels_sem' 'valid_samples_sem' 'valid_labels_sem' + dataset_ids = cat(1, dataset_ids, {'SEMAINE'}); + cd(op); + + end + + if(~isempty(find(Bosphorus_aus == au, 1))) + op = cd('../Bosphorus/'); + rest_aus = setdiff(DISFA_aus, au); + shared_defs; + + % make sure validation data's labels are balanced + [users_train, users_valid_bosph] = get_balanced_fold(Bosphorus_dir, all_recs, au, 1/3, 1); + + % need to split the rest + [train_samples_bosph, train_labels_bosph, valid_samples_bosph, valid_labels_bosph, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data(users_train, users_valid_bosph, au, rest_aus, Bosphorus_dir, hog_data_dir); + + train_labels_bosph(train_labels_bosph > 1) = 1; + valid_labels_bosph(valid_labels_bosph > 1) = 1; + + % As there are only a few Bosphorus images (it being an image dataset) + % we oversample it quite a bit + train_samples_bosph = repmat(train_samples_bosph, 10, 1); + train_labels_bosph = repmat(train_labels_bosph, 10, 1); + + train_samples = cat(1, train_samples, train_samples_bosph); + valid_samples = cat(1, valid_samples, valid_samples_bosph); + + train_labels = cat(1, train_labels, train_labels_bosph); + valid_labels = cat(1, valid_labels, valid_labels_bosph); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_bosph, 1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_bosph, 1), 1)); + end + + clear 'train_samples_bosph' 'train_labels_bosph' 'valid_samples_bosph' 'valid_labels_bosph' + dataset_ids = cat(1, dataset_ids, {'Bosphorus'}); + cd(op); + + end + + if(~isempty(find(DISFA_aus == au, 1))) + op = cd('../DISFA/'); + rest_aus = setdiff(DISFA_aus, au); + shared_defs; + + % make sure validation data's labels are balanced + [users_train, users_valid_disfa] = get_balanced_fold(DISFA_dir, users, au, 1/3, 1); + + % need to split the rest + [train_samples_disf, train_labels_disf, valid_samples_disf, valid_labels_disf, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data_generic(users_train, users_valid_disfa, au, rest_aus, hog_data_dir); + + train_labels_disf(train_labels_disf > 1) = 1; + valid_labels_disf(valid_labels_disf > 1) = 1; + + train_samples = cat(1, train_samples, train_samples_disf); + valid_samples = cat(1, valid_samples, valid_samples_disf); + + train_labels = cat(1, train_labels, train_labels_disf); + valid_labels = cat(1, valid_labels, valid_labels_disf); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_disf,1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_disf,1), 1)); + end + + clear 'train_samples_disf' 'train_labels_disf' 'valid_samples_disf' 'valid_labels_disf' + dataset_ids = cat(1, dataset_ids, {'DISFA'}); + cd(op); + + end + + if(~isempty(find(UNBC_aus == au, 1))) + op = cd('../UNBC/'); + rest_aus = setdiff(UNBC_aus, au); + shared_defs; + + [users_train, users_valid_unbc] = get_balanced_fold(UNBC_dir, all_recs, au, 1/3, 1); + + % load the training and testing data for the current fold + [train_samples_unbc, train_labels_unbc, valid_samples_unbc, valid_labels_unbc, ~, PC, means, scaling] = Prepare_HOG_AU_data(users_train, users_valid_unbc, au, rest_aus, UNBC_dir, hog_data_dir); + + % Binarizing the data + train_labels_unbc(train_labels_unbc > 1) = 1; + valid_labels_unbc(valid_labels_unbc > 1) = 1; + + train_samples = cat(1, train_samples, train_samples_unbc); + valid_samples = cat(1, valid_samples, valid_samples_unbc); + + train_labels = cat(1, train_labels, train_labels_unbc); + valid_labels = cat(1, valid_labels, valid_labels_unbc); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_unbc,1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_unbc,1), 1)); + end + + clear 'train_samples_unbc' 'train_labels_unbc' 'valid_samples_unbc' 'valid_labels_unbc' + dataset_ids = cat(1, dataset_ids, {'UNBC'}); + cd(op); + + end + + train_samples = sparse(train_samples); + dataset_ids + %% Cross-validate here + hyperparams.eval_ids = eval_ids; + [ best_params, ~ ] = validate_grid_search_no_par(svm_train, svm_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + model = svm_train(train_labels, train_samples, best_params); + + model.eval_ids = eval_ids; + + [~, predictions_all] = svm_test(valid_labels, valid_samples, model); + + name = sprintf('mat_models/AU_%d_static.mat', au); + + eval_ids_uq = unique(eval_ids)'; + F1s = []; + for i=eval_ids_uq + F1s = cat(2, F1s, compute_F1(valid_labels(eval_ids==i), predictions_all(eval_ids==i))); + end + + meanF1 = mean(F1s); + + save(name, 'model', 'F1s', 'meanF1', 'predictions_all', 'valid_labels', 'eval_ids', 'dataset_ids'); + + % Write out the model + name = sprintf('classifiers/AU_%d_static.dat', au); + + pos_lbl = model.Label(1); + neg_lbl = model.Label(2); + + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + write_lin_svm(name, means, svs, b, pos_lbl, neg_lbl); + + clear 'train_samples' 'train_labels' 'valid_samples' 'valid_labels' +end + + diff --git a/matlab_version/AU_training/experiments/full_model_training/train_static_regressors.m b/matlab_version/AU_training/experiments/full_model_training/train_static_regressors.m new file mode 100644 index 00000000..83b67d92 --- /dev/null +++ b/matlab_version/AU_training/experiments/full_model_training/train_static_regressors.m @@ -0,0 +1,227 @@ +% Change to your downloaded location +clear +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); + +%% load shared definitions and AU data +all_dataset_aus = [1, 2, 4, 5, 6, 7, 9, 10, 12, 14, 15, 17, 20, 23, 25, 26, 45]; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-7:1:4); +hyperparams.p = 10.^(-2); + +hyperparams.validate_params = {'c', 'p'}; + +% Set the training function +svr_train = @svr_train_linear; + +% Set the test function (the first output will be used for validation) +svr_test = @svr_test_linear; + +BP4D_aus = [6, 10, 12, 14, 17]; +UNBC_aus = [6, 7, 9, 12, 25, 26]; +DISFA_aus = [1, 2, 4, 5, 6, 9, 12, 15, 17, 20, 25, 26]; +Bosphorus_aus = [1, 2, 4, 5, 6, 7, 9, 10, 12, 14, 15, 17, 20, 23, 25, 26, 45]; + +for a=1:numel(all_dataset_aus) + + au = all_dataset_aus(a); + + train_samples = []; + valid_samples = []; + + train_labels = []; + valid_labels = []; + + % Keeping track which validation sample came from which dataset, as we + % will be validating based on which hyperparam leads to best + % performance on all datasets (mean F1) + eval_ids = []; + dataset_ids = {}; + vid_ids = {}; + success = []; + + if(~isempty(find(BP4D_aus == au, 1))) + op = cd('../BP4D/'); + rest_aus = setdiff(BP4D_aus, au); + shared_defs; + % load the training and testing data for the current fold + [train_samples_bp4d, train_labels_bp4d, ~, valid_samples_bp4d, valid_labels_bp4d, vid_ids_bp4d, ~, PC, means, scaling, success_devel] = Prepare_HOG_AU_data_generic_intensity(train_recs, devel_recs, au, BP4D_dir_int, hog_data_dir); + + ignore = valid_labels_bp4d == 9; + + valid_samples_bp4d = valid_samples_bp4d(~ignore, :); + valid_labels_bp4d = valid_labels_bp4d(~ignore); + vid_ids_bp4d = vid_ids_bp4d(~ignore); + success_devel = success_devel(~ignore); + + train_samples = cat(1, train_samples, train_samples_bp4d); + valid_samples = cat(1, valid_samples, valid_samples_bp4d); + + train_labels = cat(1, train_labels, train_labels_bp4d); + valid_labels = cat(1, valid_labels, valid_labels_bp4d); + vid_ids = cat(1, vid_ids, vid_ids_bp4d); + + success = cat(1, success, success_devel); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_bp4d,1), 1); + end + + clear 'train_samples_bp4d' 'train_labels_bp4d' 'valid_samples_bp4d' 'valid_labels_bp4d' + + dataset_ids = cat(1, dataset_ids, {'BP4D'}); + + cd(op); + + end + + if(~isempty(find(Bosphorus_aus == au, 1))) + op = cd('../Bosphorus/'); + rest_aus = setdiff(DISFA_aus, au); + shared_defs; + + % make sure validation data's labels are balanced + [users_train, users_valid_bosph] = get_balanced_fold(Bosphorus_dir, all_recs, au, 1/3, 1); + + % need to split the rest + [train_samples_bosph, train_labels_bosph, valid_samples_bosph, valid_labels_bosph, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data(users_train, users_valid_bosph, au, rest_aus, Bosphorus_dir, hog_data_dir); + + % As there are only a few Bosphorus images (it being an image dataset) + % we oversample it quite a bit + train_samples_bosph = repmat(train_samples_bosph, 10, 1); + train_labels_bosph = repmat(train_labels_bosph, 10, 1); + + train_samples = cat(1, train_samples, train_samples_bosph); + valid_samples = cat(1, valid_samples, valid_samples_bosph); + + train_labels = cat(1, train_labels, train_labels_bosph); + valid_labels = cat(1, valid_labels, valid_labels_bosph); + + vid_ids = cat(1, vid_ids, valid_ids); + + success = cat(1, success, valid_success); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_bosph, 1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_bosph, 1), 1)); + end + + clear 'train_samples_bosph' 'train_labels_bosph' 'valid_samples_bosph' 'valid_labels_bosph' + dataset_ids = cat(1, dataset_ids, {'Bosphorus'}); + cd(op); + + end + + if(~isempty(find(DISFA_aus == au, 1))) + op = cd('../DISFA/'); + rest_aus = setdiff(DISFA_aus, au); + shared_defs; + + % make sure validation data's labels are balanced + [users_train, users_valid_disfa] = get_balanced_fold(DISFA_dir, users, au, 1/3, 1); + + % need to split the rest + [train_samples_disf, train_labels_disf, valid_samples_disf, valid_labels_disf, raw_disfa, PC, means, scaling, vid_ids_disfa, valid_success] = Prepare_HOG_AU_data_generic(users_train, users_valid_disfa, au, rest_aus, hog_data_dir); + + train_samples = cat(1, train_samples, train_samples_disf); + valid_samples = cat(1, valid_samples, valid_samples_disf); + + train_labels = cat(1, train_labels, train_labels_disf); + valid_labels = cat(1, valid_labels, valid_labels_disf); + + vid_ids = cat(1, vid_ids, vid_ids_disfa); + + success = cat(1, success, valid_success); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_disf,1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_disf,1), 1)); + end + + clear 'train_samples_disf' 'train_labels_disf' 'valid_samples_disf' 'valid_labels_disf' + dataset_ids = cat(1, dataset_ids, {'DISFA'}); + cd(op); + + end + + if(~isempty(find(UNBC_aus == au, 1))) + op = cd('../UNBC/'); + rest_aus = setdiff(UNBC_aus, au); + shared_defs; + + [users_train, users_valid_unbc] = get_balanced_fold(UNBC_dir, all_recs, au, 1/3, 1); + + % load the training and testing data for the current fold + [train_samples_unbc, train_labels_unbc, valid_samples_unbc, valid_labels_unbc, ~, PC, means, scaling, vid_ids_unbc, success_devel] = Prepare_HOG_AU_data(users_train, users_valid_unbc, au, rest_aus, UNBC_dir, hog_data_dir); + + train_samples = cat(1, train_samples, train_samples_unbc); + valid_samples = cat(1, valid_samples, valid_samples_unbc); + + train_labels = cat(1, train_labels, train_labels_unbc); + valid_labels = cat(1, valid_labels, valid_labels_unbc); + + vid_ids = cat(1, vid_ids, vid_ids_unbc); + + success = cat(1, success, success_devel); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_unbc,1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_unbc,1), 1)); + end + + clear 'train_samples_unbc' 'train_labels_unbc' 'valid_samples_unbc' 'valid_labels_unbc' + dataset_ids = cat(1, dataset_ids, {'UNBC'}); + cd(op); + + end + + train_samples = sparse(train_samples); + dataset_ids + %% Cross-validate here + hyperparams.eval_ids = eval_ids; + hyperparams.vid_ids = vid_ids; + hyperparams.valid_samples = valid_samples; + hyperparams.success = success; + hyperparams.valid_labels = valid_labels; + + [ best_params, ~ ] = validate_grid_search_no_par(svr_train, svr_test, false, train_samples, train_labels, valid_samples, valid_labels, hyperparams); + model = svr_train(train_labels, train_samples, best_params); + + model.eval_ids = eval_ids; + model.vid_ids = vid_ids; + + [~, predictions_all] = svr_test(valid_labels, valid_samples, model); + + name = sprintf('mat_models/AU_%d_static_intensity.mat', au); + + eval_ids_uq = unique(eval_ids)'; + cccs = []; + for i=eval_ids_uq + [ ~, ~, ~, ccc_c, ~, ~ ] = evaluate_regression_results( predictions_all(eval_ids==i), valid_labels(eval_ids==i)); + cccs = cat(2, cccs, ccc_c); + end + + mean_ccc = mean(cccs); + + save(name, 'model', 'mean_ccc', 'mean_ccc', 'cccs', 'predictions_all', 'valid_labels', 'eval_ids', 'dataset_ids'); + + % Write out the model + name = sprintf('regressors/AU_%d_static_intensity.dat', au); + + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + write_lin_svr(name, means, svs, b); + + clear 'train_samples' 'train_labels' 'valid_samples' 'valid_labels' +end + + diff --git a/matlab_version/AU_training/experiments/full_model_training/train_static_regressors_with_classifiers.m b/matlab_version/AU_training/experiments/full_model_training/train_static_regressors_with_classifiers.m new file mode 100644 index 00000000..a852c684 --- /dev/null +++ b/matlab_version/AU_training/experiments/full_model_training/train_static_regressors_with_classifiers.m @@ -0,0 +1,249 @@ +% Change to your downloaded location +clear +addpath('C:\liblinear\matlab') +addpath('../training_code/'); +addpath('../utilities/'); +addpath('../../data extraction/'); + +%% load shared definitions and AU data +all_dataset_aus = [1, 2, 4, 6, 7, 10, 12, 15, 17, 23, 25, 26, 45]; + +% Set up the hyperparameters to be validated +hyperparams.c = 10.^(-8:0.5:4); +hyperparams.p = 10.^(-2); + +hyperparams.validate_params = {'c', 'p'}; + +% Set the training function +svr_train = @svr_train_linear; + +% Set the test function (the first output will be used for validation) +svr_test = @svr_test_linear; + +BP4D_aus = [6, 10, 12, 14, 17]; +UNBC_aus = [6, 7, 9, 12, 25, 26]; +DISFA_aus = [1, 2, 4, 5, 6, 9, 12, 15, 17, 20, 25, 26]; +Bosphorus_aus = [1, 2, 4, 5, 6, 7, 9, 10, 12, 14, 15, 17, 20, 23, 25, 26, 45]; + +for a=1:numel(all_dataset_aus) + + au = all_dataset_aus(a); + + train_samples = []; + valid_samples = []; + + train_labels = []; + valid_labels = []; + + % Keeping track which validation sample came from which dataset, as we + % will be validating based on which hyperparam leads to best + % performance on all datasets (mean F1) + eval_ids = []; + dataset_ids = {}; + vid_ids = {}; + success = []; + + if(~isempty(find(BP4D_aus == au, 1))) + op = cd('../BP4D/'); + rest_aus = setdiff(BP4D_aus, au); + shared_defs; + % load the training and testing data for the current fold + [train_samples_bp4d, train_labels_bp4d, ~, valid_samples_bp4d, valid_labels_bp4d, vid_ids_bp4d, ~, PC, means, scaling, success_devel] = Prepare_HOG_AU_data_generic_intensity(train_recs, devel_recs, au, BP4D_dir_int, hog_data_dir); + + ignore = valid_labels_bp4d == 9; + + valid_samples_bp4d = valid_samples_bp4d(~ignore, :); + valid_labels_bp4d = valid_labels_bp4d(~ignore); + vid_ids_bp4d = vid_ids_bp4d(~ignore); + success_devel = success_devel(~ignore); + + train_samples = cat(1, train_samples, train_samples_bp4d); + valid_samples = cat(1, valid_samples, valid_samples_bp4d); + + train_labels = cat(1, train_labels, train_labels_bp4d); + valid_labels = cat(1, valid_labels, valid_labels_bp4d); + vid_ids = cat(1, vid_ids, vid_ids_bp4d); + + success = cat(1, success, success_devel); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_bp4d,1), 1); + end + + clear 'train_samples_bp4d' 'train_labels_bp4d' 'valid_samples_bp4d' 'valid_labels_bp4d' + + dataset_ids = cat(1, dataset_ids, {'BP4D'}); + + cd(op); + + end + + if(~isempty(find(Bosphorus_aus == au, 1))) + op = cd('../Bosphorus/'); + rest_aus = setdiff(DISFA_aus, au); + shared_defs; + + % make sure validation data's labels are balanced + [users_train, users_valid_bosph] = get_balanced_fold(Bosphorus_dir, all_recs, au, 1/3, 1); + + % need to split the rest + [train_samples_bosph, train_labels_bosph, valid_samples_bosph, valid_labels_bosph, ~, PC, means, scaling, valid_ids, valid_success] = Prepare_HOG_AU_data(users_train, users_valid_bosph, au, rest_aus, Bosphorus_dir, hog_data_dir); + + % As there are only a few Bosphorus images (it being an image dataset) + % we oversample it quite a bit + train_samples_bosph = repmat(train_samples_bosph, 10, 1); + train_labels_bosph = repmat(train_labels_bosph, 10, 1); + + train_samples = cat(1, train_samples, train_samples_bosph); + valid_samples = cat(1, valid_samples, valid_samples_bosph); + + train_labels = cat(1, train_labels, train_labels_bosph); + valid_labels = cat(1, valid_labels, valid_labels_bosph); + + vid_ids = cat(1, vid_ids, valid_ids); + + success = cat(1, success, valid_success); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_bosph, 1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_bosph, 1), 1)); + end + + clear 'train_samples_bosph' 'train_labels_bosph' 'valid_samples_bosph' 'valid_labels_bosph' + dataset_ids = cat(1, dataset_ids, {'Bosphorus'}); + cd(op); + + end + + if(~isempty(find(DISFA_aus == au, 1))) + op = cd('../DISFA/'); + rest_aus = setdiff(DISFA_aus, au); + shared_defs; + + % make sure validation data's labels are balanced + [users_train, users_valid_disfa] = get_balanced_fold(DISFA_dir, users, au, 1/3, 1); + + % need to split the rest + [train_samples_disf, train_labels_disf, valid_samples_disf, valid_labels_disf, raw_disfa, PC, means, scaling, vid_ids_disfa, valid_success] = Prepare_HOG_AU_data_generic(users_train, users_valid_disfa, au, rest_aus, hog_data_dir); + + train_samples = cat(1, train_samples, train_samples_disf); + valid_samples = cat(1, valid_samples, valid_samples_disf); + + train_labels = cat(1, train_labels, train_labels_disf); + valid_labels = cat(1, valid_labels, valid_labels_disf); + + vid_ids = cat(1, vid_ids, vid_ids_disfa); + + success = cat(1, success, valid_success); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_disf,1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_disf,1), 1)); + end + + clear 'train_samples_disf' 'train_labels_disf' 'valid_samples_disf' 'valid_labels_disf' + dataset_ids = cat(1, dataset_ids, {'DISFA'}); + cd(op); + + end + + if(~isempty(find(UNBC_aus == au, 1))) + op = cd('../UNBC/'); + rest_aus = setdiff(UNBC_aus, au); + shared_defs; + + [users_train, users_valid_unbc] = get_balanced_fold(UNBC_dir, all_recs, au, 1/3, 1); + + % load the training and testing data for the current fold + [train_samples_unbc, train_labels_unbc, valid_samples_unbc, valid_labels_unbc, ~, PC, means, scaling, vid_ids_unbc, success_devel] = Prepare_HOG_AU_data(users_train, users_valid_unbc, au, rest_aus, UNBC_dir, hog_data_dir); + + train_samples = cat(1, train_samples, train_samples_unbc); + valid_samples = cat(1, valid_samples, valid_samples_unbc); + + train_labels = cat(1, train_labels, train_labels_unbc); + valid_labels = cat(1, valid_labels, valid_labels_unbc); + + vid_ids = cat(1, vid_ids, vid_ids_unbc); + + success = cat(1, success, success_devel); + + if(isempty(eval_ids)) + eval_ids = ones(size(valid_labels_unbc,1), 1); + else + eval_ids = cat(1, eval_ids, (eval_ids(end)+1)*ones(size(valid_labels_unbc,1), 1)); + end + + clear 'train_samples_unbc' 'train_labels_unbc' 'valid_samples_unbc' 'valid_labels_unbc' + dataset_ids = cat(1, dataset_ids, {'UNBC'}); + cd(op); + + end + + train_samples = sparse(train_samples); + dataset_ids + %% Cross-validate here + + name = sprintf('mat_models/AU_%d_static_intensity.mat', au); + load(name, 'model'); + model_reg = model; + + valid_all_reg = valid_samples * model_reg.w(1:end-1)' + model_reg.w(end); + train_all_reg = train_samples * model_reg.w(1:end-1)' + model_reg.w(end); + + name = sprintf('mat_models/AU_%d_static.mat', au); + load(name, 'model'); + model_class = model; + valid_all_class = valid_samples * model_class.w(1:end-1)' + model_class.w(end); + train_all_class = train_samples * model_class.w(1:end-1)' + model_class.w(end); + + valid_samples_p = cat(2, valid_all_reg, valid_all_class); + train_samples_p = sparse(cat(2, train_all_reg, train_all_class)); + + %% + hyperparams.eval_ids = eval_ids; + hyperparams.vid_ids = vid_ids; + hyperparams.valid_samples = valid_samples_p; + hyperparams.success = success; + hyperparams.valid_labels = valid_labels; + + [ best_params, ~ ] = validate_grid_search_no_par(svr_train, svr_test, false, train_samples_p, train_labels, valid_samples_p, valid_labels, hyperparams); + model_fuse = svr_train(train_labels, train_samples_p, best_params); + + % Fust the regressor and classifier based on their corresponding + % weights + p = model_fuse.w; + model = model_reg; + model.w = model_reg.w * p(1) + model_class.w * p(2); + model.w(end) = model.w(end) + p(3); + %% + name = sprintf('mat_models/AU_%d_static_intensity_comb.mat', au); + + [~, predictions_all] = svr_test(valid_labels, valid_samples, model); + + eval_ids_uq = unique(eval_ids)'; + cccs = []; + for i=eval_ids_uq + [ ~, ~, ~, ccc_c, ~, ~ ] = evaluate_regression_results( predictions_all(eval_ids==i), valid_labels(eval_ids==i)); + cccs = cat(2, cccs, ccc_c); + end + + mean_ccc = mean(cccs); + %% + save(name, 'model', 'mean_ccc', 'mean_ccc', 'cccs', 'predictions_all', 'valid_labels', 'eval_ids', 'dataset_ids'); + + % Write out the model + name = sprintf('regressors/AU_%d_static_intensity_comb.dat', au); + + w = model.w(1:end-1)'; + b = model.w(end); + + svs = bsxfun(@times, PC, 1./scaling') * w; + + write_lin_svr(name, means, svs, b); + + clear 'train_samples' 'train_labels' 'valid_samples' 'valid_labels' +end + + diff --git a/matlab_version/AU_training/experiments/training_code/compute_F1.m b/matlab_version/AU_training/experiments/training_code/compute_F1.m new file mode 100644 index 00000000..59f02ae9 --- /dev/null +++ b/matlab_version/AU_training/experiments/training_code/compute_F1.m @@ -0,0 +1,17 @@ +function [result] = compute_F1(ground_truth, prediction) + + tp = sum(ground_truth == 1 & prediction == 1); + fp = sum(ground_truth == 0 & prediction == 1); + fn = sum(ground_truth == 1 & prediction == 0); + tn = sum(ground_truth == 0 & prediction == 0); + + precision = tp/(tp+fp); + recall = tp/(tp+fn); + + f1 = 2 * precision * recall / (precision + recall); + + if(isnan(f1)) + f1 = 0; + end + result = f1; +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/training_code/evaluate_regression_results.m b/matlab_version/AU_training/experiments/training_code/evaluate_regression_results.m new file mode 100644 index 00000000..f54b563f --- /dev/null +++ b/matlab_version/AU_training/experiments/training_code/evaluate_regression_results.m @@ -0,0 +1,54 @@ +function [ accuracies, F1s, corrs, ccc, rms, classes ] = evaluate_regression_results( labels, ground_truth ) +%EVALUATE_CLASSIFICATION_RESULTS Summary of this function goes here +% Detailed explanation goes here + + classes = sort(unique(ground_truth)); + accuracies = zeros(numel(classes),1); + F1s = zeros(numel(classes),1); + + corrs = corr(labels, ground_truth); + + rms = sqrt(mean((labels-ground_truth).^2)); + + std_g = std(ground_truth); + std_p = std(labels); + + ccc = 2 * corrs * std_g * std_p / (std_g^2 + std_p^2 + (mean(labels) - mean(ground_truth))^2); + + % the label is taken to belong to a class it is closest to + label_dists = zeros(numel(labels), numel(classes)); + + for i=1:numel(classes) + label_dists(:,i) = abs(labels - classes(i)); + end + + [~, labels] = min(label_dists'); + labels = labels'; + + for i=1:numel(classes) + labels(labels==i) = classes(i); + end + + for i=1:numel(classes) + + pos_samples = ground_truth == classes(i); + neg_samples = ground_truth ~= classes(i); + + pos_labels = labels == classes(i); + neg_labels = labels ~= classes(i); + + TPs = sum(pos_samples & pos_labels); + TNs = sum(neg_samples & neg_labels); + + FPs = sum(pos_labels & neg_samples); + FNs = sum(neg_labels & pos_samples); + + accuracies(i) = (TPs + TNs) / numel(pos_samples); + + F1s(i) = 2 * TPs / (2*TPs + FNs + FPs); + + end + + +end + diff --git a/matlab_version/AU_training/experiments/training_code/svm_test_linear.m b/matlab_version/AU_training/experiments/training_code/svm_test_linear.m new file mode 100644 index 00000000..5697f838 --- /dev/null +++ b/matlab_version/AU_training/experiments/training_code/svm_test_linear.m @@ -0,0 +1,56 @@ +function [result, prediction] = svm_test_linear(test_labels, test_samples, model) + + w = model.w(1:end-1)'; + b = model.w(end); + + % Attempt own prediction + prediction = test_samples * w + b; + l1_inds = prediction > 0; + l2_inds = prediction <= 0; + prediction(l1_inds) = model.Label(1); + prediction(l2_inds) = model.Label(2); + + if(~isfield(model, 'eval_ids')) + tp = sum(test_labels == 1 & prediction == 1); + fp = sum(test_labels == 0 & prediction == 1); + fn = sum(test_labels == 1 & prediction == 0); + tn = sum(test_labels == 0 & prediction == 0); + + precision = tp/(tp+fp); + recall = tp/(tp+fn); + + f1 = 2 * precision * recall / (precision + recall); + fprintf('F1:%.3f\n', f1); + else + % If we have evaluation ids compute F1 for each of them separately, + % this is because we want a mean F1 accross datasets and not one + % datasets samples dominating + eval_ids = unique(model.eval_ids)'; + f1 = 0; + fprintf('F1: '); + for i=eval_ids + tp = sum(test_labels(model.eval_ids == i) == 1 & prediction(model.eval_ids == i) == 1); + fp = sum(test_labels(model.eval_ids == i) == 0 & prediction(model.eval_ids == i) == 1); + fn = sum(test_labels(model.eval_ids == i) == 1 & prediction(model.eval_ids == i) == 0); + tn = sum(test_labels(model.eval_ids == i) == 0 & prediction(model.eval_ids == i) == 0); + + precision = tp/(tp+fp); + recall = tp/(tp+fn); + + f1_curr = 2 * precision * recall / (precision + recall); + if(isnan(f1_curr)) + f1_curr = 0; + end + f1 = f1 + f1_curr; + fprintf('%.3f ', f1_curr); + end + f1 = f1 / numel(eval_ids); + fprintf('mean : %.3f\n', f1); + end + + + if(isnan(f1)) + f1 = 0; + end + result = f1; +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/training_code/svm_train_linear.m b/matlab_version/AU_training/experiments/training_code/svm_train_linear.m new file mode 100644 index 00000000..3d16e78e --- /dev/null +++ b/matlab_version/AU_training/experiments/training_code/svm_train_linear.m @@ -0,0 +1,8 @@ +function [model] = svm_train_linear(train_labels, train_samples, hyper) + comm = sprintf('-s 1 -B 1 -e %.10f -c %.10f -q', hyper.e, hyper.c); + model = train(train_labels, train_samples, comm); + + if(isfield(hyper, 'eval_ids')) + model.eval_ids = hyper.eval_ids; + end +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/training_code/svr_test_linear.m b/matlab_version/AU_training/experiments/training_code/svr_test_linear.m new file mode 100644 index 00000000..754d0f6b --- /dev/null +++ b/matlab_version/AU_training/experiments/training_code/svr_test_linear.m @@ -0,0 +1,35 @@ +function [result, prediction] = svr_test_linear(test_labels, test_samples, model) + + prediction = test_samples * model.w(1:end-1)' + model.w(end); + + prediction(~model.success) = 0; + + prediction(prediction<0)=0; + prediction(prediction>5)=5; + + % using CCC as the evaluation metric + % using the average of CCC errors if different datasets are used + if(~isfield(model, 'eval_ids')) + result = corr(test_labels, prediction); + [ ~, ~, ~, ccc, ~, ~ ] = evaluate_regression_results( prediction, test_labels ); + result = ccc; + fprintf('CCC: %.3f\n', ccc); + else + eval_ids = unique(model.eval_ids)'; + ccc = 0; + fprintf('CCC: '); + for i=eval_ids + [ ~, ~, ~, ccc_curr, ~, ~ ] = evaluate_regression_results( prediction(model.eval_ids == i), test_labels(model.eval_ids == i) ); + ccc = ccc + ccc_curr; + fprintf('%.3f ', ccc_curr); + end + ccc = ccc / numel(eval_ids); + fprintf('mean : %.3f\n', ccc); + result = ccc; + end + + if(isnan(result)) + result = 0; + end + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/training_code/svr_test_linear_shift.m b/matlab_version/AU_training/experiments/training_code/svr_test_linear_shift.m new file mode 100644 index 00000000..ae13f4c9 --- /dev/null +++ b/matlab_version/AU_training/experiments/training_code/svr_test_linear_shift.m @@ -0,0 +1,54 @@ +function [result, prediction] = svr_test_linear_shift(test_labels, test_samples, model) + + prediction = test_samples * model.w(1:end-1)' + model.w(end); +% prediction = predict(test_labels, test_samples, model); + + prediction(~model.success) = 0; + + if(model.cutoff >= 0) + % perform shifting here per person + users = unique(model.vid_ids); + + for i=1:numel(users) + + preds_user = prediction(strcmp(model.vid_ids, users(i))); + sorted = sort(preds_user); + + % alternative, move to histograms and pick the highest one + + shift = sorted(round(end*model.cutoff)+1); + + prediction(strcmp(model.vid_ids, users(i))) = preds_user - shift; + + end + end + + % Cap the prediction as well + prediction(prediction<0)=0; + prediction(prediction>5)=5; + + % using the average of RMS errors +% result = mean(sqrt(mean((prediction - test_labels).^2))); + if(~isfield(model, 'eval_ids')) + result = corr(test_labels, prediction); + [ ~, ~, ~, ccc, ~, ~ ] = evaluate_regression_results( prediction, test_labels ); + result = ccc; + else + eval_ids = unique(model.eval_ids)'; + ccc = 0; + fprintf('CCC: '); + for i=eval_ids + [ ~, ~, ~, ccc_curr, ~, ~ ] = evaluate_regression_results( prediction(model.eval_ids == i), test_labels(model.eval_ids == i) ); + ccc = ccc + ccc_curr; + fprintf('%.3f ', ccc_curr); + end + ccc = ccc / numel(eval_ids); + fprintf('mean : %.3f\n', ccc); + result = ccc; + end + + if(isnan(result)) + result = 0; + end + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/training_code/svr_train_linear.m b/matlab_version/AU_training/experiments/training_code/svr_train_linear.m new file mode 100644 index 00000000..e0301325 --- /dev/null +++ b/matlab_version/AU_training/experiments/training_code/svr_train_linear.m @@ -0,0 +1,13 @@ +function [model] = svr_train_linear(train_labels, train_samples, hyper) + % Change to your downloaded location + addpath('C:\liblinear\matlab') + + comm = sprintf('-s 11 -B 1 -p %.10f -c %.10f -q', hyper.p, hyper.c); + model = train(train_labels, train_samples, comm); + model.success = hyper.success; + + if(isfield(hyper, 'eval_ids')) + model.eval_ids = hyper.eval_ids; + end + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/training_code/svr_train_linear_shift.m b/matlab_version/AU_training/experiments/training_code/svr_train_linear_shift.m new file mode 100644 index 00000000..107cdc26 --- /dev/null +++ b/matlab_version/AU_training/experiments/training_code/svr_train_linear_shift.m @@ -0,0 +1,62 @@ +function [model] = svr_train_linear_shift(train_labels, train_samples, hyper) + + % Change to your downloaded location + addpath('C:\liblinear\matlab') + + comm = sprintf('-s 11 -B 1 -p %.10f -c %.10f -q', hyper.p, hyper.c); + model = train(train_labels, train_samples, comm); + + % Try predicting on the valid samples data and shifting it + + cutoffs = 0:0.05:0.8; + results = zeros(numel(cutoffs)+1, 1); + + prediction = hyper.valid_samples * model.w(1:end-1)' + model.w(end); + prediction(~hyper.success) = 0; + + for c=1:numel(cutoffs) + % perform shifting here per person + users = unique(hyper.vid_ids); + + prediction_curr = prediction; + + for i=1:numel(users) + + preds_user = prediction_curr(strcmp(hyper.vid_ids, users(i))); + sorted = sort(preds_user); + + % alternative, move to histograms and pick the highest one + + shift = sorted(round(end*cutoffs(c))+1); + + prediction_curr(strcmp(hyper.vid_ids, users(i))) = preds_user - shift; + + end + + prediction_curr(prediction_curr<0)=0; + prediction_curr(prediction_curr>5)=5; + + [ ~, ~, ~, ccc, ~, ~ ] = evaluate_regression_results( prediction_curr, hyper.valid_labels ); + result = ccc; + results(c) = result; + end + + % option of no cutoff as well + cutoffs = cat(2,cutoffs, -1); + prediction(prediction<0)=0; + prediction(prediction>5)=5; + [ ~, ~, ~, ccc, ~, ~ ] = evaluate_regression_results( prediction, hyper.valid_labels ); + + results(end) = ccc; + + [best, best_id] = max(results); + result = results(best_id); + model.cutoff = cutoffs(best_id); + model.vid_ids = hyper.vid_ids; + model.success = hyper.success; + + if(isfield(hyper, 'eval_ids')) + model.eval_ids = hyper.eval_ids; + end + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/training_code/validate_grid_search.m b/matlab_version/AU_training/experiments/training_code/validate_grid_search.m new file mode 100644 index 00000000..0d62ac50 --- /dev/null +++ b/matlab_version/AU_training/experiments/training_code/validate_grid_search.m @@ -0,0 +1,119 @@ +function [ best_params, all_params ] = validate_grid_search(train_fn, test_fn, minimise, samples_train, labels_train, samples_valid, labels_valid, hyperparams, varargin) +%crossvalidate_regressor_grid_search A utility function for crossvalidating a statistical model +% Detailed explanation goes here +% +% train_fn - a function handle that takes train_labels, train_samples, +% hyperparams as input (with each row being a sample), it must return a +% model that can be passed to test_fn +% +% test_fn - a function that takes test_labels, test_samples, model as +% input and returns the result to optimise +% +% minimise - if set to true the crossvalidation will attempt to find +% hyper-parameters that minimise the result otherwise they will maximise +% it +% +% samples - the whole training dataset (rows are samples) +% +% labels - the labels for training (rows are samples) +% +% hyperparams - the field validate_params should contain the names of +% hyperparameters to validate, and the hyperparameter to be validated +% should contain values to be tested. For example: +% If we havehyperparams.validate_params = {'c','g'}, and +% hyperparams.c = [0.1, 10, 100], hyperparams.g = [0.25, 0.5], the grid +% search algorithm will search through all their possible combinations +% +% Optional parameters: +% +% 'num_repeat' - number of times to retry the training testing (useful +% for non deterministic algorithms + + % Find the hyperparameters to optimise (if any) + + num_params = 1; + + if(isfield(hyperparams, 'validate_params')) + param_names = hyperparams.validate_params; + param_values = cell(numel(param_names),1); + + for p=1:numel(param_names) + param_values{p} = hyperparams.(param_names{p}); + num_params = num_params * numel(param_values{p}); + end + + % Create the list of parameter combinations + + % keep track of parameter value indices (will be cycling over them based on change_every) + index = ones(numel(param_values), 1); + change_every = zeros(numel(param_values), 1); + change_already = num_params; + for p=1:numel(param_names) + change_every(p) = change_already / numel(param_values{p}); + change_already = change_already / numel(param_values{p}); + end + for i=1:num_params + all_params(i) = hyperparams; + + for p=1:numel(param_names) + all_params(i).(param_names{p}) = param_values{p}(index(p)); + + % get the new value + if(mod(i, change_every(p)) == 0) + index(p) = index(p) + 1; + end + + % cycle the value if it exceeds the bounds + if(mod(index(p) - 1, numel(param_values{p})) == 0) + index(p) = 1; + end + end + + end + + % some clean-up + all_params = rmfield(all_params, 'validate_params'); + + % Initialise all results to 0 + for i=1:num_params + all_params(i).result = 0; + end + else + % if no validation needed just set to hyperparams + all_params = hyperparams; + all_params.result = 0; + end + + + % Potentially useful for non-deterministic models, we might want to + % train them multiple times for more reliable results + if(sum(strcmp(varargin,'num_repeat'))) + ind = find(strcmp(varargin,'num_repeat')) + 1; + num_repeat = varargin{ind}; + else + num_repeat = 1; + end + + % Crossvalidate the c, p, and gamma values + parfor p = 1:num_params + + for r=1:num_repeat + model = train_fn(labels_train, samples_train, all_params(p)); + + result = test_fn(labels_valid, samples_valid, model); + + all_params(p).result = all_params(p).result + result/(num_repeat); + end + end + + + %% Finding the best hyper-params + if(minimise) + [~, best] = min(cat(1, all_params.result)); + else + [~, best] = max(cat(1, all_params.result)); + end + + best_params = all_params(best); + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/training_code/validate_grid_search_no_par.m b/matlab_version/AU_training/experiments/training_code/validate_grid_search_no_par.m new file mode 100644 index 00000000..cfda40d8 --- /dev/null +++ b/matlab_version/AU_training/experiments/training_code/validate_grid_search_no_par.m @@ -0,0 +1,119 @@ +function [ best_params, all_params ] = validate_grid_search(train_fn, test_fn, minimise, samples_train, labels_train, samples_valid, labels_valid, hyperparams, varargin) +%crossvalidate_regressor_grid_search A utility function for crossvalidating a statistical model +% Detailed explanation goes here +% +% train_fn - a function handle that takes train_labels, train_samples, +% hyperparams as input (with each row being a sample), it must return a +% model that can be passed to test_fn +% +% test_fn - a function that takes test_labels, test_samples, model as +% input and returns the result to optimise +% +% minimise - if set to true the crossvalidation will attempt to find +% hyper-parameters that minimise the result otherwise they will maximise +% it +% +% samples - the whole training dataset (rows are samples) +% +% labels - the labels for training (rows are samples) +% +% hyperparams - the field validate_params should contain the names of +% hyperparameters to validate, and the hyperparameter to be validated +% should contain values to be tested. For example: +% If we havehyperparams.validate_params = {'c','g'}, and +% hyperparams.c = [0.1, 10, 100], hyperparams.g = [0.25, 0.5], the grid +% search algorithm will search through all their possible combinations +% +% Optional parameters: +% +% 'num_repeat' - number of times to retry the training testing (useful +% for non deterministic algorithms + + % Find the hyperparameters to optimise (if any) + + num_params = 1; + + if(isfield(hyperparams, 'validate_params')) + param_names = hyperparams.validate_params; + param_values = cell(numel(param_names),1); + + for p=1:numel(param_names) + param_values{p} = hyperparams.(param_names{p}); + num_params = num_params * numel(param_values{p}); + end + + % Create the list of parameter combinations + + % keep track of parameter value indices (will be cycling over them based on change_every) + index = ones(numel(param_values), 1); + change_every = zeros(numel(param_values), 1); + change_already = num_params; + for p=1:numel(param_names) + change_every(p) = change_already / numel(param_values{p}); + change_already = change_already / numel(param_values{p}); + end + for i=1:num_params + all_params(i) = hyperparams; + + for p=1:numel(param_names) + all_params(i).(param_names{p}) = param_values{p}(index(p)); + + % get the new value + if(mod(i, change_every(p)) == 0) + index(p) = index(p) + 1; + end + + % cycle the value if it exceeds the bounds + if(mod(index(p) - 1, numel(param_values{p})) == 0) + index(p) = 1; + end + end + + end + + % some clean-up + all_params = rmfield(all_params, 'validate_params'); + + % Initialise all results to 0 + for i=1:num_params + all_params(i).result = 0; + end + else + % if no validation needed just set to hyperparams + all_params = hyperparams; + all_params.result = 0; + end + + + % Potentially useful for non-deterministic models, we might want to + % train them multiple times for more reliable results + if(sum(strcmp(varargin,'num_repeat'))) + ind = find(strcmp(varargin,'num_repeat')) + 1; + num_repeat = varargin{ind}; + else + num_repeat = 1; + end + + % Crossvalidate the c, p, and gamma values + for p = 1:num_params + + for r=1:num_repeat + model = train_fn(labels_train, samples_train, all_params(p)); + + result = test_fn(labels_valid, samples_valid, model); + + all_params(p).result = all_params(p).result + result/(num_repeat); + end + end + + + %% Finding the best hyper-params + if(minimise) + [~, best] = min(cat(1, all_params.result)); + else + [~, best] = max(cat(1, all_params.result)); + end + + best_params = all_params(best); + +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/utilities/writeMatrixBin.m b/matlab_version/AU_training/experiments/utilities/writeMatrixBin.m new file mode 100644 index 00000000..a0fc5c34 --- /dev/null +++ b/matlab_version/AU_training/experiments/utilities/writeMatrixBin.m @@ -0,0 +1,37 @@ +% for easier readibility write them row by row +function writeMatrixBin(fileID, M, type) + + % 4 bytes each for the description + fwrite(fileID, size(M,1), 'uint'); + fwrite(fileID, size(M,2), 'uint'); + fwrite(fileID, type, 'uint'); + + % Convert the matrix to OpenCV format (row minor as opposed to column + % minor) + M = M'; + + % type 0 - uint8, 1 - int8, 2 - uint16, 3 - int16, 4 - int, 5 - + % float32, 6 - float64 + + % Write out the matrix itself + + switch type + case 0 + type = 'uint8'; + case 1 + type = 'int8'; + case 2 + type = 'uint16'; + case 3 + type = 'int16'; + case 4 + type = 'int'; + case 5 + type = 'float32'; + case 6 + type = 'float64'; + otherwise + type = 'float32'; + end + fwrite(fileID, M, type); +end \ No newline at end of file diff --git a/matlab_version/AU_training/experiments/utilities/write_lin_dyn_svm.m b/matlab_version/AU_training/experiments/utilities/write_lin_dyn_svm.m new file mode 100644 index 00000000..bcec94fe --- /dev/null +++ b/matlab_version/AU_training/experiments/utilities/write_lin_dyn_svm.m @@ -0,0 +1,28 @@ +function [ success ] = write_lin_dyn_svm( location, means, w, b, pos_lbl, neg_lbl) +%WRITE_LIN_SVR Summary of this function goes here +% Detailed explanation goes here + + fileID = fopen(location, 'w'); + + if(fileID ~= -1) + + % Write the regressor type 5 - linear dynamic SVM + fwrite(fileID, 5, 'uint'); + + writeMatrixBin(fileID, means, 6); + writeMatrixBin(fileID, w, 6); + fwrite(fileID, b, 'float64'); + + fwrite(fileID, pos_lbl, 'float64'); + fwrite(fileID, neg_lbl, 'float64'); + + fclose(fileID); + + success = true; + + else + success = false; + end + +end + diff --git a/matlab_version/AU_training/experiments/utilities/write_lin_dyn_svr.m b/matlab_version/AU_training/experiments/utilities/write_lin_dyn_svr.m new file mode 100644 index 00000000..f9122578 --- /dev/null +++ b/matlab_version/AU_training/experiments/utilities/write_lin_dyn_svr.m @@ -0,0 +1,27 @@ +function [ success ] = write_lin_dyn_svr( location, means, w, b, cutoff) +%WRITE_LIN_SVR Summary of this function goes here +% Detailed explanation goes here + + fileID = fopen(location, 'w'); + + if(fileID ~= -1) + + % Write the regressor type 1 - linear dynamic SVR + fwrite(fileID, 1, 'uint'); + + fwrite(fileID, cutoff, 'float64'); + + writeMatrixBin(fileID, means, 6); + writeMatrixBin(fileID, w, 6); + fwrite(fileID, b, 'float64'); + + fclose(fileID); + + success = true; + + else + success = false; + end + +end + diff --git a/matlab_version/AU_training/experiments/utilities/write_lin_svm.m b/matlab_version/AU_training/experiments/utilities/write_lin_svm.m new file mode 100644 index 00000000..671fc0c7 --- /dev/null +++ b/matlab_version/AU_training/experiments/utilities/write_lin_svm.m @@ -0,0 +1,28 @@ +function [ success ] = write_lin_svm( location, means, w, b, pos_lbl, neg_lbl) +%WRITE_LIN_SVR Summary of this function goes here +% Detailed explanation goes here + + fileID = fopen(location, 'w'); + + if(fileID ~= -1) + + % Write the regressor type 4 - linear SVM + fwrite(fileID, 4, 'uint'); + + writeMatrixBin(fileID, means, 6); + writeMatrixBin(fileID, w, 6); + fwrite(fileID, b, 'float64'); + + fwrite(fileID, pos_lbl, 'float64'); + fwrite(fileID, neg_lbl, 'float64'); + + fclose(fileID); + + success = true; + + else + success = false; + end + +end + diff --git a/matlab_version/AU_training/experiments/utilities/write_lin_svr.m b/matlab_version/AU_training/experiments/utilities/write_lin_svr.m new file mode 100644 index 00000000..f8392a36 --- /dev/null +++ b/matlab_version/AU_training/experiments/utilities/write_lin_svr.m @@ -0,0 +1,25 @@ +function [ success ] = write_lin_svr( location, means, w, b) +%WRITE_LIN_SVR Summary of this function goes here +% Detailed explanation goes here + + fileID = fopen(location, 'w'); + + if(fileID ~= -1) + + % Write the regressor type 0 - linear SVR + fwrite(fileID, 0, 'uint'); + + writeMatrixBin(fileID, means, 6); + writeMatrixBin(fileID, w, 6); + fwrite(fileID, b, 'float64'); + + fclose(fileID); + + success = true; + + else + success = false; + end + +end + diff --git a/matlab_version/AU_training/instructions.txt b/matlab_version/AU_training/instructions.txt new file mode 100644 index 00000000..91b41c7f --- /dev/null +++ b/matlab_version/AU_training/instructions.txt @@ -0,0 +1,27 @@ +The instructions are for a Windows machine, but it should be fairly easy to adapt them to other operating systems + +0. You need to acquire the following AU datasets for the code to work (if you do not have some of them you will need to modify the code slightly to account for that): + - Bosphorus (http://bosphorus.ee.boun.edu.tr/) + - BP4D from FERA2015 (http://sspnet.eu/fera2015/) + - DISFA (http://www.engr.du.edu/mmahoor/DISFA.htm) + - FERA2011 (http://sspnet.eu/fera2011/fera2011data/) + - SEMAINE from FERA2015 (http://sspnet.eu/fera2015/) + - UNBC (http://www.pitt.edu/~emotion/um-spread.htm) +1. First compile the 64-bit C++ models to be able to extract the features (possible to use 32-bit models as well but default path assumes 64 bit) +2. Extract features using scripts in the "data extraction" folder, this allows to build a PCA subspace for HOGs that is relevant to faces and facial expressions + - change the directory locations to where you downloaded the datasets from step 0 + - run all of the extract_features_*.m scripts + - this will take some time: 4-20 hours depending on your machine as you will need to process a lot of visual data + - you need to make sure you have the right datasets and they are in the right locations +3. Create a PCA model + - run the createSubFaceModels.m in the pca_generation folder + - this will create a full, lower and upper face PCAs + - this will take some time (30-60 minutes or so) and require lots of RAM (up to 16GB) +4. Training the actual models, go to experiments/full_model_training + - train_static_regressors.m + - train_static_classifiers.m + - train_dynamic_regressors.m + - train_dynamic_classifiers.m + - train_static_regressors_with_classifiers.m + - train_dynamic_regressors_with_classifiers.m + - this will create the .dat files that can be used with the C++ code for AU prediction \ No newline at end of file diff --git a/matlab_version/AU_training/pca_generation/Read_HOG_files_small.m b/matlab_version/AU_training/pca_generation/Read_HOG_files_small.m new file mode 100644 index 00000000..1e580434 --- /dev/null +++ b/matlab_version/AU_training/pca_generation/Read_HOG_files_small.m @@ -0,0 +1,107 @@ +function [hog_data, valid_inds, vid_id] = Read_HOG_files_small(hog_files, hog_data_dir, num_samples) + + hog_data = []; + vid_id = {}; + + feats_filled = 0; + + curr_data_buff = []; + + for i=1:numel(hog_files) + + hog_file = [hog_data_dir, hog_files(i).name]; + + fprintf('%d %s\n', i, hog_file); + + f = fopen(hog_file, 'r'); + + curr_ind = 0; + + while(~feof(f)) + + if(i == 1 && curr_ind == 0) + num_cols = fread(f, 1, 'int32'); + if(isempty(num_cols)) + break; + end + + num_rows = fread(f, 1, 'int32'); + num_chan = fread(f, 1, 'int32'); + + curr_ind = curr_ind + 1; + + % preallocate some space + if(curr_ind == 1) + curr_data_buff = zeros(5000, 1 + num_rows * num_cols * num_chan); + + num_feats = 1 + num_rows * num_cols * num_chan; + end + + if(curr_ind > size(curr_data_buff,1)) + curr_data_buff = cat(1, curr_data_buff, zeros(6000, num_rows * num_cols * num_chan)); + end + feature_vec = fread(f, [1, 1 + num_rows * num_cols * num_chan], 'float32'); + curr_data_buff(curr_ind, :) = feature_vec; + + else + + % Reading in batches of 5000 + + feature_vec = fread(f, [4 + num_rows * num_cols * num_chan, 5000], 'float32'); + feature_vec = feature_vec(4:end,:)'; + + if(~isempty(feature_vec)) + num_rows_read = size(feature_vec,1); + + curr_data_buff(curr_ind+1:curr_ind+num_rows_read,:) = feature_vec; + %valid_data_buff = + curr_ind = curr_ind + size(feature_vec,1); + end + end + + end + + fclose(f); + + curr_data_small = curr_data_buff(1:curr_ind,:); + vid_id_curr = cell(curr_ind,1); + vid_id_curr(:) = {hog_files(i).name}; + + % Keep up to 20 frames from the whole video (so that it is balanced + % per dataset/video/participant) + + if(nargin > 2) + num_instances = num_samples; + else + num_instances = 20; + end + + increment = round(curr_ind / num_instances); + if(increment == 0) + increment = 1; + end + + curr_data_small = curr_data_small(1:increment:end,:); + vid_id_curr = vid_id_curr(1:increment:end,:); + + vid_id = cat(1, vid_id, vid_id_curr); + + % Assume same number of frames per video + if(i==1) + hog_data = zeros(10*numel(hog_files), num_feats); + end + + if(size(hog_data,1) < feats_filled+size(curr_data_small,1)) + hog_data = cat(1, hog_data, zeros(feats_filled + size(curr_data_small,1) - size(hog_data,1), num_feats)); + end + + hog_data(feats_filled+1:feats_filled + size(curr_data_small,1),:) = curr_data_small; + + feats_filled = feats_filled + size(curr_data_small,1); + + end + + valid_inds = hog_data(1:feats_filled,1) > 0; + hog_data = hog_data(1:feats_filled,2:end); + +end \ No newline at end of file diff --git a/matlab_version/AU_training/pca_generation/createGenericFaceModel.m b/matlab_version/AU_training/pca_generation/createGenericFaceModel.m new file mode 100644 index 00000000..6811d1c4 --- /dev/null +++ b/matlab_version/AU_training/pca_generation/createGenericFaceModel.m @@ -0,0 +1,67 @@ +clear; + +%% CK+, FERA2011 and UNBC datasets +hog_dir = 'D:\Datasets/face_datasets/hog_aligned_rigid/'; +hog_files = dir([hog_dir, '*.hog']); + +[appearance_data, valid_inds, vid_ids_train] = Read_HOG_files_small(hog_files, hog_dir); +appearance_data = appearance_data(valid_inds,:); +vid_ids_train = vid_ids_train(valid_inds,:); + +%% DISFA +hog_dir = 'D:\Datasets\DISFA\hog_aligned_rigid/'; +hog_files = dir([hog_dir, '*.hog']); + +[appearance_data_disfa, valid_inds, vid_ids_train_disfa] = Read_HOG_files_small(hog_files, hog_dir, 100); + +appearance_data_disfa = appearance_data_disfa(valid_inds,:); +vid_ids_train_disfa = vid_ids_train_disfa(valid_inds,:); + +appearance_data = cat(1,appearance_data, appearance_data_disfa); +vid_ids_train = cat(1,vid_ids_train, vid_ids_train_disfa); + +%% BP4D +hog_dir = 'D:\Datasets\FERA_2015\bp4d\processed_data/train/'; +hog_files = dir([hog_dir, '*.hog']); + +[appearance_data_bp, valid_inds, vid_ids_train_bp] = Read_HOG_files_small(hog_files, hog_dir, 50); + +appearance_data_bp = appearance_data_bp(valid_inds,:); +vid_ids_train_bp = vid_ids_train_bp(valid_inds,:); + +appearance_data = cat(1,appearance_data, appearance_data_bp); +vid_ids_train = cat(1,vid_ids_train, vid_ids_train_bp); + +%% SEMAINE +hog_dir = 'D:\Datasets\FERA_2015\semaine\processed_data\train\'; +hog_files = dir([hog_dir, '*.hog']); + +[appearance_data_semaine, valid_inds, vid_ids_train_semaine] = Read_HOG_files_small(hog_files, hog_dir, 300); + +appearance_data_semaine = appearance_data_semaine(valid_inds,:); +vid_ids_train_semaine = vid_ids_train_semaine(valid_inds,:); + +appearance_data = cat(1,appearance_data, appearance_data_semaine); +vid_ids_train = cat(1,vid_ids_train, vid_ids_train_semaine); + +%% +means_norm = mean(appearance_data); +stds_norm = std(appearance_data); + +normed_data = bsxfun(@times, bsxfun(@plus, appearance_data, -means_norm), 1./stds_norm); + +[PC, score, eigen_vals] = princomp(normed_data, 'econ'); + +% Keep 95 percent of variability +total_sum = sum(eigen_vals); +count = numel(eigen_vals); +for i=1:numel(eigen_vals) + if ((sum(eigen_vals(1:i)) / total_sum) >= 0.95) + count = i; + break; + end +end + +PC = PC(:,1:count); + +save('generic_face_rigid.mat', 'PC', 'means_norm', 'stds_norm'); diff --git a/matlab_version/AU_training/pca_generation/createSubFaceModels.m b/matlab_version/AU_training/pca_generation/createSubFaceModels.m new file mode 100644 index 00000000..38f0f300 --- /dev/null +++ b/matlab_version/AU_training/pca_generation/createSubFaceModels.m @@ -0,0 +1,120 @@ +clear; + +%% CK+, FERA2011, and UNBC datasets +hog_dir = 'D:\Datasets/face_datasets/hog_aligned_rigid/'; +hog_files = dir([hog_dir, '*.hog']); + +[appearance_data, valid_inds, vid_ids_train] = Read_HOG_files_small(hog_files, hog_dir); +appearance_data = appearance_data(valid_inds,:); +vid_ids_train = vid_ids_train(valid_inds,:); + +%% Bosphorus dataset +hog_dir = 'D:\Datasets/face_datasets/hog_aligned_rigid_b/'; +hog_files = dir([hog_dir, '*.hog']); + +[appearance_data_bosph, valid_inds, vid_ids_train_bosph] = Read_HOG_files_small(hog_files, hog_dir); + +appearance_data_bosph = appearance_data_bosph(valid_inds,:); +vid_ids_train_bosph = vid_ids_train_bosph(valid_inds,:); + +appearance_data = cat(1,appearance_data, appearance_data_bosph); +vid_ids_train = cat(1,vid_ids_train, vid_ids_train_bosph); + +%% DISFA +hog_dir = 'D:\Datasets\DISFA\hog_aligned_rigid/'; +hog_files = dir([hog_dir, '*.hog']); + +[appearance_data_disfa, valid_inds, vid_ids_train_disfa] = Read_HOG_files_small(hog_files, hog_dir, 100); + +appearance_data_disfa = appearance_data_disfa(valid_inds,:); +vid_ids_train_disfa = vid_ids_train_disfa(valid_inds,:); + +appearance_data = cat(1,appearance_data, appearance_data_disfa); +vid_ids_train = cat(1,vid_ids_train, vid_ids_train_disfa); + +%% BP4D +hog_dir = 'D:\Datasets\FERA_2015\bp4d\processed_data/train/'; +hog_files = dir([hog_dir, '*.hog']); + +[appearance_data_bp, valid_inds, vid_ids_train_bp] = Read_HOG_files_small(hog_files, hog_dir, 50); + +appearance_data_bp = appearance_data_bp(valid_inds,:); +vid_ids_train_bp = vid_ids_train_bp(valid_inds,:); + +appearance_data = cat(1,appearance_data, appearance_data_bp); +vid_ids_train = cat(1,vid_ids_train, vid_ids_train_bp); + +%% SEMAINE +hog_dir = 'D:\Datasets\FERA_2015\semaine\processed_data\train\'; +hog_files = dir([hog_dir, '*.hog']); + +[appearance_data_semaine, valid_inds, vid_ids_train_semaine] = Read_HOG_files_small(hog_files, hog_dir, 300); + +appearance_data_semaine = appearance_data_semaine(valid_inds,:); +vid_ids_train_semaine = vid_ids_train_semaine(valid_inds,:); + +appearance_data = cat(1,appearance_data, appearance_data_semaine); +vid_ids_train = cat(1,vid_ids_train, vid_ids_train_semaine); + +%% +means_norm = mean(appearance_data); +stds_norm = std(appearance_data); + +normed_data = bsxfun(@times, bsxfun(@plus, appearance_data, -means_norm), 1./stds_norm); + +%% Creating a generic model +[PC, score, eigen_vals] = princomp(normed_data, 'econ'); + +% Keep 95 percent of variability +total_sum = sum(eigen_vals); +count = numel(eigen_vals); +for i=1:numel(eigen_vals) + if ((sum(eigen_vals(1:i)) / total_sum) >= 0.95) + count = i; + break; + end +end + +PC = PC(:,1:count); + +save('generic_face_rigid.mat', 'PC', 'means_norm', 'stds_norm'); + +%% Creating a lower face model +normed_data_lower_face = normed_data; +normed_data_lower_face(:, 1:5*12*31) = 0; + +[PC, score, eigen_vals] = princomp(normed_data_lower_face, 'econ'); + +% Keep 98 percent of variability +total_sum = sum(eigen_vals); +count = numel(eigen_vals); +for i=1:numel(eigen_vals) + if ((sum(eigen_vals(1:i)) / total_sum) >= 0.98) + count = i; + break; + end +end + +PC = PC(:,1:count); + +save('generic_face_lower.mat', 'PC', 'means_norm', 'stds_norm'); + +%% Creating an upper face model +normed_data_upper_face = normed_data; +normed_data_upper_face(:, end-5*12*31+1:end) = 0; + +[PC, score, eigen_vals] = princomp(normed_data_upper_face, 'econ'); + +% Keep 98 percent of variability +total_sum = sum(eigen_vals); +count = numel(eigen_vals); +for i=1:numel(eigen_vals) + if ((sum(eigen_vals(1:i)) / total_sum) >= 0.98) + count = i; + break; + end +end + +PC = PC(:,1:count); + +save('generic_face_upper.mat', 'PC', 'means_norm', 'stds_norm'); \ No newline at end of file diff --git a/matlab_version/AU_training/pca_generation/generic_face_lower.mat b/matlab_version/AU_training/pca_generation/generic_face_lower.mat new file mode 100644 index 00000000..1cb17298 Binary files /dev/null and b/matlab_version/AU_training/pca_generation/generic_face_lower.mat differ diff --git a/matlab_version/AU_training/pca_generation/generic_face_rigid.mat b/matlab_version/AU_training/pca_generation/generic_face_rigid.mat new file mode 100644 index 00000000..7107e845 Binary files /dev/null and b/matlab_version/AU_training/pca_generation/generic_face_rigid.mat differ diff --git a/matlab_version/AU_training/pca_generation/generic_face_upper.mat b/matlab_version/AU_training/pca_generation/generic_face_upper.mat new file mode 100644 index 00000000..3c9652f4 Binary files /dev/null and b/matlab_version/AU_training/pca_generation/generic_face_upper.mat differ diff --git a/matlab_version/AU_training/pca_generation/pdm_68_aligned_wild.mat b/matlab_version/AU_training/pca_generation/pdm_68_aligned_wild.mat new file mode 100644 index 00000000..914b25f7 Binary files /dev/null and b/matlab_version/AU_training/pca_generation/pdm_68_aligned_wild.mat differ diff --git a/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_afw.mat b/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_afw.mat new file mode 100644 index 00000000..5fb35fbe Binary files /dev/null and b/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_afw.mat differ diff --git a/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_helen_testset.mat b/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_helen_testset.mat new file mode 100644 index 00000000..de7a22b4 Binary files /dev/null and b/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_helen_testset.mat differ diff --git a/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_helen_trainset.mat b/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_helen_trainset.mat new file mode 100644 index 00000000..f5e31210 Binary files /dev/null and b/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_helen_trainset.mat differ diff --git a/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_ibug.mat b/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_ibug.mat new file mode 100644 index 00000000..84ff0a0d Binary files /dev/null and b/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_ibug.mat differ diff --git a/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_lfpw_testset.mat b/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_lfpw_testset.mat new file mode 100644 index 00000000..c7fa32fb Binary files /dev/null and b/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_lfpw_testset.mat differ diff --git a/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_lfpw_trainset.mat b/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_lfpw_trainset.mat new file mode 100644 index 00000000..66fc591e Binary files /dev/null and b/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_lfpw_trainset.mat differ diff --git a/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_xm2vts.mat b/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_xm2vts.mat new file mode 100644 index 00000000..b1e3021f Binary files /dev/null and b/matlab_version/bounding_box_mapping/Bounding Boxes/bounding_boxes_xm2vts.mat differ diff --git a/matlab_version/demo/face_image_demo_eyes.m b/matlab_version/demo/face_image_demo_eyes.m index 40a37141..05bf43f6 100644 --- a/matlab_version/demo/face_image_demo_eyes.m +++ b/matlab_version/demo/face_image_demo_eyes.m @@ -9,22 +9,30 @@ addpath('../CCNF/'); [clmParams, pdm] = Load_CLM_params_wild(); -[clmParams_eye, pdm_eye] = Load_CLM_params_eye(); - % An accurate CCNF (or CLNF) model % [patches] = Load_Patch_Experts( '../models/general/', 'ccnf_patches_*_general.mat', [], [], clmParams); % A simpler (but less accurate SVR) [patches] = Load_Patch_Experts( '../models/general/', 'svr_patches_*_general.mat', [], [], clmParams); -[patches_eye] = Load_Patch_Experts( 'C:\Users\Tadas\Dropbox\AAM\patch_experts_eyes\svr_training\trained/', 'svr_patches_*_synth.mat', [], [], clmParams); +% Loading eye PDM and patch experts +[clmParams_eye, pdm_right_eye, pdm_left_eye] = Load_CLM_params_eye_28(); +[patches_right_eye] = Load_Patch_Experts( '../models/hierarch/', 'ccnf_patches_*_synth_right_eye.mat', [], [], clmParams_eye); +[patches_left_eye] = Load_Patch_Experts( '../models/hierarch/', 'ccnf_patches_*_synth_left_eye.mat', [], [], clmParams_eye); +clmParams_eye.multi_modal_types = patches_right_eye(1).multi_modal_types; +right_eye_inds = [43,44,45,46,47,48]; +left_eye_inds = [37,38,39,40,41,42]; + +right_eye_inds_synth = [9 11 13 15 17 19]; +left_eye_inds_synth = [9 11 13 15 17 19]; clmParams.multi_modal_types = patches(1).multi_modal_types; -clmParams_eye.multi_modal_types = patches_eye(1).multi_modal_types; - %% -root_dir = 'C:\Users\Tadas\Dropbox\AAM\test data\gaze_original\p00/'; -images = dir([root_dir, '*.jpg']); +% root_dir = 'C:\Users\Tadas\Dropbox\AAM\test data\gaze_original\p00/'; +% images = dir([root_dir, '*.jpg']); + +root_dir = './sample_eye_imgs/'; +images = dir([root_dir, '/*.png']); verbose = true; @@ -83,43 +91,36 @@ for img=1:numel(images) % shape correction for matlab format shape = shape + 1; + + % Perform eye fitting now + shape_r_eye = zeros(numel(pdm_right_eye.M)/3, 2); + shape_r_eye(right_eye_inds_synth,:) = shape(right_eye_inds, :); - if(verbose) + [ a, R, T, ~, l_params] = fit_PDM_ortho_proj_to_2D(pdm_right_eye.M, pdm_right_eye.E, pdm_right_eye.V, shape_r_eye); - % valid points to draw (not to draw self-occluded ones) - v_points = logical(patches(1).visibilities(view_used,:)); + bbox = [min(shape_r_eye(:,1)), min(shape_r_eye(:,2)), max(shape_r_eye(:,1)), max(shape_r_eye(:,2))]; - try - - plot(shape(v_points,1), shape(v_points',2),'.r','MarkerSize',20); - plot(shape(v_points,1), shape(v_points',2),'.b','MarkerSize',10); - - catch warn - - end - end - - % Map from detected landmarks to eye params - shape_r_eye = zeros(20,2); - shape_r_eye([9,11,13,15,17,19],:) = shape([43,44,45,46,47,48], :); - - [ a, R, T, ~, params, err, shapeOrtho] = fit_PDM_ortho_proj_to_2D(pdm_eye.M, pdm_eye.E, pdm_eye.V, shape_r_eye); - g_param = [a; Rot2Euler(R)'; T]; - l_param = params; - % Use the initial global and local params for clm fitting in the image - patches_eye(1).visibilities(1:8) = 0; - patches_eye(2).visibilities(1:8) = 0; - patches_eye(3).visibilities(1:8) = 0; - [shape_eye,~,~,lhood,lmark_lhood,view_used] = Fitting_from_bb(image, [], bbox, pdm_eye, patches_eye, clmParams_eye, 'gparam', g_param, 'lparam', l_param); + [shape_r_eye] = Fitting_from_bb(image, [], bbox, pdm_right_eye, patches_right_eye, clmParams_eye, 'gparam', g_param, 'lparam', l_params); - plot(shape_eye(:,1), shape_eye(:,2), '.g', 'MarkerSize',15); -% % Now do the eyes -% min_x = shape(43,1); -% max_x = shape(43,1); -% bbox_eye = shape(43,1) - + % Perform eye fitting now + shape_l_eye = zeros(numel(pdm_right_eye.M)/3, 2); + shape_l_eye(left_eye_inds_synth,:) = shape(left_eye_inds, :); + + [ a, R, T, ~, l_params] = fit_PDM_ortho_proj_to_2D(pdm_left_eye.M, pdm_left_eye.E, pdm_left_eye.V, shape_l_eye); + + bbox = [min(shape_l_eye(:,1)), min(shape_l_eye(:,2)), max(shape_l_eye(:,1)), max(shape_l_eye(:,2))]; + + g_param = [a; Rot2Euler(R)'; T]; + + [shape_l_eye] = Fitting_from_bb(image, [], bbox, pdm_left_eye, patches_left_eye, clmParams_eye, 'gparam', g_param, 'lparam', l_params); + + plot(shape_l_eye(9:20,1), shape_l_eye(9:20,2), '.g', 'MarkerSize',15); + plot(shape_l_eye(1:8,1), shape_l_eye(1:8,2), '.b', 'MarkerSize',15); + + plot(shape_r_eye(9:20,1), shape_r_eye(9:20,2), '.g', 'MarkerSize',15); + plot(shape_r_eye(1:8,1), shape_r_eye(1:8,2), '.b', 'MarkerSize',15); end hold off; diff --git a/matlab_version/demo/sample_eye_imgs/image_0037.png b/matlab_version/demo/sample_eye_imgs/image_0037.png new file mode 100644 index 00000000..34721de1 Binary files /dev/null and b/matlab_version/demo/sample_eye_imgs/image_0037.png differ diff --git a/matlab_version/demo/sample_eye_imgs/image_0038.png b/matlab_version/demo/sample_eye_imgs/image_0038.png new file mode 100644 index 00000000..af58c186 Binary files /dev/null and b/matlab_version/demo/sample_eye_imgs/image_0038.png differ diff --git a/matlab_version/demo/sample_eye_imgs/image_0039.png b/matlab_version/demo/sample_eye_imgs/image_0039.png new file mode 100644 index 00000000..a665a2d7 Binary files /dev/null and b/matlab_version/demo/sample_eye_imgs/image_0039.png differ diff --git a/matlab_version/demo/sample_eye_imgs/image_0093.png b/matlab_version/demo/sample_eye_imgs/image_0093.png new file mode 100644 index 00000000..defd5e9f Binary files /dev/null and b/matlab_version/demo/sample_eye_imgs/image_0093.png differ diff --git a/matlab_version/experiments_in_the_wild/Script_PDM_eyes.m b/matlab_version/experiments_in_the_wild/Script_PDM_eyes.m deleted file mode 100644 index e83a29d6..00000000 --- a/matlab_version/experiments_in_the_wild/Script_PDM_eyes.m +++ /dev/null @@ -1,80 +0,0 @@ -function Script_PDM_eyes() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% Replace this with the location of in 300 faces in the wild data -if(exist([getenv('USERPROFILE') '/Dropbox/AAM/test data/'], 'file')) - root_test_data = [getenv('USERPROFILE') '/Dropbox/AAM/test data/']; -else - root_test_data = 'F:/Dropbox/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs(root_test_data); - -%% Fitting the model to the provided image - -% the default PDM to use -pdmLoc = ['../models/pdm/pdm_68_aligned_wild_eyes.mat']; - -load(pdmLoc); - -pdm = struct; -pdm.M = double(M); -pdm.E = double(E); -pdm.V = double(V); - -num_points = numel(M)/3; - -errors = zeros(numel(images),1); -shapes_all = zeros(size(labels,2),size(labels,3), size(labels,1)); -labels_all = zeros(size(labels,2),size(labels,3), size(labels,1)); -errors_normed = zeros(numel(images),1); - -errors_left_eye = zeros(numel(images),1); -errors_right_eye = zeros(numel(images),1); - -tic -for i=1:numel(images) - - image = imread(images(i).img); - image_orig = image; - - if(size(image,3) == 3) - image = rgb2gray(image); - end - - labels_curr = squeeze(labels(i,:,:)); - - [ a, R, T, ~, l_params, err, shapeOrtho] = fit_PDM_ortho_proj_to_2D(pdm.M, pdm.E, pdm.V, labels_curr); - - shape = shapeOrtho; - shapes_all(:,:,i) = shapeOrtho; - labels_all(:,:,i) = labels_curr; - - if(mod(i, 200)==0) - fprintf('%d done\n', i ); - end - - valid_points = sum(squeeze(labels(i,:,:)),2) > 0; - valid_points(1:17) = 0; - - actualShape = squeeze(labels(i,:,:)); - errors(i) = sqrt(mean(sum((actualShape(valid_points,:) - shape(valid_points,:)).^2,2))); - width = ((max(actualShape(valid_points,1)) - min(actualShape(valid_points,1)))+(max(actualShape(valid_points,2)) - min(actualShape(valid_points,2))))/2; - errors_normed(i) = errors(i)/width; - - errors_left_eye(i) = compute_error_point_to_line_left_eye(actualShape, shapeOrtho, [0]); - errors_right_eye(i) = compute_error_point_to_line_right_eye(actualShape, shapeOrtho, [0]); - - if(errors_normed(i) > 0.035 || errors_left_eye(i) > 0.035 || errors_right_eye(i) > 0.035) - imshow(image);hold on; plot(shape(:,1), shape(:,2), '.g'); hold off; - end -end - -save('Errors_PDM_eyes.mat', 'errors_normed', 'errors_left_eye', 'errors_right_eye'); - -end diff --git a/matlab_version/experiments_in_the_wild/Script_PDM_general.m b/matlab_version/experiments_in_the_wild/Script_PDM_general.m deleted file mode 100644 index fb52e2ed..00000000 --- a/matlab_version/experiments_in_the_wild/Script_PDM_general.m +++ /dev/null @@ -1,80 +0,0 @@ -function Script_PDM_general() - -addpath('../PDM_helpers/'); -addpath('../fitting/normxcorr2_mex_ALL'); -addpath('../fitting/'); -addpath('../CCNF/'); -addpath('../models/'); - -% Replace this with the location of in 300 faces in the wild data -if(exist([getenv('USERPROFILE') '/Dropbox/AAM/test data/'], 'file')) - root_test_data = [getenv('USERPROFILE') '/Dropbox/AAM/test data/']; -else - root_test_data = 'F:/Dropbox/Dropbox/AAM/test data/'; -end - -[images, detections, labels] = Collect_wild_imgs(root_test_data); - -%% Fitting the model to the provided image - -% the default PDM to use -pdmLoc = ['../models/pdm/pdm_68_aligned_wild.mat']; - -load(pdmLoc); - -pdm = struct; -pdm.M = double(M); -pdm.E = double(E); -pdm.V = double(V); - -num_points = numel(M)/3; - -errors = zeros(numel(images),1); -shapes_all = zeros(size(labels,2),size(labels,3), size(labels,1)); -labels_all = zeros(size(labels,2),size(labels,3), size(labels,1)); -errors_normed = zeros(numel(images),1); - -errors_left_eye = zeros(numel(images),1); -errors_right_eye = zeros(numel(images),1); - -tic -for i=1:numel(images) - - image = imread(images(i).img); - image_orig = image; - - if(size(image,3) == 3) - image = rgb2gray(image); - end - - labels_curr = squeeze(labels(i,:,:)); - - [ a, R, T, ~, l_params, err, shapeOrtho] = fit_PDM_ortho_proj_to_2D(pdm.M, pdm.E, pdm.V, labels_curr); - - shape = shapeOrtho; - shapes_all(:,:,i) = shapeOrtho; - labels_all(:,:,i) = labels_curr; - - if(mod(i, 200)==0) - fprintf('%d done\n', i ); - end - - valid_points = sum(squeeze(labels(i,:,:)),2) > 0; - valid_points(1:17) = 0; - - actualShape = squeeze(labels(i,:,:)); - errors(i) = sqrt(mean(sum((actualShape(valid_points,:) - shape(valid_points,:)).^2,2))); - width = ((max(actualShape(valid_points,1)) - min(actualShape(valid_points,1)))+(max(actualShape(valid_points,2)) - min(actualShape(valid_points,2))))/2; - errors_normed(i) = errors(i)/width; - - errors_left_eye(i) = compute_error_point_to_line_left_eye(actualShape, shapeOrtho, [0]); - errors_right_eye(i) = compute_error_point_to_line_right_eye(actualShape, shapeOrtho, [0]); - - if(errors_normed(i) > 0.035 || errors_left_eye(i) > 0.035 || errors_right_eye(i) > 0.035) - imshow(image);hold on; plot(shape(:,1), shape(:,2), '.g'); hold off; - end -end - -save('Errors_PDM_basic.mat', 'errors_normed', 'errors_left_eye', 'errors_right_eye'); - -end diff --git a/matlab_version/experiments_in_the_wild/compute_error_point_to_line_left_eye.m b/matlab_version/experiments_in_the_wild/compute_error_point_to_line_left_eye.m deleted file mode 100644 index 4b93b432..00000000 --- a/matlab_version/experiments_in_the_wild/compute_error_point_to_line_left_eye.m +++ /dev/null @@ -1,86 +0,0 @@ -function [ error_per_image ] = compute_error_point_to_line_left_eye( ground_truth_all, detected_points_all, occluded ) -%compute_error -% compute the average point-to-point Euclidean error normalized by the -% inter-ocular distance (measured as the Euclidean distance between the -% outer corners of the eyes) -% -% Inputs: -% grounth_truth_all, size: num_of_points x 2 x num_of_images -% detected_points_all, size: num_of_points x 2 x num_of_images -% Output: -% error_per_image, size: num_of_images x 1 - - - -right_eye_inds_from_68 = [37,38,39,40,41,42,37]; -right_eye_inds_from_28 = [9,11,13,15,17,19]; - -num_of_images = size(ground_truth_all,3); - -num_points_gt = size(ground_truth_all,1); - -num_points_det = size(detected_points_all,1); - -error_per_image = zeros(num_of_images,1); - -for i =1:num_of_images - - if(num_points_det == 6) - detected_points = detected_points_all(:,:,i); - elseif(num_points_det == 68 || num_points_det == 66) - detected_points = detected_points_all(right_eye_inds_from_68,:,i); - elseif(num_points_det == 28) - detected_points = detected_points_all(right_eye_inds_from_28,:,i); - elseif(num_points_det == 49) - - end - ground_truth_points = ground_truth_all(:,:,i); - - if(num_points_gt == 66 || num_points_gt == 68) - interocular_distance = norm(ground_truth_points(37,:)-ground_truth_points(46,:)); - ground_truth_points = ground_truth_points(right_eye_inds_from_68,:,:); - else - interocular_distance = norm(ground_truth_points(37-17,:)-ground_truth_points(46-17,:)); - ground_truth_points = ground_truth_points(right_eye_inds_from_68,:,:); - end - - sum=0; - for j=1:6 - - if(j== 1 || j == 6) - % eye corners should align perfectly - sum = sum + norm(detected_points(j,:)-ground_truth_points(j,:)); - else - % points between eye corners measured in distance to the two appropriate line - % segments - sum = sum + point_to_segments(detected_points(j,:), ground_truth_points(j-1:j+1,:)); - end - end - error_per_image(i) = sum/(6*interocular_distance); -end - -error_per_image = error_per_image(~occluded); - -end - -function seg_dist = point_to_segments(point, segments) - - seg_dists = zeros(size(segments, 1)-1,1); - - for i=1:size(segments, 1)-1 - - vec1 = point - segments(i,:); - vec2 = segments(i+1,:) - segments(i,:); - - d = (vec1 * vec2') / (norm(vec2)^2); - - if(d < 0) - seg_dists(i) = norm(vec1); - elseif(d > 1) - seg_dists(i) = norm(point - segments(i+1,:)); - else - seg_dists(i) = sqrt( norm(vec1)^2 - norm(d * vec2)^2); - end - end - seg_dist = min(seg_dists); -end \ No newline at end of file diff --git a/matlab_version/experiments_in_the_wild/compute_error_point_to_line_right_eye.m b/matlab_version/experiments_in_the_wild/compute_error_point_to_line_right_eye.m deleted file mode 100644 index b6dd94a0..00000000 --- a/matlab_version/experiments_in_the_wild/compute_error_point_to_line_right_eye.m +++ /dev/null @@ -1,86 +0,0 @@ -function [ error_per_image ] = compute_error_point_to_line_right_eye( ground_truth_all, detected_points_all, occluded ) -%compute_error -% compute the average point-to-point Euclidean error normalized by the -% inter-ocular distance (measured as the Euclidean distance between the -% outer corners of the eyes) -% -% Inputs: -% grounth_truth_all, size: num_of_points x 2 x num_of_images -% detected_points_all, size: num_of_points x 2 x num_of_images -% Output: -% error_per_image, size: num_of_images x 1 - - - -right_eye_inds_from_68 = [43,44,45,46,47,48,43]; -right_eye_inds_from_28 = [9,11,13,15,17,19]; - -num_of_images = size(ground_truth_all,3); - -num_points_gt = size(ground_truth_all,1); - -num_points_det = size(detected_points_all,1); - -error_per_image = zeros(num_of_images,1); - -for i =1:num_of_images - - if(num_points_det == 6) - detected_points = detected_points_all(:,:,i); - elseif(num_points_det == 68 || num_points_det == 66) - detected_points = detected_points_all(right_eye_inds_from_68,:,i); - elseif(num_points_det == 28) - detected_points = detected_points_all(right_eye_inds_from_28,:,i); - elseif(num_points_det == 49) - - end - ground_truth_points = ground_truth_all(:,:,i); - - if(num_points_gt == 66 || num_points_gt == 68) - interocular_distance = norm(ground_truth_points(37,:)-ground_truth_points(46,:)); - ground_truth_points = ground_truth_points(right_eye_inds_from_68,:,:); - else - interocular_distance = norm(ground_truth_points(37-17,:)-ground_truth_points(46-17,:)); - ground_truth_points = ground_truth_points(right_eye_inds_from_68,:,:); - end - - sum=0; - for j=1:6 - - if(j== 1 || j == 6) - % eye corners should align perfectly - sum = sum + norm(detected_points(j,:)-ground_truth_points(j,:)); - else - % points between eye corners measured in distance to the two appropriate line - % segments - sum = sum + point_to_segments(detected_points(j,:), ground_truth_points(j-1:j+1,:)); - end - end - error_per_image(i) = sum/(6*interocular_distance); -end - -error_per_image = error_per_image(~occluded); - -end - -function seg_dist = point_to_segments(point, segments) - - seg_dists = zeros(size(segments, 1)-1,1); - - for i=1:size(segments, 1)-1 - - vec1 = point - segments(i,:); - vec2 = segments(i+1,:) - segments(i,:); - - d = (vec1 * vec2') / (norm(vec2)^2); - - if(d < 0) - seg_dists(i) = norm(vec1); - elseif(d > 1) - seg_dists(i) = norm(point - segments(i+1,:)); - else - seg_dists(i) = sqrt( norm(vec1)^2 - norm(d * vec2)^2); - end - end - seg_dist = min(seg_dists); -end \ No newline at end of file diff --git a/matlab_version/experiments_in_the_wild/Script_CLNF_general_eyes.m b/matlab_version/experiments_in_the_wild/hierarch_checks/Script_CLNF_general_eyes.m similarity index 100% rename from matlab_version/experiments_in_the_wild/Script_CLNF_general_eyes.m rename to matlab_version/experiments_in_the_wild/hierarch_checks/Script_CLNF_general_eyes.m diff --git a/matlab_version/experiments_in_the_wild/hierarch_checks/Script_PDM_eyes.m b/matlab_version/experiments_in_the_wild/hierarch_checks/Script_PDM_eyes.m index 955524dd..e83a29d6 100644 --- a/matlab_version/experiments_in_the_wild/hierarch_checks/Script_PDM_eyes.m +++ b/matlab_version/experiments_in_the_wild/hierarch_checks/Script_PDM_eyes.m @@ -27,8 +27,12 @@ pdm.M = double(M); pdm.E = double(E); pdm.V = double(V); +num_points = numel(M)/3; + +errors = zeros(numel(images),1); shapes_all = zeros(size(labels,2),size(labels,3), size(labels,1)); labels_all = zeros(size(labels,2),size(labels,3), size(labels,1)); +errors_normed = zeros(numel(images),1); errors_left_eye = zeros(numel(images),1); errors_right_eye = zeros(numel(images),1); @@ -36,30 +40,41 @@ errors_right_eye = zeros(numel(images),1); tic for i=1:numel(images) + image = imread(images(i).img); + image_orig = image; + + if(size(image,3) == 3) + image = rgb2gray(image); + end + labels_curr = squeeze(labels(i,:,:)); - [ a, R, T, ~, l_params, err, shapeOrtho] = fit_PDM_ortho_proj_to_2D_no_reg(pdm.M, pdm.E, pdm.V, labels_curr); + [ a, R, T, ~, l_params, err, shapeOrtho] = fit_PDM_ortho_proj_to_2D(pdm.M, pdm.E, pdm.V, labels_curr); + shape = shapeOrtho; shapes_all(:,:,i) = shapeOrtho; labels_all(:,:,i) = labels_curr; - if(mod(i, 100)==0) + if(mod(i, 200)==0) fprintf('%d done\n', i ); end + valid_points = sum(squeeze(labels(i,:,:)),2) > 0; + valid_points(1:17) = 0; + actualShape = squeeze(labels(i,:,:)); + errors(i) = sqrt(mean(sum((actualShape(valid_points,:) - shape(valid_points,:)).^2,2))); + width = ((max(actualShape(valid_points,1)) - min(actualShape(valid_points,1)))+(max(actualShape(valid_points,2)) - min(actualShape(valid_points,2))))/2; + errors_normed(i) = errors(i)/width; errors_left_eye(i) = compute_error_point_to_line_left_eye(actualShape, shapeOrtho, [0]); errors_right_eye(i) = compute_error_point_to_line_right_eye(actualShape, shapeOrtho, [0]); - if(errors_left_eye(i) > 0.02 || errors_right_eye(i) > 0.02) - plot(shapeOrtho(:,1), -shapeOrtho(:,2), 'r.'); hold on; - axis equal; - plot(labels_curr(:,1), -labels_curr(:,2), 'g.'); hold off; + if(errors_normed(i) > 0.035 || errors_left_eye(i) > 0.035 || errors_right_eye(i) > 0.035) + imshow(image);hold on; plot(shape(:,1), shape(:,2), '.g'); hold off; end - end -save('Errors_PDM_eyes.mat', 'errors_left_eye', 'errors_right_eye'); +save('Errors_PDM_eyes.mat', 'errors_normed', 'errors_left_eye', 'errors_right_eye'); end diff --git a/matlab_version/experiments_in_the_wild/hierarch_checks/Script_PDM_general.m b/matlab_version/experiments_in_the_wild/hierarch_checks/Script_PDM_general.m index 119ffd27..fb52e2ed 100644 --- a/matlab_version/experiments_in_the_wild/hierarch_checks/Script_PDM_general.m +++ b/matlab_version/experiments_in_the_wild/hierarch_checks/Script_PDM_general.m @@ -1,4 +1,4 @@ -function Script_PDM_eyes() +function Script_PDM_general() addpath('../PDM_helpers/'); addpath('../fitting/normxcorr2_mex_ALL'); @@ -27,8 +27,12 @@ pdm.M = double(M); pdm.E = double(E); pdm.V = double(V); +num_points = numel(M)/3; + +errors = zeros(numel(images),1); shapes_all = zeros(size(labels,2),size(labels,3), size(labels,1)); labels_all = zeros(size(labels,2),size(labels,3), size(labels,1)); +errors_normed = zeros(numel(images),1); errors_left_eye = zeros(numel(images),1); errors_right_eye = zeros(numel(images),1); @@ -36,31 +40,41 @@ errors_right_eye = zeros(numel(images),1); tic for i=1:numel(images) + image = imread(images(i).img); + image_orig = image; + + if(size(image,3) == 3) + image = rgb2gray(image); + end + labels_curr = squeeze(labels(i,:,:)); - [ a, R, T, ~, l_params, err, shapeOrtho] = fit_PDM_ortho_proj_to_2D_no_reg(pdm.M, pdm.E, pdm.V, labels_curr); + [ a, R, T, ~, l_params, err, shapeOrtho] = fit_PDM_ortho_proj_to_2D(pdm.M, pdm.E, pdm.V, labels_curr); + shape = shapeOrtho; shapes_all(:,:,i) = shapeOrtho; labels_all(:,:,i) = labels_curr; - if(mod(i, 100)==0) + if(mod(i, 200)==0) fprintf('%d done\n', i ); end + valid_points = sum(squeeze(labels(i,:,:)),2) > 0; + valid_points(1:17) = 0; + actualShape = squeeze(labels(i,:,:)); + errors(i) = sqrt(mean(sum((actualShape(valid_points,:) - shape(valid_points,:)).^2,2))); + width = ((max(actualShape(valid_points,1)) - min(actualShape(valid_points,1)))+(max(actualShape(valid_points,2)) - min(actualShape(valid_points,2))))/2; + errors_normed(i) = errors(i)/width; errors_left_eye(i) = compute_error_point_to_line_left_eye(actualShape, shapeOrtho, [0]); errors_right_eye(i) = compute_error_point_to_line_right_eye(actualShape, shapeOrtho, [0]); - - if(errors_left_eye(i) > 0.02 || errors_right_eye(i) > 0.02) - plot(shapeOrtho(:,1), -shapeOrtho(:,2), 'r.'); hold on; - axis equal; - plot(labels_curr(:,1), -labels_curr(:,2), 'g.'); hold off; + if(errors_normed(i) > 0.035 || errors_left_eye(i) > 0.035 || errors_right_eye(i) > 0.035) + imshow(image);hold on; plot(shape(:,1), shape(:,2), '.g'); hold off; end - end -save('Errors_PDM_basic.mat', 'errors_left_eye', 'errors_right_eye'); +save('Errors_PDM_basic.mat', 'errors_normed', 'errors_left_eye', 'errors_right_eye'); end diff --git a/matlab_version/experiments_in_the_wild/compute_brow_error_to_line.m b/matlab_version/experiments_in_the_wild/hierarch_checks/compute_brow_error_to_line.m similarity index 100% rename from matlab_version/experiments_in_the_wild/compute_brow_error_to_line.m rename to matlab_version/experiments_in_the_wild/hierarch_checks/compute_brow_error_to_line.m diff --git a/matlab_version/experiments_in_the_wild/hierarch_checks/compute_error_point_to_line_left_eye.m b/matlab_version/experiments_in_the_wild/hierarch_checks/compute_error_point_to_line_left_eye.m index c2edd30e..4b93b432 100644 --- a/matlab_version/experiments_in_the_wild/hierarch_checks/compute_error_point_to_line_left_eye.m +++ b/matlab_version/experiments_in_the_wild/hierarch_checks/compute_error_point_to_line_left_eye.m @@ -59,9 +59,7 @@ for i =1:num_of_images error_per_image(i) = sum/(6*interocular_distance); end -if(nargin > 2) - error_per_image = error_per_image(~occluded); -end +error_per_image = error_per_image(~occluded); end diff --git a/matlab_version/experiments_in_the_wild/hierarch_checks/compute_error_point_to_line_right_eye.m b/matlab_version/experiments_in_the_wild/hierarch_checks/compute_error_point_to_line_right_eye.m index e03fb471..b6dd94a0 100644 --- a/matlab_version/experiments_in_the_wild/hierarch_checks/compute_error_point_to_line_right_eye.m +++ b/matlab_version/experiments_in_the_wild/hierarch_checks/compute_error_point_to_line_right_eye.m @@ -59,9 +59,7 @@ for i =1:num_of_images error_per_image(i) = sum/(6*interocular_distance); end -if(nargin > 2) - error_per_image = error_per_image(~occluded); -end +error_per_image = error_per_image(~occluded); end diff --git a/matlab_version/models/Load_CLM_params_eye_28.m b/matlab_version/models/Load_CLM_params_eye_28.m new file mode 100644 index 00000000..a5b8ea52 --- /dev/null +++ b/matlab_version/models/Load_CLM_params_eye_28.m @@ -0,0 +1,38 @@ +function [ clmParams, pdm_right, pdm_left ] = Load_CLM_params_eye_28() +%LOAD_CLM_PARAMS_WILD Summary of this function goes here +% Detailed explanation goes here + clmParams.window_size = [17,17; 15,15; 13,13;]; + clmParams.numPatchIters = size(clmParams.window_size,1); + + % the PDM created from in the wild data + pdmLoc = ['../models/hierarch_pdm/pdm_28_r_eye.mat']; + + load(pdmLoc); + + pdm_right = struct; + pdm_right.M = double(M); + pdm_right.E = double(E); + pdm_right.V = double(V); + + pdmLoc = ['../models/hierarch_pdm/pdm_28_l_eye.mat']; + + load(pdmLoc); + + pdm_left = struct; + pdm_left.M = double(M); + pdm_left.E = double(E); + pdm_left.V = double(V); + + % the default model parameters to use + clmParams.regFactor = 2.0; + clmParams.sigmaMeanShift = 1.5; + clmParams.tikhonov_factor = 0; + + clmParams.startScale = 1; + clmParams.num_RLMS_iter = 10; + clmParams.fTol = 0.01; + clmParams.useMultiScale = true; + clmParams.use_multi_modal = 0; + clmParams.tikhonov_factor = 0; +end + diff --git a/matlab_version/models/hierarch/ccnf_patches_0.75_synth_left_eye.mat b/matlab_version/models/hierarch/ccnf_patches_0.75_synth_left_eye.mat new file mode 100644 index 00000000..919a6a33 Binary files /dev/null and b/matlab_version/models/hierarch/ccnf_patches_0.75_synth_left_eye.mat differ diff --git a/matlab_version/models/hierarch/ccnf_patches_0.75_synth_right_eye.mat b/matlab_version/models/hierarch/ccnf_patches_0.75_synth_right_eye.mat new file mode 100644 index 00000000..60244e29 Binary files /dev/null and b/matlab_version/models/hierarch/ccnf_patches_0.75_synth_right_eye.mat differ diff --git a/matlab_version/models/hierarch/ccnf_patches_1.00_synth_left_eye.mat b/matlab_version/models/hierarch/ccnf_patches_1.00_synth_left_eye.mat new file mode 100644 index 00000000..9969757a Binary files /dev/null and b/matlab_version/models/hierarch/ccnf_patches_1.00_synth_left_eye.mat differ diff --git a/matlab_version/models/hierarch/ccnf_patches_1.00_synth_right_eye.mat b/matlab_version/models/hierarch/ccnf_patches_1.00_synth_right_eye.mat new file mode 100644 index 00000000..57c42dfe Binary files /dev/null and b/matlab_version/models/hierarch/ccnf_patches_1.00_synth_right_eye.mat differ diff --git a/matlab_version/models/hierarch/ccnf_patches_1.50_synth_left_eye.mat b/matlab_version/models/hierarch/ccnf_patches_1.50_synth_left_eye.mat new file mode 100644 index 00000000..21170afb Binary files /dev/null and b/matlab_version/models/hierarch/ccnf_patches_1.50_synth_left_eye.mat differ diff --git a/matlab_version/models/hierarch/ccnf_patches_1.50_synth_right_eye.mat b/matlab_version/models/hierarch/ccnf_patches_1.50_synth_right_eye.mat new file mode 100644 index 00000000..deec91bd Binary files /dev/null and b/matlab_version/models/hierarch/ccnf_patches_1.50_synth_right_eye.mat differ diff --git a/matlab_version/models/hierarch_pdm/pdm_28_l_eye.mat b/matlab_version/models/hierarch_pdm/pdm_28_l_eye.mat new file mode 100644 index 00000000..3c224d6b Binary files /dev/null and b/matlab_version/models/hierarch_pdm/pdm_28_l_eye.mat differ diff --git a/matlab_version/models/hierarch_pdm/pdm_28_r_eye.mat b/matlab_version/models/hierarch_pdm/pdm_28_r_eye.mat new file mode 100644 index 00000000..ea364f0a Binary files /dev/null and b/matlab_version/models/hierarch_pdm/pdm_28_r_eye.mat differ