# 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 }