File size: 4,323 Bytes
ae31891 208adf4 9c8de54 ef22967 |
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 |
# Hugging Face Spaces μ
λ‘λ μ€ν¬λ¦½νΈ
# μ¬μ©λ²: .\upload_to_hf.ps1 -HFSpacePath "C:\path\to\huggingface\space"
param(
[Parameter(Mandatory=$true)]
[string]$HFSpacePath
)
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Hugging Face Spaces μ
λ‘λ μ€λΉ" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
# κ²½λ‘ νμΈ
if (-not (Test-Path $HFSpacePath)) {
Write-Host "μ€λ₯: Hugging Face Spaces λλ ν 리λ₯Ό μ°Ύμ μ μμ΅λλ€: $HFSpacePath" -ForegroundColor Red
Write-Host "λ¨Όμ 'git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME' λͺ
λ ΉμΌλ‘ ν΄λ‘ νμΈμ." -ForegroundColor Yellow
exit 1
}
Write-Host "`nλμ λλ ν 리: $HFSpacePath" -ForegroundColor Green
# νμ¬ λλ ν 리 νμΈ
$currentDir = Get-Location
Write-Host "νμ¬ λλ ν 리: $currentDir" -ForegroundColor Green
# νμ νμΌ νμΈ
$requiredFiles = @("app.py", "Dockerfile", "requirements.txt", "README_HF.md")
$missingFiles = @()
foreach ($file in $requiredFiles) {
if (-not (Test-Path $file)) {
$missingFiles += $file
}
}
if ($missingFiles.Count -gt 0) {
Write-Host "`nμ€λ₯: λ€μ νμ νμΌμ΄ μμ΅λλ€:" -ForegroundColor Red
foreach ($file in $missingFiles) {
Write-Host " - $file" -ForegroundColor Red
}
exit 1
}
# νμ λλ ν 리 νμΈ
$requiredDirs = @("app", "templates", "static")
$missingDirs = @()
foreach ($dir in $requiredDirs) {
if (-not (Test-Path $dir)) {
$missingDirs += $dir
}
}
if ($missingDirs.Count -gt 0) {
Write-Host "`nμ€λ₯: λ€μ νμ λλ ν λ¦¬κ° μμ΅λλ€:" -ForegroundColor Red
foreach ($dir in $missingDirs) {
Write-Host " - $dir" -ForegroundColor Red
}
exit 1
}
Write-Host "`nνμ νμΌ λ° λλ ν 리 νμΈ μλ£!" -ForegroundColor Green
# νμΌ λ³΅μ¬ μμ
Write-Host "`nνμΌ λ³΅μ¬ μμ..." -ForegroundColor Yellow
try {
# νμ νμΌ λ³΅μ¬
Write-Host "`n[1/4] νμ νμΌ λ³΅μ¬ μ€..." -ForegroundColor Cyan
Copy-Item "app.py" "$HFSpacePath\" -Force
Copy-Item "Dockerfile" "$HFSpacePath\" -Force
Copy-Item "requirements.txt" "$HFSpacePath\" -Force
Copy-Item "README_HF.md" "$HFSpacePath\README.md" -Force
Write-Host " β νμ νμΌ λ³΅μ¬ μλ£" -ForegroundColor Green
# app λλ ν 리 볡μ¬
Write-Host "`n[2/4] app λλ ν 리 λ³΅μ¬ μ€..." -ForegroundColor Cyan
if (Test-Path "$HFSpacePath\app") {
Remove-Item "$HFSpacePath\app" -Recurse -Force
}
Copy-Item -Recurse "app" "$HFSpacePath\app" -Force
Write-Host " β app λλ ν 리 λ³΅μ¬ μλ£" -ForegroundColor Green
# templates λλ ν 리 볡μ¬
Write-Host "`n[3/4] templates λλ ν 리 λ³΅μ¬ μ€..." -ForegroundColor Cyan
if (Test-Path "$HFSpacePath\templates") {
Remove-Item "$HFSpacePath\templates" -Recurse -Force
}
Copy-Item -Recurse "templates" "$HFSpacePath\templates" -Force
Write-Host " β templates λλ ν 리 λ³΅μ¬ μλ£" -ForegroundColor Green
# static λλ ν 리 볡μ¬
Write-Host "`n[4/4] static λλ ν 리 λ³΅μ¬ μ€..." -ForegroundColor Cyan
if (Test-Path "$HFSpacePath\static") {
Remove-Item "$HFSpacePath\static" -Recurse -Force
}
Copy-Item -Recurse "static" "$HFSpacePath\static" -Force
Write-Host " β static λλ ν 리 λ³΅μ¬ μλ£" -ForegroundColor Green
Write-Host "`n========================================" -ForegroundColor Cyan
Write-Host "νμΌ λ³΅μ¬ μλ£!" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "`nλ€μ λ¨κ³:" -ForegroundColor Yellow
Write-Host "1. Hugging Face Spaces λλ ν λ¦¬λ‘ μ΄λ: cd $HFSpacePath" -ForegroundColor White
Write-Host "2. Git 컀λ°: git add ." -ForegroundColor White
Write-Host "3. Git 컀λ°: git commit -m 'Initial deployment'" -ForegroundColor White
Write-Host "4. Git νΈμ: git push" -ForegroundColor White
Write-Host "`nλλ Hugging Face μΉ μΈν°νμ΄μ€μμ νμΌμ νμΈνκ³ μ»€λ°νμΈμ." -ForegroundColor White
} catch {
Write-Host "`nμ€λ₯ λ°μ: $_" -ForegroundColor Red
exit 1
}
|