#!/usr/bin/env bash # One-command setup: venv + deps + model weights (~1.8 GB from HuggingFace). # ./setup.sh modern GPU (sm_70+, CUDA 12.x) or CPU # ./setup.sh --pascal Pascal/Maxwell/Volta cards (GTX 9/10, TITAN, V100): # pins torch 2.6.0+cu124, the last wheels shipping # sm_61 kernels # ./setup.sh --skip-weights keep existing weights/ set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" PASCAL=0; SKIP_WEIGHTS=0 for a in "$@"; do case "$a" in --pascal) PASCAL=1 ;; --skip-weights) SKIP_WEIGHTS=1 ;; *) echo "unknown flag: $a"; exit 1 ;; esac done command -v python3 >/dev/null || { echo "python3 required (3.10+)"; exit 1; } python3 -c 'import sys; assert sys.version_info >= (3, 10)' || { echo "python >= 3.10 required"; exit 1; } echo "== venv" [[ -d .venv ]] || python3 -m venv .venv .venv/bin/pip install -q --upgrade pip echo "== torch" if [[ $PASCAL == 1 ]]; then .venv/bin/pip install -q torch==2.6.0 torchvision==0.21.0 \ --index-url https://download.pytorch.org/whl/cu124 else .venv/bin/pip install -q torch torchvision fi echo "== rest of requirements (a few minutes)" .venv/bin/pip install -q -r requirements.txt if [[ $SKIP_WEIGHTS == 0 ]]; then echo "== weights (~1.8 GB from huggingface.co/microsoft/OmniParser-v2.0)" mkdir -p weights/icon_caption_florence weights/icon_detect_v3 base=https://huggingface.co/microsoft/OmniParser-v2.0/resolve/main curl -fSL --retry 3 -o weights/icon_caption_florence/config.json "$base/icon_caption/config.json" curl -fSL --retry 3 -o weights/icon_caption_florence/generation_config.json "$base/icon_caption/generation_config.json" curl -fSL --retry 3 -o weights/icon_caption_florence/model.safetensors "$base/icon_caption/model.safetensors" # YOLOv9-E icon detector (upstream recommends the icon_detect_v3 revision) curl -fSL --retry 3 -o weights/icon_detect_v3/model.pt \ "https://huggingface.co/microsoft/OmniParser-v2.0/resolve/refs%2Fpr%2F37/icon_detect_v3/model.pt" fi .venv/bin/python - <<'EOF' import torch print(f"torch {torch.__version__} cuda={torch.cuda.is_available()}" + (f" device={torch.cuda.get_device_name(0)} arch={torch.cuda.get_device_capability(0)}" if torch.cuda.is_available() else " (CPU only - parses will be slow)")) EOF echo echo "done. next:" echo " ./start.sh # start the service (health-checked, self-tested)" echo " then register the MCP tool in your harness (README: 'MCP registration')"