Compare commits

...

3 Commits

Author SHA1 Message Date
Alex Berezhkovsky 4e2eec9382
Merge 72287ce89e into e36c746c81 2024-09-10 19:04:10 +05:30
Kenneth Estanislao e36c746c81 Update setup_deep_live_cam.bat 2024-09-08 20:31:36 +08:00
Alex Berezhkovsky 72287ce89e
add elif for pygrabber import 2024-08-18 18:33:46 +05:00
2 changed files with 83 additions and 79 deletions

View File

@ -6,7 +6,6 @@ from typing import Callable, Tuple, List, Any
from types import ModuleType from types import ModuleType
import cv2 import cv2
from PIL import Image, ImageOps from PIL import Image, ImageOps
from pygrabber.dshow_graph import FilterGraph
import pyvirtualcam import pyvirtualcam
# Import OS-specific modules only when necessary # Import OS-specific modules only when necessary
@ -14,6 +13,8 @@ if platform.system() == 'Darwin': # macOS
import objc import objc
from Foundation import NSObject from Foundation import NSObject
import AVFoundation import AVFoundation
elif platform.system() == 'Windows' or platform.system() == 'Linux':
from pygrabber.dshow_graph import FilterGraph
import modules.globals import modules.globals
import modules.metadata import modules.metadata

View File

