From 1b760f3b413d28652965a51f629d3c2b8d33ce22 Mon Sep 17 00:00:00 2001 From: skal Date: Sat, 14 Feb 2026 01:01:52 +0100 Subject: Fix --mix option: blend prev layer with static p4-p7, not p0-p3 Updated gen_identity_weights.py --mix mode to use static features p4-p7 (uv_x, uv_y, sin20_y, bias) at channels 8-11 instead of p0-p3 (RGB+D) at channels 4-7. Before: 0.5*prev[i] + 0.5*static_p{i} (channels 4-7) After: 0.5*prev[i] + 0.5*static_p{4+i} (channels 8-11) Co-Authored-By: Claude Sonnet 4.5 --- training/diagnose_255_to_253.md | 69 ----------------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 training/diagnose_255_to_253.md (limited to 'training/diagnose_255_to_253.md') diff --git a/training/diagnose_255_to_253.md b/training/diagnose_255_to_253.md deleted file mode 100644 index 764d328..0000000 --- a/training/diagnose_255_to_253.md +++ /dev/null @@ -1,69 +0,0 @@ -# Diagnosis: 255 → 253 Loss (-2 LSBs) - -## Findings - -### F16 Precision -✅ **No loss:** 1.0 → f16(0x3c00) → 1.0 (exact round-trip) - -### Visualization Scale -⚠️ **Inconsistent:** -- Layer 1 uses `vizScale = 0.5` (line 1530) -- Should render as 128, not 253 -- **User seeing 253 suggests viewing Static Features (scale=1.0), not CNN output** - -### Suspected Issue: Input Alpha Channel - -**Code:** `tools/cnn_v2_test/index.html` line 1233 -```javascript -depthData[i] = pixels[i * 4 + 3] / 255.0; // Alpha from canvas -``` - -**Hypothesis:** Input PNG alpha channel = 253 (not 255) -- Browsers may set alpha < 255 for certain images -- Pre-multiplied alpha corrections -- PNG encoder compression artifacts - -### Test - -**Check input alpha:** -```javascript -// In HTML tool console: -const canvas = document.createElement('canvas'); -canvas.width = tester.image.width; -canvas.height = tester.image.height; -const ctx = canvas.getContext('2d'); -ctx.drawImage(tester.image, 0, 0); -const imgData = ctx.getImageData(0, 0, canvas.width, canvas.height); -const alpha = imgData.data[3]; // First pixel alpha -console.log('First pixel alpha:', alpha); -``` - -### Alternative: C++ Reference - -Check if `cnn_test` tool produces same -2 loss: -```bash -# Generate solid white 8×8 test image with alpha=255 -python3 -c " -from PIL import Image -import numpy as np -img = np.ones((8, 8, 4), dtype=np.uint8) * 255 -Image.fromarray(img, 'RGBA').save('test_white_255.png') -print('Created test_white_255.png: all pixels RGBA=(255,255,255,255)') -" - -# Test with HTML tool → check if p3 = 1.0 or 0.9921875 -# Test with cnn_test → compare output -./build/cnn_test test_white_255.png output.png --cnn-version 2 --debug-hex -``` - -### Next Steps - -1. **Verify input:** Check alpha channel of user's input image -2. **Add debug:** Log first pixel RGBA values in HTML tool -3. **Compare:** Run same image through C++ cnn_test -4. **Isolate:** Test with synthetic 255 alpha image - -## Conclusion - -**Most likely:** Input image alpha ≠ 255, already 253 before CNN processing. -**Verify:** User should check input PNG metadata and alpha channel values. -- cgit v1.2.3