Skip to content

Commit

Permalink
adding (redundant) fields that are needed for the TensorFlow Object D…
Browse files Browse the repository at this point in the history
…etection repository
  • Loading branch information
gvanhorn38 committed Apr 28, 2018
1 parent 0db6ed8 commit 718ef45
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion create_tfrecords.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import argparse
from datetime import datetime
import hashlib
import json
import os
from Queue import Queue
Expand Down Expand Up @@ -118,6 +119,10 @@ def _convert_to_example(image_example, image_buffer, height, width, colorspace='
# Any extra data (e.g. stringified json)
extra_info = str(image_class.get('extra', ''))

# Additional fields for the format needed by the Object Detection repository
key = hashlib.sha256(image_buffer).hexdigest()
is_crowd = image_objects.get('is_crowd', [])

example = tf.train.Example(features=tf.train.Features(feature={
'image/height': _int64_feature(height),
'image/width': _int64_feature(width),
Expand Down Expand Up @@ -145,7 +150,15 @@ def _convert_to_example(image_example, image_buffer, height, width, colorspace='
'image/object/parts/score' : _float_feature(parts_s),
'image/object/count' : _int64_feature(object_count),
'image/object/area' : _float_feature(object_areas),
'image/object/id' : _bytes_feature(object_ids)
'image/object/id' : _bytes_feature(object_ids),

# Additional fields for the format needed by the Object Detection repository
'image/source_id': _bytes_feature(image_id),
'image/key/sha256': _bytes_feature(key),
'image/object/class/label': _int64_feature(bbox_labels),
'image/object/class/text': _bytes_feature(bbox_text),
'image/object/is_crowd': _int64_feature(is_crowd)

}))
return example

Expand Down

0 comments on commit 718ef45

Please sign in to comment.