File size: 1,548 Bytes
43abac3 | 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 | #!/bin/bash
# EcoPulse — Hugging Face Spaces build-time setup
# Downloads model checkpoints once at build time so they're cached on disk
# when users visit the Space. Runs automatically by HF Spaces during the
# build phase (not on every page visit).
set -e # Exit on error
echo ""
echo "================================================"
echo " EcoPulse — Build Setup"
echo "================================================"
echo ""
# Create models directory
mkdir -p outputs/models
# 1. Download SAM ViT-B checkpoint (350 MB)
SAM_CHECKPOINT="outputs/models/sam_vit_b_01ec64.pth"
SAM_URL="https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth"
if [ ! -f "$SAM_CHECKPOINT" ]; then
echo ">> Downloading SAM ViT-B checkpoint (350 MB)..."
curl -fL "$SAM_URL" -o "$SAM_CHECKPOINT"
echo ">> SAM checkpoint ready."
else
echo ">> SAM checkpoint already exists — skipping."
fi
# 2. Download trained CNN weights from Hugging Face
CNN_CHECKPOINT="outputs/models/resnet50_eurosat.pth"
CNN_URL="https://huggingface.co/datasets/acibZ/ecopulse-satellite-analysis-resnet50-model-weights/resolve/main/resnet50_eurosat.pth"
if [ ! -f "$CNN_CHECKPOINT" ]; then
echo ">> Downloading CNN weights (95 MB)..."
curl -fL "$CNN_URL" -o "$CNN_CHECKPOINT"
echo ">> CNN weights ready."
else
echo ">> CNN weights already exist — skipping."
fi
echo ""
echo "================================================"
echo " EcoPulse build setup complete."
echo "================================================"
echo ""
|