1

I'm having trouble deploying the best_float16.tflite model to Kotlin because it has a different data type compared to the code I'm following. Here are the differences I have identified...

This is my model

another model

As you can see, there are differences in the output between my model and the other model. (pict 1 : my model : best_float16.tflite, pict 2: another model) I'm confused about how to call it like the code below:

 val outputs = model.process(image)
                val locations = outputs.locationsAsTensorBuffer.floatArray
                val classes = outputs.classesAsTensorBuffer.floatArray
                val scores = outputs.scoresAsTensorBuffer.floatArray
                val numberOfDetections = outputs.numberOfDetectionsAsTensorBuffer.floatArray

                var mutable = bitmap.copy(Bitmap.Config.ARGB_8888, true)
                val canvas = Canvas(mutable)

                val h = mutable.height
                val w = mutable.width
                paint.textSize = h/15f
                paint.strokeWidth = h/85f
                var x = 0
                scores.forEachIndexed { index, fl ->
                    x = index
                    x *= 4
                    if(fl > 0.5){
                        paint.setColor(colors.get(index))
                        paint.style = Paint.Style.STROKE
                        canvas.drawRect(RectF(locations.get(x+1)*w, locations.get(x)*h, locations.get(x+3)*w, locations.get(x+2)*h), paint)
                        paint.style = Paint.Style.FILL
                        canvas.drawText(labels.get(classes.get(index).toInt())+" "+fl.toString(), locations.get(x+1)*w, locations.get(x)*h, paint)
                    }

source : https://github.com/Pawandeep-prog/realtime_object_detection/blob/main/app/src/main/java/com/programminghut/realtime_object/MainActivity.kt

"I tried to retrieve classes, locations, and scores, but they are not available, and using TensorBuffer also doesn't work. I can only use outputAsCategoryList like below: my code

I need advice from those of you who know how to implement the best_float16.tflite model and suggestions on which part of my code is incorrect and needs to be fixed.

ryan
  • 21
  • 6

0 Answers0