diff options
Diffstat (limited to 'doc/HOWTO.md')
| -rw-r--r-- | doc/HOWTO.md | 74 |
1 files changed, 42 insertions, 32 deletions
diff --git a/doc/HOWTO.md b/doc/HOWTO.md index f89d375..3746d65 100644 --- a/doc/HOWTO.md +++ b/doc/HOWTO.md @@ -136,18 +136,33 @@ Enhanced CNN with parametric static features (7D input: RGBD + UV + sin encoding **Complete Pipeline** (recommended): ```bash -# Train → Export → Build → Validate +# Train → Export → Build → Validate (default config) ./scripts/train_cnn_v2_full.sh -# With custom mip level for p0-p3 features -./scripts/train_cnn_v2_full.sh --mip-level 1 +# Custom training parameters +./scripts/train_cnn_v2_full.sh --epochs 500 --batch-size 32 --checkpoint-every 100 + +# Custom architecture +./scripts/train_cnn_v2_full.sh --kernel-sizes 3,5,3 --num-layers 3 --mip-level 1 + +# Grayscale loss (compute loss on luminance instead of RGBA) +./scripts/train_cnn_v2_full.sh --grayscale-loss + +# Custom directories +./scripts/train_cnn_v2_full.sh --input training/input --target training/target_2 + +# Full-image mode (instead of patch-based) +./scripts/train_cnn_v2_full.sh --full-image --image-size 256 + +# See all options +./scripts/train_cnn_v2_full.sh --help ``` -Config: 100 epochs, 3×3 kernels, 8→4→4 channels, patch-based (harris detector). +**Defaults:** 200 epochs, 3×3 kernels, 8→4→4 channels, batch-size 16, patch-based (8×8, harris detector). - Live progress with single-line update - Validates all input images on final epoch - Exports binary weights (storage buffer architecture) -- Mip level: 0 (default, original resolution) +- All parameters configurable via command-line **Validation Only** (skip training): ```bash @@ -176,6 +191,12 @@ Config: 100 epochs, 3×3 kernels, 8→4→4 channels, patch-based (harris detect --input training/input/ --target training/target_2/ \ --mip-level 1 \ --epochs 100 --batch-size 16 + +# Grayscale loss (compute loss on luminance Y = 0.299*R + 0.587*G + 0.114*B) +./training/train_cnn_v2.py \ + --input training/input/ --target training/target_2/ \ + --grayscale-loss \ + --epochs 100 --batch-size 16 ``` **Export Binary Weights:** @@ -243,40 +264,29 @@ See `doc/ASSET_SYSTEM.md` and `doc/WORKSPACE_SYSTEM.md`. ### Offline Shader Validation -**Note:** Tool builds and runs but produces incorrect output. Use CNNEffect visual validation in demo. See `doc/CNN_TEST_TOOL.md`. - ```bash -# Test trained CNN on PNG input -./build/cnn_test input.png output.png - -# Adjust blend amount (0.0 = original, 1.0 = full CNN) -./build/cnn_test input.png output.png --blend 0.5 +# CNN v2 (recommended, fully functional) +./build/cnn_test input.png output.png --cnn-version 2 -# PPM output format -./build/cnn_test input.png output.ppm --format ppm -``` +# CNN v2 with runtime weight loading (loads layer config from .bin) +./build/cnn_test input.png output.png --weights checkpoints/checkpoint_epoch_100.pth.bin -### Ground Truth Comparison -```bash -# Generate Python ground truth -./training/train_cnn.py --infer input.png \ - --export-only checkpoints/checkpoint_epoch_1000.pth \ - --output ground_truth.png +# CNN v1 (produces incorrect output, debug only) +./build/cnn_test input.png output.png --cnn-version 1 -# Run tool -./build/cnn_test input.png tool_output.png +# Adjust blend (0.0 = original, 1.0 = full CNN) +./build/cnn_test input.png output.png --cnn-version 2 --blend 0.5 -# Compare (Python required) -python3 -c " -import numpy as np -from PIL import Image -gt = np.array(Image.open('ground_truth.png').convert('RGB')) -out = np.array(Image.open('tool_output.png').convert('RGB')) -mse = np.mean((gt.astype(float) - out.astype(float)) ** 2) -print(f'MSE: {mse:.4f} (target: < 10.0)') -" +# Debug hex dump (first 8 pixels) +./build/cnn_test input.png output.png --cnn-version 2 --debug-hex ``` +**Status:** +- **CNN v2:** ✅ Fully functional, matches CNNv2Effect +- **CNN v1:** ⚠️ Produces incorrect output, use CNNEffect in demo for validation + +**Note:** `--weights` loads layer count and kernel sizes from the binary file, overriding `--layers` and forcing CNN v2. + See `doc/CNN_TEST_TOOL.md` for full documentation. --- |
