IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Python Discussion :

Récupération des informations avec subprocess.Popen


Sujet :

Python

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau membre du Club
    Femme Profil pro
    Data Analyst
    Inscrit en
    Mars 2017
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 33
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Data Analyst
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Mars 2017
    Messages : 5
    Par défaut Récupération des informations avec subprocess.Popen
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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

  2. #2
    Membre confirmé
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Mars 2013
    Messages
    25
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2013
    Messages : 25
    Par défaut
    print(err) ça donne quoi ?

    Citation Envoyé par aurorelaurent Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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

  3. #3
    Nouveau membre du Club
    Femme Profil pro
    Data Analyst
    Inscrit en
    Mars 2017
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 33
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Data Analyst
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Mars 2017
    Messages : 5
    Par défaut
    Citation Envoyé par laurentv88 Voir le message
    print(err) ça donne quoi ?
    print(err) renvoi None

  4. #4
    Nouveau membre du Club
    Femme Profil pro
    Data Analyst
    Inscrit en
    Mars 2017
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 33
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Data Analyst
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Mars 2017
    Messages : 5
    Par défaut
    Problème résolu :

    Pour ceux que ça intéresse voici la solution :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    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' "], stdin=subprocess.PIPE, stdout=subprocess.PIPE,stderr=subprocess.PIPE, shell=True)
    (out, err)= proc.communicate(b"input data that is passed to subprocess' stdin")
    print(err)

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Récupération d'information avec des boutons radio
    Par fred19732 dans le forum PHP & Base de données
    Réponses: 6
    Dernier message: 10/05/2009, 20h23
  2. Récupération des informations envoyées avec POST
    Par d.florian dans le forum Langage
    Réponses: 2
    Dernier message: 17/01/2009, 21h59
  3. Réponses: 9
    Dernier message: 17/08/2004, 16h16
  4. Récupération des paramètres avec une procedure stockée
    Par samlerouge dans le forum Bases de données
    Réponses: 2
    Dernier message: 31/03/2004, 22h00
  5. Réponses: 13
    Dernier message: 20/03/2003, 08h11

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo