Sasya-AI-Backend / scripts /deploy_to_agriforge.ps1
Neel2601's picture
Sasya AI: replace farmer-ai-backend with 4-model API + Gradio UI
041a776
Raw
History Blame Contribute Delete
2.3 kB
# Deploy Sasya AI to an existing HF Space (e.g. old agriforge with CPU basic)
# Usage:
# powershell -File scripts\deploy_to_agriforge.ps1
# powershell -File scripts\deploy_to_agriforge.ps1 -SpaceName "agriforge"
param(
[string]$SpaceName = "agriforge",
[string]$Owner = "Neel2601"
)
$ErrorActionPreference = "Stop"
$ROOT = $PSScriptRoot | Split-Path -Parent
Set-Location $ROOT
$SpaceUrl = "https://huggingface.co/spaces/$Owner/$SpaceName"
$ApiUrl = "https://$($Owner.ToLower())-$($SpaceName.ToLower()).hf.space"
Write-Host "=== Deploying Sasya AI to $Owner/$SpaceName (CPU basic) ===" -ForegroundColor Cyan
Write-Host "Space: $SpaceUrl" -ForegroundColor Gray
Write-Host "API: $ApiUrl" -ForegroundColor Gray
Write-Host "`n=== HF login ===" -ForegroundColor Cyan
hf auth whoami 2>$null
if ($LASTEXITCODE -ne 0) { hf auth login }
Write-Host "`n=== Upload disease model ===" -ForegroundColor Cyan
& "D:\AI-ML\envs\agriforge-backend\Scripts\python.exe" scripts\upload_disease_model.py
Write-Host "`n=== Git LFS ===" -ForegroundColor Cyan
if (-not (Test-Path ".git")) { git init }
git lfs install
git lfs track "trained_models/agricultural_tinyllama/agricultural_kb.json"
Write-Host "`n=== Stage files ===" -ForegroundColor Cyan
git add .gitignore .gitattributes README.md requirements.txt packages.txt
git add space.py gradio_ui.py app/
git add trained_models/disease_detection/classes.json
git add trained_models/agricultural_tinyllama/agricultural_kb.json
$remote = $null
try { $remote = git remote get-url origin 2>$null } catch { $remote = $null }
if ($remote) {
git remote set-url origin $SpaceUrl
} else {
git remote add origin $SpaceUrl
}
Write-Host "Remote: $SpaceUrl"
git add -A
git commit -m "Replace with Sasya AI backend (CPU basic)" 2>$null
if ($LASTEXITCODE -ne 0) { Write-Host "No new changes to commit" }
Write-Host "`n=== Force push (replaces old agriforge Space) ===" -ForegroundColor Yellow
Write-Host "Paste HF write token when asked for password." -ForegroundColor Yellow
git branch -M main
git push -u origin main --force
Write-Host "`nDone!" -ForegroundColor Green
Write-Host "Space: $SpaceUrl" -ForegroundColor Green
Write-Host "API: $ApiUrl/docs" -ForegroundColor Green
Write-Host "Expo: EXPO_PUBLIC_API_URL=$ApiUrl" -ForegroundColor Green