sample-tensorflow-imageclassifier
sample-tensorflow-imageclassifier copied to clipboard
Predicted labels print in incorrect order
There is a bug here causing predicted labels to be printed in incorrect order. Traversing a java.util.PriorityQueue with a range-based for loop does not guarantee traversal in sorted order. Fixed by converting PQ to array, sorting array with PQ.comparator(), and returning the results in sorted order.
More information on the undefined behavior of traversing PQ here.
I just put in a pull request to fix this issue in the similar Codelabs TF image classifier repo. The same fix to TensorFlowHelper.java will work here.