This repository was archived by the owner on Jul 7, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
tensor2tensor/data_generators Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -46,10 +46,13 @@ def to_example(dictionary):
4646 elif isinstance (v [0 ], float ):
4747 features [k ] = tf .train .Feature (float_list = tf .train .FloatList (value = v ))
4848 elif isinstance (v [0 ], six .string_types ):
49+ v = [bytes (x , 'utf-8' ) for x in v ]
50+ features [k ] = tf .train .Feature (bytes_list = tf .train .BytesList (value = v ))
51+ elif isinstance (v [0 ], bytes ):
4952 features [k ] = tf .train .Feature (bytes_list = tf .train .BytesList (value = v ))
5053 else :
51- raise ValueError ("Value is neither an int nor a float; v: %s type: %s" %
52- (str (v [0 ]), str (type (v [0 ]))))
54+ raise ValueError ("Value for %s is neither an int nor a float; v: %s type: %s" %
55+ (k , str (v [0 ]), str (type (v [0 ]))))
5356 return tf .train .Example (features = tf .train .Features (feature = features ))
5457
5558
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ def image_generator(images, labels):
6868 yield {
6969 "image/encoded" : [enc_string ],
7070 "image/format" : ["png" ],
71- "image/class/label" : [label ],
71+ "image/class/label" : [int ( label ) ],
7272 "image/height" : [height ],
7373 "image/width" : [width ]
7474 }
You can’t perform that action at this time.
0 commit comments