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

refactor: script

Browse files
Files changed (1) hide show
  1. generated-usa-passeports-dataset.py +4 -38
generated-usa-passeports-dataset.py CHANGED
@@ -1,8 +1,4 @@
1
- from pathlib import Path
2
-
3
  import datasets
4
- import numpy as np
5
- import pandas as pd
6
  import PIL.Image
7
  import PIL.ImageOps
8
 
@@ -135,7 +131,6 @@ class GeneratedUsaPasseportsDataset(datasets.GeneratorBasedBuilder):
135
  ]
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 = [
@@ -144,37 +139,8 @@ class GeneratedUsaPasseportsDataset(datasets.GeneratorBasedBuilder):
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(
158
- # zip(sorted(images), sorted(attacks, key=lambda x: x[0]))):
159
- # image_name = Path(image_path).name
160
- # yield idx, {
161
- # "photo":
162
- # load_image_file(image_path),
163
- # "attack":
164
- # attack_path,
165
- # # annotations_df.loc[annotations_df['photo'].str.lower() ==
166
- # # image_name.lower()]['attack'].values[0],
167
- # 'phone':
168
- # annotations_df.loc[annotations_df['photo'].str.lower() ==
169
- # image_name.lower()]['phone'].values[0],
170
- # 'gender':
171
- # annotations_df.loc[annotations_df['photo'].str.lower() ==
172
- # image_name.lower()]['gender'].values[0],
173
- # 'age':
174
- # annotations_df.loc[annotations_df['photo'].str.lower() ==
175
- # image_name.lower()]['age'].values[0],
176
- # 'country':
177
- # annotations_df.loc[annotations_df['photo'].str.lower() ==
178
- # image_name.lower()]
179
- # ['country'].values[0],
180
- # }
 
 
 
1
  import datasets
 
 
2
  import PIL.Image
3
  import PIL.ImageOps
4
 
 
131
  ]
132
 
133
  def _generate_examples(self, original, augmentation, annotations):
 
134
  original = list(original)
135
  augmentation = list(augmentation)
136
  augmentation = [
 
139
 
140
  for idx, (org, aug) in enumerate(zip(original, augmentation)):
141
  yield idx, {
142
+ 'original': load_image_file(org),
143
+ 'us_pass_augmentated_1': load_image_file(aug[0]),
144
+ 'us_pass_augmentated_2': load_image_file(aug[1]),
145
+ 'us_pass_augmentated_3': load_image_file(aug[2])
 
 
 
 
146
  }