Created
July 16, 2019 13:35
-
-
Save obeshor/04e8d99b620f5ce774231ad4d7e116c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun getSortedResult(labelProbArray: Array<FloatArray>): List<Classifier.Recognition> { | |
Log.d("Classifier", "List Size:(%d, %d, %d)".format(labelProbArray.size,labelProbArray[0].size,LABEL_LIST.size)) | |
val pq = PriorityQueue( | |
MAX_RESULTS, | |
Comparator<Classifier.Recognition> { | |
(_, _, confidence1), (_, _, confidence2) | |
-> java.lang.Float.compare(confidence1, confidence2) * -1 | |
}) | |
for (i in LABEL_LIST.indices) { | |
val confidence = labelProbArray[0][i] | |
if (confidence >= THRESHOLD) { | |
pq.add(Classifier.Recognition("" + i, | |
if (LABEL_LIST.size > i) LABEL_LIST[i] else "Unknown", confidence) | |
) | |
} | |
} | |
Log.d("Classifier", "pqsize:(%d)".format(pq.size)) | |
val recognitions = ArrayList<Classifier.Recognition>() | |
val recognitionsSize = Math.min(pq.size, MAX_RESULTS) | |
for (i in 0 until recognitionsSize) { | |
recognitions.add(pq.poll()) | |
} | |
return recognitions | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment