From 7547e8ff4744339b92650b6ef3ff7405befe4beb Mon Sep 17 00:00:00 2001 From: skal Date: Thu, 12 Feb 2026 11:50:52 +0100 Subject: CNN v2: Patch-based training as default (like CNN v1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Salient point detection on original images with patch extraction. Changes: - Added PatchDataset class (harris/fast/shi-tomasi/gradient detectors) - Detects salient points on ORIGINAL images (no resize) - Extracts 32×32 patches around salient points - Default: 64 patches/image, harris detector - Batch size: 16 (512 patches per batch) Training modes: 1. Patch-based (default): --patch-size 32 --patches-per-image 64 --detector harris 2. Full-image (option): --full-image --image-size 256 Benefits: - Focuses training on interesting regions - Handles variable image sizes naturally - Matches CNN v1 workflow - Better convergence with limited data (8 images → 512 patches) Script updated: - train_cnn_v2_full.sh: Patch-based by default - Configuration exposed for easy switching Example: ./scripts/train_cnn_v2_full.sh # Patch-based # Edit script: uncomment FULL_IMAGE for resize mode Co-Authored-By: Claude Sonnet 4.5 --- scripts/train_cnn_v2_full.sh | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/train_cnn_v2_full.sh b/scripts/train_cnn_v2_full.sh index 119b788..4ddd9ac 100755 --- a/scripts/train_cnn_v2_full.sh +++ b/scripts/train_cnn_v2_full.sh @@ -14,8 +14,17 @@ CHECKPOINT_DIR="checkpoints" VALIDATION_DIR="validation_results" EPOCHS=10000 CHECKPOINT_EVERY=500 -BATCH_SIZE=8 -IMAGE_SIZE=256 +BATCH_SIZE=16 + +# Patch-based training (default) +PATCH_SIZE=32 +PATCHES_PER_IMAGE=64 +DETECTOR="harris" + +# Full-image training (alternative - uncomment to use) +# FULL_IMAGE="--full-image" +# IMAGE_SIZE=256 + KERNEL_SIZES="1 3 5" CHANNELS="16 8 4" @@ -31,13 +40,16 @@ echo "[1/4] Training CNN v2 model..." python3 training/train_cnn_v2.py \ --input "$INPUT_DIR" \ --target "$TARGET_DIR" \ - --image-size $IMAGE_SIZE \ + --patch-size $PATCH_SIZE \ + --patches-per-image $PATCHES_PER_IMAGE \ + --detector $DETECTOR \ --kernel-sizes $KERNEL_SIZES \ --channels $CHANNELS \ --epochs $EPOCHS \ --batch-size $BATCH_SIZE \ --checkpoint-dir "$CHECKPOINT_DIR" \ - --checkpoint-every $CHECKPOINT_EVERY + --checkpoint-every $CHECKPOINT_EVERY \ + $FULL_IMAGE if [ $? -ne 0 ]; then echo "Error: Training failed" -- cgit v1.2.3