File size: 1,476 Bytes
179df43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a6d894c
 
179df43
a6d894c
 
 
179df43
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
#
# Fetch SAM3 pretrained weights from HuggingFace.
#
# The sam3 pip package downloads weights automatically via load_from_HF=True,
# so this script is only needed if you want to cache them locally or use
# checkpoint_path= instead.
#
# Overridable via env:
#   SAM3_WEIGHTS_DIR  default ./weights

set -euo pipefail

WEIGHTS_DIR="${SAM3_WEIGHTS_DIR:-./weights}"
mkdir -p "$WEIGHTS_DIR"

have() { [[ -s "$1" ]]; }

echo "Weights dir: $WEIGHTS_DIR"

# --- SAM3 pretrained checkpoint (HuggingFace)
# The sam3 package auto-downloads from HF when load_from_HF=True.
# If you need a local copy, use huggingface-cli:
echo ""
echo "The server resolves sam3.pt from facebook/sam3 (GATED - request access, then 'hf auth login')"
echo "at the pinned revision; to pre-cache it into your HF cache, run:"
echo "  pip install huggingface-hub"
echo "  hf download facebook/sam3 sam3.pt config.json --revision 3c879f39826c281e95690f02c7821c4de09afae7"
echo "For a fully offline host run, download into a directory and point SAM3_WEIGHTS_DIR at it:"
echo "  hf download facebook/sam3 sam3.pt --revision 3c879f39826c281e95690f02c7821c4de09afae7 --local-dir $WEIGHTS_DIR"
echo ""

# --- Sample test image
if have "$WEIGHTS_DIR/../media/source_1.png"; then
  echo "ok  media/source_1.png already present"
else
  echo "Sample images are included in the media/ directory."
fi

echo ""
echo "Done."
ls -lh "$WEIGHTS_DIR" 2>/dev/null || true