Récupération des informations avec subprocess.Popen
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
import subprocess
import glob
from os.path import basename, splitext
#extraction du nom des images
filename=[]
for i in range(0,3):
filepath = glob.glob('/home/aurore/tensorflow-master/*.jpg')[i]
filename.append(splitext(basename(filepath))[0])
print(filename)
proc = subprocess.Popen(["bazel-bin/tensorflow/examples/label_image/label_image --graph=/tmp/output_graph.pb --labels=/tmp/output_labels.txt --output_layer=final_result --image=$HOME/tensorflow-master/"+str(filename[0])+".jpg --input_layer=Mul --output_layer='final_result' "], stdout=subprocess.PIPE, shell=True)
(out, err) = proc.communicate()
print(out) |
Lorsque j’exécute ce script j'obtient la sortie suivante :
Code:
1 2 3 4 5 6 7 8 9 10 11
| ['cad_image_191277_260592_475_634', 'cad_image_191268_260592_848_2217', 'cad_image_191268_260624_302_1878']
2017-07-21 10:55:16.266856: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-21 10:55:16.266928: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-21 10:55:16.266939: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-07-21 10:55:16.266946: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-21 10:55:16.266952: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
2017-07-21 10:55:17.538981: W tensorflow/core/framework/op_def_util.cc:333] Op BatchNormWithGlobalNormalization is deprecated. It will cease to work in GraphDef version 9. Use tf.nn.batch_normalization().
2017-07-21 10:55:18.154345: I tensorflow/examples/label_image/main.cc:247] nvxpool (2): 0.986495
2017-07-21 10:55:18.154363: I tensorflow/examples/label_image/main.cc:247] cadastre (1): 0.00700608
2017-07-21 10:55:18.154368: I tensorflow/examples/label_image/main.cc:247] hs (0): 0.00649887
b'' |
Lorsque je veux imprimer l'output cela me renvoi : b''. Je pense que la sortie qui m'intéresse est considérée comme un Warning/Information .
En effet, comment puis-je récupérer par exemple "nvxpool (2): 0.986495"
En vous remerciant,
Aurore