From 8465735da8f746b6c0f64c9192a2d4b05bbdf467 Mon Sep 17 00:00:00 2001 From: alganzory Date: Sat, 23 Mar 2024 00:53:47 +0300 Subject: [PATCH] fix bug: tensor memory leak on nsfw-only mode --- src/offscreen.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/offscreen.js b/src/offscreen.js index b9db837..32680b8 100644 --- a/src/offscreen.js +++ b/src/offscreen.js @@ -89,7 +89,11 @@ const runDetection = async (img, isVideo = false) => { detector.human.tf.dispose(tensor); return "nsfw"; } - if (!settings.shouldDetectGender()) return false; // no need to run gender detection if it's not enabled + if (!settings.shouldDetectGender()) + { + detector.human.tf.dispose(tensor); + return false; // no need to run gender detection if it's not enabled + } const predictions = await detector.humanModelClassify(tensor); // console.log("offscreen human result", predictions); detector.human.tf.dispose(tensor);