This repository was archived by the owner on Jul 7, 2023. It is now read-only.
File tree 2 files changed +6
-3
lines changed
tensor2tensor/data_generators
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):
46
46
elif isinstance (v [0 ], float ):
47
47
features [k ] = tf .train .Feature (float_list = tf .train .FloatList (value = v ))
48
48
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 ):
49
52
features [k ] = tf .train .Feature (bytes_list = tf .train .BytesList (value = v ))
50
53
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 ]))))
53
56
return tf .train .Example (features = tf .train .Features (feature = features ))
54
57
55
58
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ def image_generator(images, labels):
68
68
yield {
69
69
"image/encoded" : [enc_string ],
70
70
"image/format" : ["png" ],
71
- "image/class/label" : [label ],
71
+ "image/class/label" : [int ( label ) ],
72
72
"image/height" : [height ],
73
73
"image/width" : [width ]
74
74
}
You can’t perform that action at this time.
0 commit comments