vkashko commited on
Commit
bb1187f
1 Parent(s): c06c4d5

fix: generate examples

Browse files
Files changed (1) hide show
  1. generated-usa-passeports-dataset.py +13 -8
generated-usa-passeports-dataset.py CHANGED
@@ -123,8 +123,8 @@ class GeneratedUsaPasseportsDataset(datasets.GeneratorBasedBuilder):
123
  augmentation = dl_manager.download_and_extract(
124
  f"{_DATA}augmentation.zip")
125
  annotations = dl_manager.download(f"{_DATA}{_NAME}.csv")
126
- # original = dl_manager.iter_files(original)
127
- # augmentation = dl_manager.iter_files(augmentation)
128
  return [
129
  datasets.SplitGenerator(name=datasets.Split.TRAIN,
130
  gen_kwargs={
@@ -136,17 +136,22 @@ class GeneratedUsaPasseportsDataset(datasets.GeneratorBasedBuilder):
136
 
137
  def _generate_examples(self, original, augmentation, annotations):
138
  annotations_df = pd.read_csv(annotations, sep=';')
 
 
 
 
 
139
 
140
- for row in annotations_df.itertuples():
141
- yield row[0], {
142
  'original':
143
- load_image_file(f'{original}/{row[1]}'),
144
  'us_pass_augmentated_1':
145
- load_image_file(f'{augmentation}/{row[2]}'),
146
  'us_pass_augmentated_2':
147
- load_image_file(f'{augmentation}/{row[3]}'),
148
  'us_pass_augmentated_3':
149
- load_image_file(f'{augmentation}/{row[4]}')
150
  }
151
 
152
  # for idx, (image_path, (attack_path, attack)) in enumerate(
 
123
  augmentation = dl_manager.download_and_extract(
124
  f"{_DATA}augmentation.zip")
125
  annotations = dl_manager.download(f"{_DATA}{_NAME}.csv")
126
+ original = dl_manager.iter_files(original)
127
+ augmentation = dl_manager.iter_files(augmentation)
128
  return [
129
  datasets.SplitGenerator(name=datasets.Split.TRAIN,
130
  gen_kwargs={
 
136
 
137
  def _generate_examples(self, original, augmentation, annotations):
138
  annotations_df = pd.read_csv(annotations, sep=';')
139
+ original = list(original)
140
+ augmentation = list(augmentation)
141
+ augmentation = [
142
+ augmentation[i:i + 3] for i in range(0, len(augmentation), 3)
143
+ ]
144
 
145
+ for idx, (org, aug) in enumerate(zip(original, augmentation)):
146
+ yield idx, {
147
  'original':
148
+ load_image_file(org),
149
  'us_pass_augmentated_1':
150
+ load_image_file(aug[0]),
151
  'us_pass_augmentated_2':
152
+ load_image_file(aug[1]),
153
  'us_pass_augmentated_3':
154
+ load_image_file(aug[2])
155
  }
156
 
157
  # for idx, (image_path, (attack_path, attack)) in enumerate(