Crop image on GPU with TFLite

Hi!
I have a 2-stage CNN that i want to run on an Android phone GPU.
The first stage predicts the center of a bounding box. I use that to extract 128x128 pixels around that center which I then feed to the second stage. This works fine on my computer but when I try to run it on the phone GPU it says that the tensor shapes are dynamic, which is not supported.

The tensor shape is not dynamic, the crop is always 128x128, but the crop location is not constant.
Is there any way to make this run on my phone GPU?

Thanks!

Hi @Johan_Ek ,

Can you please verify that you are not having any issues while running this on the phone’s cpu

Thank you !

Yes, It works just fine on the phone’s cpu.
Thanks!

Hi @Johan_Ek ,

Could you please share the Tflite file with us

Thanks

Hello,
As per my knowledge, to run your 2-stage CNN on an Android phone GPU without issues with dynamic tensor shapes, follow these steps:

You can use the GPU to predict the center of the bounding box.

You need to perform the cropping operation on the CPU. After obtaining the predicted center from the GPU, calculate the bounding box coordinates and extract a fixed-size region (128x128 pixels) from the image.

And the feed the cropped image (now a fixed-size tensor) into the GPU for the second stage of processing.

Sorry, I got some great help from another place.
Here is a more detailed description and solution to the problem

Follow up question: Understand tflite model running on android GPU