ViewingSoundPAQ / runners /run_final_cv.sh
xiaohaoy's picture
Scene-type figure on the final pairs
274f87c verified
Raw History Blame Contribute Delete
3.07 kB
#!/usr/bin/env bash
# 10-fold CV of the final model (kernel ridge on SigLIP 2 giant + PE-Core bigG, kernel ridge spread model for the 80%
# range) on the combined revision, then the scene-type check and the hardest held-out photos. Every step resumes.
# Options: --revision NAME (combined revision; default ..._allnew_ref40_usotw4) --compare-with DIR (an earlier CV
# output to compare against, paired over place groups) --device cuda --python python
set -euo pipefail
cd "$(dirname "$0")/.."; source scripts/common/lib.sh
REVISION="urbansas_whole_yfcc_binaural_v1_yfcc_nogeo_b0_21105_allnew_ref40_usotw4"; COMPARE_WITH=""
parse_args "$@"
rev="runs_main_all_datasets/direct_aq_dataset_gain/$REVISION"
cache="runs_main_all_datasets/photo_aqnet/$REVISION/feature_cache.npz"
out=runs_main_all_datasets/cv_final
need "$rev/metadata_manifest.csv" "$cache" data/final_split/final_pairs.csv
# folds and pairs of the final model for the available datasets (data/final_split/final_pairs.csv)
[[ -e "$rev/cv_folds_final_allscored.csv" ]] || run "1 Folds, training pairs and scored pairs" \
scripts/data_preparation/assemble/apply_final_split.py --revision-dir "$rev"
if [[ ! -e "$out/range_predictions.csv" ]]; then
run "2 10-fold CV (point + 80% range)" scripts/model/train_test/compare_ranges.py --manifest "$rev/metadata_manifest.csv" --cache "$cache" \
--folds "$rev/cv_folds_final_allscored.csv" --train-exclude-views "$rev/train_exclude_final.csv" \
--method ours_krr_siglip_pe --point krr_rbf --spread krr --save-predictions --device "$DEVICE" \
--report-exclude-datasets sonicurban open_sipset_v2 eth_binaural_zurich taiwan_linebot --output-dir "$out" \
${EXTRA[@]+"${EXTRA[@]}"}
fi
run "2b Full report: every dataset, original datasets, all pooled, per AQ" scripts/model/train_test/report_cv_all.py "$out" \
--score-views "$rev/score_views_final.csv"
run "3 Scene types and transient events (segmentation groups, not a model input)" scripts/model/evaluation/scene_type_validation.py \
--predictions "$out/range_predictions.csv" --manifest "$rev/metadata_manifest.csv" --score-views "$rev/score_views_final.csv" \
--output "$out/scene_type_validation.json"
run "3b Scene-type figure" scripts/model/evaluation/plot_scene_contrasts.py --validation "$out/scene_type_validation.json" \
--output docs/figures/scene_type_contrasts.png
run "3c Place-level average figure" scripts/model/evaluation/plot_place_average.py --predictions "$out/range_predictions.csv" \
--manifest "$rev/metadata_manifest.csv" --score-views "$rev/score_views_final.csv" --output docs/figures/place_average
run "4 Hardest held-out photos" scripts/model/evaluation/plot_hard_examples.py --predictions "$out/range_predictions.csv" \
--manifest "$rev/metadata_manifest.csv" --output reports/figures/fig_hard_examples
if [[ -n "$COMPARE_WITH" ]]; then
run "5 Paired comparison with $COMPARE_WITH" scripts/model/train_test/compare_cv_runs.py "$COMPARE_WITH/range_predictions.csv" "$out/range_predictions.csv"
fi
ok "Done: $out"