From ac334c8c92367b4baf2df4bd52430b95261b962d Mon Sep 17 00:00:00 2001 From: skal Date: Fri, 13 Feb 2026 16:43:55 +0100 Subject: CNN v2 full pipeline: Add --mip-level option Training pipeline now accepts --mip-level flag (0-3) and passes to train_cnn_v2.py. Compatible with all existing modes (train, validate, export-only). Changes: - Add --mip-level argument parsing (default: 0) - Pass MIP_LEVEL to training command - Display mip level in config output - Update help text with examples Usage: ./scripts/train_cnn_v2_full.sh --mip-level 1 Co-Authored-By: Claude Sonnet 4.5 --- scripts/train_cnn_v2_full.sh | 56 +++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/scripts/train_cnn_v2_full.sh b/scripts/train_cnn_v2_full.sh index 99c104a..6468d12 100755 --- a/scripts/train_cnn_v2_full.sh +++ b/scripts/train_cnn_v2_full.sh @@ -8,6 +8,7 @@ # --validate Validate only (skip training, use existing weights) # --validate CHECKPOINT Validate with specific checkpoint file # --export-only CHECKPOINT Export weights only (skip training, build, validation) +# --mip-level LEVEL Mip level for p0-p3 features: 0=original, 1=half, 2=quarter, 3=eighth (default: 0) # --help Show this help message # # Examples: @@ -15,6 +16,7 @@ # ./train_cnn_v2_full.sh --validate # ./train_cnn_v2_full.sh --validate checkpoints/checkpoint_epoch_50.pth # ./train_cnn_v2_full.sh --export-only checkpoints/checkpoint_epoch_100.pth +# ./train_cnn_v2_full.sh --mip-level 1 set -e @@ -26,25 +28,48 @@ VALIDATE_ONLY=false VALIDATE_CHECKPOINT="" EXPORT_ONLY=false EXPORT_CHECKPOINT="" +MIP_LEVEL=0 if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then - head -20 "$0" | grep "^#" | grep -v "^#!/" | sed 's/^# *//' + head -21 "$0" | grep "^#" | grep -v "^#!/" | sed 's/^# *//' exit 0 fi -if [ "$1" = "--export-only" ]; then - EXPORT_ONLY=true - if [ -z "$2" ]; then - echo "Error: --export-only requires a checkpoint file argument" - exit 1 - fi - EXPORT_CHECKPOINT="$2" -elif [ "$1" = "--validate" ]; then - VALIDATE_ONLY=true - if [ -n "$2" ]; then - VALIDATE_CHECKPOINT="$2" - fi -fi +# Parse all arguments +while [[ $# -gt 0 ]]; do + case "$1" in + --export-only) + EXPORT_ONLY=true + if [ -z "$2" ]; then + echo "Error: --export-only requires a checkpoint file argument" + exit 1 + fi + EXPORT_CHECKPOINT="$2" + shift 2 + ;; + --validate) + VALIDATE_ONLY=true + if [ -n "$2" ] && [[ ! "$2" =~ ^-- ]]; then + VALIDATE_CHECKPOINT="$2" + shift 2 + else + shift + fi + ;; + --mip-level) + if [ -z "$2" ]; then + echo "Error: --mip-level requires a level argument (0-3)" + exit 1 + fi + MIP_LEVEL="$2" + shift 2 + ;; + *) + echo "Unknown option: $1" + exit 1 + ;; + esac +done # Configuration INPUT_DIR="training/input" @@ -66,6 +91,7 @@ DETECTOR="harris" KERNEL_SIZES="3,3,3" # Comma-separated per-layer kernel sizes NUM_LAYERS=3 +# MIP_LEVEL set via --mip-level argument (default: 0) # Handle export-only mode if [ "$EXPORT_ONLY" = true ]; then @@ -102,6 +128,7 @@ else echo "Target: $TARGET_DIR" echo "Epochs: $EPOCHS" echo "Checkpoint interval: $CHECKPOINT_EVERY" + echo "Mip level: $MIP_LEVEL (p0-p3 features)" echo "" fi @@ -116,6 +143,7 @@ python3 training/train_cnn_v2.py \ --detector $DETECTOR \ --kernel-sizes $KERNEL_SIZES \ --num-layers $NUM_LAYERS \ + --mip-level $MIP_LEVEL \ --epochs $EPOCHS \ --batch-size $BATCH_SIZE \ --checkpoint-dir "$CHECKPOINT_DIR" \ -- cgit v1.2.3