`import subprocess
subprocess.check_call(
['/home/kadia/tensorflow/bazelbin/tensorflow/examples/label_image/label_image',
'--graph=/home/kadia/Desktop/TrainedShadowModel-1/output_graph.pb',
'--labels=/home/kadia/Desktop/TrainedShadowModel-1/output_labels.txt',
'--output_layer=final_result',
'--input_layer=Mul',
'--image=/home/kadia/Desktop/2.jpg']`
How can I print the output from this? Output right now going in console. I want to save the output in file
You can use popen:
from subprocess import Popen, PIPE
p = Popen(['/home/kadia/tensorflow/bazelbin/tensorflow/examples/label_image/label_image',
'--graph=/home/kadia/Desktop/TrainedShadowModel-1/output_graph.pb',
'--labels=/home/kadia/Desktop/TrainedShadowModel-1/output_labels.txt',
'--output_layer=final_result',
'--input_layer=Mul',
'--image=/home/kadia/Desktop/2.jpg'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
output, err = p.communicate(b"input data that is passed to subprocess' stdin")
rc = p.returncode
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.