问题
I am using Python to do object detection in a video stream. I have a TensorFlow Lite model which takes a relatively long time to evaluate. Using interpreter.invoke()
, it takes about 500 ms per evaluation. I'd like to use parallelism to get more evaluations per second.
I see that I can call the TensorFlow config tf.config.experimental.set_synchronous_execution
. I was hoping that setting this would magically cause the interpreter to run in multiple processes.
However, running help(tf.lite.Interpreter)
states that:
invoke(self) Invoke the interpreter. Be sure to set the input sizes, allocate tensors and fill values before calling this. Also, note that this function releases the GIL so heavy computation can be done in the background while the Python interpreter continues. No other function on this object should be called while the invoke() call has not finished.
Do I need to write my own multiprocessing code, similar to speedup TFLite inference in python with multiprocessing pool?
来源:https://stackoverflow.com/questions/61263640/does-tf-config-experimental-set-synchronous-execution-make-the-python-tensorfl