From ba224677cbd183f6e5e592c58162383e18e8e7c7 Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 22 Mar 2026 16:42:20 +0100 Subject: fix(cnn_v3/tools): refresh zoom canvas when new sample is loaded --- cnn_v3/tools/tester.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'cnn_v3/tools') diff --git a/cnn_v3/tools/tester.js b/cnn_v3/tools/tester.js index 4286060..c1eb9f0 100644 --- a/cnn_v3/tools/tester.js +++ b/cnn_v3/tools/tester.js @@ -385,6 +385,7 @@ class CNNv3Tester { this.layerTextures={feat0:f0,feat1:f1,enc0:e0,enc1:e1,bn,dec1:d1,output:ot}; this.lastResult={ot,itex:this.inputTex,uDp,dispPL:this.getDisp(),w,h}; this.updateVizPanel(); + this.refreshZoom(); } destroyLayerTex(){for(const t of Object.values(this.layerTextures||{}))try{t.destroy();}catch(_){} this.layerTextures={};} @@ -492,6 +493,7 @@ class CNNv3Tester { if (!def || !tex || !this.device) return; const wrap = document.getElementById('chzoomWrap'); const lbl = document.getElementById('chzoomLbl'); + this.activeZoom = {layerId, ch, label}; lbl.textContent = label; wrap.style.display = 'flex'; // Wait for layout so clientWidth/clientHeight reflect the flex-distributed size @@ -521,6 +523,13 @@ class CNNv3Tester { }); } + refreshZoom() { + if (this.activeZoom) { + const {layerId, ch, label} = this.activeZoom; + this.zoomChannel(layerId, ch, label); + } + } + // ── Save PNG ───────────────────────────────────────────────────────────── async savePNG() { @@ -787,6 +796,7 @@ class CNNv3Tester { this.layerTextures = {feat0:f0, feat1:f1, enc0:e0, enc1:e1, bn, dec1:d1, output:ot}; this.lastResult = {ot, itex:this.inputTex, uDp, dispPL:this.getDisp(), w, h}; this.updateVizPanel(); + this.refreshZoom(); const ms = (performance.now()-t0).toFixed(1); document.getElementById('cnnLabel').textContent = `CNN output (${ms}ms)`; -- cgit v1.2.3