J'essaye de construire un simple CNN en utilisant Tensorflow. Le problème est que je ne suis pas capable de lire un simple fichier .png pour alimenter le CNN.Lire un fichier png et alimenter un flux Tensor cnn
>>> filename = tf.constant("training/a1.png")
>>> filename
<tf.Tensor 'Const_1:0' shape=() dtype=string>
>>> image_string = tf.read_file(filename)
>>> image_string
<tf.Tensor 'ReadFile_1:0' shape=() dtype=string>
>>> image_decoded = tf.image.decode_png(image_string)
>>> image_decoded
<tf.Tensor 'DecodePng_1:0' shape=(?, ?, ?) dtype=uint8>
Comme vous pouvez le voir sur le code ci-dessus. Le fichier tf.image.decode_png (image_string) renvoie un tenseur de forme inconnu.
Merci vladimir-bystricky! Je l'ai. Voici le code, il peut aider d'autres personnes.
>>> import tensorflow as tf
>>> filename = tf.constant("training/a1.png")
>>> image_string = tf.read_file(filename)
>>> image_decoded = tf.image.decode_png(image_string)
>>> shape = tf.shape(image_decoded)
>>> sess = tf.Session()
>>> print(sess.run(shape))
[360 360 4]