The error is caused by PipelinedModelRunner's __del__() function, pushing an empty request to ensure pipeline closes.
The example code have passed an empty request earlier during execution, and already closed the pipeline. Passing the empty request again will result in Runtime Error.
I wrapped the action of pushing an empty request inside an try statement, while retaining the function to release unconsumed tensors. This is the following result of the pipeline example after modification:
$ python3 model_pipelining_classify_image.py --models test_data/pipeline/inception_v3_299_quant_segment_%d_of_2_edgetpu.tflite --labels test_data/imagenet_labels.txt --input test_data/parrot.jpg
Using devices: ['usb:0', 'usb:1']
Using models: ['test_data/pipeline/inception_v3_299_quant_segment_0_of_2_edgetpu.tflite', 'test_data/pipeline/inception_v3_299_quant_segment_1_of_2_edgetpu.tflite']
/home/pi/Downloads/tests/test2_mod_py/model_pipelining_classify_image.py:130: DeprecationWarning: ANTIALIAS is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.LANCZOS instead.
Image.open(args.input).convert('RGB').resize(size, Image.ANTIALIAS))
WARNING: Logging before InitGoogleLogging() is written to STDERR
I20220606 19:23:16.864081 3949 pipelined_model_runner.cc:175] Thread: 2881299520 receives empty request
I20220606 19:23:16.864403 3949 pipelined_model_runner.cc:248] Thread: 2881299520 is shutting down the pipeline...
I20220606 19:23:17.116384 3949 pipelined_model_runner.cc:258] Thread: 2881299520 Pipeline is off.
I20220606 19:23:17.116871 3950 pipelined_model_runner.cc:210] Queue is empty and `StopWaiters()` is called.
-------RESULTS--------
macaw: 0.99609
Average inference time (over 5 iterations): 55.4ms
Push empty request to stop the pipeline...
I20220606 19:23:17.117740 3928 pipelined_model_runner.cc:175] Thread: 3069839744 receives empty request
E20220606 19:23:17.118194 3928 pipelined_model_runner.cc:243] Thread: 3069839744 Pipeline was turned off before.
The pipeline has already been closed successfully.
E20220606 19:23:17.118814 3928 pipelined_model_runner.cc:243] Thread: 3069839744 Pipeline was turned off before.
E20220606 19:23:17.118907 3928 pipelined_model_runner.cc:150] Failed to shutdown status: INTERNAL: Pipeline was turned off before.
There are two additional error logs after the line "The pipeline has already been closed successfully.", and the error logs are caused by pipelined_model_runner.cc in libcoral, which is another problem to be fixed in that repo.
This fixes #43, reporting pipeline example model_pipelining_classify_image.py results in a Runtime Error. Part of the error logs comes from libcoral, I submitted another PR for that.
The error is caused by PipelinedModelRunner's __del__() function, pushing an empty request to ensure pipeline closes. The example code have passed an empty request earlier during execution, and already closed the pipeline. Passing the empty request again will result in Runtime Error.
I wrapped the action of pushing an empty request inside an try statement, while retaining the function to release unconsumed tensors. This is the following result of the pipeline example after modification:
There are two additional error logs after the line "The pipeline has already been closed successfully.", and the error logs are caused by pipelined_model_runner.cc in libcoral, which is another problem to be fixed in that repo.