# PowerShell script to run the FastAPI application from app.py # Run this script from the project root directory Write-Host "=========================================" -ForegroundColor Cyan Write-Host "Starting SAM2 Image Auto Segment API" -ForegroundColor Cyan Write-Host "=========================================" -ForegroundColor Cyan Write-Host "" # Check if Python is installed try { $pythonVersion = python --version 2>&1 Write-Host "Found: $pythonVersion" -ForegroundColor Green } catch { Write-Host "ERROR: Python is not installed or not in PATH!" -ForegroundColor Red Write-Host "Please install Python 3.10 or higher from https://www.python.org/" -ForegroundColor Red exit 1 } # Set default port (can be overridden with PORT environment variable) $port = if ($env:PORT) { $env:PORT } else { "8000" } Write-Host "Using port: $port" -ForegroundColor Yellow Write-Host "" Write-Host "Starting FastAPI server..." -ForegroundColor Cyan Write-Host "API will be available at: http://localhost:$port" -ForegroundColor Green Write-Host "API documentation at: http://localhost:$port/docs" -ForegroundColor Green Write-Host "" Write-Host "Press Ctrl+C to stop the server" -ForegroundColor Yellow Write-Host "" # Run the FastAPI application using uvicorn python -m uvicorn app:app --host 0.0.0.0 --port $port --reload