TFlite Model that runs on a List of tensor Images

Viewed 13

So I'm stuck trying to feed this model input data, it's supposed to take an array of TensorImages, but I'm stuck doing it, if someone could help me with it I would really appreciate it, I can't figure it out.

@RequiresApi(Build.VERSION_CODES.P)
fun getCount(interpreter: Interpreter): Int {
    var images = getImages()
    images = preprocessImages(images as ArrayList<TensorImage>) as ArrayList<TensorImage>
    var listImages = mutableListOf<TensorBuffer>()
    for(i in 0 until images.size){
        listImages.add(i,images[i].tensorBuffer)
    }
    var imgBatches = mutableListOf<List<TensorBuffer>>()
    imgBatches.add(0,listImages as List<TensorBuffer>)

    var inputBuffer = TensorBuffer.createFixedSize(interpreter.getInputTensor(0).shape(),interpreter.getInputTensor(0).dataType())
    var outputBuffer = TensorBuffer.createDynamic(interpreter.getOutputTensor(0).dataType())


    inputBuffer.loadArray(imgBatches,interpreter.getInputTensor(0).shape())
    interpreter.run(inputBuffer,outputBuffer)
    interpreter.close()
    Log.d("Output", outputBuffer.toString())
    return 0
}

The error is

None of the following functions can be called with the arguments supplied.

loadArray(FloatArray!, IntArray!) defined in org.tensorflow.lite.support.tensorbuffer.TensorBuffer loadArray(IntArray!, IntArray!) defined in org.tensorflow.lite.support.tensorbuffer.TensorBuffer

when I call inputBuffer.loadArray

0 Answers
Related