|
|
#!/bin/bash |
|
|
|
|
|
set -e |
|
|
|
|
|
echo "π Deploying SAM3 to HuggingFace..." |
|
|
echo "" |
|
|
|
|
|
|
|
|
REGISTRY="sam3acr4hf.azurecr.io" |
|
|
IMAGE="sam3-hf:latest" |
|
|
ENDPOINT_NAME="sam3-segmentation" |
|
|
NAMESPACE="Logiroad" |
|
|
|
|
|
|
|
|
cd "$(dirname "$0")/../.." |
|
|
|
|
|
|
|
|
echo "[1/4] Building Docker image..." |
|
|
docker build -t ${REGISTRY}/${IMAGE} -f docker/Dockerfile . |
|
|
echo "β Build complete" |
|
|
echo "" |
|
|
|
|
|
|
|
|
echo "[2/4] Logging in to Azure Container Registry..." |
|
|
az acr login --name sam3acr4hf |
|
|
echo "β Login successful" |
|
|
echo "" |
|
|
|
|
|
|
|
|
echo "[3/4] Pushing image to registry..." |
|
|
docker push ${REGISTRY}/${IMAGE} |
|
|
echo "β Push complete" |
|
|
echo "" |
|
|
|
|
|
|
|
|
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" |
|
|
|