@ -3,73 +3,35 @@ setlocal EnableDelayedExpansion
:: 1. Setup your platform :: 1. Setup your platform
echo Setting up your platform... echo Setting up your platform...
call :check_installation python "Python 3.10 or later"
:: Python call :check_installation pip "Pip"
where python >nul 2>&1 call :install_if_missing git "Git" "winget install --id Git.Git -e --source winget"
if %ERRORLEVEL% neq 0 ( call :install_if_missing ffmpeg "FFMPEG" "winget install --id Gyan.FFmpeg -e --source winget"
echo Python is not installed. Please install Python 3.10 or later.
pause
exit /b
)
:: Pip
where pip >nul 2>&1
if %ERRORLEVEL% neq 0 (
echo Pip is not installed. Please install Pip.
pause
exit /b
)
:: Git
where git >nul 2>&1
if %ERRORLEVEL% neq 0 (
echo Git is not installed. Installing Git...
winget install --id Git.Git -e --source winget
)
:: FFMPEG
where ffmpeg >nul 2>&1
if %ERRORLEVEL% neq 0 (
echo FFMPEG is not installed. Installing FFMPEG...
winget install --id Gyan.FFmpeg -e --source winget
)
:: Visual Studio 2022 Runtimes :: Visual Studio 2022 Runtimes
echo Installing Visual Studio 2022 Runtimes... echo Installing Visual Studio 2022 Runtimes...
winget install --id Microsoft.VC++2015-2022Redist-x64 -e --source winget winget install --id Microsoft.VC++2015-2022Redist-x64 -e --source winget
:: 2. Clone Repository :: 2. Clone Repository
if exist Deep-Live-Cam ( call :clone_repository "https://github.com/iVideoGameBoss/iRoopDeepFaceCam.git" "iRoopDeepFaceCam"
echo Deep-Live-Cam directory already exists.
set /p overwrite="Do you want to overwrite? (Y/N): "
if /i "%overwrite%"=="Y" (
rmdir /s /q Deep-Live-Cam
git clone https://github.com/hacksider/Deep-Live-Cam.git
) else (
echo Skipping clone, using existing directory.
)
) else (
git clone https://github.com/hacksider/Deep-Live-Cam.git
)
cd Deep-Live-Cam
:: 3. Download Models :: 3. Download Models
echo Downloading models... echo Downloading models...
mkdir models if not exist models mkdir models
curl -L -o models/GFPGANv1.4.pth https://path.to.model/GFPGANv1.4.pth curl -L -o models\GFPGANv1.4.pth https://huggingface.co/ivideogameboss/iroopdeepfacecam/resolve/main/GFPGANv1.4.pth
curl -L -o models/inswapper_128_fp16.onnx https://path.to.model/inswapper_128_fp16.onnx curl -L -o models\inswapper_128_fp16.onnx https://huggingface.co/ivideogameboss/iroopdeepfacecam/resolve/main/inswapper_128_fp16.onnx
:: 4. Install dependencies :: 4. Install dependencies
echo Creating a virtual environment... echo Creating a virtual environment...
python -m venv venv python -m venv venv
call venv\Scripts\activate call venv\Scripts\activate.bat
echo Installing required Python packages... echo Installing required Python packages...
pip install --upgrade pip pip install --upgrade pip
pip install -r requirements.txt pip install -r requirements.txt
echo Setup complete. You can now run the application. echo Setup complete. You can now run the application.
:menu
:: GPU Acceleration Options :: GPU Acceleration Options
echo. echo.
echo Choose the GPU Acceleration Option if applicable: echo Choose the GPU Acceleration Option if applicable:
@ -81,42 +43,83 @@ echo 5. OpenVINO (Intel)
echo 6. None echo 6. None
set /p choice="Enter your choice (1-6): " set /p choice="Enter your choice (1-6): "
if "%choice%"=="1" ( set "exec_provider="
echo Installing CUDA dependencies... call :set_execution_provider %choice%
pip uninstall -y onnxruntime onnxruntime-gpu
pip install onnxruntime-gpu==1.16.3 :end_choice
set exec_provider="cuda" echo.
) else if "%choice%"=="2" ( echo GPU Acceleration setup complete.
echo Installing CoreML (Apple Silicon) dependencies... echo Selected provider: !exec_provider!
pip uninstall -y onnxruntime onnxruntime-silicon echo.
pip install onnxruntime-silicon==1.13.1
set exec_provider="coreml"
) else if "%choice%"=="3" (
echo Installing CoreML (Apple Legacy) dependencies...
pip uninstall -y onnxruntime onnxruntime-coreml
pip install onnxruntime-coreml==1.13.1
set exec_provider="coreml"
) else if "%choice%"=="4" (
echo Installing DirectML dependencies...
pip uninstall -y onnxruntime onnxruntime-directml
pip install onnxruntime-directml==1.15.1
set exec_provider="directml"
) else if "%choice%"=="5" (
echo Installing OpenVINO dependencies...
pip uninstall -y onnxruntime onnxruntime-openvino
pip install onnxruntime-openvino==1.15.0
set exec_provider="openvino"
) else (
echo Skipping GPU acceleration setup.
)
:: Run the application :: Run the application
if defined exec_provider ( if defined exec_provider (
echo Running the application with %exec_provider% execution provider... echo Running the application with !exec_provider! execution provider...
python run.py --execution-provider %exec_provider% python run.py --execution-provider !exec_provider!
) else ( ) else (
echo Running the application... echo Running the application...
python run.py python run.py
) )
:: Deactivate the virtual environment
call venv\Scripts\deactivate.bat
echo.
echo Script execution completed.
pause pause
exit /b
:check_installation
where %1 >nul 2>&1
if %ERRORLEVEL% neq 0 (
echo %2 is not installed. Please install %2.
pause
exit /b
)
:install_if_missing
where %1 >nul 2>&1
if %ERRORLEVEL% neq 0 (
echo %2 is not installed. Installing %2...
%3
)
:clone_repository
if exist %2 (
echo %2 directory already exists.
set /p overwrite="Do you want to overwrite? (Y/N): "
if /i "%overwrite%"=="Y" (
rmdir /s /q %2
git clone %1
) else (
echo Skipping clone, using existing directory.
)
) else (
git clone %1
)
:set_execution_provider
if "%1"=="1" (
call :install_onnxruntime "onnxruntime-gpu" "1.16.3" "cuda"
) else if "%1"=="2" (
call :install_onnxruntime "onnxruntime-silicon" "1.13.1" "coreml"
) else if "%1"=="3" (
call :install_onnxruntime "onnxruntime-coreml" "1.13.1" "coreml"
) else if "%1"=="4" (
call :install_onnxruntime "onnxruntime-directml" "1.15.1" "directml"
) else if "%1"=="5" (
call :install_onnxruntime "onnxruntime-openvino" "1.15.0" "openvino"
) else if "%1"=="6" (
echo Skipping GPU acceleration setup.
set "exec_provider=none"
) else (
echo Invalid choice. Please try again.
goto menu
)
:install_onnxruntime
echo Installing %1 dependencies...
pip uninstall -y onnxruntime %1
pip install %1==%2
set "exec_provider=%3"
goto end_choice