Spaces:
Runtime error
Runtime error
Niv Sardi
commited on
Commit
·
c853074
1
Parent(s):
9849035
python/augment: better debug output
Browse files- python/augment.py +11 -5
python/augment.py
CHANGED
@@ -26,7 +26,6 @@ import pipelines
|
|
26 |
BATCH_SIZE = 16
|
27 |
|
28 |
def process(args):
|
29 |
-
|
30 |
dest_images_path = os.path.join(args.dest, 'images')
|
31 |
dest_labels_path = os.path.join(args.dest, 'labels')
|
32 |
|
@@ -129,19 +128,26 @@ def process(args):
|
|
129 |
|
130 |
batches_generator = create_generator(batches)
|
131 |
|
|
|
132 |
with pipeline.pool(processes=-1, seed=1) as pool:
|
133 |
batches_aug = pool.imap_batches(batches_generator, output_buffer_size=5)
|
134 |
|
135 |
-
print(f"Requesting next augmented batch...")
|
136 |
for i, batch_aug in enumerate(batches_aug):
|
137 |
idx = list(range(len(batch_aug.images_aug)))
|
138 |
random.shuffle(idx)
|
139 |
for j, d in enumerate(background_images):
|
140 |
-
|
|
|
|
|
|
|
|
|
|
|
141 |
basename = d.name.replace('.png', '') + f'.{i}.{j}'
|
142 |
|
143 |
anotations = []
|
144 |
for k in range(math.floor(len(batch_aug.images_aug)/3)):
|
|
|
145 |
logo_idx = (j+k*4)%len(batch_aug.images_aug)
|
146 |
|
147 |
orig = batch_aug.images_unaug[logo_idx]
|
@@ -173,8 +179,8 @@ def process(args):
|
|
173 |
print(f'couldnt write image {basename}')
|
174 |
|
175 |
if i < len(batches)-1:
|
176 |
-
print("Requesting next augmented batch...")
|
177 |
-
|
178 |
bar.finish()
|
179 |
|
180 |
if __name__ == '__main__':
|
|
|
26 |
BATCH_SIZE = 16
|
27 |
|
28 |
def process(args):
|
|
|
29 |
dest_images_path = os.path.join(args.dest, 'images')
|
30 |
dest_labels_path = os.path.join(args.dest, 'labels')
|
31 |
|
|
|
128 |
|
129 |
batches_generator = create_generator(batches)
|
130 |
|
131 |
+
batch = 0
|
132 |
with pipeline.pool(processes=-1, seed=1) as pool:
|
133 |
batches_aug = pool.imap_batches(batches_generator, output_buffer_size=5)
|
134 |
|
135 |
+
print(f"Requesting next augmented batch...{batch}/{len(batches)}")
|
136 |
for i, batch_aug in enumerate(batches_aug):
|
137 |
idx = list(range(len(batch_aug.images_aug)))
|
138 |
random.shuffle(idx)
|
139 |
for j, d in enumerate(background_images):
|
140 |
+
try:
|
141 |
+
img = imtool.remove_white(cv2.imread(d.path))
|
142 |
+
except:
|
143 |
+
print("couldnt remove white, skipping")
|
144 |
+
next
|
145 |
+
|
146 |
basename = d.name.replace('.png', '') + f'.{i}.{j}'
|
147 |
|
148 |
anotations = []
|
149 |
for k in range(math.floor(len(batch_aug.images_aug)/3)):
|
150 |
+
bar.next()
|
151 |
logo_idx = (j+k*4)%len(batch_aug.images_aug)
|
152 |
|
153 |
orig = batch_aug.images_unaug[logo_idx]
|
|
|
179 |
print(f'couldnt write image {basename}')
|
180 |
|
181 |
if i < len(batches)-1:
|
182 |
+
print(f"Requesting next augmented batch...{batch}/{len(batches)}")
|
183 |
+
batch += 1
|
184 |
bar.finish()
|
185 |
|
186 |
if __name__ == '__main__':
|