Skip to content

Commit

Permalink
topk fix (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrpheasK authored Aug 22, 2024
1 parent f363340 commit e3a4ee7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/ImageClassifier/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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);
Expand Down

0 comments on commit e3a4ee7

Please sign in to comment.