File size: 2,016 Bytes
647f69c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b2e88b8
647f69c
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# Deploy SAM3 to HuggingFace Inference Endpoints
set -e

echo "πŸš€ Deploying SAM3 to HuggingFace..."
echo ""

# Configuration
REGISTRY="sam3acr4hf.azurecr.io"
IMAGE="sam3-hf:latest"
ENDPOINT_NAME="sam3-segmentation"
NAMESPACE="Logiroad"

# Navigate to project root
cd "$(dirname "$0")/../.."

# Step 1: Build Docker image
echo "[1/4] Building Docker image..."
docker build -t ${REGISTRY}/${IMAGE} -f docker/Dockerfile .
echo "βœ“ Build complete"
echo ""

# Step 2: Login to ACR
echo "[2/4] Logging in to Azure Container Registry..."
az acr login --name sam3acr4hf
echo "βœ“ Login successful"
echo ""

# Step 3: Push image
echo "[3/4] Pushing image to registry..."
docker push ${REGISTRY}/${IMAGE}
echo "βœ“ Push complete"
echo ""

# Step 4: Restart endpoint
echo "[4/4] Restarting HuggingFace endpoint..."
python3 << 'EOF'
from huggingface_hub import HfApi
import time

api = HfApi()
endpoint = api.get_inference_endpoint('sam3-segmentation', namespace='Logiroad')

print("  Pausing endpoint...")
endpoint.pause()
time.sleep(5)

print("  Resuming endpoint...")
endpoint.resume()

print("  Waiting for endpoint to be running...")
for i in range(60):
    endpoint = api.get_inference_endpoint('sam3-segmentation', namespace='Logiroad')
    if endpoint.status == 'running':
        print(f"  βœ“ Endpoint running after {i*5}s")
        break
    time.sleep(5)
else:
    print("  ⚠ Timeout waiting for endpoint")
EOF

echo ""
echo "════════════════════════════════════════════════════════════"
echo "βœ… HuggingFace Deployment Complete"
echo "════════════════════════════════════════════════════════════"
echo ""
echo "Endpoint: https://p6irm2x7y9mwp4l4.us-east-1.aws.endpoints.huggingface.cloud"
echo ""
echo "Test with:"
echo "  python3 scripts/test/test_api.py"