fix: generate examples
Browse files
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 |
-
|
127 |
-
|
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
|
141 |
-
yield
|
142 |
'original':
|
143 |
-
load_image_file(
|
144 |
'us_pass_augmentated_1':
|
145 |
-
load_image_file(
|
146 |
'us_pass_augmentated_2':
|
147 |
-
load_image_file(
|
148 |
'us_pass_augmentated_3':
|
149 |
-
load_image_file(
|
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(
|