hi everyone,
android phone with 835 cpu, snpe 1.13.0.0
i build and run the sample, when the time i execute the NeuralNetwork in other thread (not ui thread).
new Thread() { void run() { nn.execute(inputs) } }.start() ;
it will block the ui thread, , android users will get bad UX.
nn = new SNPE.NeuralNetworkBuilder(application) .setPerformanceProfile(NeuralNetwork.PerformanceProfile.DEFAULT) .setRuntimeOrder(order) // using gpu .setModel( example model ) .build();
How can i config the SNPE, the Android UI is the high priority, Neural is the lower priority.
Tensowflow Mobile:
Running in background will not block the ui, but take 4 seconds,
but we can batch in the background, user will get batter UX.
SNPE 1.13
execute by GPU but will blcok the UI, take 1 seconds, how can i execute in background?
Hi,
Android blocks the UI rendering if any heavy operation is done in the main thread.
You can try any of the below options to load network using a thread,
1. Use Thread to build neural network, create thread with Handler to infer if the network is successfully built.
2. Use Async Task, Call loadNeuralNetwork() method in doInBackground() and update the UI in onPostExecute() method.
Use below code as the reference to use Thread with Handler.
Start a thread as shown below whenever you want to build the neural network.