Spaces:
Sleeping
Sleeping
| # ============================================================================= | |
| # docker-entrypoint.sh — GeoVision-CLIP Cali | |
| # Descarga checkpoints desde HF Dataset, luego arranca el servidor | |
| # ============================================================================= | |
| set -e | |
| echo "=== GeoVision-CLIP Backend — Entrypoint ===" | |
| echo "Mode: $MODE" | |
| echo "Device: $DEVICE" | |
| CHECKPOINT_DIR="/app/backend/checkpoints" | |
| mkdir -p "$CHECKPOINT_DIR/sae_modelo_final" | |
| mkdir -p "$CHECKPOINT_DIR/sit3_convlstm_weights" | |
| python3 -c " | |
| import os, urllib.request, sys | |
| CHECKPOINT_DIR = '/app/backend/checkpoints' | |
| TOKEN = os.environ.get('HF_TOKEN', '') | |
| BASE_URL = 'https://huggingface.co/datasets/nicothinoo/geovision-cali-checkpoints/resolve/main' | |
| FILES = [ | |
| ('sae_modelo_final/sae_best.pt', f'{BASE_URL}/sae_modelo_final/sae_best.pt'), | |
| ('sit3_convlstm_weights/best.ckpt', f'{BASE_URL}/sit3_convlstm_weights/best.ckpt'), | |
| ] | |
| for rel_path, url in FILES: | |
| dest = os.path.join(CHECKPOINT_DIR, rel_path) | |
| if os.path.exists(dest): | |
| print(f' Ya existe: {rel_path}') | |
| continue | |
| os.makedirs(os.path.dirname(dest), exist_ok=True) | |
| print(f' Descargando {rel_path} ...') | |
| req = urllib.request.Request(url) | |
| if TOKEN: | |
| req.add_header('Authorization', f'Bearer {TOKEN}') | |
| try: | |
| with urllib.request.urlopen(req, timeout=120) as resp: | |
| with open(dest, 'wb') as f: | |
| f.write(resp.read()) | |
| size = os.path.getsize(dest) / 1e6 | |
| print(f' OK {rel_path} ({size:.1f} MB)') | |
| except Exception as e: | |
| print(f' Fallo {rel_path}: {e}') | |
| print(f' ERROR: No se pudo descargar {rel_path}') | |
| " | |
| # DAGMA data (desde el mismo dataset) | |
| DAGMA_DEST="/app/backend/checkpoints/DAGMA_con_Acopi_NO2.parquet" | |
| if [ ! -f "$DAGMA_DEST" ]; then | |
| echo " Descargando DAGMA datos ..." | |
| python3 -c " | |
| import urllib.request, os | |
| TOKEN = os.environ.get('HF_TOKEN', '') | |
| url = 'https://huggingface.co/datasets/nicothinoo/geovision-cali-checkpoints/resolve/main/DAGMA_con_Acopi_NO2.parquet' | |
| dest = '$DAGMA_DEST' | |
| req = urllib.request.Request(url) | |
| if TOKEN: | |
| req.add_header('Authorization', f'Bearer {TOKEN}') | |
| try: | |
| with urllib.request.urlopen(req, timeout=120) as resp: | |
| with open(dest, 'wb') as f: | |
| f.write(resp.read()) | |
| size = os.path.getsize(dest) / 1e6 | |
| print(f' OK DAGMA ({size:.1f} MB)') | |
| except Exception as e: | |
| print(f' Fallo DAGMA: {e}') | |
| " 2>&1 | |
| fi | |
| echo "=== Iniciando servidor ===" | |
| exec "$@" | |