Android TensorFlow GPU Delegate

I want to apply cartoon effect to picture in android (java/kotlin or c/c++) with tensorflow lite. (tflite model / dr, fp16, int8 quantization)

I found this tutorial.

This code is also based on it.

My demo app works on CPU with 4 threads but when I want to test it with GPU delegate gives an error.

I used several devices and the result was the same in all of them.

// Check if device supports GPU delegate

val compatList = CompatibilityList()

val isSupported = compatList.isDelegateSupportedOnThisDevice

// If device does not support, then it will be done on 4 CPU threads

val options = Model.Options.Builder().apply {

if(isSupported) setDevice(Model.Device.GPU)

else setNumThreads(4)


val model = WhiteboxCartoonGanFp16.newInstance(this, options)

val process = model.process(picture)
val cartoon = process.cartoonizedImageAsTensorImage

val bitmap = image.bitmap

Hi @soiava ,

Have you tried the specific code here without ml model binding feature? Please try it and see if that initialize the delegate correctly. It also has an additional step of finding the best options for specific device. (Use both dependencies in build.gradle file and change their versions to 2.7.0)

Get back here with the results.