-
tfrecord, when writing is written line by line, when reading is to read to each batch of rows.
-
Writing, by the for loop (e.g.: img_path, cls_label = img_paths [i ], cls_labels [I]) to the inside tf.train.Example feed feature.
Thus, feature tf.train.Example fed in a single line of data (including a img_path, its corresponding encode_img, cls_label, pts_label).example = tf.train.Example(features=tf.train.Features(feature={ 'img_path': _bytes_feature(img_path), 'encoded': _bytes_feature(image_buffer), 'cls_label': _int64_feature(cls_label) }))
You can
print(example)
view it. -
The final data will form a two-dimensional list in tfrecord in:
[ { [img_path], [img_encode], [cls_label], [pts_label] } { [img_path], [img_encode], [cls_label], [pts_label] } { [img_path], [img_encode], [cls_label], [pts_label] } { [img_path], [img_encode], [cls_label], [pts_label] } … … { [img_path], [img_encode], [cls_label], [pts_label] } ]
Each row in the list, is a complete data element, element = {[img_path], [img_encode], [cls_label], [pts_label]}
-
Specifically, element = {[b '\ path \ to \ img_1.jpg'], [\ df \ sdf \ df \ df \ dfsxc \ d], [1], [21.2, 34.6, 45.1, 56.7]}
-
Every individual is in the type list element, the writing _int64_feature, _float_feature, when _bytes_feature, it must be a one-dimensional list!
[Tensorflow] TFRecord read and write mechanism
Guess you like
Origin blog.csdn.net/JNingWei/article/details/104879886
Recommended
Ranking