asus4 / tf-lite-unity-sample

TensorFlow Lite Samples on Unity
872 stars 255 forks source link

Performance degradation on iPhone #285

Closed peperunii closed 1 year ago

peperunii commented 1 year ago

Hi, thank you very much for this project. I have a problem when using the Metal delegate on IOS. At the beginning a model execution time is 0.04 seconds which is perfect and then over time it gets slower. After 1 minute is 0.06 seconds, after 2 minutes is 0.1 and at some point it gets stable when each execution takes 0.4 seconds. When I restart the App everything is back to normal again. I tried to reinitialize the Interpreter from the 'BaseImagePredictor' class when I detect the drop in performance - but it is not helping. Is that something I am doing wrong or a specific Unity setting that I have to do? My unity editor version is 2021.3.15f and I am trying to run it on iPhone 13 mini -> with IOS 15.7

asus4 commented 1 year ago

@peperunii Thanks for reporting it. Which example did you test?

peperunii commented 1 year ago

It is a custom TFLite model (Semantic segmentation network) that I generated - Accepting normalized image in float [,,] format and returning float[,,]. I tested with various networks and architectures that I trained - the effect is the same. When running the app inside Unity on Mac - everything is ok. The problem is only on the iPhone even when the GPU utilization is at 60-70% only

asus4 commented 1 year ago

Okay, it could be thermal throttling or GC. But I probably cannot figure out the cause as I cannot test it on my end.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.