`topk` in the `options` for `imageClassifier` doesn't work
Opened this issue · 3 comments
In ml5@1.0.1
, 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);
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.
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.
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?