From bf8c088763eda14ff269f2152f1ff806bc545c90 Mon Sep 17 00:00:00 2001 From: skal Date: Fri, 13 Feb 2026 15:31:41 +0100 Subject: CNN v2 web tool: Major UI redesign with three-panel layout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UI Changes: - Three-panel layout: left (weights), center (canvas), right (activations) - Left sidebar: clickable weights drop zone, weights info, kernel visualization - Right sidebar: 4 small activation views + large 4× zoom view - Controls moved to header (inline with title) Weights Visualization: - Dedicated panel in left sidebar with layer buttons - 1 pixel per weight (was 20px) - All input channels horizontal, output channels stacked vertically - Renders to separate canvas (not in activation grid) Activation Viewer: - 4 channels in horizontal row (was 2×2 grid) - Mouse-driven zoom view below (32×32 area at 4× magnification) - Zoom shows all 4 channels in 2×2 quadrant layout - Removed activations/weights mode toggle State Preservation: - Blend changes preserve selected layer/channel - Fixed activation view reset bug Documentation: - Updated README with new layout and feature descriptions - Marked implemented features (weights viz, layer viewer) - Updated size estimates (~22 KB total) Co-Authored-By: Claude Sonnet 4.5 --- tools/cnn_v2_test/README.md | 94 ++++++---- tools/cnn_v2_test/index.html | 403 ++++++++++++++++++++++++++++--------------- 2 files changed, 322 insertions(+), 175 deletions(-) (limited to 'tools') diff --git a/tools/cnn_v2_test/README.md b/tools/cnn_v2_test/README.md index 2a8e08d..b9439e5 100644 --- a/tools/cnn_v2_test/README.md +++ b/tools/cnn_v2_test/README.md @@ -6,12 +6,14 @@ WebGPU-based browser tool for testing trained CNN v2 weights. ## Features -- Drag-drop PNG images and `.bin` weights +- Drag-drop PNG images and `.bin` weights (or click to browse) - Real-time CNN inference with WebGPU compute shaders - View modes: CNN output, original input, difference (×10) - Adjustable blend amount and depth - Data-driven pipeline (supports variable layer count) - GPU timing display +- **Left Panel:** Weights info + kernel visualization (1px/weight, all layers) +- **Right Panel:** Layer activation viewer with 4-channel split + 4× zoom --- @@ -41,28 +43,36 @@ python3 -m http.server 8000 ### 2. Load Data -1. **Drop PNG image** anywhere in window (shows preview immediately) -2. **Drop `.bin` weights** into header drop zone +1. **Drop `.bin` weights** into left sidebar zone (or click to browse) +2. **Drop PNG image** anywhere in center canvas area 3. CNN runs automatically when both loaded -### 3. Controls +### 3. Layout -**Sliders:** -- **Blend:** Mix between original (0.0) and CNN output (1.0) -- **Depth:** Uniform depth value for all pixels (0.0–1.0) +**Left Sidebar:** +- Weights drop zone (click or drag-drop `.bin` files) +- Weights info panel (layer specs, ranges, file size) +- Weights visualization (click Layer 0/1/2 buttons) + - 1 pixel per weight, all input channels horizontally + - Output channels (Out 0-3) stacked vertically + +**Center Canvas:** +- Main output view (CNN result, original, or diff) +- Keyboard: `SPACE` = original, `D` = diff (×10) -**Keyboard:** -- `SPACE` - Toggle original input view -- `D` - Toggle difference view (×10 amplification) +**Right Sidebar:** +- Layer selection buttons (Static 0-3/4-7, Layer 0/1/2) +- 4 small activation views (Ch0/1/2/3) in a row +- Large zoom view below (4× magnification, follows mouse) -**Status Bar:** -- Shows GPU timing (ms), image dimensions, and current view mode -- Red text indicates errors +**Header Controls:** +- **Blend:** Mix between original (0.0) and CNN output (1.0) +- **Depth:** Uniform depth value for all pixels (0.0–1.0) +- **View:** Current display mode -**Console Log:** -- Timestamped event log at bottom -- Tracks file loads, pipeline execution, errors -- Auto-scrolls to latest messages +**Footer:** +- Status: GPU timing (ms), image dimensions, view mode +- Console: Timestamped event log (file loads, errors) --- @@ -167,24 +177,32 @@ Open browser console (F12) for detailed errors. Common issues: --- +## Implemented Features + +**✓ Weights Metadata Panel:** +- Layer descriptions (kernel size, channels, weight count) +- Weight statistics (min/max per layer) +- File size and layer count + +**✓ Weights Visualization:** +- Per-layer kernel heatmaps (1px/weight) +- All input channels displayed horizontally +- Output channels stacked vertically +- Normalized grayscale display + +**✓ Layer Activation Viewer:** +- Static features (8D split into 0-3 and 4-7 views) +- All CNN layer outputs (Layer 0/1/2...) +- 4-channel split view (grayscale per channel) +- Mouse-driven 4× zoom view + ## TODO -**Side Panel (Right):** -- Display .bin content metadata: - - Layer descriptions (kernel size, channels, weight count) - - Weight statistics (min/max/mean per layer) - - Weight heatmap visualization - - Binary format validation status - - Memory usage breakdown - -**Layer Inspection Views:** -- Split R/G/B/A plane visualization -- Intermediate layer output display: - - View static features (8D packed as heatmaps) - - View layer 0 output (before activation) - - View layer 1 output - - Toggle between channels -- Activation heatmaps (where neurons fire) +**Future Enhancements:** +- Weight distribution histograms per layer +- Activation statistics (min/max/mean overlay) +- Side-by-side diff mode (browser vs C++ output) +- Export rendered layers as PNG --- @@ -213,13 +231,15 @@ Planned enhancements: ## Size -- HTML structure: ~1 KB -- CSS styling: ~1 KB -- JavaScript logic: ~5 KB +- HTML structure: ~2 KB +- CSS styling: ~2 KB +- JavaScript logic: ~10 KB (includes zoom + weights viz) - Static shader: ~1 KB - CNN shader: ~3 KB - Display shader: ~1 KB -- **Total: ~12 KB** (single file, no dependencies) +- Layer viz shader: ~2 KB +- Zoom shader: ~1 KB +- **Total: ~22 KB** (single file, no dependencies) --- diff --git a/tools/cnn_v2_test/index.html b/tools/cnn_v2_test/index.html index 91f7942..cc045f1 100644 --- a/tools/cnn_v2_test/index.html +++ b/tools/cnn_v2_test/index.html @@ -37,8 +37,12 @@ background: #2a2a2a; padding: 16px; border-bottom: 1px solid #404040; + display: flex; + align-items: center; + gap: 24px; + flex-wrap: wrap; } - h1 { font-size: 18px; margin-bottom: 12px; } + h1 { font-size: 18px; } .controls { display: flex; gap: 16px; @@ -60,7 +64,8 @@ cursor: pointer; transition: all 0.2s; font-size: 12px; - margin-top: 12px; + background: #1a1a1a; + border-radius: 4px; } .drop-zone:hover { border-color: #606060; background: #252525; } .drop-zone.active { border-color: #4a9eff; background: #1a2a3a; } @@ -69,6 +74,17 @@ flex: 1; display: flex; overflow: hidden; + gap: 1px; + background: #404040; + } + .left-sidebar { + width: 300px; + background: #2a2a2a; + overflow-y: auto; + display: flex; + flex-direction: column; + gap: 16px; + padding: 16px; } .main { flex: 1; @@ -78,6 +94,7 @@ padding: 24px; overflow: auto; position: relative; + background: #1a1a1a; } .main.drop-active::after { content: 'Drop PNG image here'; @@ -94,9 +111,8 @@ z-index: 10; } .sidebar { - width: 350px; + width: 400px; background: #2a2a2a; - border-left: 1px solid #404040; overflow-y: auto; display: flex; flex-direction: column; @@ -175,8 +191,9 @@ } .layer-grid { display: grid; - grid-template-columns: 1fr 1fr; - gap: 8px; + grid-template-columns: repeat(4, 1fr); + gap: 4px; + margin-bottom: 12px; } .layer-view { aspect-ratio: 1; @@ -186,6 +203,18 @@ flex-direction: column; overflow: hidden; } + .layer-zoom { + background: #1a1a1a; + border: 1px solid #404040; + display: flex; + flex-direction: column; + overflow: hidden; + } + .layer-zoom canvas { + width: 100%; + height: 100%; + image-rendering: pixelated; + } .layer-view-label { background: #2a2a2a; padding: 4px; @@ -252,9 +281,27 @@ CNN Output -
Drop .bin Weights
+
@@ -265,14 +312,6 @@

Load image + weights

-
-
- Weights Info -
-
-

No weights loaded

-
-