Datasets:
fix: pyarrow float to int64 conversion error in dataset generator
#3
by
samuellimabraz
- opened
The dataset fails to load with datasets==3.6.0
and pyarrow==20.0.0
due to a type conversion error:
pyarrow.lib.ArrowInvalid: Float value 0.000012 was truncated converting to int64
This occurs because the JSON data contains floating-point values in bounding box coordinates, but the dataset schema expects int64
values.
Solution
- Added
convert_bbox_to_int()
helper function to properly convert float coordinates to integers usingint(round(coord))
- Applied conversion to both
bboxes_block
andbboxes_line
in_generate_examples()
Tested with:
datasets==3.6.0
pyarrow==20.0.0
- Successfully loads all splits (train/validation/test) without errors