albertvillanova HF staff commited on
Commit
d00cc9e
1 Parent(s): c1a84a1

Replace iter_files with sorted glob

Browse files
Files changed (1) hide show
  1. CC6204-Hackaton-Cub-Dataset.py +5 -4
CC6204-Hackaton-Cub-Dataset.py CHANGED
@@ -1,4 +1,5 @@
1
  """CC6204-Hackaton-Cub-Dataset: Multimodal"""
 
2
  import os
3
  import re
4
  import datasets
@@ -102,14 +103,14 @@ class CubDataset(datasets.GeneratorBasedBuilder):
102
  test_idx = []
103
 
104
  # Download images
105
- img_data_files = dl_manager.download_and_extract(_URLS["image_urls"])
106
- text_data_files = dl_manager.download_and_extract(_URLS["text_urls"])
107
  #logger.info(f"text_data_files: {text_data_files}")
108
  #logger.info(f"text_data_files: {text_data_files[10]}")
109
 
110
 
111
- img_path_files = dl_manager.iter_files(img_data_files)
112
- text_path_files = dl_manager.iter_files(text_data_files)
113
 
114
  for img, text in zip(img_path_files, text_path_files):
115
  img_idx = _IMGNAME2ID[os.path.basename(img)]
 
1
  """CC6204-Hackaton-Cub-Dataset: Multimodal"""
2
+ import glob
3
  import os
4
  import re
5
  import datasets
 
103
  test_idx = []
104
 
105
  # Download images
106
+ img_data_files = os.path.join(dl_manager.download_and_extract(_URLS["image_urls"]), "images") # skip _MACOSX dir
107
+ text_data_files = os.path.join(dl_manager.download_and_extract(_URLS["text_urls"]), "text") # skip _MACOSX dir
108
  #logger.info(f"text_data_files: {text_data_files}")
109
  #logger.info(f"text_data_files: {text_data_files[10]}")
110
 
111
 
112
+ img_path_files = sorted(glob.glob(os.path.join(img_data_files, "*", "*.jpg")))
113
+ text_path_files = sorted(glob.glob(os.path.join(text_data_files, "*", "*.txt")))
114
 
115
  for img, text in zip(img_path_files, text_path_files):
116
  img_idx = _IMGNAME2ID[os.path.basename(img)]