feat: Add Windows setup and run scripts, update README

This commit introduces automation scripts for Windows users and updates the README.md accordingly.

New/Modified Windows Scripts:
- setup_windows.bat: New script to automate Python checks, ffmpeg warning, virtual environment (.venv) creation, pip upgrade, and dependency installation.
- run_windows.bat: New script to run the application with CPU execution provider by default, activating .venv.
- run-cuda.bat: Updated to use .venv and pass arguments.
- run-directml.bat: Updated to use .venv and pass arguments.

README.md Changes:
- Updated the "For Windows:" section under "Installation (Manual)" to detail the new automated setup using setup_windows.bat and the revised run scripts.
- Recommended Python 3.10 for Windows for best compatibility.
- Provided updated manual setup notes for Windows, including a PowerShell command for ffmpeg installation and using .venv for consistency.
- Ensured the general Python recommendation in the manual setup prerequisites also mentions Python 3.10.
pull/1313/head
google-labs-jules[bot] 2025-05-25 18:42:44 +00:00
parent d2794038f7
commit 5f2e54552c
5 changed files with 182 additions and 8 deletions

View File

@ -134,12 +134,57 @@ Place these files in the "**models**" folder.
We highly recommend using a `venv` to avoid issues.
For Windows:
```bash
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
```
**For Windows:**
It is highly recommended to use Python 3.10 for Windows for best compatibility with all features and dependencies.
**Automated Setup (Recommended):**
1. **Run the setup script:**
Double-click `setup_windows.bat` or run it from your command prompt:
```batch
setup_windows.bat
```
This script will:
* Check if Python is in your PATH.
* Warn if `ffmpeg` is not found (see "Manual Steps / Notes" below for ffmpeg help).
* Create a virtual environment named `.venv` (consistent with macOS setup).
* Activate the virtual environment for the script's session.
* Upgrade pip.
* Install Python packages from `requirements.txt`.
Wait for the script to complete. It will pause at the end; press any key to close the window if you double-clicked it.
2. **Run the application:**
After setup, use the provided `.bat` scripts to run the application. These scripts automatically activate the correct virtual environment:
* `run_windows.bat`: Runs the application with the CPU execution provider by default. This is a good starting point if you don't have a dedicated GPU or are unsure.
* `run-cuda.bat`: Runs with the CUDA (NVIDIA GPU) execution provider. Requires an NVIDIA GPU and CUDA Toolkit installed (see GPU Acceleration section).
* `run-directml.bat`: Runs with the DirectML (AMD/Intel GPU on Windows) execution provider.
Example: Double-click `run_windows.bat` to launch the UI, or run from a command prompt:
```batch
run_windows.bat --source path\to\your_face.jpg --target path\to\video.mp4
```
**Manual Steps / Notes:**
* **Python:** Ensure Python 3.10 is installed and added to your system's PATH. You can download it from [python.org](https://www.python.org/downloads/).
* **ffmpeg:**
* `ffmpeg` is required for video processing. The `setup_windows.bat` script will warn if it's not found in your PATH.
* An easy way to install `ffmpeg` on Windows is to open PowerShell as Administrator and run:
```powershell
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')); choco install ffmpeg -y
```
Alternatively, download from [ffmpeg.org](https://ffmpeg.org/download.html), extract the files, and add the `bin` folder (containing `ffmpeg.exe`) to your system's PATH environment variable. The original README also linked to a [YouTube guide](https://www.youtube.com/watch?v=OlNWCpFdVMA) or `iex (irm ffmpeg.tc.ht)` via PowerShell.
* **Visual Studio Runtimes:** If you encounter errors during `pip install` for packages that compile C code (e.g., some scientific computing or image processing libraries), you might need the [Visual Studio Build Tools (or Runtimes)](https://visualstudio.microsoft.com/visual-cpp-build-tools/). Ensure "C++ build tools" (or similar workload) are selected during installation.
* **Virtual Environment (Manual Alternative):** If you prefer to set up the virtual environment manually instead of using `setup_windows.bat`:
```batch
python -m venv .venv
.venv\Scripts\activate.bat
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
```
(The new automated scripts use `.venv` as the folder name for consistency with the macOS setup).
For Linux:
```bash
# Ensure you use the installed Python 3.10

View File

@ -1 +1,16 @@
python run.py --execution-provider cuda
@echo off
set VENV_DIR=.venv
:: Check if virtual environment exists
if not exist "%VENV_DIR%\Scripts\activate.bat" (
echo Virtual environment '%VENV_DIR%' not found.
echo Please run setup_windows.bat first.
pause
exit /b 1
)
echo Activating virtual environment...
call "%VENV_DIR%\Scripts\activate.bat"
echo Starting the application with CUDA execution provider...
python run.py --execution-provider cuda %*

View File

@ -1 +1,16 @@
python run.py --execution-provider dml
@echo off
set VENV_DIR=.venv
:: Check if virtual environment exists
if not exist "%VENV_DIR%\Scripts\activate.bat" (
echo Virtual environment '%VENV_DIR%' not found.
echo Please run setup_windows.bat first.
pause
exit /b 1
)
echo Activating virtual environment...
call "%VENV_DIR%\Scripts\activate.bat"
echo Starting the application with DirectML execution provider...
python run.py --execution-provider dml %*

20
run_windows.bat 100644
View File

@ -0,0 +1,20 @@
@echo off
set VENV_DIR=.venv
:: Check if virtual environment exists
if not exist "%VENV_DIR%\Scripts\activate.bat" (
echo Virtual environment '%VENV_DIR%' not found.
echo Please run setup_windows.bat first to create the environment and install dependencies.
pause
exit /b 1
)
echo Activating virtual environment...
call "%VENV_DIR%\Scripts\activate.bat"
echo Starting the application with CPU execution provider...
:: Passes all arguments passed to this script to run.py
python run.py --execution-provider cpu %*
:: Optional: Deactivate after script finishes
:: call deactivate

79
setup_windows.bat 100644
View File

@ -0,0 +1,79 @@
@echo off
echo Starting Windows setup...
:: 1. Check for Python
echo Checking for Python...
python --version >nul 2>&1
if errorlevel 1 (
echo Python could not be found in your PATH.
echo Please install Python 3 (3.10 or higher recommended) and ensure it's added to your PATH.
echo You can download Python from https://www.python.org/downloads/
pause
exit /b 1
)
:: Optional: Check Python version (e.g., >= 3.9 or >=3.10).
:: This is a bit more complex in pure batch. For now, rely on user having a modern Python 3.
:: The README will recommend 3.10.
echo Found Python:
python --version
:: 2. Check for ffmpeg (informational)
echo Checking for ffmpeg...
ffmpeg -version >nul 2>&1
if errorlevel 1 (
echo WARNING: ffmpeg could not be found in your PATH. This program requires ffmpeg for video processing.
echo Please download ffmpeg from https://ffmpeg.org/download.html and add it to your system's PATH.
echo (The README.md contains a link for a potentially easier ffmpeg install method using a PowerShell command)
echo Continuing with setup, but video processing might fail later.
pause
) else (
echo ffmpeg found.
)
:: 3. Define virtual environment directory
set VENV_DIR=.venv
:: 4. Create virtual environment
if exist "%VENV_DIR%\Scripts\activate.bat" (
echo Virtual environment '%VENV_DIR%' already exists. Skipping creation.
) else (
echo Creating virtual environment in '%VENV_DIR%'...
python -m venv "%VENV_DIR%"
if errorlevel 1 (
echo Failed to create virtual environment. Please check your Python installation.
pause
exit /b 1
)
)
:: 5. Activate virtual environment (for this script's session)
echo Activating virtual environment...
call "%VENV_DIR%\Scripts\activate.bat"
:: 6. Upgrade pip
echo Upgrading pip...
python -m pip install --upgrade pip
:: 7. Install requirements
echo Installing requirements from requirements.txt...
if exist "requirements.txt" (
python -m pip install -r requirements.txt
) else (
echo ERROR: requirements.txt not found. Cannot install dependencies.
pause
exit /b 1
)
echo.
echo Setup complete!
echo.
echo To activate the virtual environment in your command prompt, run:
echo %VENV_DIR%\Scripts\activate.bat
echo.
echo After activating, you can run the application using:
echo python run.py [arguments]
echo Or use one of the run-*.bat scripts (e.g., run-cuda.bat, run_windows.bat).
echo.
pause
exit /b 0