miojizzy commited on
Commit
9ac9100
·
1 Parent(s): 9158ac7

Update mhr_recognize_datasets.py

Browse files
Files changed (1) hide show
  1. mhr_recognize_datasets.py +10 -7
mhr_recognize_datasets.py CHANGED
@@ -51,25 +51,28 @@ class MHRRecognizeDatasets(datasets.GeneratorBasedBuilder):
51
  def _split_generators(self, dl_manager):
52
  """Returns SplitGenerators."""
53
  download_files = dl_manager.download_and_extract(_DATA_URL)
54
- print(download_files)
 
 
 
55
  return [
56
  datasets.SplitGenerator(
57
  name=datasets.Split.TRAIN,
58
  gen_kwargs={
59
- "image_path": os.path.join(download_files[self.config.name+"_image"]),
60
- "label_path": os.path.join(download_files[self.config.name+"_label"]),
61
  },
62
  )
63
  ]
64
 
65
- def _generate_examples(self, image_path, label_path):
66
- print("1:", image_path, label_path)
67
  if True:
68
  # if self.config.name == "whole":
69
  # Read csv with image labels
70
- label_csv = pd.read_csv(label_path)
71
  print("2:", label_csv)
72
- for i, path in enumerate(image_path):
73
  file_name = os.path.basename(path)
74
  print("3:", i, path, file_name)
75
  # Get image id to filter the respective row of the csv
 
51
  def _split_generators(self, dl_manager):
52
  """Returns SplitGenerators."""
53
  download_files = dl_manager.download_and_extract(_DATA_URL)
54
+ name = self.config.name
55
+ images = dl_manager.iter_files(os.path.join(download_files[name+"_image"]))
56
+ label = os.path.join(download_files[name+"_label"])
57
+ print(download_files, images, label)
58
  return [
59
  datasets.SplitGenerator(
60
  name=datasets.Split.TRAIN,
61
  gen_kwargs={
62
+ "images": images,
63
+ "label": label,
64
  },
65
  )
66
  ]
67
 
68
+ def _generate_examples(self, images, label):
69
+ print("1:", images, label_path)
70
  if True:
71
  # if self.config.name == "whole":
72
  # Read csv with image labels
73
+ label_csv = pd.read_csv(label)
74
  print("2:", label_csv)
75
+ for i, path in enumerate(images):
76
  file_name = os.path.basename(path)
77
  print("3:", i, path, file_name)
78
  # Get image id to filter the respective row of the csv