From 56db38586ba34c30e884acac0bed82f80d5649af Mon Sep 17 00:00:00 2001 From: OrpheasK <45125993+OrpheasK@users.noreply.github.com> Date: Sat, 27 Jul 2024 18:19:30 -0400 Subject: [PATCH] topk fix --- src/ImageClassifier/index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ImageClassifier/index.js b/src/ImageClassifier/index.js index d9b0b85e..ff1c6f62 100644 --- a/src/ImageClassifier/index.js +++ b/src/ImageClassifier/index.js @@ -248,7 +248,7 @@ class ImageClassifier { "image", "No input image provided. If you want to classify a video, use classifyStart." ); - return callCallback(this.classifyInternal(image, number), callback); + return callCallback(this.classifyInternal(image, number || this.topk), callback); } /** @@ -269,10 +269,9 @@ class ImageClassifier { // Function to classify a single frame const classifyFrame = async () => { await mediaReady(image, true); - await this.classifyInternal(image, number); // call the callback function - callCallback(this.classifyInternal(image, number), callback); - + await callCallback(this.classifyInternal(image, number || this.topk), callback); + // call recursively for continuous classification if (!this.signalStop) { requestAnimationFrame(classifyFrame);