From aa6af6f1f26e70d6d19d17e6a1d9de5986893cd8 Mon Sep 17 00:00:00 2001
From: Tadas Baltrusaitis <tadyla@gmail.com>
Date: Wed, 3 Oct 2018 19:53:32 +0100
Subject: [PATCH] Feature/code cleanup (#580)

- name of revision
- better scripts for model download (not only in Dropbox also OneDrive)
---
 .travis.yml                                | 12 +---
 README.md                                  |  2 +-
 download_models.ps1                        | 67 +++++++++++++++++++---
 download_models.sh                         | 34 ++++++++---
 exe/releases/package_windows_executables.m |  2 +-
 5 files changed, 88 insertions(+), 29 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index c6a9d22f0..e169a0213 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -74,16 +74,8 @@ before_install:
   
 script:
   - $CXX --version
-  - cd lib/local/LandmarkDetector/model/patch_experts
-  - wget https://www.dropbox.com/s/7na5qsjzz8yfoer/cen_patches_0.25_of.dat?dl=1
-  - wget https://www.dropbox.com/s/k7bj804cyiu474t/cen_patches_0.35_of.dat?dl=1
-  - wget https://www.dropbox.com/s/ixt4vkbmxgab1iu/cen_patches_0.50_of.dat?dl=1
-  - wget https://www.dropbox.com/s/2t5t1sdpshzfhpj/cen_patches_1.00_of.dat?dl=1
-  - mv cen_patches_0.25_of.dat?dl=1 cen_patches_0.25_of.dat
-  - mv cen_patches_0.35_of.dat?dl=1 cen_patches_0.35_of.dat
-  - mv cen_patches_0.50_of.dat?dl=1 cen_patches_0.50_of.dat
-  - mv cen_patches_1.00_of.dat?dl=1 cen_patches_1.00_of.dat
-  - cd ../../../../../
+  - chmod 777 ./download_models.sh
+  - ./download_models.sh
   - mkdir build
   - cd build
   - cmake -D CMAKE_BUILD_TYPE=RELEASE CMAKE_CXX_FLAGS="-std=c++11" -D CMAKE_EXE_LINKER_FLAGS="-std=c++11" .. 
diff --git a/README.md b/README.md
index 71c4f6460..3aac455a9 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# OpenFace 2.0.4: an open source facial behavior analysis toolkit
+# OpenFace 2.0.6: 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)
diff --git a/download_models.ps1 b/download_models.ps1
index c2e7a3640..f7463f280 100644
--- a/download_models.ps1
+++ b/download_models.ps1
@@ -1,12 +1,63 @@
-$source = "https://www.dropbox.com/s/7na5qsjzz8yfoer/cen_patches_0.25_of.dat?dl=1"
+# Download the models from the cloud (stored in Dropbox, OneDrive, and Google Drive
+
+# Start with 0.25 scale models
 $destination = "lib/local/LandmarkDetector/model/patch_experts/cen_patches_0.25_of.dat"
-Invoke-WebRequest $source -OutFile $destination
-$source = "https://www.dropbox.com/s/k7bj804cyiu474t/cen_patches_0.35_of.dat?dl=1"
+
+if(!([System.IO.File]::Exists($destination)))
+{
+	$source = "https://www.dropbox.com/s/7na5qsjzz8yfoer/cen_patches_0.25_of.dat?dl=1"
+	Invoke-WebRequest $source -OutFile $destination
+}
+
+if(!([System.IO.File]::Exists($destination)))
+{
+	$source = "https://onedrive.live.com/download?cid=2E2ADA578BFF6E6E&resid=2E2ADA578BFF6E6E%2153072&authkey=AKqoZtcN0PSIZH4"
+	Invoke-WebRequest $source -OutFile $destination
+}
+
+# 0.35 scale models
 $destination = "lib/local/LandmarkDetector/model/patch_experts/cen_patches_0.35_of.dat"
-Invoke-WebRequest $source -OutFile $destination
-$source = "https://www.dropbox.com/s/ixt4vkbmxgab1iu/cen_patches_0.50_of.dat?dl=1"
+
+if(!([System.IO.File]::Exists($destination)))
+{
+	$source = "https://www.dropbox.com/s/k7bj804cyiu474t/cen_patches_0.35_of.dat?dl=1"
+	Invoke-WebRequest $source -OutFile $destination
+}
+
+if(!([System.IO.File]::Exists($destination)))
+{
+	$source = "https://onedrive.live.com/download?cid=2E2ADA578BFF6E6E&resid=2E2ADA578BFF6E6E%2153079&authkey=ANpDR1n3ckL_0gs"
+	Invoke-WebRequest $source -OutFile $destination
+}
+
+
+# 0.5 scale models
 $destination = "lib/local/LandmarkDetector/model/patch_experts/cen_patches_0.50_of.dat"
-Invoke-WebRequest $source -OutFile $destination
-$source = "https://www.dropbox.com/s/2t5t1sdpshzfhpj/cen_patches_1.00_of.dat?dl=1"
+
+if(!([System.IO.File]::Exists($destination)))
+{
+	$source = "https://www.dropbox.com/s/ixt4vkbmxgab1iu/cen_patches_0.50_of.dat?dl=1"
+	Invoke-WebRequest $source -OutFile $destination
+}
+
+if(!([System.IO.File]::Exists($destination)))
+{
+	$source = "https://onedrive.live.com/download?cid=2E2ADA578BFF6E6E&resid=2E2ADA578BFF6E6E%2153074&authkey=AGi-e30AfRc_zvs"
+	Invoke-WebRequest $source -OutFile $destination
+}
+
+# 1.0 scale models
 $destination = "lib/local/LandmarkDetector/model/patch_experts/cen_patches_1.00_of.dat"
-Invoke-WebRequest $source -OutFile $destination
\ No newline at end of file
+
+if(!([System.IO.File]::Exists($destination)))
+{
+	$source = "https://www.dropbox.com/s/2t5t1sdpshzfhpj/cen_patches_1.00_of.dat?dl=1"
+	Invoke-WebRequest $source -OutFile $destination
+}
+
+if(!([System.IO.File]::Exists($destination)))
+{
+	$source = "https://onedrive.live.com/download?cid=2E2ADA578BFF6E6E&resid=2E2ADA578BFF6E6E%2153070&authkey=AD6KjtYipphwBPc"
+	Invoke-WebRequest $source -OutFile $destination
+}
+
diff --git a/download_models.sh b/download_models.sh
index e83586887..2f4edbefe 100644
--- a/download_models.sh
+++ b/download_models.sh
@@ -1,11 +1,27 @@
 cd lib/local/LandmarkDetector/model/patch_experts
-wget https://www.dropbox.com/s/7na5qsjzz8yfoer/cen_patches_0.25_of.dat?dl=1
-wget https://www.dropbox.com/s/k7bj804cyiu474t/cen_patches_0.35_of.dat?dl=1
-wget https://www.dropbox.com/s/ixt4vkbmxgab1iu/cen_patches_0.50_of.dat?dl=1
-wget https://www.dropbox.com/s/2t5t1sdpshzfhpj/cen_patches_1.00_of.dat?dl=1
-mv cen_patches_0.25_of.dat?dl=1 cen_patches_0.25_of.dat
-mv cen_patches_0.35_of.dat?dl=1 cen_patches_0.35_of.dat
-mv cen_patches_0.50_of.dat?dl=1 cen_patches_0.50_of.dat
-mv cen_patches_1.00_of.dat?dl=1 cen_patches_1.00_of.dat
-ls
+
+wget https://www.dropbox.com/s/7na5qsjzz8yfoer/cen_patches_0.25_of.dat
+if [ $? -ne 0 ]
+then
+  wget https://onedrive.live.com/download?cid=2E2ADA578BFF6E6E&resid=2E2ADA578BFF6E6E%2153072&authkey=AKqoZtcN0PSIZH4
+fi
+
+wget https://www.dropbox.com/s/k7bj804cyiu474t/cen_patches_0.35_of.dat
+if [ $? -ne 0 ]
+then
+  wget https://onedrive.live.com/download?cid=2E2ADA578BFF6E6E&resid=2E2ADA578BFF6E6E%2153079&authkey=ANpDR1n3ckL_0gs
+fi
+
+wget https://www.dropbox.com/s/ixt4vkbmxgab1iu/cen_patches_0.50_of.dat
+if [ $? -ne 0 ]
+then
+  wget https://onedrive.live.com/download?cid=2E2ADA578BFF6E6E&resid=2E2ADA578BFF6E6E%2153074&authkey=AGi-e30AfRc_zvs
+fi
+
+wget https://www.dropbox.com/s/2t5t1sdpshzfhpj/cen_patches_1.00_of.dat
+if [ $? -ne 0 ]
+then
+  wget https://onedrive.live.com/download?cid=2E2ADA578BFF6E6E&resid=2E2ADA578BFF6E6E%2153070&authkey=AD6KjtYipphwBPc
+fi
+
 cd ../../../../../
diff --git a/exe/releases/package_windows_executables.m b/exe/releases/package_windows_executables.m
index 35c60fd79..6e74cb43e 100644
--- a/exe/releases/package_windows_executables.m
+++ b/exe/releases/package_windows_executables.m
@@ -1,5 +1,5 @@
 clear;
-version = '2.0.4';
+version = '2.0.6';
 
 out_x86 = sprintf('OpenFace_%s_win_x86', version);
 out_x64 = sprintf('OpenFace_%s_win_x64', version);