File size: 1,888 Bytes
393850c
 
 
 
 
 
 
 
 
 
 
decc0ef
 
 
 
 
 
 
 
 
 
 
 
 
393850c
 
 
2a04c3c
393850c
 
decc0ef
393850c
fec5388
393850c
 
 
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
# onw one-line installer for Windows. In PowerShell:
#   irm https://huggingface.co/ryugyosoft/onw/resolve/main/install.ps1 | iex
# Downloads onw into %LOCALAPPDATA%\onw (no git / hf needed) and runs setup.bat, which finds or installs Python,
# sets up the environment, adds "onw" to the Start menu and starts the tray app. Run it again to update onw.
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"
$repo = "ryugyosoft/onw"
$dest = Join-Path $env:LOCALAPPDATA "onw"
Write-Host ""
Write-Host "onw - Ore no NPU ga konna ni ugoku wake nai"
Write-Host "Installing into $dest ..."
function Get-WithRetry($uri, $out) {
    for ($i = 1; $i -le 4; $i++) {
        try {
            if ($out) { Invoke-WebRequest -UseBasicParsing -Uri $uri -OutFile $out; return }
            return Invoke-RestMethod $uri
        } catch {
            if ($i -eq 4) { throw }
            Write-Host "  retrying ($($_.Exception.Message)) ..."
            Start-Sleep -Seconds (2 * $i)
        }
    }
}
$info = Get-WithRetry "https://huggingface.co/api/models/$repo" $null
foreach ($s in $info.siblings) {
    $f = $s.rfilename
    if ($f -eq ".gitattributes") { continue }
    if ($f.StartsWith("onw/npukit/linux/")) { continue }      # (the NPU kit for Linux)
    $out = Join-Path $dest ($f -replace "/", "\")
    New-Item -ItemType Directory -Force -Path (Split-Path $out) | Out-Null
    Get-WithRetry "https://huggingface.co/$repo/resolve/main/$f" $out
}
Set-Content -Path (Join-Path $dest ".onw-installed") -Value "installer" -Encoding ascii   # onw may update itself here
Write-Host "Downloaded $($info.siblings.Count - 1) files. Starting setup (Python, packages, Start menu, tray) ..."
Start-Process -FilePath (Join-Path $dest "setup.bat") -WorkingDirectory $dest
Write-Host "A setup window opened. When it finishes, onw appears in the task tray and asks which model to download."