File size: 3,296 Bytes
5a26b95 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | @echo off
rem FaceAttend setup for Windows 10/11 64-bit (CPU). Uses the offline packages in ..\packages\windows when present,
rem otherwise downloads from the internet.
rem Python must be 3.9.9 exactly: a 3.9.9 that is already installed is used, otherwise 3.9.9 is installed into its own
rem folder (Python399). Another Python 3.9.x is never used and never replaced.
setlocal
cd /d "%~dp0"
title FaceAttend setup
set "PKG=%~dp0..\packages\windows"
set "MODELS_SRC=%~dp0..\models"
set "PYDIR=%LOCALAPPDATA%\Programs\Python\Python399"
set "IS399=import sys, platform; sys.exit(0 if platform.python_version() == '3.9.9' and sys.maxsize == 2**63 - 1 else 1)"
echo [1/4] Python 3.9.9 (64-bit)
set "PY="
py -3.9 -c "%IS399%" >nul 2>&1 && set "PY=py -3.9"
for %%D in ("%PYDIR%" "%LOCALAPPDATA%\Programs\Python\Python39" "%ProgramFiles%\Python39") do if not defined PY "%%~D\python.exe" -c "%IS399%" >nul 2>&1 && set PY="%%~D\python.exe"
if defined PY goto have_python
reg query "HKCU\Software\Python\PythonCore\3.9\InstallPath" >nul 2>&1 && goto other_python
if not exist "%PKG%\python-3.9.9-amd64.exe" (
echo Python 3.9.9 64-bit not found. Put the "Windows installer 64-bit" from
echo https://www.python.org/downloads/release/python-399/ into ..\packages\windows and run setup.bat again.
goto fail
)
echo Installing Python 3.9.9 into "%PYDIR%" ...
"%PKG%\python-3.9.9-amd64.exe" /passive InstallAllUsers=0 TargetDir="%PYDIR%" PrependPath=0 Include_test=0 Include_launcher=0
set PY="%PYDIR%\python.exe"
%PY% -c "%IS399%" >nul 2>&1 || goto no_python
:have_python
echo using %PY%
echo [2/4] Microsoft Visual C++ runtime (needed by PyTorch and ONNX Runtime)
if exist "%SystemRoot%\System32\vcruntime140_1.dll" (
echo already installed
) else if exist "%PKG%\vc_redist.x64.exe" (
"%PKG%\vc_redist.x64.exe" /install /passive /norestart
) else (
echo Missing - install it from https://aka.ms/vs/17/release/vc_redist.x64.exe
)
echo [3/4] Virtual environment and packages
rem a .venv made by another Python version is rebuilt
".venv\Scripts\python.exe" -c "%IS399%" >nul 2>&1 || %PY% -m venv --clear .venv
".venv\Scripts\python.exe" -c "%IS399%" >nul 2>&1 || goto fail
if exist "%PKG%\*.whl" (
".venv\Scripts\python.exe" -m pip install --no-index --find-links "%PKG%" -r requirements.txt
) else (
".venv\Scripts\python.exe" -m pip install -r requirements.txt
)
if errorlevel 1 goto fail
echo [4/4] Face recognition models
if not exist models mkdir models
if exist "%MODELS_SRC%\*.onnx" xcopy /y /d /q "%MODELS_SRC%\*.onnx" models\ >nul
if exist "%MODELS_SRC%\*.pt" xcopy /y /d /q "%MODELS_SRC%\*.pt" models\ >nul
echo Models missing here are downloaded by the app when you select them.
echo.
echo Setup complete. Start FaceAttend with run.bat
pause
exit /b 0
:other_python
echo Another Python 3.9.x is installed for this user. Windows keeps one Python 3.9 per user, so the 3.9.9
echo installer would replace it - nothing was changed. If you agree, uninstall that version in
echo Settings - Apps and run setup.bat again.
goto fail
:no_python
echo Python 3.9.9 was not installed - see the message of its installer.
:fail
echo.
echo Setup failed - see the messages above.
pause
exit /b 1
|