Я пытаюсь прочитать данные Imag enet, полученные при запуске этого сценария . Чтобы увидеть, как выглядят данные, я решил включить eager_execution, чтобы распечатать закодированное изображение, просто чтобы убедиться, что с моими данными все в порядке и что я ничего не испортил.
tf.enable_eager_execution()
raw_dataset = tf.data.TFRecordDataset(data)
feature_description = {
'image/height': tf.io.FixedLenFeature([], tf.int64),
'image/width': tf.io.FixedLenFeature([], tf.int64),
'image/colorspace': tf.io.FixedLenFeature([], tf.string),
'image/channels': tf.io.FixedLenFeature([], tf.int64),
'image/class/label': tf.io.FixedLenFeature([], tf.int64),
'image/class/synset': tf.io.FixedLenFeature([], tf.string),
'image/class/text': tf.io.FixedLenFeature([], tf.string),
'image/object/bbox/xmin': tf.io.FixedLenFeature([], tf.float32),
'image/object/bbox/xmax': tf.io.FixedLenFeature([], tf.float32),
'image/object/bbox/ymin': tf.io.FixedLenFeature([], tf.float32),
'image/object/bbox/ymax': tf.io.FixedLenFeature([], tf.float32),
'image/object/bbox/label': tf.io.FixedLenFeature([], tf.int64),
'image/format': tf.io.FixedLenFeature([], tf.string),
'image/filename': tf.io.FixedLenFeature([], tf.string),
'image/encoded': tf.io.FixedLenFeature([], tf.string)}
def _parse_image_function(example_proto):
return tf.io.parse_single_example(example_proto, feature_description)
parsed_image_dataset = raw_dataset.map(_parse_image_function)
for parsed_record in parsed_image_dataset:
image = image_features['image/encoded'].numpy()
scipy.misc.imsave('outfile.jpg', image_array)
break;
Поэтому, когда я закомментирую eager_execution, скрипт хорошо разбирает набор данных, но, конечно, мы не можем с нетерпением получить представление тензора numpy. Однако, когда я включаю eager_execution, я получаю сообщение об ошибке:
2020-02-21 17:40:50.817277: I tensorflow/core/common_runtime/process_util.cc:115] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance.
2020-02-21 17:40:50.853654: W tensorflow/core/framework/op_kernel.cc:1502] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Key: image/object/bbox/xmin. Can't parse serialized Example.
2020-02-21 17:40:50.853705: W tensorflow/core/framework/op_kernel.cc:1502] OP_REQUIRES failed at iterator_ops.cc:1037 : Invalid argument: Key: image/object/bbox/xmin. Can't parse serialized Example.
[[{{node ParseSingleExample/ParseSingleExample}}]]
Traceback (most recent call last):
File "bare_bench.py", line 117, in <module>
for parsed_record in parsed_image_dataset:
File "/root/manatee/venv/lib/python3.6/site-packages/tensorflow/python/data/ops/iterator_ops.py", line 586, in __next__
return self.next()
File "/root/manatee/venv/lib/python3.6/site-packages/tensorflow/python/data/ops/iterator_ops.py", line 623, in next
return self._next_internal()
File "/root/manatee/venv/lib/python3.6/site-packages/tensorflow/python/data/ops/iterator_ops.py", line 615, in _next_internal
output_shapes=self._flat_output_shapes)
File "/root/manatee/venv/lib/python3.6/site-packages/tensorflow/python/ops/gen_dataset_ops.py", line 2120, in iterator_get_next_sync
_six.raise_from(_core._status_to_exception(e.code, message), None)
File "<string>", line 3, in raise_from
tensorflow.python.framework.errors_impl.InvalidArgumentError: Key: image/object/bbox/xmin. Can't parse serialized Example.
[[{{node ParseSingleExample/ParseSingleExample}}]] [Op:IteratorGetNextSync]
Что именно я делаю не так и почему выполнение с нетерпением вызывает эту проблему?