-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-python.ps1
More file actions
47 lines (38 loc) · 1.19 KB
/
setup-python.ps1
File metadata and controls
47 lines (38 loc) · 1.19 KB
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
param(
[switch]$Run,
[string]$ExecutionProvider = "auto",
[switch]$VirtualCamera,
[ValidateSet("auto", "obs", "unitycapture")]
[string]$VirtualCameraBackend = "auto",
[switch]$NoPreview
)
$ErrorActionPreference = "Stop"
if (-not (Get-Command py -ErrorAction SilentlyContinue)) {
throw "The Python launcher 'py' was not found. Install Python 3.11 first."
}
$pythonVersion = & py -3.11 --version 2>$null
if (-not $pythonVersion) {
throw "Python 3.11 was not found. Install Python 3.11 first."
}
$venvPython = Join-Path $PWD ".venv\Scripts\python.exe"
if (-not (Test-Path $venvPython)) {
Write-Host "Creating Python virtual environment..."
& py -3.11 -m venv .venv
}
Write-Host "Installing Python dependencies..."
& $venvPython -m pip install --upgrade pip
& $venvPython -m pip install -r .\python\requirements.txt
if ($Run) {
$runArgs = @(
".\python\live_face_swap.py",
"--execution-provider=$ExecutionProvider"
)
if ($VirtualCamera) {
$runArgs += "--virtual-camera"
$runArgs += "--virtual-camera-backend=$VirtualCameraBackend"
}
if ($NoPreview) {
$runArgs += "--no-preview"
}
& $venvPython @runArgs
}