diff --git a/js/brainchop/mainMeshNetFunctions.js b/js/brainchop/mainMeshNetFunctions.js
index cccce07..eca83e1 100644
--- a/js/brainchop/mainMeshNetFunctions.js
+++ b/js/brainchop/mainMeshNetFunctions.js
@@ -4260,9 +4260,13 @@ class SequentialConvLayer {
// console.log("---------------------------------------------------------");
console.log(" channel loop");
- let seqTimer = window.setInterval(function() {
+ let seqTimer = window.setInterval(async function() {
- console.log(chIdx);
+ console.log('=======================');
+ const memoryInfo0 = tf.memory();
+ console.log(`| Number of Tensors: ${memoryInfo0.numTensors}`);
+ console.log(`| Number of Data Buffers: ${memoryInfo0.numDataBuffers}`);
+ console.log("Channel : ", chIdx);
const result = tf.tidy(() => {
const filterWeights = weights.slice([0, 0, 0, 0, chIdx], [-1, -1, -1, -1, 1]);
@@ -4274,12 +4278,27 @@ class SequentialConvLayer {
const newoutB = tf.where(greater, outA, outB);
const newoutC = tf.where(greater, tf.fill(outC.shape, chIdx), outC);
// Dispose the old tensors before reassigning
- tf.dispose([outB, outC]);
+ tf.dispose([outB, outC, filterWeights, filterBiases, outA, greater]);
return [newoutC, newoutB];
});
// -- await showMemStatus(chIdx, self.outChannels);
+ const memoryInfo1 = tf.memory();
+ console.log(`| Number of Tensors: ${memoryInfo1.numTensors}`);
+ console.log(`| Number of Data Buffers: ${memoryInfo1.numDataBuffers}`);
+ console.log('=======================');
+
+ // Log memory usage
+
+ const memoryInfo = tf.memory();
+ console.log(`Iteration ${chIdx}:`);
+ console.log(`Number of Tensors: ${memoryInfo.numTensors}`);
+ console.log(`Number of Data Buffers: ${memoryInfo.numDataBuffers}`);
+ console.log(`Bytes In Use: ${memoryInfo.numBytes}`);
+ console.log(`Megabytes In Use: ${(memoryInfo.numBytes / 1048576).toFixed(3)} MB`);
+ console.log(`Unreliable: ${memoryInfo.unreliable}`);
+
// Assign the new values to outC and outB
outC = result[0];
outB = result[1];
@@ -4296,11 +4315,14 @@ class SequentialConvLayer {
} else {
chIdx++;
+
+ // Artificially introduce a pause to allow for garbage collection to catch up
+ await new Promise(resolve => setTimeout(resolve, 0));
document.getElementById("progressBarChild").style.width = (chIdx + 1)*100/self.outChannels + "%";
}
- }, 50);
+ }, 0);
});
}
diff --git a/js/brainchop/mainParameters.js b/js/brainchop/mainParameters.js
index 151d2d8..2d983df 100644
--- a/js/brainchop/mainParameters.js
+++ b/js/brainchop/mainParameters.js
@@ -178,7 +178,7 @@
enableCrop: true, // For speed-up inference, crop brain from background before feeding to inference model to lower memory use.
cropPadding: 2, // Padding size add to cropped brain
filterOutWithPreMask: false, // Can be used to multiply final output with premodel output mask to crean noisy areas
- enableSeqConv: false, // For low memory system and low configuration, enable sequential convolution instead of last layer
+ enableSeqConv: true, // For low memory system and low configuration, enable sequential convolution instead of last layer
textureSize: 13585, // Requested Texture size for the model, if unknown can be 0.
warning: "This model may need dedicated graphics card. For more info please check with Browser Resources .",
inferenceDelay: 100, // Delay in ms time while looping layers applying.
@@ -220,7 +220,7 @@
enableCrop: true, // For speed-up inference, crop brain from background before feeding to inference model to lower memory use.
cropPadding: 2, // Padding size add to cropped brain
filterOutWithPreMask: false, // Can be used to multiply final output with premodel output mask to crean noisy areas
- enableSeqConv: false, // For low memory system and low configuration, enable sequential convolution instead of last layer
+ enableSeqConv: true, // For low memory system and low configuration, enable sequential convolution instead of last layer
textureSize: 13585, // Requested Texture size for the model, if unknown can be 0.
warning: "This model may need dedicated graphics card. For more info please check with Browser Resources .",
inferenceDelay: 100, // Delay in ms time while looping layers applying.