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
classes= 52 | |
train = cards/train.txt | |
valid = cards/test.txt | |
names = obj.names | |
backup = output/ |
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
./bazel-bin/tensorflow/contrib/lite/toco/toco \ | |
--input_file=yolov2-tiny.pb \ | |
--output_file=foo.tflite \ | |
--input_format=TENSORFLOW_GRAPHDEF \ | |
--output_format=TFLITE \ | |
--input_arrays=input \ | |
--input_shapes=1,416,416,3 \ | |
--output_arrays=output |
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
override fun process(bitmap: Bitmap): List<Detection> { | |
convertBitmapToByteBuffer(bitmap) | |
tensorflow.run(imgData, output) | |
return processOutput(output) | |
} | |
private fun convertBitmapToByteBuffer(bitmap: Bitmap) { | |
imgData.rewind() | |
val resizedBitmap = Bitmap.createScaledBitmap(bitmap, 416, 416, true) | |
resizedBitmap.getPixels(intValues, 0, resizedBitmap.width, 0, 0, resizedBitmap.width, resizedBitmap.height) |
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
fun processOutput(data: Array<Array<Array<FloatArray>>>): Map<Int, Float> { | |
val output = data[0] //output is now 13x13x285 | |
val flatOutput = mutableListOf<Float>() | |
output.forEach { flatOutput.addAll(it.flatten()) } | |
val resultsMap = mutableMapOf<Int, Float>() | |
val gridHeight = 13 | |
val gridWidth = 13 |