| | #!/bin/bash |
| | |
| | set -e |
| |
|
| | |
| | GREEN='\033[0;32m' |
| | BLUE='\033[0;34m' |
| | YELLOW='\033[1;33m' |
| | NC='\033[0m' |
| |
|
| | echo -e "${BLUE}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}" |
| | echo -e "${BLUE}β SAM3 Dual Deployment Script β${NC}" |
| | echo -e "${BLUE}β HuggingFace + Azure AI Foundry β${NC}" |
| | echo -e "${BLUE}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}" |
| | echo "" |
| |
|
| | |
| | HF_REGISTRY="sam3acr4hf.azurecr.io" |
| | HF_IMAGE="sam3-hf:latest" |
| | AZURE_REGISTRY="sam3acr.azurecr.io" |
| | AZURE_IMAGE="sam3-foundry:latest" |
| |
|
| | |
| | DEPLOY_HF=false |
| | DEPLOY_AZURE=false |
| |
|
| | while [[ $# -gt 0 ]]; do |
| | case $1 in |
| | --hf) |
| | DEPLOY_HF=true |
| | shift |
| | ;; |
| | --azure) |
| | DEPLOY_AZURE=true |
| | shift |
| | ;; |
| | --all) |
| | DEPLOY_HF=true |
| | DEPLOY_AZURE=true |
| | shift |
| | ;; |
| | --help) |
| | echo "Usage: ./deploy_all.sh [options]" |
| | echo "" |
| | echo "Options:" |
| | echo " --hf Deploy to HuggingFace only" |
| | echo " --azure Deploy to Azure AI Foundry only" |
| | echo " --all Deploy to both platforms" |
| | echo " --help Show this help message" |
| | echo "" |
| | echo "Examples:" |
| | echo " ./deploy_all.sh --hf # Deploy to HuggingFace" |
| | echo " ./deploy_all.sh --azure # Deploy to Azure AI Foundry" |
| | echo " ./deploy_all.sh --all # Deploy to both" |
| | exit 0 |
| | ;; |
| | *) |
| | echo "Unknown option: $1" |
| | echo "Use --help for usage information" |
| | exit 1 |
| | ;; |
| | esac |
| | done |
| |
|
| | |
| | if [ "$DEPLOY_HF" = false ] && [ "$DEPLOY_AZURE" = false ]; then |
| | echo -e "${YELLOW}No deployment target specified. Defaulting to HuggingFace.${NC}" |
| | echo -e "${YELLOW}Use --all to deploy to both platforms.${NC}" |
| | echo "" |
| | DEPLOY_HF=true |
| | fi |
| |
|
| | |
| | echo -e "${BLUE}[1/4] Building Docker image...${NC}" |
| | docker build -t sam3:latest -f docker/Dockerfile . |
| | echo -e "${GREEN}β Build complete${NC}" |
| | echo "" |
| |
|
| | |
| | if [ "$DEPLOY_HF" = true ]; then |
| | echo -e "${BLUE}[2/4] Deploying to HuggingFace...${NC}" |
| |
|
| | |
| | docker tag sam3:latest ${HF_REGISTRY}/${HF_IMAGE} |
| | echo " Tagged: ${HF_REGISTRY}/${HF_IMAGE}" |
| |
|
| | |
| | echo " Logging in to HuggingFace ACR..." |
| | az acr login --name sam3acr4hf |
| |
|
| | |
| | echo " Pushing to HuggingFace ACR..." |
| | docker push ${HF_REGISTRY}/${HF_IMAGE} |
| |
|
| | echo -e "${GREEN}β HuggingFace deployment complete${NC}" |
| | echo "" |
| | else |
| | echo -e "${YELLOW}[2/4] Skipping HuggingFace deployment${NC}" |
| | echo "" |
| | fi |
| |
|
| | |
| | if [ "$DEPLOY_AZURE" = true ]; then |
| | echo -e "${BLUE}[3/4] Deploying to Azure AI Foundry...${NC}" |
| |
|
| | |
| | docker tag sam3:latest ${AZURE_REGISTRY}/${AZURE_IMAGE} |
| | echo " Tagged: ${AZURE_REGISTRY}/${AZURE_IMAGE}" |
| |
|
| | |
| | echo " Logging in to Azure ACR..." |
| | az acr login --name sam3acr |
| |
|
| | |
| | echo " Pushing to Azure ACR..." |
| | docker push ${AZURE_REGISTRY}/${AZURE_IMAGE} |
| |
|
| | echo -e "${GREEN}β Azure AI Foundry image pushed${NC}" |
| | echo -e "${YELLOW} β Note: Azure AI Foundry endpoint deployment pending GPU quota${NC}" |
| | echo -e "${YELLOW} β See DEPLOYMENT.md for endpoint deployment instructions${NC}" |
| | echo "" |
| | else |
| | echo -e "${YELLOW}[3/4] Skipping Azure AI Foundry deployment${NC}" |
| | echo "" |
| | fi |
| |
|
| | |
| | echo -e "${BLUE}[4/4] Deployment Summary${NC}" |
| | echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ" |
| |
|
| | if [ "$DEPLOY_HF" = true ]; then |
| | echo -e "${GREEN}β
HuggingFace:${NC}" |
| | echo " Registry: ${HF_REGISTRY}" |
| | echo " Image: ${HF_IMAGE}" |
| | echo " Endpoint: https://p6irm2x7y9mwp4l4.us-east-1.aws.endpoints.huggingface.cloud" |
| | echo "" |
| | echo " Restart endpoint with:" |
| | echo " python3 -c 'from huggingface_hub import HfApi; api = HfApi(); e = api.get_inference_endpoint(\"sam3-segmentation\", namespace=\"Logiroad\"); e.pause(); e.resume()'" |
| | echo "" |
| | fi |
| |
|
| | if [ "$DEPLOY_AZURE" = true ]; then |
| | echo -e "${YELLOW}β³ Azure AI Foundry:${NC}" |
| | echo " Registry: ${AZURE_REGISTRY}" |
| | echo " Image: ${AZURE_IMAGE}" |
| | echo " Status: Image ready, endpoint deployment pending GPU quota" |
| | echo "" |
| | echo " Once GPU quota is approved, deploy with:" |
| | echo " az ml online-endpoint create --name sam3-foundry ..." |
| | echo " See DEPLOYMENT.md for complete instructions" |
| | echo "" |
| | fi |
| |
|
| | echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ" |
| | echo -e "${GREEN}β Deployment complete!${NC}" |
| | echo "" |
| | echo "Test the deployment:" |
| | echo " python3 scripts/test/test_api.py" |
| | echo "" |
| | echo "For more information:" |
| | echo " cat README.md # HuggingFace usage" |
| | echo " cat docs/DEPLOYMENT.md # Dual deployment guide" |
| |
|