46
46
from tensorflow_datasets .core import download
47
47
from tensorflow_datasets .core import split_builder as split_builder_lib
48
48
from tensorflow_datasets .core import splits as splits_lib
49
+ from tensorflow_datasets .core .features import bounding_boxes
49
50
from tensorflow_datasets .core .features import feature as feature_lib
50
51
from tensorflow_datasets .core .features import features_dict
51
52
from tensorflow_datasets .core .features import image_feature
@@ -86,12 +87,15 @@ def datatype_converter(
86
87
if not field_data_type :
87
88
# Fields with sub fields are of type None
88
89
if field .sub_fields :
89
- return features_dict .FeaturesDict ({
90
- subfield .id : datatype_converter (
91
- subfield , int_dtype = int_dtype , float_dtype = float_dtype
92
- )
93
- for subfield in field .sub_fields
94
- })
90
+ return features_dict .FeaturesDict (
91
+ {
92
+ subfield .id : datatype_converter (
93
+ subfield , int_dtype = int_dtype , float_dtype = float_dtype
94
+ )
95
+ for subfield in field .sub_fields
96
+ },
97
+ doc = field .description ,
98
+ )
95
99
return None
96
100
elif field_data_type == int :
97
101
return int_dtype
@@ -106,6 +110,9 @@ def datatype_converter(
106
110
return text_feature .Text (doc = field .description )
107
111
elif field_data_type == mlc .DataType .IMAGE_OBJECT :
108
112
return image_feature .Image (doc = field .description )
113
+ elif field_data_type == mlc .DataType .BOUNDING_BOX :
114
+ # TFDS uses REL_YXYX by default, but Hugging Face doesn't enforce a format.
115
+ return bounding_boxes .BBoxFeature (doc = field .description , bbox_format = None )
109
116
else :
110
117
raise ValueError (f'Unknown data type: { field_data_type } .' )
111
118
@@ -225,7 +232,9 @@ def __init__(
225
232
@property
226
233
def builder_config (self ) -> dataset_builder .BuilderConfig :
227
234
"""`tfds.core.BuilderConfig` for this builder."""
228
- return self ._builder_config # pytype: disable=bad-return-type # always-use-return-annotations
235
+ return (
236
+ self ._builder_config
237
+ ) # pytype: disable=bad-return-type # always-use-return-annotations
229
238
230
239
def _info (self ) -> dataset_info .DatasetInfo :
231
240
return dataset_info .DatasetInfo (
0 commit comments