meta-dataset icon indicating copy to clipboard operation
meta-dataset copied to clipboard

I've managed to prepare most of the datasets in tfrecords format except Aircraft

Open AntreasAntoniou opened this issue 2 years ago • 2 comments

I am getting this error when I ran the specified command:

python -m meta_dataset.dataset_conversion.convert_datasets_to_records   --dataset=aircraft   --aircraft_data_root=$DATASRC/fgvc-aircraft-2013b   --splits_root=$SPLITS   --records_root=$RECORDS
I0422 17:38:55.954329 140686909982528 convert_datasets_to_records.py:151] Creating FGVC-Aircraft Benchmark specification and records in directory /disk/scratch_fast/antreas-dev/meta-dataset-data/tf_records/aircraft...
I0422 17:38:55.954490 140686909982528 dataset_to_records.py:650] Attempting to read splits from /disk/scratch_fast/antreas-dev/meta-dataset-data/splits/aircraft_splits.json...
I0422 17:38:55.954948 140686909982528 dataset_to_records.py:659] Successful.
I0422 17:38:56.088124 140686909982528 dataset_to_records.py:1232] Creating record for class ID 0 (A340-300)...
<map object at 0x7ff3eb9dc3d0>
Traceback (most recent call last):
  File "/disk/scratch_fast/antreas-dev/conda/envs/GATE-env/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/disk/scratch_fast/antreas-dev/conda/envs/GATE-env/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/disk/scratch_fast/antreas-dev/meta-dataset/meta_dataset/dataset_conversion/convert_datasets_to_records.py", line 157, in <module>
    tf.app.run(main)
  File "/disk/scratch_fast/antreas-dev/conda/envs/GATE-env/lib/python3.8/site-packages/tensorflow/python/platform/app.py", line 40, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
  File "/disk/scratch_fast/antreas-dev/conda/envs/GATE-env/lib/python3.8/site-packages/absl/app.py", line 312, in run
    _run_main(main, args)
  File "/disk/scratch_fast/antreas-dev/conda/envs/GATE-env/lib/python3.8/site-packages/absl/app.py", line 258, in _run_main
    sys.exit(main(argv))
  File "/disk/scratch_fast/antreas-dev/meta-dataset/meta_dataset/dataset_conversion/convert_datasets_to_records.py", line 153, in main
    converter.convert_dataset()
  File "/disk/scratch_fast/antreas-dev/meta-dataset/meta_dataset/dataset_conversion/dataset_to_records.py", line 611, in convert_dataset
    self.create_dataset_specification_and_records()
  File "/disk/scratch_fast/antreas-dev/meta-dataset/meta_dataset/dataset_conversion/dataset_to_records.py", line 1248, in create_dataset_specification_and_records
    write_tfrecord_from_image_files(
  File "/disk/scratch_fast/antreas-dev/meta-dataset/meta_dataset/dataset_conversion/dataset_to_records.py", line 375, in write_tfrecord_from_image_files
    img = load_and_process_image(path, bbox)
  File "/disk/scratch_fast/antreas-dev/meta-dataset/meta_dataset/dataset_conversion/dataset_to_records.py", line 356, in load_and_process_image
    img = img.crop(bbox)
  File "/disk/scratch_fast/antreas-dev/conda/envs/GATE-env/lib/python3.8/site-packages/PIL/Image.py", line 1203, in crop
    if box[2] < box[0]:
TypeError: 'map' object is not subscriptable

I have managed to get the rest to be properly converted so I am assuming that the rest of my environment setup should be on point. Please let me know how to proceed.

AntreasAntoniou avatar Apr 22 '22 16:04 AntreasAntoniou

OK, I fixed it.

I added a new line before the line that causes the issue that casts the bbox into a list to explicitly unpack it from the map.

bbox = list(bbox)

AntreasAntoniou avatar Apr 22 '22 16:04 AntreasAntoniou

Thanks @AntreasAntoniou; it's kind of funny that this simple fix has not been incorporated in the main repo yet, it's impossible to prepare the Aircraft dataset without it :smile:

peustr avatar Nov 08 '22 10:11 peustr