-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.yaml
172 lines (147 loc) · 8.75 KB
/
config.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# The width of the square to which sign images will be scaled during processing
sign_width: 480 # Recommended: 240 or 480 for GTSDB Wikipedia templates
sign_placement:
min_ratio: 0.02 # Minimum ratio of sign width to background width
max_ratio: 0.16
middle_third: False # Whether to restrict placement to vertical middle third of image
# BUG: preprocessing breaks with AUS diamond warning signs
# When to stop the program, in the case that not all the sequential steps are required
final_op: dataset # Either 'process', 'damage', 'transform', 'manipulate', or 'dataset'
# Whether to disable background removal in preprocessing
disable_bg_removal: True # Set to true if all input templates are already PNGs with transparent backgrounds
# TODO: Create a debug: mode where the program stops after each step and displays the image
# Method of image transformation
# Either '3d_rotation' or 'fixed_affine'; '3d_rotation' is recommended
tform_method: 3d_rotation
# Number of (offline) transformations applied to each damaged sign template
# `fixed_affine` transformations are ordered by intensity (i.e. t12 is more
# visually similar to the original image than t1)
num_transform: 11 # Range (only for `fixed_affine`): [0,11], default: 11
# Parameters for transformation by 3d_rotation
# tilt: 3D tilt rotation around the X and Y axes
# Z: 2D clockwise/anti-clockwise rotation
transforms: # TODO: Rename to rotation_params? Would need to place `online` elsewhere
tilt_SD: 30
tilt_range: 70 # Recommended: <=70
Z_SD: 45 # Std. dev. for Z axis rotation
Z_range: 180 # Max pos/neg value for Z axis rotation # FIXME: Can't be set to 0, but should be 0 for no rotation
online: True # On-the-fly or not
prob: 0.8 # Probability of any rotation for each appliation when online=True
# TODO: Rotation function should be changed so that dz can always be 0, with image auto-resized; do this, but 3D:
# https://www.geeksforgeeks.org/rotate-image-without-cutting-off-sides-using-python-opencv/
# FIXME: ^ THIS MUST BE ADDRESSED BEFORE PUBLICATION, 2 orders of magnitude slower with bounding axis resizing method
# TODO: Currently only really tested with/suitable for 0 Z_range rotation; y rotation is good, x rotation is... okay...
poles:
# BUG: When [tranforms][online] is True, non-pole sign faces are used for final data generation
add_poles: False # TODO: Replace with 'prob' which can be set to 0.0
colour: [201, 182, 167, 255] # Colour is BGRA, not RGBA; A should be 255
# METAL_GREY = [201, 182, 167, 255]
# WA_YELLOW_UNOFFICIAL = [0, 154, 193, 255] # TODO: Try figure out the exact colour as defined by Main Roads
# Method of image manipulation
# Either 'gamma_exposure_fast', 'gamma_exposure', 'exposure', 'gamma', or 'histogram' (broken)
man_method: gamma_exposure_fast
man_online: True # On-the-fly brightness manipulations or not
# TODO: Region-based, rather than image-wide, when online=True
augments: # TODO: Config input validation for all in augments
# Applied both to each final signs independently and the entire final image with overlaid signs
# Contrast alteration parameters
min_alpha: 0.75
max_alpha: 1.25
# Brightness alteration parameters
min_beta: -120
max_beta: 120
# Applied to only the final signs before placement
# Random noise parameters
noise_types: # Enable/disable random noise types
none: True
gaussian: True
salt_pepper: False # Possibly too close to appearing like uncounted damage
poisson: True
speckle: True
noise_vars: [0.01, 0.005, 0.0025] # Randomly chosen variances for gaussian and speckle
# Applied only to the entire final image with overlaid signs
# Final image normalizing parameters to minimize synthetic-specific features
non_local_means_denoising: True
gaussian_kernel: 3 # Kernel size for Gaussian blur; must be odd; 1 for no blur
gaussian_sigma: 0.7 # 0 for default as calculated by OpenCV, which should equal 0.8 only when gaussian_kernel=3
# Motion blur parameters
linear_motion_blur_intensity: 13 # Length of line in kernel
linear_motion_blur_angle: 90 # In degrees; 90 for vertical, 0 for horizontal
linear_motion_blur_p: 0.1 # Probability of applying linear motion blur instead of standard normalizing blur
# TODO: Figure out what the two changeable values for radial actually mean, then put them here
radial_motion_blur_p: 0.1
# Number of times each damage is applied (online=False) OR relative likelihood of damage type (online=True)
num_damages:
# BUG: Damage spread across whole height over pole when [poles][add_poles] is True
# FIXME: Too many levels of directories when online=True (e.g. "13/13_no_damage", "13_no_damage" should be removed)
online: True # On-the-fly or not # BUG: Empty 3_Damage directories from SynthImage's self.class_num in damage.py
no_damage: 2 # Max 1 when online=False
quadrant: 1 # Max 4 when online=False
big_hole: 1
bullet_holes: 2
graffiti: 3
stickers: 3
overlays: 3
# Below damage types are not currently being used in experiments
# FIXME: Extreme distortions generated when bend and 3D tilt rotations are mixed
bend: 0 # Will make n different bends for *each* background if detect_light_source=True
tint_yellow: 0
grey: 0
# Parameters for the bullet_holes damage type (note: num_holes may include 'holes' that missed the sign)
# TODO: ^ Change to only count holes which remove visible pixels
bullet_holes:
min_holes: 7 # Not relevant if target != -1
max_holes: 30 # Not relevant if target != -1
target: -1 # The target level of damage, either -1 or in range (0.0,1.0), <= 0.50 is recommended
# Parameters for the graffiti damage type, each in range (0.0,1.0]
graffiti: # Step size between damage levels is determined by num_damages above (relevant when online=False)
initial: 0.2 # First target level of damage (relevant when online=False)
final: 0.6 # Level of damage to stop at (relevant when online=False)
max: 0.8 # Max graffiti coverage (relevant when online=True); uses trunc. norm. with mu=max/4, sd=max/3
solid: True # Whether or not transparency is minimised through only alpha values of 255 and morphological dilation
colour_p: 0.6 # Probability of using a random colour for graffiti, otherwise use black
# TODO: Block libpng warnings from showing (assuming they are never actually an issue)
stickers:
min_stickers: 1
max_stickers: 15
# Parameters for the bend damage type
bend: # Bend may randomly be either a single-sided or double-sided bend
max_axis: 60 # Clockwise rotation of the bending axis (in x-y plane)
max_bend: 60 # Level of bending performed (from 0 to 90 degrees)
# Randomization seed (online damage application does not use this seed)
seed: 7 # Use different seeds for generating train vs. eval datasets
# Set both values to 0 to have just one sign per image
# BUG: Activating multi_sign causes crash when num templates == 1 (fine for > 1)
multi_sign:
# TODO: Include probability variable for having image with 0 signs (in generate.new_data())
zero_p: 0.15 # Probability of having an image with 0 signs
min_extra_signs: 0 # Minimum number of additional signs overlaid onto each background
max_extra_signs: 3 # Maximum number of additional signs to overlay onto each background
# Prunes the dataset by using a maximum of n images for each
# background+class+damage combination, selected randomly.
# In other words, how many images of the same sign class with the same damage
# but varied shading and angle do you want over the same background image?
prune_dataset:
prune: True
max_images: 1 # FIXME: Buggy when using online modes; e.g. try value other than 1
# Parameters defining the annotation type, and whether damage labelling is used
annotations:
type: 'coco' # Either 'retinanet' or 'coco'
damage_labelling: True
# Number of grid cell sectors on each sign, over which damage is calculated
num_damage_sectors: 4 # Must be a perfect square
# 'ssim' will calculate structural difference relative to all pixels in each image/sector
# This means the magnitude of damage values will be dependent on the shape of the sign (i.e. max < 1.0)
# 'pixel_wise' will calculate the pixel-by-pixel difference only for pixels part of the original sign (i.e. visible)
damage_measure_method: 'pixel_wise'
# A setting that uses an algorithm to find the light source locations and intensities
# in each background image, and adjusts relative exposure between bent and unbent portions of
# a sign to mimic a shadow. Does not work with saturating manipulation methods (i.e. 'exposure').
detect_light_src: False
# TODO: Fix and add description
vertical_grid_placement: False
# Whether to reuse .npy file in the 'damage' or 'manipulate' intermediate folders.
# TODO: Clarify functionality when using online damage
reuse_data:
damage: False
manipulate: False