From 2adcf1bac1ec651861930eb2af00641eb23f6ef1 Mon Sep 17 00:00:00 2001 From: skal Date: Tue, 10 Feb 2026 22:54:38 +0100 Subject: docs: Update CNN training documentation with patch extraction Streamlined and updated all training docs with new patch-based approach. Changes: - HOWTO.md: Updated training section with patch/full-image examples - CNN_EFFECT.md: Streamlined training workflow, added detector info - training/README.md: Complete rewrite with detector comparison table New sections: - Detector comparison (harris, fast, shi-tomasi, gradient) - Practical examples for different use cases - Tips for patch size and batch size selection - Benefits of patch-based training Co-Authored-By: Claude Sonnet 4.5 --- doc/HOWTO.md | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'doc/HOWTO.md') diff --git a/doc/HOWTO.md b/doc/HOWTO.md index 5ea6afd..ba550bb 100644 --- a/doc/HOWTO.md +++ b/doc/HOWTO.md @@ -88,23 +88,40 @@ make run_util_tests # Utility tests ## Training +### Patch-Based (Recommended) +Extracts patches at salient points, preserves natural pixel scale: ```bash -./training/train_cnn.py --layers 3 --kernel_sizes 3,5,3 --epochs 10000 --batch_size 8 --input training/input/ --target training/output/ --checkpoint-every 1000 +# Train with 32×32 patches at detected corners/edges +./training/train_cnn.py \ + --input training/input/ --target training/output/ \ + --patch-size 32 --patches-per-image 64 --detector harris \ + --layers 3 --kernel_sizes 3,5,3 --epochs 5000 --batch_size 16 \ + --checkpoint-every 1000 ``` -Generate shaders from checkpoint: +**Detectors:** `harris` (default), `fast`, `shi-tomasi`, `gradient` + +### Full-Image (Legacy) +Resizes to 256×256 (distorts scale): ```bash -./training/train_cnn.py --export-only training/checkpoints/checkpoint_epoch_7000.pth +./training/train_cnn.py \ + --input training/input/ --target training/output/ \ + --layers 3 --kernel_sizes 3,5,3 --epochs 10000 --batch_size 8 \ + --checkpoint-every 1000 ``` -Generate ground truth (for shader validation): +### Export & Validation ```bash -./training/train_cnn.py --infer input.png --export-only checkpoints/checkpoint_epoch_7000.pth --output ground_truth.png +# Generate shaders from checkpoint +./training/train_cnn.py --export-only checkpoints/checkpoint_epoch_5000.pth + +# Generate ground truth for comparison +./training/train_cnn.py --infer input.png \ + --export-only checkpoints/checkpoint_epoch_5000.pth \ + --output ground_truth.png ``` -**Note:** Kernel sizes must match shader functions: -- 3×3 kernel → `cnn_conv3x3_7to4` (36 weights: 9 pos × 4 channels) -- 5×5 kernel → `cnn_conv5x5_7to4` (100 weights: 25 pos × 4 channels) +**Kernel sizes:** 3×3 (36 weights), 5×5 (100 weights), 7×7 (196 weights) --- -- cgit v1.2.3