#!/usr/bin/env bash
# Create the dedicated SAM 3 runtime used by backend/services/sam3_external_worker.py.
# Keep Hugging Face tokens outside this repository, for example:
#   export HF_TOKEN=...
#   huggingface-cli login --token "$HF_TOKEN"

set -euo pipefail

ENV_NAME="${SAM3_CONDA_ENV:-sam3}"

source /home/wkmgc/miniconda3/etc/profile.d/conda.sh

if ! conda env list | awk '{print $1}' | grep -qx "$ENV_NAME"; then
  conda create -y -n "$ENV_NAME" python=3.12
fi

conda activate "$ENV_NAME"
python -m pip install --upgrade pip
python -m pip install "setuptools<81"
python -m pip install torch==2.10.0 torchvision --index-url https://download.pytorch.org/whl/cu128
python -m pip install opencv-python pillow numpy huggingface_hub einops pycocotools psutil
python -m pip install git+https://github.com/facebookresearch/sam3.git

python /home/wkmgc/Desktop/Seg_Server/backend/services/sam3_external_worker.py --status
