Skip to content

Commit

Permalink
Remove dlib (deepfakes#725)
Browse files Browse the repository at this point in the history
* Sort to vgg_face. Remove Face Recognition requirements

* Remove dlib components from setup.py

* Remove dlib from Windows Installer script

* Remove dlib and cmake from requirements.txt

* Update INSTALL.md to remove all dlib requirements

* Remove dlib and cmake from dockerfiles

* Windows installer. Output cli to details Window. Setup.py bugfix

* Skip FaceFilter if invalid paths passed in
  • Loading branch information
torzdf authored May 12, 2019
1 parent 1483187 commit 12d83c6
Show file tree
Hide file tree
Showing 9 changed files with 214 additions and 390 deletions.
87 changes: 36 additions & 51 deletions .install/windows/install.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ InstallDir $PROFILE\faceswap
!define flagsRepo "--depth 1 --no-single-branch ${wwwRepo}"
!define flagsEnv "-y python=3.6"

# Dlib Wheel prefix
!define prefixDlib "dlib-19.16.99-cp36-cp36m-win_amd64"
!define dlibFinalName "dlib-19.16.99-cp36-cp36m-win_amd64.whl" # Dlib Wheel MUST have this name before installing
!define cudaDlib "_cuda90"
!define avxDlib "_avx"
!define sseDlib "_sse4"
!define noneDlib "_none"


# Folders
Var ProgramData
Var dirTemp
Expand All @@ -48,7 +39,6 @@ Var dirConda
# Items to Install
Var InstallGit
Var InstallConda
Var dlibWhl

# Misc
Var gitInf
Expand Down Expand Up @@ -78,6 +68,7 @@ Var envName
Page custom pgPrereqCreate pgPrereqLeave

# Install Faceswap Page
!define MUI_PAGE_CUSTOMFUNCTION_SHOW InstFilesShow
!define MUI_PAGE_HEADER_SUBTEXT "Installing Faceswap..."
!insertmacro MUI_PAGE_INSTFILES

Expand All @@ -99,11 +90,16 @@ Function .onInit
StrCpy $gitInf "$dirTemp\git_install.inf"
StrCpy $envName "faceswap"
SetOutPath "$dirTemp"
File *.whl
File git_install.inf
Call CheckPrerequisites
FunctionEnd

# Enable the cancel button during installation
Function InstFilesShow
GetDlgItem $0 $HWNDPARENT 2
EnableWindow $0 1
FunctionEnd

Function VerifyInstallDir
# Check install folder does not already exist
IfFileExists $INSTDIR 0 +3
Expand Down Expand Up @@ -278,7 +274,6 @@ Section Install
Call InstallPrerequisites
Call CloneRepo
Call SetEnvironment
Call InstallDlib
Call SetupFaceSwap
Call DesktopShortcut
SectionEnd
Expand All @@ -292,7 +287,10 @@ Function InstallPrerequisites
${If} $0 == "OK"
DetailPrint "Installing Git..."
SetDetailsPrint listonly
ExecWait "$\"$dirTemp\git_installer.exe$\" ${flagsGit} /LOADINF=$\"$gitInf$\"" $0
ExecDos::exec /NOUNLOAD /ASYNC /DETAILED "$\"$dirTemp\git_installer.exe$\" ${flagsGit} /LOADINF=$\"$gitInf$\""
pop $0
ExecDos::wait $0
pop $0
SetDetailsPrint both
${If} $0 != 0
DetailPrint "Error Installing Git"
Expand All @@ -312,7 +310,10 @@ Function InstallPrerequisites
${If} $0 == "OK"
DetailPrint "Installing Miniconda3. This will take a few minutes..."
SetDetailsPrint listonly
ExecWait "$\"$dirTemp\Miniconda3.exe$\" ${flagsConda}" $0
ExecDos::exec /NOUNLOAD /ASYNC /DETAILED "$\"$dirTemp\Miniconda3.exe$\" ${flagsConda}"
pop $0
ExecDos::wait $0
pop $0
StrCpy $dirConda "$dirMiniconda"
SetDetailsPrint both
${If} $0 != 0
Expand Down Expand Up @@ -340,7 +341,10 @@ Function CloneRepo
${Else}
StrCpy $9 "git"
${EndIf}
ExecWait "$9 clone ${flagsRepo} $\"$INSTDIR$\"" $0
ExecDos::exec /NOUNLOAD /ASYNC /DETAILED "$9 clone ${flagsRepo} $\"$INSTDIR$\""
pop $0
ExecDos::wait $0
pop $0
SetDetailsPrint both
${If} $0 != 0
DetailPrint "Error Downloading Faceswap"
Expand All @@ -352,14 +356,20 @@ Function SetEnvironment
# Updating Conda breaks setup.py. Commented out in case this issue gets resolved in future
# DetailPrint "Initializing Conda..."
# SetDetailsPrint listonly
# ExecWait "$dirConda\scripts\activate.bat && conda update -y -n base -c defaults conda && conda deactivate" $0
# ExecDos::exec /NOUNLOAD /ASYNC /DETAILED "$dirConda\scripts\activate.bat && conda update -y -n base -c defaults conda && conda deactivate"
# pop $0
# ExecDos::wait $0
# pop $0
# SetDetailsPrint both
DetailPrint "Creating Conda Virtual Environment..."

IfFileExists "$dirConda\envs\$envName" DeleteEnv CreateEnv
DeleteEnv:
SetDetailsPrint listonly
ExecWait "$\"$dirConda\scripts\activate.bat$\" && conda env remove -y -n $\"$envName$\" && conda deactivate" $0
ExecDos::exec /NOUNLOAD /ASYNC /DETAILED "$\"$dirConda\scripts\activate.bat$\" && conda env remove -y -n $\"$envName$\" && conda deactivate"
pop $0
ExecDos::wait $0
pop $0
SetDetailsPrint both
${If} $0 != 0
DetailPrint "Error deleting Conda Virtual Environment"
Expand All @@ -368,54 +378,29 @@ Function SetEnvironment

CreateEnv:
SetDetailsPrint listonly
ExecWait "$\"$dirConda\scripts\activate.bat$\" && conda create ${flagsEnv} -n $\"$envName$\" && conda deactivate" $0
ExecDos::exec /NOUNLOAD /ASYNC /DETAILED "$\"$dirConda\scripts\activate.bat$\" && conda create ${flagsEnv} -n $\"$envName$\" && conda deactivate"
pop $0
ExecDos::wait $0
pop $0
SetDetailsPrint both
${If} $0 != 0
DetailPrint "Error Creating Conda Virtual Environment"
Call Abort
${EndIf}
FunctionEnd

Function InstallDlib
DetailPrint "Installing Dlib..."
SetDetailsPrint listonly

StrCpy $dlibWhl ${prefixDlib}

${If} $noNvidia != 1
StrCpy $dlibWhl "$dlibWhl${cudaDlib}"
${EndIf}

${If} $hasAVX == 1
StrCpy $dlibWhl "$dlibWhl${avxDlib}"
${ElseIf} $hasSSE4 == 1
StrCpy $dlibWhl "$dlibWhl${sseDlib}"
${Else}
StrCpy $dlibWhl "$dlibWhl${noneDlib}"
${EndIf}

StrCpy $dlibWhl "$dlibWhl.whl"
DetailPrint "Renaming $dlibWhl to ${dlibFinalName}"
Rename "$dirTemp\$dlibWhl" "$dirTemp\${dlibFinalName}"

ExecWait "$\"$dirConda\scripts\activate.bat$\" && conda activate $\"$envName$\" && pip install $\"$dirTemp\${dlibFinalName}$\" && conda deactivate" $0
SetDetailsPrint both
${If} $0 != 0
DetailPrint "Error Installing Dlib"
Call Abort
${EndIf}

FunctionEnd

Function SetupFaceSwap
DetailPrint "Setting up FaceSwap Environment"
DetailPrint "Setting up FaceSwap Environment... This may take a while"
StrCpy $0 "${flagsSetup}"
${If} $noNvidia != 1
StrCpy $0 "$0 --gpu"
${EndIf}

SetDetailsPrint listonly
ExecWait "$\"$dirConda\scripts\activate.bat$\" && conda activate $\"$envName$\" && python $\"$INSTDIR\setup.py$\" $0 && conda deactivate" $0
ExecDos::exec /NOUNLOAD /ASYNC /DETAILED "$\"$dirConda\scripts\activate.bat$\" && conda activate $\"$envName$\" && python $\"$INSTDIR\setup.py$\" $0 && conda deactivate"
pop $0
ExecDos::wait $0
pop $0
SetDetailsPrint both
${If} $0 != 0
DetailPrint "Error Setting up Faceswap"
Expand Down
2 changes: 0 additions & 2 deletions Dockerfile.cpu
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ RUN apt-get update -qq -y \

COPY requirements.txt /opt/
RUN pip3 install --upgrade pip
RUN pip3 install cmake
RUN pip3 install dlib
RUN pip3 --no-cache-dir install -r /opt/requirements.txt && rm /opt/requirements.txt

WORKDIR "/srv"
Expand Down
2 changes: 0 additions & 2 deletions Dockerfile.gpu
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ RUN apt-get update -qq -y \

COPY requirements.txt /opt/
RUN pip3 install --upgrade pip
RUN pip3 install cmake
RUN pip3 install dlib
RUN pip3 --no-cache-dir install -r /opt/requirements.txt && rm /opt/requirements.txt
RUN pip3 install jupyter matplotlib
RUN pip3 install jupyter_http_over_ws
Expand Down
Loading

0 comments on commit 12d83c6

Please sign in to comment.