# 🚀 ECG-FM Dual Model Deployment to HF Spaces # PowerShell script to deploy the optimized dual-model ECG-FM API Write-Host "🚀 DEPLOYING ECG-FM DUAL MODEL API TO HF SPACES" -ForegroundColor Green Write-Host "=" * 60 -ForegroundColor Green # Configuration $SPACE_NAME = "mystic-cbk-ecg-fm-api" $REPO_URL = "https://huggingface.co/spaces/mystic-cbk/$SPACE_NAME" $LOCAL_DIR = "." $BRANCH = "main" Write-Host "📋 Deployment Configuration:" -ForegroundColor Yellow Write-Host " Space Name: $SPACE_NAME" -ForegroundColor White Write-Host " Repository: $REPO_URL" -ForegroundColor White Write-Host " Local Directory: $LOCAL_DIR" -ForegroundColor White Write-Host " Branch: $BRANCH" -ForegroundColor White Write-Host "" # Check if git is available try { $gitVersion = git --version Write-Host "✅ Git available: $gitVersion" -ForegroundColor Green } catch { Write-Host "❌ Git not available. Please install Git first." -ForegroundColor Red exit 1 } # Check if we're in a git repository if (-not (Test-Path ".git")) { Write-Host "🔄 Initializing git repository..." -ForegroundColor Yellow git init git add . git commit -m "Initial commit: ECG-FM Dual Model API" } # Check current git status Write-Host "📊 Current Git Status:" -ForegroundColor Yellow git status # Add all changes Write-Host "🔄 Adding all changes to git..." -ForegroundColor Yellow git add . # Commit changes $commitMessage = "🚀 Deploy ECG-FM Dual Model API v2.0.0 - $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" Write-Host "💾 Committing changes: $commitMessage" -ForegroundColor Yellow git commit -m $commitMessage # Check if remote exists $remotes = git remote -v if ($remotes -match $SPACE_NAME) { Write-Host "✅ Remote already exists: $SPACE_NAME" -ForegroundColor Green } else { Write-Host "🔄 Adding remote repository..." -ForegroundColor Yellow git remote add origin $REPO_URL } # Push to HF Spaces Write-Host "🚀 Pushing to Hugging Face Spaces..." -ForegroundColor Green Write-Host " This will trigger automatic deployment..." -ForegroundColor White Write-Host "" try { git push -u origin $BRANCH --force Write-Host "✅ Successfully pushed to HF Spaces!" -ForegroundColor Green Write-Host "" Write-Host "🌐 Your API will be available at:" -ForegroundColor Cyan Write-Host " https://huggingface.co/spaces/mystic-cbk/$SPACE_NAME" -ForegroundColor White Write-Host "" Write-Host "📊 Monitor deployment progress at:" -ForegroundColor Cyan Write-Host " https://huggingface.co/spaces/mystic-cbk/$SPACE_NAME/settings" -ForegroundColor White Write-Host "" Write-Host "⏱️ Deployment typically takes 5-10 minutes..." -ForegroundColor Yellow Write-Host " Models will be downloaded automatically on first startup" -ForegroundColor White } catch { Write-Host "❌ Error pushing to HF Spaces: $_" -ForegroundColor Red Write-Host "" Write-Host "🔧 Troubleshooting:" -ForegroundColor Yellow Write-Host " 1. Check your HF token is set: git config --global credential.helper store" -ForegroundColor White Write-Host " 2. Verify repository permissions" -ForegroundColor White Write-Host " 3. Check internet connection" -ForegroundColor White exit 1 } Write-Host "" Write-Host "🎉 DEPLOYMENT INITIATED SUCCESSFULLY!" -ForegroundColor Green Write-Host "=" * 60 -ForegroundColor Green Write-Host "" Write-Host "📋 Next Steps:" -ForegroundColor Yellow Write-Host " 1. Monitor deployment at HF Spaces" -ForegroundColor White Write-Host " 2. Wait for models to download (5-10 minutes)" -ForegroundColor White Write-Host " 3. Test API endpoints when ready" -ForegroundColor White Write-Host " 4. Run batch analysis scripts" -ForegroundColor White Write-Host "" Write-Host "🔗 API Endpoints:" -ForegroundColor Cyan Write-Host " • /health - Health check" -ForegroundColor White Write-Host " • /analyze - Full ECG analysis (both models)" -ForegroundColor White Write-Host " • /extract_features - Feature extraction (pretrained model)" -ForegroundColor White Write-Host " • /assess_quality - Signal quality assessment" -ForegroundColor White