kope-repro-scripts / run_all.sh
Crocolil's picture
Upload folder using huggingface_hub
8518175 verified
Raw
History Blame Contribute Delete
3.07 kB
#!/usr/bin/env bash
set -euo pipefail
echo "=== [1/6] System deps ==="
apt-get update -qq && apt-get install -y -qq git >/dev/null
echo "=== [2/6] Clone official KoPE repo ==="
git clone --depth 1 https://github.com/microsoft/Neuro-inspired_Phase_Encoding.git /repo
cd /repo
echo "=== [3/6] Install python deps ==="
pip install -q --extra-index-url https://download.pytorch.org/whl/cu126 \
torch==2.7.1 torchvision==0.22.1 xformers==0.0.31
pip install -q fvcore omegaconf iopath submitit einops timm torchmetrics termcolor Pillow numpy pandas pyarrow huggingface_hub
python -c "import torch; print('CUDA available:', torch.cuda.is_available(), torch.cuda.get_device_name(0) if torch.cuda.is_available() else '')"
echo "=== [4/6] Download released checkpoints ==="
mkdir -p /ckpts
cd /ckpts
curl -sL -o base.zip https://github.com/microsoft/Neuro-inspired_Phase_Encoding/releases/download/v1.0.0/supervised_vitkope_base_patch16_in1k_300e.zip
curl -sL -o large.zip https://github.com/microsoft/Neuro-inspired_Phase_Encoding/releases/download/v1.0.0/supervised_vitkope_large_patch16_in1k_300e.zip
unzip -q base.zip -d base
unzip -q large.zip -d large
find /ckpts -maxdepth 2
echo "=== [5/6] Materialize ImageNet-1K val set (ImageFolder layout) ==="
mkdir -p /data/val
python /scripts/prepare_imagenet_val.py --out-dir /data/val --mapping-file /scripts/synset_mapping.txt
find /data/val -type f | wc -l
echo "=== [6/6] Run evaluations ==="
mkdir -p /output
echo "--- KoPE ViT-Base (released, 300ep supervised) ---"
python /repo/simdinov2/supervised/eval/eval.py \
--checkpoint /ckpts/base \
--imagenet-val /data/val \
--output-json /output/kope_base_results.json || echo "KOPE_BASE_EVAL_FAILED"
echo "--- KoPE ViT-Large (released, 300ep supervised) ---"
python /repo/simdinov2/supervised/eval/eval.py \
--checkpoint /ckpts/large \
--imagenet-val /data/val \
--output-json /output/kope_large_results.json || echo "KOPE_LARGE_EVAL_FAILED"
echo "--- Baseline DeiT-III ViT-Base (no KoPE, timm fb_in1k, 300ep) ---"
python /scripts/eval_baseline_timm.py \
--model-name deit3_base_patch16_224.fb_in1k \
--imagenet-val /data/val \
--output-json /output/baseline_base_results.json || echo "BASELINE_BASE_EVAL_FAILED"
echo "--- Baseline DeiT-III ViT-Large (no KoPE, timm fb_in1k, 300ep) ---"
python /scripts/eval_baseline_timm.py \
--model-name deit3_large_patch16_224.fb_in1k \
--imagenet-val /data/val \
--output-json /output/baseline_large_results.json || echo "BASELINE_LARGE_EVAL_FAILED"
echo "=== Collected results ==="
for f in /output/*.json; do echo "--- $f ---"; cat "$f"; echo; done
echo "=== Uploading results to HF dataset repo ==="
python -c "
from huggingface_hub import HfApi
api = HfApi()
api.create_repo('Crocolil/kope-repro-imagenet-eval-results', repo_type='dataset', exist_ok=True, private=True)
api.upload_folder(folder_path='/output', repo_id='Crocolil/kope-repro-imagenet-eval-results', repo_type='dataset')
print('uploaded results to hf.co/datasets/Crocolil/kope-repro-imagenet-eval-results')
"
echo "=== DONE ==="