Add -Upscale parameter to Clone-Image.ps1 for AI upscaling with upscayl-bin before ffmpeg processing, add -Model and -Keep parameters for model selection and output preservation, and update Stich-InBetween.ps1 to use RIFE_HOME and NCNN_GPU_ID environment variables for TNTwise fork compatibility

This commit is contained in:
2026-06-10 17:36:45 -04:00
parent 1e58558308
commit fb4f371450
2 changed files with 205 additions and 8 deletions
+36 -7
View File
@@ -41,12 +41,17 @@
.NOTES
Requires:
- rife-ncnn-vulkan.exe in the system PATH
- rife-ncnn-vulkan.exe (TNTwise fork, RIFE 4.26) in the system PATH
- The RIFE_HOME environment variable set to the rife-ncnn-vulkan install directory
(the same directory that is on PATH; it must contain the rife-v4.26 model folder)
- The NCNN_GPU_ID environment variable set to the desired GPU device ID
(-1 for CPU, 0/1/2/etc. for GPU) passed to rife-ncnn-vulkan via the -g flag
- ffmpeg in the system PATH
- PowerShell 7 or later
The script automatically locates rife-ncnn-vulkan.exe from PATH and expects
the rife-v4 model directory to be in the same directory as the executable.
The script locates rife-ncnn-vulkan.exe from PATH and resolves the rife-v4.26
model directory from %RIFE_HOME%\rife-v4.26. The GPU device is selected from
%NCNN_GPU_ID%.
Supports -WhatIf and -Confirm for safe execution.
#>
@@ -161,15 +166,39 @@ if (-not $rifeExe) {
}
$rifeExePath = $rifeExe.Source
$rifeDir = Split-Path -Parent $rifeExePath
$rifeModelPath = Join-Path $rifeDir "rife-v4"
# Resolve the model directory via RIFE_HOME (required by the TNTwise fork's
# install layout, see mkdocs/RIFE.md). RIFE_HOME must point to the install
# folder containing the rife-v4.26 model directory.
$rifeHome = $env:RIFE_HOME
if (-not $rifeHome) {
throw "RIFE_HOME environment variable is not set. Set it to the rife-ncnn-vulkan install directory (the same folder that is on PATH)."
}
$rifeHome = $rifeHome.TrimEnd('\', '/')
if (-not (Test-Path -LiteralPath $rifeHome -PathType Container)) {
throw "RIFE_HOME directory does not exist: $rifeHome"
}
$rifeModelPath = Join-Path $rifeHome "rife-v4.26"
if (-not (Test-Path -LiteralPath $rifeModelPath -PathType Container)) {
throw "RIFE model directory not found at: $rifeModelPath"
throw "RIFE model directory not found at: $rifeModelPath. Ensure the rife-v4.26 model folder ships under %RIFE_HOME%."
}
# Resolve the GPU device ID for the -g flag from NCNN_GPU_ID.
$gpuId = $env:NCNN_GPU_ID
if (-not $gpuId) {
throw "NCNN_GPU_ID environment variable is not set. Set it to -1 (CPU) or 0/1/2/etc. (GPU device index)."
}
if ($gpuId -notmatch '^-?\d+$') {
throw "NCNN_GPU_ID must be an integer (-1 for CPU, 0+ for GPU). Current value: $gpuId"
}
Write-Host "Found rife-ncnn-vulkan.exe at: $rifeExePath"
Write-Host "Using RIFE_HOME: $rifeHome"
Write-Host "Using model path: $rifeModelPath"
Write-Host "Using GPU device (-g): $gpuId"
# --- Prepare TempDir ---
@@ -190,7 +219,7 @@ if (Test-Path -LiteralPath $tempDirPath) {
if ($PSCmdlet.ShouldProcess($TempDir, "Generate interpolated frames with rife-ncnn-vulkan (Count=$Count)")) {
Write-Host "Executing rife-ncnn-vulkan.exe (Count=$Count, EndsAt=$EndsAt)..."
& $rifeExePath -0 $FirstFilename -1 $LastFilename -i $InputTempDir -o $TempDir -n $Count -m $rifeModelPath
& $rifeExePath -0 $FirstFilename -1 $LastFilename -i $InputTempDir -o $TempDir -n $Count -m $rifeModelPath -g $gpuId
if ($LASTEXITCODE -ne 0) {
throw "rife-ncnn-vulkan.exe failed with exit code $LASTEXITCODE"