Created
June 18, 2020 07:03
-
-
Save MITsVision/cc5debb87d223e613cd81ebc541738ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
train_record = 'tf-records/coco_train.record-00000-of-00001' | |
for i, record in enumerate(tf.python_io.tf_record_iterator(train_record)): | |
#print("######################### Record", i, "#########################") | |
example = tf.train.Example() | |
example.ParseFromString(record) | |
feature = example.features.feature | |
imgHeight = feature['image/height'].int64_list.value[0] | |
imgWidth = feature['image/width'].int64_list.value[0] | |
imgFileName = feature['image/filename'].bytes_list .value[0].decode('utf-8') | |
print(imgWidth,imgHeight,imgFileName) | |
#print(feature) | |
bboxes = [] | |
for ibbox, label in enumerate (feature["image/object/class/text"].bytes_list.value): | |
textLabel = label.decode("utf-8") | |
bboxes.append( (textLabel, | |
feature["image/object/bbox/xmin"].float_list.value[ibbox], | |
feature["image/object/bbox/xmax"].float_list.value[ibbox], | |
feature["image/object/bbox/ymin"].float_list.value[ibbox], | |
feature["image/object/bbox/ymax"].float_list.value[ibbox] | |
)) | |
print(bboxes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment