Issue with collate datasets script

#2
by oscarloch - opened

Hi!, I was trying to use the script to collate both datasets using the script provided in the Challenge Web page:

from datasets import load_dataset, Sequence, Image, DatasetDict, concatenate_datasets

dataset = load_dataset("StanfordAIMI/interpret-cxr-public")
dataset_mimic = load_dataset(
"json",
data_files={"train": "train_mimic.json", "validation": "val_mimic.json"},
).cast_column("images", Sequence(Image()))
dataset_final = DatasetDict({"train": concatenate_datasets([dataset["train"], dataset_mimic["train"]]),
"validation": concatenate_datasets([dataset["validation"], dataset_mimic["validation"]])})
dataset_final.save_to_disk("path/to/dataset/directory")

And I got this error:

Generating train split: 100%|██████████| 333205/333205 [03:25<00:00, 1623.30 examples/s]
Generating validation split: 100%|██████████| 8543/8543 [00:07<00:00, 1153.53 examples/s]
Generating train split: 217190 examples [00:02, 98320.62 examples/s]
Generating validation split: 5568 examples [00:00, 164644.85 examples/s]
Casting the dataset: 100%|██████████| 217190/217190 [00:00<00:00, 458441.98 examples/s]
Casting the dataset: 100%|██████████| 5568/5568 [00:00<00:00, 234446.15 examples/s]
Saving the dataset (89/147 shards): 61%|██████ | 333243/550395 [04:39<03:02, 1192.11 examples/s]
Traceback (most recent call last):
File "/mnt/researchers/denis-parra/datasets/physionet.org/files/mimic-cxr-jpg/2.0.0/collate_datasets.py", line 19, in
dataset_final.save_to_disk("/mnt/researchers/denis-parra/datasets/challenge_cxr")
File "/mnt/workspace/dcampanini/.conda/envs/mistral_env/lib/python3.11/site-packages/datasets/dataset_dict.py", line 1297, in save_to_disk
dataset.save_to_disk(
File "/mnt/workspace/dcampanini/.conda/envs/mistral_env/lib/python3.11/site-packages/datasets/arrow_dataset.py", line 1536, in save_to_disk
for job_id, done, content in Dataset._save_to_disk_single(**kwargs):
File "/mnt/workspace/dcampanini/.conda/envs/mistral_env/lib/python3.11/site-packages/datasets/arrow_dataset.py", line 1569, in _save_to_disk_single
writer.write_table(pa_table)
File "/mnt/workspace/dcampanini/.conda/envs/mistral_env/lib/python3.11/site-packages/datasets/arrow_writer.py", line 586, in write_table
pa_table = embed_table_storage(pa_table)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/workspace/dcampanini/.conda/envs/mistral_env/lib/python3.11/site-packages/datasets/table.py", line 2218, in embed_table_storage
arrays = [
^
File "/mnt/workspace/dcampanini/.conda/envs/mistral_env/lib/python3.11/site-packages/datasets/table.py", line 2219, in
embed_array_storage(table[name], feature) if require_storage_embed(feature) else table[name]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/workspace/dcampanini/.conda/envs/mistral_env/lib/python3.11/site-packages/datasets/table.py", line 1793, in wrapper
return pa.chunked_array([func(chunk, *args, **kwargs) for chunk in array.chunks])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/workspace/dcampanini/.conda/envs/mistral_env/lib/python3.11/site-packages/datasets/table.py", line 1793, in
return pa.chunked_array([func(chunk, *args, **kwargs) for chunk in array.chunks])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/workspace/dcampanini/.conda/envs/mistral_env/lib/python3.11/site-packages/datasets/table.py", line 2115, in embed_array_storage
return pa.ListArray.from_arrays(array_offsets, _e(array.values, feature.feature))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/workspace/dcampanini/.conda/envs/mistral_env/lib/python3.11/site-packages/datasets/table.py", line 1795, in wrapper
return func(array, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/workspace/dcampanini/.conda/envs/mistral_env/lib/python3.11/site-packages/datasets/table.py", line 2098, in embed_array_storage
return feature.embed_storage(array)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/workspace/dcampanini/.conda/envs/mistral_env/lib/python3.11/site-packages/datasets/features/image.py", line 276, in embed_storage
storage = pa.StructArray.from_arrays([bytes_array, path_array], ["bytes", "path"], mask=bytes_array.is_null())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "pyarrow/array.pxi", line 3257, in pyarrow.lib.StructArray.from_arrays
File "pyarrow/array.pxi", line 3697, in pyarrow.lib.c_mask_inverted_from_obj
TypeError: Mask must be a pyarrow.Array of type boolean

Has anyone got this error before or know any solution?, thank you so much in advance for your help

Stanford AIMI org

hopefully this helps:
https://github.com/Stanford-AIMI/RRG24/issues/2
We used datasets==2.17.1

IAMJB changed discussion status to closed

Sign up or log in to comment