File size: 3,080 Bytes
cfa2024
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
49
50
51
52
53
54
55
56
57
#!/bin/bash
# db: 8-camera data, round 1 (official validation 1,000 clips + supplement keyframes), after vlr_hub_fetch.py started.
# wait for the fetch -> one resumable retry pass -> devkit questions for val -> records + ego futures -> encode
# (shared GPU via gpu_hold / gpu_take) -> check every record has its latent and no frame was substituted -> delete
# the fetched images. HF_TOKEN must be set (retry pass).
cd /home/db/ThuongBui/localization/vlr
ulimit -n "$(ulimit -Hn)" 2>/dev/null
PY=/home/db/miniforge3/envs/locnet/bin/python
D=/mnt/10TB_HDD/nuReasoning/vlr
NUR=/mnt/10TB_HDD/nuReasoning
export NUR_WORK=$NUR/vljepa_testmatch/hub_tar_index
hold() {
    [ -f /tmp/vlr_gpu_hold.pid ] && kill -0 "$(cat /tmp/vlr_gpu_hold.pid)" 2>/dev/null && return
    rm -f /tmp/vlr_gpu_held /tmp/vlr_gpu_release
    nohup $PY gpu_hold.py 9000 >> gpu_hold.log 2>&1 & sleep 1
}
echo "$(date +%T) wait for fetch"
while pgrep -f "python vlr_hub_fetch.py --kind" > /dev/null || pgrep -f "bash inc_encode.sh" > /dev/null; do sleep 60; done
echo "$(date +%T) retry pass"
$PY vlr_hub_fetch.py --kind val --entries val_entries.txt --procs 2 --threads 32 --log hub_fetch_val_retry.jsonl > hub_fetch_val_retry.out 2>&1
$PY vlr_hub_fetch.py --kind supp --entries supp_entries.txt --procs 2 --threads 32 --log hub_fetch_supp_retry.jsonl > hub_fetch_supp_retry.out 2>&1
tail -1 hub_fetch_val_retry.out hub_fetch_supp_retry.out

echo "$(date +%T) questions (devkit generator)"
(cd /home/db/ThuongBui/localization/vljepa_testmatch && $PY tools/gen_vqa.py --data-root $NUR/data_val_official \
    --output $NUR/vqa_output_val_official --seed 42 --workers 12 > /home/db/ThuongBui/localization/vlr/gen_val.log 2>&1)
while pgrep -f "gen_vqa.py --data-root $NUR/data_supplement" > /dev/null; do sleep 30; done

echo "$(date +%T) records"
$PY vlr_build_hub.py --kind val --root $NUR/data_val_official --vqa $NUR/vqa_output_val_official || exit 1
$PY vlr_build_hub.py --kind supp --root $NUR/data_supplement_20261022 --vqa $NUR/vqa_output_supp_vlr || exit 1
$PY vlr_build_hub.py --kind egofut || exit 1

echo "$(date +%T) encode"
hold
$PY vlr_encode_local.py --splits val_off train_supp > encode_round1.log 2>&1
tail -2 encode_round1.log

echo "$(date +%T) check before deleting images"
$PY - <<'EOF' || { echo "check failed: images kept"; exit 1; }
import json, pickle, sys
from pathlib import Path
D = Path('/mnt/10TB_HDD/nuReasoning/vlr')
bad = 0
for s in ('val_off', 'train_supp'):
    recs = pickle.load(open(D / 'data' / f'{s}.pkl', 'rb'))
    miss = [r['kf_id'] for r in recs if not (D / 'cache' / s / f"{r['kf_id']}.npz").is_file()]
    sub = json.loads((D / f'missing_frames_{s}.json').read_text()) if (D / f'missing_frames_{s}.json').is_file() else {}
    print(s, len(recs), 'records,', len(miss), 'without latent,', len(sub), 'with substituted frames')
    bad += len(miss) + len(sub)
sys.exit(1 if bad else 0)
EOF
$PY vlr_hub_fetch.py --kind val --entries val_entries.txt --delete
$PY vlr_hub_fetch.py --kind supp --entries supp_entries.txt --delete
df -h /mnt/10TB_HDD | tail -1
echo DATA_DONE