gallidev / final-year-project

1 stars 0 forks source link

Crash: android.renderscript.RSIllegalArgumentException: Array too small for allocation type. #1

Open anilsathyan7 opened 5 years ago

anilsathyan7 commented 5 years ago

Hi, The application crashes after we select anyone of the segmentation models from the menu.Here is the debug log:- (Using OnePlus3 Android 8.0.0) E/AndroidRuntime: FATAL EXCEPTION: FrameProcessorsWorker Process: com.example.videosegmentation, PID: 28238 android.renderscript.RSIllegalArgumentException: Array too small for allocation type. at android.renderscript.Allocation.data1DChecks(Allocation.java:1118) at android.renderscript.Allocation.copy1DRangeFromUnchecked(Allocation.java:1147) at android.renderscript.Allocation.copyFromUnchecked(Allocation.java:696) at android.renderscript.Allocation.copyFrom(Allocation.java:946) at com.example.videosegmentation.ImageProcessor$startProcessing$1.process(ImageProcessor.kt:55) at com.otaliastudios.cameraview.CameraView$Callbacks$13.run(CameraView.java:1721) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.os.HandlerThread.run(HandlerThread.java:65)

gallidev commented 5 years ago

@anilsathyan7 I just pushed a new commit that should fix the problem. Please pull the latest version and let me know :) I will try to test the app with other Android devices and let you know if other issues arise.

anilsathyan7 commented 5 years ago

Ok, it works this time... But it seems to be very slow, for a real-time video application.. The best model runs at 3 fps (330 ms)

gallidev commented 5 years ago

yes the fastest model for me runs at 55ms on a Google Pixel XL and with the release version of the app. The U-Net architecture that most of the models are based on is not the fastest. In the future, it would be great to try different ones. Also, it requires time and expertise to fully optimise the models for Tensorflow Lite, these guys have shared some of their experience https://hyperconnect.github.io/2018/07/06/tips-for-building-fast-portrait-segmentation-network-with-tensorflow-lite.html

anilsathyan7 commented 5 years ago

Are you getting 55 ms on CPU or GPU ? When we benchmarked some of your models using tflite benchmark tool (with gpu options enabled )for android, we got around 20ms in our phone; but inside the app it goes to 55ms, using gpu delegate.It seems there are some time-consuming memory(I/O) operations involved in this case.

gallidev commented 5 years ago

I got 55ms on CPU, I was not able to run it with GPU delegate on my device. It might be because of the operations to convert YUV images into RGB format.