From d3d72f7b70e8f7d1f1ec0fb3030c447a8f876d8f Mon Sep 17 00:00:00 2001 From: skal Date: Fri, 13 Feb 2026 15:59:54 +0100 Subject: CNN v2 test tool: Add video playback support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Features: - Video file support (MP4, WebM, etc.) via drag-and-drop - Play/Pause button with non-realtime playback (drops frames if CNN slow) - Frame-by-frame navigation (◄/► step buttons) - Unified image/video processing through same CNN pipeline - Audio muted (video frames only) Optimizations: - Layer visualization updates only on pause/seek (~5-10ms saved per frame) Architecture: - copyExternalImageToTexture() works with both ImageBitmap and HTMLVideoElement - Video loading: wait for metadata → seek to frame 0 → wait for readyState≥2 (decoded) - Playback loop: requestAnimationFrame with isProcessing guard prevents overlapping inference - Controls always visible, disabled for images Co-Authored-By: Claude Sonnet 4.5 --- tools/cnn_v2_test/index.html | 188 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 166 insertions(+), 22 deletions(-) (limited to 'tools/cnn_v2_test/index.html') diff --git a/tools/cnn_v2_test/index.html b/tools/cnn_v2_test/index.html index cc045f1..95ec788 100644 --- a/tools/cnn_v2_test/index.html +++ b/tools/cnn_v2_test/index.html @@ -14,9 +14,19 @@ - weights.layers[] array: Layer 0 = weights.layers[0], Layer 1 = weights.layers[1] Features: + - Input: PNG images or video files (MP4, WebM, etc.) + - Video playback: Play/Pause, frame-by-frame navigation (◄/► buttons) + - Video mode: Non-realtime processing (drops frames if CNN slower than playback) - Side panel: .bin metadata display, weight statistics per layer - Layer inspection: 4-channel grayscale split, intermediate layer visualization - View modes: CNN output, original, diff (×10) + - Optimization: Layer viz updates only on pause/seek during video playback + + WGSL Shader Reuse: + - CNN_SHADER (inference), STATIC_SHADER, LAYER_VIZ_SHADER are inline for single-file deployment + - Can extract to .wgsl files for: better IDE support, testing, cross-tool reuse + - Tradeoff: extraction needs fetch() or build step, breaks single-file portability + - C++ sync: manual (WGSL ≠ GLSL) but logic identical --> @@ -67,6 +77,20 @@ background: #1a1a1a; border-radius: 4px; } + button { + background: #1a1a1a; + border: 1px solid #404040; + color: #e0e0e0; + padding: 6px 12px; + font-size: 12px; + font-family: 'Courier New', monospace; + cursor: pointer; + transition: all 0.2s; + border-radius: 4px; + } + button:hover { border-color: #606060; background: #252525; } + button:disabled { opacity: 0.3; cursor: not-allowed; } + video { display: none; } .drop-zone:hover { border-color: #606060; background: #252525; } .drop-zone.active { border-color: #4a9eff; background: #1a2a3a; } .drop-zone.error { border-color: #ff4a4a; background: #3a1a1a; } @@ -97,7 +121,7 @@ background: #1a1a1a; } .main.drop-active::after { - content: 'Drop PNG image here'; + content: 'Drop PNG/video here'; position: absolute; inset: 24px; display: flex; @@ -267,6 +291,11 @@

CNN v2 Testing Tool

+
+ + + +
@@ -282,6 +311,7 @@
+