Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

topk in the options for imageClassifier doesn't work #166

Open
jackbdu opened this issue Jul 11, 2024 · 3 comments
Open

topk in the options for imageClassifier doesn't work #166

jackbdu opened this issue Jul 11, 2024 · 3 comments

Comments

@jackbdu
Copy link

jackbdu commented Jul 11, 2024

In [email protected], when initializing the imageClassifier object, passing { topk: 5 } as options does not seem to affect the number of labels to return. On the other hand, specifying kNumber works fine when calling imageClassifier.classifyStart(media, ?kNumber, callback);

Tagging relevant issues/PRs for reference: #71 #83

@shiffman
Copy link
Member

Thank you @jackbdu for pointing this out! Tagging @OrpheasK who worked on the original implementation to check the code.

I additionally wonder how universally understood or clear topk is? It is documented as "The number of top predictions to return, applicable to MobileNet."

Should we consider our own name here (like we use "confidence" instead of "score" across all models) or is topk sufficient? We could also consider a glossary entry.

@OrpheasK
Copy link
Collaborator

I looked into this and while there is a simple workaround to correct it and have the topk parameter actually apply to the number of classes, maybe it is a chance to address the first issue of #83 raised by @lindapaiste an mentioned here. The topk parameter can only currently apply to MobileNet and is overridden by kNumber.

Since it is correctly documented in the website, correcting the issue (and perhaps renaming the parameter @shiffman) is a simple solution, we might also consider however which parameter to make the universal one for choosing the number of classes.

@shiffman
Copy link
Member

This has now been addressed in #179, I've tested this with the imageClassifier-webcam example, adding the argument to classifyStart() produces the desired result:

// Get the top 25 labels
classifier.classifyStart(video, 25, gotResult);

Should an example include this feature or is it just a matter of making sure the documentation is clear?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants