@@ -16,6 +16,8 @@ def get_pipeline():
16
16
dithering_dither_type = random .choice (["ordered" , "floyd-steinberg" ])
17
17
# Dithering.order determines the dimensions of the threshold map
18
18
dithering_order = random .choice (range (3 ,10 ))
19
+ # dithering.p is the probability to run this augmentation
20
+ dithering_p = (random .random ()> 0.7 ) * 1
19
21
20
22
# InkBleed.intensity_range is a tuple with bounds for bleed intensity to be selected from
21
23
inkbleed_intensity_range = (0.1 , 0.4 )
@@ -51,6 +53,8 @@ def get_pipeline():
51
53
letterpress_value_threshold_range = (96 , 128 )
52
54
# Letterpress.blur enables blur in the noise mask
53
55
letterpress_blur = 1
56
+ # Letterpress.p is the probability to run this augmentation
57
+ letterpress_p = (random .random ()> 0.5 ) * 1
54
58
55
59
# LowInkLines.count_range is a pair determining how many lines should be drawn
56
60
lowinkrandomlines_count_range = (3 , 12 )
@@ -98,7 +102,9 @@ def get_pipeline():
98
102
dirtyrollers_line_width_range = (2 , 32 )
99
103
# DirtyRollers.scanline_type changes the background of lines
100
104
dirtyrollers_scanline_type = 0
101
-
105
+ # DirtyRollers.p is the probability to run this augmentation
106
+ dirtyrollers_p = (random .random ()> 0.5 ) * 1
107
+
102
108
# LightingGradient.mask_size determines how big the mask should be
103
109
lightinggradient_light_position = None
104
110
# LightingGradient.direction indicates the rotation degree of the light strip
@@ -127,7 +133,9 @@ def get_pipeline():
127
133
dirtydrum_ksize = random .choice ([(3 , 3 ),(5 ,5 ),(7 ,7 )])
128
134
# DirtyDrum.sigmaX is the stdev of the kernel in the x direction
129
135
dirtydrum_sigmaX = 0
130
-
136
+ # DirtyDrum.p is the probability to run this augmentation
137
+ dirtydrum_p = (random .random ()> 0.5 ) * 1
138
+
131
139
# SubleNoise.range gives the variation range for sampling noise
132
140
subtlenoise_range = 10
133
141
@@ -150,6 +158,8 @@ def get_pipeline():
150
158
markup_single_word_mode = random .choice ([True , False ])
151
159
# Markup.repetitions determines the number of times the effect is drawn
152
160
markup_repetitions = random .randint (1 ,2 ) if markup_type == "highlight" else 1
161
+ # Markup.p is the probability to run this augmentation
162
+ markup_p = (random .random ()> 0.5 ) * 1
153
163
154
164
# PencilScribbles.size_range determines the size of scribbles to draw
155
165
pencilscribbles_size_range = (100 , 700 )
@@ -161,7 +171,9 @@ def get_pipeline():
161
171
pencilscribbles_thickness_range = (2 , 6 )
162
172
# PencilScribbles.brightness_change is the brightness value of each stroke
163
173
pencilscribbles_brightness_change = random .randint (64 ,224 )
164
-
174
+ # PencilScribbles.p is the probability to run this augmentation
175
+ pencilscribbles_p = (random .random ()> 0.5 ) * 1
176
+
165
177
# BindingsAndFasteners.overlay_types can be min, max, or mix
166
178
bindingsandfasteners_overlay_types = "darken"
167
179
# BindingsAndFasteners.foreground is the path to fg image or the image itself
@@ -201,6 +213,8 @@ def get_pipeline():
201
213
badphotocopy_wave_pattern = random .choice ([True ,False ])
202
214
# BadPhotoCopy.edge_effect adds the Sobel edge effect to the noise mask
203
215
badphotocopy_edge_effect = random .choice ([True ,False ])
216
+ # BadPhotoCopy.p is the probability to run this augmentation
217
+ badphotocopy_p = (random .random ()> 0.5 ) * 1
204
218
205
219
# Gamma.range is an interval from which to sample a gamma shift
206
220
gamma_range = (0.8 , 1.2 )
@@ -237,6 +251,14 @@ def get_pipeline():
237
251
# Faxify.sigma is the sigma value of the Gaussian kernel in the halftone effect
238
252
faxify_sigma = (1 ,3 )
239
253
254
+ # to prevent text becomes unreadable after the agumentation
255
+ if badphotocopy_p > 0 or dirtyrollers_p > 0 or dirtydrum_p > 0 or markup_p > 0 or pencilscribbles_p > 0 :
256
+ faxify_monochrome_method = "grayscale"
257
+ if dithering_p or faxify_halftone :
258
+ letterpress_p = 0
259
+ if dithering_p :
260
+ faxify_halftone = 0
261
+
240
262
################################################################################
241
263
# PIPELINE
242
264
#
@@ -246,13 +268,13 @@ def get_pipeline():
246
268
ink_phase = [
247
269
Dithering (dithering_dither_type ,
248
270
dithering_order ,
249
- p = 0.2 ),
271
+ p = dithering_p ),
250
272
251
273
InkBleed (inkbleed_intensity_range ,
252
274
inkbleed_color_range ,
253
275
inkbleed_kernel_size ,
254
276
inkbleed_severity ,
255
- p = 1 ),
277
+ p = 0.5 ),
256
278
257
279
BleedThrough (bleedthrough_intensity_range ,
258
280
bleedthrough_color_range ,
@@ -268,7 +290,7 @@ def get_pipeline():
268
290
letterpress_value_range ,
269
291
letterpress_value_threshold_range ,
270
292
letterpress_blur ,
271
- p = 0.5 ),
293
+ p = letterpress_p ),
272
294
273
295
OneOf (
274
296
[
@@ -329,7 +351,8 @@ def get_pipeline():
329
351
pageborder_value ),
330
352
331
353
DirtyRollers (dirtyrollers_line_width_range ,
332
- dirtyrollers_scanline_type )
354
+ dirtyrollers_scanline_type ,
355
+ p = dirtyrollers_p )
333
356
],
334
357
p = 0.5 ),
335
358
@@ -354,7 +377,7 @@ def get_pipeline():
354
377
dirtydrum_noise_value ,
355
378
dirtydrum_ksize ,
356
379
dirtydrum_sigmaX ,
357
- p = 0.5 ),
380
+ p = dirtydrum_p ),
358
381
359
382
SubtleNoise (subtlenoise_range ,
360
383
p = 0.5 ),
@@ -369,14 +392,14 @@ def get_pipeline():
369
392
markup_color ,
370
393
markup_single_word_mode ,
371
394
markup_repetitions ,
372
- p = 0.5 ),
395
+ p = markup_p ),
373
396
374
397
PencilScribbles (pencilscribbles_size_range ,
375
398
pencilscribbles_count_range ,
376
399
pencilscribbles_stroke_count_range ,
377
400
pencilscribbles_thickness_range ,
378
401
pencilscribbles_brightness_change ,
379
- p = 0.5 ),
402
+ p = pencilscribbles_p ),
380
403
381
404
BindingsAndFasteners (bindingsandfasteners_overlay_types ,
382
405
bindingsandfasteners_foreground ,
@@ -399,7 +422,7 @@ def get_pipeline():
399
422
badphotocopy_blur_noise_kernel ,
400
423
badphotocopy_wave_pattern ,
401
424
badphotocopy_edge_effect ,
402
- p = 0.5 ),
425
+ p = badphotocopy_p ),
403
426
404
427
Gamma (gamma_range ,
405
428
p = 0.5 ),
0 commit comments