Files
aigen/scripts/setup-caption.ps1
T

55 lines
2.0 KiB
PowerShell

# Caption (Qwen2.5-VL NSFW Caption V4 GGUF) — verify host files only.
# Models are already on the 5080 host. Do not download. Do not search Hugging Face.
$ErrorActionPreference = 'Stop'
function Resolve-ModelsRoot {
if ($env:COMFY_MODELS_ROOT) { return $env:COMFY_MODELS_ROOT }
$shared = Join-Path $env:LOCALAPPDATA 'Comfy-Desktop\ComfyUI-Shared\models'
if (Test-Path $shared) { return $shared }
throw 'Set COMFY_MODELS_ROOT or install Comfy Desktop Shared models.'
}
$root = Join-Path (Resolve-ModelsRoot) 'caption\qwen25vl-7b-nsfw-v4'
if (-not (Test-Path $root)) {
throw "Caption models folder missing: $root"
}
$files = @(
'Qwen2.5-VL-7B-NSFW-Caption-V4.Q5_K_M.gguf',
'Qwen2.5-VL-7B-NSFW-Caption-V4.mmproj-f16.gguf'
)
foreach ($name in $files) {
$path = Join-Path $root $name
if (-not (Test-Path $path)) {
throw "Missing $name under $root. Do not download; use the files already on this host."
}
Write-Host "OK $name"
}
$llama = $null
if ($env:CAPTION_LLAMA_SERVER -and (Test-Path $env:CAPTION_LLAMA_SERVER)) {
$llama = Get-Item $env:CAPTION_LLAMA_SERVER
} else {
$winget = Join-Path $env:LOCALAPPDATA 'Microsoft\WinGet\Packages\ggml.llamacpp_Microsoft.Winget.Source_8wekyb3d8bbwe\llama-server.exe'
if (Test-Path $winget) { $llama = Get-Item $winget }
else { $llama = Get-Command llama-server -ErrorAction SilentlyContinue }
}
if (-not $llama) {
throw 'llama-server not found. Install with: winget install ggml.llamacpp'
}
$llamaPath = if ($llama.PSObject.Properties['FullName'] -and $llama.FullName) { $llama.FullName } elseif ($llama.PSObject.Properties['Source'] -and $llama.Source) { $llama.Source } else { [string]$llama }
Write-Host "llama-server: $llamaPath"
$ready = @{
model = 'Qwen2.5-VL-7B-NSFW-Caption-V4.Q5_K_M.gguf'
mmproj = 'Qwen2.5-VL-7B-NSFW-Caption-V4.mmproj-f16.gguf'
modelsDir = $root
llamaServer = $llamaPath
readyAt = (Get-Date).ToUniversalTime().ToString('o')
} | ConvertTo-Json
Set-Content -Path (Join-Path $root 'aigen-ready.json') -Value $ready -Encoding utf8
Write-Host "Caption ready: $root"