-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.bat
More file actions
270 lines (224 loc) · 9.69 KB
/
install.bat
File metadata and controls
270 lines (224 loc) · 9.69 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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
@echo off
setlocal enableextensions
:: ============================================================
:: CorridorKey for Resolve - One-Click Installer
:: ============================================================
echo.
echo ============================================================
echo CorridorKey for Resolve - Installer
echo ============================================================
echo.
:: Save script directory
set "INSTALLER_DIR=%~dp0"
:: Configuration
set "APPDATA_DIR=%APPDATA%\CorridorKeyForResolve"
set "VENV_DIR=%APPDATA_DIR%\venv"
set "CK_REPO_DIR=%APPDATA_DIR%\CorridorKey"
set "OFX_DIR=C:\Program Files\Common Files\OFX\Plugins\CorridorKeyForResolve.ofx.bundle"
set "CK_ZIP_URL=https://github.com/nikopueringer/CorridorKey/archive/refs/heads/main.zip"
set "CKPT_URL=https://huggingface.co/nikopueringer/CorridorKey_v1.0/resolve/main/CorridorKey_v1.0.pth"
:: --------------------------------------------------------
:: Step 1: Find Python 3.10-3.13
:: --------------------------------------------------------
echo [1/6] Finding Python...
set "PYTHON_EXE="
if exist "%LOCALAPPDATA%\Programs\Python\Python313\python.exe" set "PYTHON_EXE=%LOCALAPPDATA%\Programs\Python\Python313\python.exe"
if "%PYTHON_EXE%"=="" if exist "%LOCALAPPDATA%\Programs\Python\Python312\python.exe" set "PYTHON_EXE=%LOCALAPPDATA%\Programs\Python\Python312\python.exe"
if "%PYTHON_EXE%"=="" if exist "%LOCALAPPDATA%\Programs\Python\Python311\python.exe" set "PYTHON_EXE=%LOCALAPPDATA%\Programs\Python\Python311\python.exe"
if "%PYTHON_EXE%"=="" if exist "%LOCALAPPDATA%\Programs\Python\Python310\python.exe" set "PYTHON_EXE=%LOCALAPPDATA%\Programs\Python\Python310\python.exe"
if "%PYTHON_EXE%"=="" (
where python >nul 2>&1
if %errorlevel% equ 0 (
for /f "delims=" %%p in ('where python') do set "PYTHON_EXE=%%p"
)
)
if "%PYTHON_EXE%"=="" (
echo.
echo ERROR: Python not found!
echo Install Python 3.13 from:
echo https://www.python.org/downloads/release/python-31312/
echo Check "Add Python to PATH" during installation.
echo.
goto :error
)
echo Found: %PYTHON_EXE%
for /f "tokens=2 delims= " %%v in ('"%PYTHON_EXE%" --version 2^>^&1') do set "PY_VER=%%v"
echo Version: %PY_VER%
:: Check version range
for /f "tokens=1,2 delims=." %%a in ("%PY_VER%") do set "PY_MAJOR=%%a" & set "PY_MINOR=%%b"
if %PY_MINOR% lss 10 goto :bad_python
if %PY_MINOR% gtr 13 goto :bad_python
goto :python_ok
:bad_python
echo.
echo ERROR: Python %PY_VER% is not supported!
echo PyTorch requires Python 3.10-3.13.
echo Install Python 3.13 from:
echo https://www.python.org/downloads/release/python-31312/
echo.
goto :error
:python_ok
:: --------------------------------------------------------
:: Step 2: Install OFX plugin (needs admin)
:: --------------------------------------------------------
echo.
echo [2/6] Installing OFX plugin...
set "BUNDLE_SRC="
if exist "%INSTALLER_DIR%CorridorKeyForResolve.ofx.bundle\Contents\Win64\CorridorKeyForResolve.ofx" set "BUNDLE_SRC=%INSTALLER_DIR%CorridorKeyForResolve.ofx.bundle"
if "%BUNDLE_SRC%"=="" if exist "%INSTALLER_DIR%plugin\build\CorridorKeyForResolve.ofx.bundle\Contents\Win64\CorridorKeyForResolve.ofx" set "BUNDLE_SRC=%INSTALLER_DIR%plugin\build\CorridorKeyForResolve.ofx.bundle"
if "%BUNDLE_SRC%"=="" (
echo.
echo ERROR: OFX plugin bundle not found!
echo Download from: https://github.com/gitcapoom/corridorkey_ofx/releases
echo.
goto :error
)
echo Copying plugin to Program Files (may prompt for admin)...
powershell -Command "Start-Process powershell -ArgumentList '-Command Copy-Item -Path ''%BUNDLE_SRC%'' -Destination ''C:\Program Files\Common Files\OFX\Plugins\'' -Recurse -Force' -Verb RunAs -Wait"
if not exist "%OFX_DIR%\Contents\Win64\CorridorKeyForResolve.ofx" (
echo ERROR: Failed to install OFX plugin. Close DaVinci Resolve and retry.
goto :error
)
echo Plugin installed.
:: --------------------------------------------------------
:: Step 3: Create virtual environment
:: --------------------------------------------------------
echo.
echo [3/6] Setting up Python environment...
if not exist "%APPDATA_DIR%" mkdir "%APPDATA_DIR%"
if not exist "%VENV_DIR%\Scripts\python.exe" goto :create_venv
:: Check existing venv version - recreate if incompatible
for /f "tokens=2 delims= " %%v in ('"%VENV_DIR%\Scripts\python.exe" --version 2^>^&1') do set "VENV_VER=%%v"
for /f "tokens=2 delims=." %%m in ("%VENV_VER%") do set "VENV_MINOR=%%m"
if %VENV_MINOR% gtr 13 goto :recreate_venv
if %VENV_MINOR% lss 10 goto :recreate_venv
echo Virtual environment exists (Python %VENV_VER%).
goto :venv_ready
:recreate_venv
echo Existing venv uses Python %VENV_VER% - recreating...
rmdir /S /Q "%VENV_DIR%"
:create_venv
echo Creating virtual environment...
"%PYTHON_EXE%" -m venv "%VENV_DIR%"
if %errorlevel% neq 0 goto :venv_error
"%VENV_DIR%\Scripts\python.exe" -m pip install --upgrade pip >nul 2>&1
:venv_ready
set "PIP=%VENV_DIR%\Scripts\python.exe -m pip"
goto :venv_ok
:venv_error
echo ERROR: Failed to create virtual environment.
goto :error
:venv_ok
:: --------------------------------------------------------
:: Step 4: Download CorridorKey source + model weights
:: --------------------------------------------------------
echo.
echo [4/6] Downloading CorridorKey...
:: Download source code
if exist "%CK_REPO_DIR%\CorridorKeyModule\inference_engine.py" goto :ck_src_ok
echo Downloading source code...
powershell -Command "$ProgressPreference='SilentlyContinue'; (New-Object Net.WebClient).DownloadFile('%CK_ZIP_URL%','%APPDATA_DIR%\ck.zip')"
if %errorlevel% neq 0 goto :download_error
echo Extracting...
powershell -Command "$ProgressPreference='SilentlyContinue'; Expand-Archive -Path '%APPDATA_DIR%\ck.zip' -DestinationPath '%APPDATA_DIR%\ck_temp' -Force"
for /d %%d in ("%APPDATA_DIR%\ck_temp\CorridorKey*") do move "%%d" "%CK_REPO_DIR%" >nul
rmdir /S /Q "%APPDATA_DIR%\ck_temp" 2>nul
del "%APPDATA_DIR%\ck.zip" 2>nul
echo Source code ready.
goto :ck_model
:ck_src_ok
echo Source code already downloaded.
:ck_model
:: Download model weights
set "CKPT_DIR=%CK_REPO_DIR%\CorridorKeyModule\checkpoints"
set "CKPT_FILE=%CKPT_DIR%\CorridorKey_v1.0.pth"
if exist "%CKPT_FILE%" goto :ck_model_ok
echo Downloading model weights (~400MB)...
if not exist "%CKPT_DIR%" mkdir "%CKPT_DIR%"
powershell -Command "$ProgressPreference='SilentlyContinue'; [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; (New-Object Net.WebClient).DownloadFile('%CKPT_URL%','%CKPT_FILE%')"
if %errorlevel% neq 0 goto :download_error
echo Model weights ready.
goto :download_ok
:ck_model_ok
echo Model weights already downloaded.
goto :download_ok
:download_error
echo ERROR: Download failed. Check your internet connection.
goto :error
:download_ok
:: --------------------------------------------------------
:: Step 5: Install Python dependencies
:: --------------------------------------------------------
echo.
echo [5/6] Installing Python dependencies...
echo Installing PyTorch with CUDA (~2.5GB)...
%PIP% install torch torchvision --index-url https://download.pytorch.org/whl/cu124
if %errorlevel% neq 0 (
echo.
echo ERROR: PyTorch installation failed.
echo Python version: %PY_VER%
echo Retry: %PIP% install torch torchvision --index-url https://download.pytorch.org/whl/cu124
echo.
goto :error
)
echo Installing other dependencies...
%PIP% install numpy Pillow opencv-python timm transformers huggingface_hub einops kornia
if %errorlevel% neq 0 echo WARNING: Some dependencies failed.
echo Installing Triton...
%PIP% install triton-windows >nul 2>&1
if %errorlevel% neq 0 echo Warning: Triton unavailable. torch.compile will be slower.
:: --------------------------------------------------------
:: Step 6: Install backend files and verify
:: --------------------------------------------------------
echo.
echo [6/6] Installing backend files...
copy /Y "%INSTALLER_DIR%backend\server.py" "%APPDATA_DIR%\server.py" >nul 2>&1
copy /Y "%INSTALLER_DIR%backend\ipc_protocol.py" "%APPDATA_DIR%\ipc_protocol.py" >nul 2>&1
copy /Y "%INSTALLER_DIR%backend\inference_wrapper.py" "%APPDATA_DIR%\inference_wrapper.py" >nul 2>&1
if exist "%APPDATA_DIR%\server.py" echo Copied server.py
if exist "%APPDATA_DIR%\ipc_protocol.py" echo Copied ipc_protocol.py
if exist "%APPDATA_DIR%\inference_wrapper.py" echo Copied inference_wrapper.py
if not exist "%APPDATA_DIR%\server.py" (
echo ERROR: Backend files not found next to install.bat
echo Script location: %INSTALLER_DIR%
goto :error
)
:: Final verification
echo.
echo Verifying...
set "FAIL="
if not exist "%OFX_DIR%\Contents\Win64\CorridorKeyForResolve.ofx" echo MISSING: OFX plugin & set "FAIL=1"
if not exist "%APPDATA_DIR%\server.py" echo MISSING: server.py & set "FAIL=1"
if not exist "%CKPT_FILE%" echo MISSING: Model weights & set "FAIL=1"
if not exist "%VENV_DIR%\Scripts\python.exe" echo MISSING: Python venv & set "FAIL=1"
if defined FAIL (
echo ERROR: Installation incomplete.
goto :error
)
echo All components OK.
:: --------------------------------------------------------
:: Done!
:: --------------------------------------------------------
echo.
echo ============================================================
echo Installation complete!
echo ============================================================
echo.
echo How to use:
echo 1. Open DaVinci Resolve
echo 2. Go to Color page or Fusion page
echo 3. Add CorridorKey from OFX plugins
echo 4. The backend starts automatically
echo.
echo NOTE: The first frame takes ~60s for one-time GPU
echo kernel compilation. After that: ~3s per frame.
echo ============================================================
echo.
pause
exit /b 0
:error
echo.
echo Installation failed. Fix the issue above and re-run.
echo.
pause
exit /b 1