| param( |
| [Parameter(Mandatory = $true)] |
| [string]$RepoId, |
|
|
| [string]$Token = "" |
| ) |
|
|
| $ErrorActionPreference = "Stop" |
|
|
| Write-Host "This uploads the GGUF LoRA adapter repo to Hugging Face:" -ForegroundColor Cyan |
| Write-Host $RepoId -ForegroundColor Yellow |
| Write-Host "" |
| Write-Host "Important: this is an adapter repo, not a standalone merged full model." -ForegroundColor Yellow |
| Write-Host "" |
|
|
| if (-not (Get-Command hf -ErrorAction SilentlyContinue)) { |
| $hfFromPython = Join-Path $env:LOCALAPPDATA "Python\pythoncore-3.14-64\Scripts\hf.exe" |
| if (Test-Path -LiteralPath $hfFromPython) { |
| $script:HfCli = $hfFromPython |
| } |
| else { |
| $script:HfCli = "hf" |
| } |
| } |
| else { |
| $script:HfCli = "hf" |
| } |
|
|
| if (-not (Get-Command $script:HfCli -ErrorAction SilentlyContinue) -and -not (Test-Path -LiteralPath $script:HfCli)) { |
| Write-Host "Installing huggingface_hub..." -ForegroundColor Cyan |
| py -m pip install -U huggingface_hub |
| $script:HfCli = Join-Path $env:LOCALAPPDATA "Python\pythoncore-3.14-64\Scripts\hf.exe" |
| } |
|
|
| if ($Token) { |
| $tokenArgs = @("--token", $Token) |
| } |
| else { |
| $tokenArgs = @() |
| Write-Host "If upload fails with 403, create a Hugging Face token with WRITE access and rerun with -Token YOUR_TOKEN." -ForegroundColor Yellow |
| } |
|
|
| Write-Host "Creating repo if needed..." -ForegroundColor Cyan |
| & $script:HfCli repo create $RepoId --type model --public --exist-ok @tokenArgs |
|
|
| Write-Host "Uploading files..." -ForegroundColor Cyan |
| & $script:HfCli upload $RepoId . . --repo-type model @tokenArgs |
|
|
| Write-Host "Done. Repo uploaded:" -ForegroundColor Green |
| Write-Host "https://huggingface.co/$RepoId" |
|
|