Commit
·
6e61d26
1
Parent(s):
4fe3025
formatting
Browse files- configs/augmentations.json +424 -168
- src/control.py +27 -18
- src/main.py +36 -27
configs/augmentations.json
CHANGED
|
@@ -1,170 +1,426 @@
|
|
| 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 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"ToGray": [],
|
| 3 |
+
"ToSepia": [],
|
| 4 |
+
"ChannelShuffle": [],
|
| 5 |
+
"InvertImg": [],
|
| 6 |
+
"VerticalFlip": [],
|
| 7 |
+
"HorizontalFlip": [],
|
| 8 |
+
"Flip": [],
|
| 9 |
+
"RandomGridShuffle": [
|
| 10 |
+
{
|
| 11 |
+
"param_name": "grid",
|
| 12 |
+
"type": "several_ints",
|
| 13 |
+
"subparam_names": [
|
| 14 |
+
"y",
|
| 15 |
+
"x"
|
| 16 |
+
],
|
| 17 |
+
"limits_list": [
|
| 18 |
+
[
|
| 19 |
+
1,
|
| 20 |
+
10
|
| 21 |
+
],
|
| 22 |
+
[
|
| 23 |
+
1,
|
| 24 |
+
10
|
| 25 |
+
]
|
| 26 |
+
],
|
| 27 |
+
"defaults_list": [
|
| 28 |
+
3,
|
| 29 |
+
3
|
| 30 |
+
]
|
| 31 |
+
}
|
| 32 |
+
],
|
| 33 |
+
"Blur": [
|
| 34 |
+
{
|
| 35 |
+
"param_name": "blur_limit",
|
| 36 |
+
"type": "int_interval",
|
| 37 |
+
"limits_list": [
|
| 38 |
+
3,
|
| 39 |
+
100
|
| 40 |
+
],
|
| 41 |
+
"defaults": [
|
| 42 |
+
3,
|
| 43 |
+
7
|
| 44 |
+
]
|
| 45 |
+
}
|
| 46 |
+
],
|
| 47 |
+
"MotionBlur": [
|
| 48 |
+
{
|
| 49 |
+
"param_name": "blur_limit",
|
| 50 |
+
"type": "int_interval",
|
| 51 |
+
"limits_list": [
|
| 52 |
+
3,
|
| 53 |
+
100
|
| 54 |
+
],
|
| 55 |
+
"defaults": [
|
| 56 |
+
3,
|
| 57 |
+
7
|
| 58 |
+
]
|
| 59 |
+
}
|
| 60 |
+
],
|
| 61 |
+
"MedianBlur": [
|
| 62 |
+
{
|
| 63 |
+
"param_name": "blur_limit",
|
| 64 |
+
"type": "int_interval",
|
| 65 |
+
"limits_list": [
|
| 66 |
+
3,
|
| 67 |
+
100
|
| 68 |
+
],
|
| 69 |
+
"defaults": [
|
| 70 |
+
3,
|
| 71 |
+
7
|
| 72 |
+
]
|
| 73 |
+
}
|
| 74 |
+
],
|
| 75 |
+
"GaussNoise": [
|
| 76 |
+
{
|
| 77 |
+
"param_name": "var_limit",
|
| 78 |
+
"type": "int_interval",
|
| 79 |
+
"limits_list": [
|
| 80 |
+
0.0,
|
| 81 |
+
500.0
|
| 82 |
+
],
|
| 83 |
+
"defaults": [
|
| 84 |
+
10.0,
|
| 85 |
+
50.0
|
| 86 |
+
]
|
| 87 |
+
},
|
| 88 |
+
{
|
| 89 |
+
"param_name": "mean",
|
| 90 |
+
"type": "int_interval",
|
| 91 |
+
"limits_list": [
|
| 92 |
+
-100.0,
|
| 93 |
+
100.0
|
| 94 |
+
],
|
| 95 |
+
"defaults": 0.0
|
| 96 |
+
}
|
| 97 |
+
],
|
| 98 |
+
"RandomBrightness": [
|
| 99 |
+
{
|
| 100 |
+
"param_name": "limit",
|
| 101 |
+
"type": "int_interval",
|
| 102 |
+
"limits_list": [
|
| 103 |
+
-1.0,
|
| 104 |
+
1.0
|
| 105 |
+
],
|
| 106 |
+
"defaults": [
|
| 107 |
+
-0.2,
|
| 108 |
+
0.2
|
| 109 |
+
]
|
| 110 |
+
}
|
| 111 |
+
],
|
| 112 |
+
"RandomContrast": [
|
| 113 |
+
{
|
| 114 |
+
"param_name": "limit",
|
| 115 |
+
"type": "int_interval",
|
| 116 |
+
"limits_list": [
|
| 117 |
+
-1.0,
|
| 118 |
+
1.0
|
| 119 |
+
],
|
| 120 |
+
"defaults": [
|
| 121 |
+
-0.2,
|
| 122 |
+
0.2
|
| 123 |
+
]
|
| 124 |
+
}
|
| 125 |
+
],
|
| 126 |
+
"HueSaturationValue": [
|
| 127 |
+
{
|
| 128 |
+
"param_name": "hue_shift_limit",
|
| 129 |
+
"type": "int_interval",
|
| 130 |
+
"limits_list": [
|
| 131 |
+
-100,
|
| 132 |
+
100
|
| 133 |
+
],
|
| 134 |
+
"defaults": [
|
| 135 |
+
-20,
|
| 136 |
+
20
|
| 137 |
+
]
|
| 138 |
+
},
|
| 139 |
+
{
|
| 140 |
+
"param_name": "sat_shift_limit",
|
| 141 |
+
"type": "int_interval",
|
| 142 |
+
"limits_list": [
|
| 143 |
+
-100,
|
| 144 |
+
100
|
| 145 |
+
],
|
| 146 |
+
"defaults": [
|
| 147 |
+
-30,
|
| 148 |
+
30
|
| 149 |
+
]
|
| 150 |
+
},
|
| 151 |
+
{
|
| 152 |
+
"param_name": "val_shift_limit",
|
| 153 |
+
"type": "int_interval",
|
| 154 |
+
"limits_list": [
|
| 155 |
+
-100,
|
| 156 |
+
100
|
| 157 |
+
],
|
| 158 |
+
"defaults": [
|
| 159 |
+
-20,
|
| 160 |
+
20
|
| 161 |
+
]
|
| 162 |
+
}
|
| 163 |
+
],
|
| 164 |
+
"RGBShift": [
|
| 165 |
+
{
|
| 166 |
+
"param_name": "r_shift_limit",
|
| 167 |
+
"type": "int_interval",
|
| 168 |
+
"limits_list": [
|
| 169 |
+
-255,
|
| 170 |
+
255
|
| 171 |
+
],
|
| 172 |
+
"defaults": [
|
| 173 |
+
-20,
|
| 174 |
+
20
|
| 175 |
+
]
|
| 176 |
+
},
|
| 177 |
+
{
|
| 178 |
+
"param_name": "g_shift_limit",
|
| 179 |
+
"type": "int_interval",
|
| 180 |
+
"limits_list": [
|
| 181 |
+
-255,
|
| 182 |
+
255
|
| 183 |
+
],
|
| 184 |
+
"defaults": [
|
| 185 |
+
-20,
|
| 186 |
+
20
|
| 187 |
+
]
|
| 188 |
+
},
|
| 189 |
+
{
|
| 190 |
+
"param_name": "b_shift_limit",
|
| 191 |
+
"type": "int_interval",
|
| 192 |
+
"limits_list": [
|
| 193 |
+
-255,
|
| 194 |
+
255
|
| 195 |
+
],
|
| 196 |
+
"defaults": [
|
| 197 |
+
-20,
|
| 198 |
+
20
|
| 199 |
+
]
|
| 200 |
+
}
|
| 201 |
+
],
|
| 202 |
+
"JpegCompression": [
|
| 203 |
+
{
|
| 204 |
+
"param_name": "quality_lower",
|
| 205 |
+
"type": "int_interval",
|
| 206 |
+
"limits_list": [
|
| 207 |
+
0,
|
| 208 |
+
100
|
| 209 |
+
],
|
| 210 |
+
"defaults": 99
|
| 211 |
+
},
|
| 212 |
+
{
|
| 213 |
+
"param_name": "quality_upper",
|
| 214 |
+
"type": "int_interval",
|
| 215 |
+
"limits_list": [
|
| 216 |
+
0,
|
| 217 |
+
100
|
| 218 |
+
],
|
| 219 |
+
"defaults": 100
|
| 220 |
+
}
|
| 221 |
+
],
|
| 222 |
+
"ImageCompression": [
|
| 223 |
+
{
|
| 224 |
+
"param_name": "quality_lower",
|
| 225 |
+
"type": "int_interval",
|
| 226 |
+
"limits_list": [
|
| 227 |
+
0,
|
| 228 |
+
100
|
| 229 |
+
],
|
| 230 |
+
"defaults": 99
|
| 231 |
+
},
|
| 232 |
+
{
|
| 233 |
+
"param_name": "quality_upper",
|
| 234 |
+
"type": "int_interval",
|
| 235 |
+
"limits_list": [
|
| 236 |
+
0,
|
| 237 |
+
100
|
| 238 |
+
],
|
| 239 |
+
"defaults": 100
|
| 240 |
+
},
|
| 241 |
+
{
|
| 242 |
+
"param_name": "compression_type",
|
| 243 |
+
"type": "radio",
|
| 244 |
+
"options_list": [
|
| 245 |
+
0,
|
| 246 |
+
1
|
| 247 |
+
]
|
| 248 |
+
}
|
| 249 |
+
],
|
| 250 |
+
"CLAHE": [
|
| 251 |
+
{
|
| 252 |
+
"param_name": "clip_limit",
|
| 253 |
+
"type": "int_interval",
|
| 254 |
+
"limits_list": [
|
| 255 |
+
1,
|
| 256 |
+
100
|
| 257 |
+
],
|
| 258 |
+
"defaults": [
|
| 259 |
+
1,
|
| 260 |
+
4
|
| 261 |
+
]
|
| 262 |
+
},
|
| 263 |
+
{
|
| 264 |
+
"param_name": "tile_grid_size",
|
| 265 |
+
"type": "several_ints",
|
| 266 |
+
"subparam_names": [
|
| 267 |
+
"y",
|
| 268 |
+
"x"
|
| 269 |
+
],
|
| 270 |
+
"limits_list": [
|
| 271 |
+
[
|
| 272 |
+
1,
|
| 273 |
+
100
|
| 274 |
+
],
|
| 275 |
+
[
|
| 276 |
+
1,
|
| 277 |
+
100
|
| 278 |
+
]
|
| 279 |
+
],
|
| 280 |
+
"defaults_list": [
|
| 281 |
+
8,
|
| 282 |
+
8
|
| 283 |
+
]
|
| 284 |
+
}
|
| 285 |
+
],
|
| 286 |
+
"Cutout": [
|
| 287 |
+
{
|
| 288 |
+
"param_name": "num_holes",
|
| 289 |
+
"type": "int_interval",
|
| 290 |
+
"limits_list": [
|
| 291 |
+
1,
|
| 292 |
+
100
|
| 293 |
+
],
|
| 294 |
+
"defaults": 8
|
| 295 |
+
},
|
| 296 |
+
{
|
| 297 |
+
"param_name": "max_h_size",
|
| 298 |
+
"type": "int_interval",
|
| 299 |
+
"limits_list": [
|
| 300 |
+
1,
|
| 301 |
+
100
|
| 302 |
+
],
|
| 303 |
+
"defaults": 8
|
| 304 |
+
},
|
| 305 |
+
{
|
| 306 |
+
"param_name": "max_w_size",
|
| 307 |
+
"type": "int_interval",
|
| 308 |
+
"limits_list": [
|
| 309 |
+
1,
|
| 310 |
+
100
|
| 311 |
+
],
|
| 312 |
+
"defaults": 8
|
| 313 |
+
},
|
| 314 |
+
{
|
| 315 |
+
"param_name": "fill_value",
|
| 316 |
+
"type": "rgb"
|
| 317 |
+
}
|
| 318 |
+
],
|
| 319 |
+
"RandomSnow": [
|
| 320 |
+
{
|
| 321 |
+
"param_name": "snow_point_lower",
|
| 322 |
+
"type": "int_interval",
|
| 323 |
+
"limits_list": [
|
| 324 |
+
0.0,
|
| 325 |
+
1.0
|
| 326 |
+
],
|
| 327 |
+
"defaults": 0.1
|
| 328 |
+
},
|
| 329 |
+
{
|
| 330 |
+
"param_name": "snow_point_upper",
|
| 331 |
+
"type": "int_interval",
|
| 332 |
+
"limits_list": [
|
| 333 |
+
0.0,
|
| 334 |
+
1.0
|
| 335 |
+
],
|
| 336 |
+
"defaults": 0.1
|
| 337 |
+
},
|
| 338 |
+
{
|
| 339 |
+
"param_name": "brightness_coeff",
|
| 340 |
+
"type": "int_interval",
|
| 341 |
+
"limits_list": [
|
| 342 |
+
0.0,
|
| 343 |
+
20.0
|
| 344 |
+
],
|
| 345 |
+
"defaults": 2.5
|
| 346 |
+
}
|
| 347 |
+
],
|
| 348 |
+
"RandomFog": [
|
| 349 |
+
{
|
| 350 |
+
"param_name": "fog_coef_lower",
|
| 351 |
+
"type": "int_interval",
|
| 352 |
+
"limits_list": [
|
| 353 |
+
0.0,
|
| 354 |
+
1.0
|
| 355 |
+
],
|
| 356 |
+
"defaults": 0.1
|
| 357 |
+
},
|
| 358 |
+
{
|
| 359 |
+
"param_name": "fog_coef_upper",
|
| 360 |
+
"type": "int_interval",
|
| 361 |
+
"limits_list": [
|
| 362 |
+
0.0,
|
| 363 |
+
1.0
|
| 364 |
+
],
|
| 365 |
+
"defaults": 0.1
|
| 366 |
+
},
|
| 367 |
+
{
|
| 368 |
+
"param_name": "alpha_coef",
|
| 369 |
+
"type": "int_interval",
|
| 370 |
+
"limits_list": [
|
| 371 |
+
0.0,
|
| 372 |
+
1.0
|
| 373 |
+
],
|
| 374 |
+
"defaults": 0.08
|
| 375 |
+
}
|
| 376 |
+
],
|
| 377 |
+
"ChannelDropout": [
|
| 378 |
+
{
|
| 379 |
+
"param_name": "channel_drop_range",
|
| 380 |
+
"type": "int_interval",
|
| 381 |
+
"limits_list": [
|
| 382 |
+
1,
|
| 383 |
+
3
|
| 384 |
+
],
|
| 385 |
+
"defaults": [
|
| 386 |
+
1,
|
| 387 |
+
1
|
| 388 |
+
]
|
| 389 |
+
},
|
| 390 |
+
{
|
| 391 |
+
"param_name": "fill_value",
|
| 392 |
+
"type": "int_interval",
|
| 393 |
+
"limits_list": [
|
| 394 |
+
0,
|
| 395 |
+
255
|
| 396 |
+
],
|
| 397 |
+
"defaults": 0
|
| 398 |
+
}
|
| 399 |
+
],
|
| 400 |
+
"Solarize": [
|
| 401 |
+
{
|
| 402 |
+
"param_name": "threshold",
|
| 403 |
+
"type": "int_interval",
|
| 404 |
+
"limits_list": [
|
| 405 |
+
0,
|
| 406 |
+
255
|
| 407 |
+
],
|
| 408 |
+
"defaults": 128
|
| 409 |
+
}
|
| 410 |
+
],
|
| 411 |
+
"Equalize": [
|
| 412 |
+
{
|
| 413 |
+
"param_name": "mode",
|
| 414 |
+
"type": "radio",
|
| 415 |
+
"options_list": [
|
| 416 |
+
"cv",
|
| 417 |
+
"pil"
|
| 418 |
+
]
|
| 419 |
+
},
|
| 420 |
+
{
|
| 421 |
+
"param_name": "by_channels",
|
| 422 |
+
"type": "checkbox",
|
| 423 |
+
"defaults": 1
|
| 424 |
+
}
|
| 425 |
+
]
|
| 426 |
}
|
src/control.py
CHANGED
|
@@ -3,32 +3,43 @@ import streamlit as st
|
|
| 3 |
|
| 4 |
def select_int_interval(param_name, limits_list, defaults, **kwargs):
|
| 5 |
st.sidebar.subheader(param_name)
|
| 6 |
-
min_max_interval = st.sidebar.slider(
|
|
|
|
|
|
|
| 7 |
return min_max_interval
|
| 8 |
|
| 9 |
|
| 10 |
-
def select_several_ints(
|
|
|
|
|
|
|
| 11 |
st.sidebar.subheader(param_name)
|
| 12 |
result = []
|
| 13 |
assert len(limits_list) == len(defaults_list)
|
| 14 |
assert len(subparam_names) == len(defaults_list)
|
| 15 |
-
|
| 16 |
for name, limits, defaults in zip(subparam_names, limits_list, defaults_list):
|
| 17 |
-
result.append(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
return tuple(result)
|
| 19 |
|
|
|
|
| 20 |
def select_several_RGB(param_name, **kwargs):
|
| 21 |
-
result = select_several_ints(
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
| 25 |
return tuple(result)
|
| 26 |
|
| 27 |
|
| 28 |
def select_radio(param_name, options_list, **kwargs):
|
| 29 |
st.sidebar.subheader(param_name)
|
| 30 |
-
result = st.sidebar.radio(
|
| 31 |
-
if isinstance(options_list[0],str):
|
| 32 |
result = '"' + result + '"'
|
| 33 |
return result
|
| 34 |
|
|
@@ -39,13 +50,11 @@ def select_checkbox(param_name, defaults, **kwargs):
|
|
| 39 |
return result
|
| 40 |
|
| 41 |
|
| 42 |
-
|
| 43 |
# dict from param name to function showing this param
|
| 44 |
param2func = {
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
}
|
|
|
|
| 3 |
|
| 4 |
def select_int_interval(param_name, limits_list, defaults, **kwargs):
|
| 5 |
st.sidebar.subheader(param_name)
|
| 6 |
+
min_max_interval = st.sidebar.slider(
|
| 7 |
+
"", limits_list[0], limits_list[1], defaults, key=hash(param_name)
|
| 8 |
+
)
|
| 9 |
return min_max_interval
|
| 10 |
|
| 11 |
|
| 12 |
+
def select_several_ints(
|
| 13 |
+
param_name, subparam_names, limits_list, defaults_list, **kwargs
|
| 14 |
+
):
|
| 15 |
st.sidebar.subheader(param_name)
|
| 16 |
result = []
|
| 17 |
assert len(limits_list) == len(defaults_list)
|
| 18 |
assert len(subparam_names) == len(defaults_list)
|
| 19 |
+
|
| 20 |
for name, limits, defaults in zip(subparam_names, limits_list, defaults_list):
|
| 21 |
+
result.append(
|
| 22 |
+
st.sidebar.slider(
|
| 23 |
+
name, limits[0], limits[1], defaults, key=hash(param_name + name)
|
| 24 |
+
)
|
| 25 |
+
)
|
| 26 |
return tuple(result)
|
| 27 |
|
| 28 |
+
|
| 29 |
def select_several_RGB(param_name, **kwargs):
|
| 30 |
+
result = select_several_ints(
|
| 31 |
+
param_name,
|
| 32 |
+
subparam_names=["Red", "Green", "Blue"],
|
| 33 |
+
limits_list=[[0, 255], [0, 255], [0, 255]],
|
| 34 |
+
defaults_list=[0, 0, 0],
|
| 35 |
+
)
|
| 36 |
return tuple(result)
|
| 37 |
|
| 38 |
|
| 39 |
def select_radio(param_name, options_list, **kwargs):
|
| 40 |
st.sidebar.subheader(param_name)
|
| 41 |
+
result = st.sidebar.radio("", options_list)
|
| 42 |
+
if isinstance(options_list[0], str):
|
| 43 |
result = '"' + result + '"'
|
| 44 |
return result
|
| 45 |
|
|
|
|
| 50 |
return result
|
| 51 |
|
| 52 |
|
|
|
|
| 53 |
# dict from param name to function showing this param
|
| 54 |
param2func = {
|
| 55 |
+
"int_interval": select_int_interval,
|
| 56 |
+
"several_ints": select_several_ints,
|
| 57 |
+
"radio": select_radio,
|
| 58 |
+
"rgb": select_several_RGB,
|
| 59 |
+
"checkbox": select_checkbox,
|
| 60 |
+
}
|
|
|
src/main.py
CHANGED
|
@@ -9,56 +9,65 @@ import streamlit as st
|
|
| 9 |
from control import *
|
| 10 |
|
| 11 |
|
| 12 |
-
def load_image(image_name, path_to_folder
|
| 13 |
path_to_image = os.path.join(path_to_folder, image_name)
|
| 14 |
image = cv2.imread(path_to_image)
|
| 15 |
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 16 |
return image
|
| 17 |
|
| 18 |
|
| 19 |
-
st.title(
|
| 20 |
|
| 21 |
|
| 22 |
# selecting the image
|
| 23 |
-
path_to_images =
|
| 24 |
-
image_names_list = [
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
image = load_image(image_name, path_to_images)
|
| 27 |
|
| 28 |
|
| 29 |
# selecting the transformation
|
| 30 |
-
path_to_config =
|
| 31 |
-
with open(path_to_config,
|
| 32 |
augmentations = json.load(config_file)
|
| 33 |
-
transform_name = st.sidebar.selectbox(
|
|
|
|
|
|
|
| 34 |
transform_params = augmentations[transform_name]
|
| 35 |
|
| 36 |
|
| 37 |
# show the transform options
|
| 38 |
if len(transform_params) == 0:
|
| 39 |
-
st.sidebar.text(transform_name +
|
| 40 |
else:
|
| 41 |
for param in transform_params:
|
| 42 |
-
param[
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
params_string = ", ".join([param['param_name'] + '=' + str(param['value']) for param in transform_params] + ['p=1.0'])
|
| 46 |
-
params_string = '(' + params_string + ')'
|
| 47 |
|
| 48 |
-
st.text(transform_name + params_string)
|
| 49 |
-
st.text('Press R to update')
|
| 50 |
-
exec('transform = A.' + transform_name + params_string)
|
| 51 |
-
st.image([image, transform(image = image)['image']],
|
| 52 |
-
caption = ['Original image', 'Transformed image'],
|
| 53 |
-
width = 320)
|
| 54 |
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
st.text(str(transform.__doc__))
|
| 57 |
|
| 58 |
|
| 59 |
-
st.text(
|
| 60 |
-
st.text(
|
| 61 |
-
st.subheader(
|
| 62 |
-
st.text(
|
| 63 |
-
st.text(
|
| 64 |
-
st.text(
|
|
|
|
| 9 |
from control import *
|
| 10 |
|
| 11 |
|
| 12 |
+
def load_image(image_name, path_to_folder="../images"):
|
| 13 |
path_to_image = os.path.join(path_to_folder, image_name)
|
| 14 |
image = cv2.imread(path_to_image)
|
| 15 |
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 16 |
return image
|
| 17 |
|
| 18 |
|
| 19 |
+
st.title("Demo of Albumentations transforms")
|
| 20 |
|
| 21 |
|
| 22 |
# selecting the image
|
| 23 |
+
path_to_images = "images"
|
| 24 |
+
image_names_list = [
|
| 25 |
+
x for x in os.listdir(path_to_images) if x[-3:] in ["jpg", "peg", "png"]
|
| 26 |
+
]
|
| 27 |
+
image_name = st.sidebar.selectbox("Select an image:", image_names_list)
|
| 28 |
image = load_image(image_name, path_to_images)
|
| 29 |
|
| 30 |
|
| 31 |
# selecting the transformation
|
| 32 |
+
path_to_config = "configs/augmentations.json"
|
| 33 |
+
with open(path_to_config, "r") as config_file:
|
| 34 |
augmentations = json.load(config_file)
|
| 35 |
+
transform_name = st.sidebar.selectbox(
|
| 36 |
+
"Select a transformation:", sorted(list(augmentations.keys()))
|
| 37 |
+
)
|
| 38 |
transform_params = augmentations[transform_name]
|
| 39 |
|
| 40 |
|
| 41 |
# show the transform options
|
| 42 |
if len(transform_params) == 0:
|
| 43 |
+
st.sidebar.text(transform_name + " transform has no parameters")
|
| 44 |
else:
|
| 45 |
for param in transform_params:
|
| 46 |
+
param["value"] = param2func[param["type"]](**param)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
+
params_string = ", ".join(
|
| 50 |
+
[param["param_name"] + "=" + str(param["value"]) for param in transform_params]
|
| 51 |
+
+ ["p=1.0"]
|
| 52 |
+
)
|
| 53 |
+
params_string = "(" + params_string + ")"
|
| 54 |
+
|
| 55 |
+
st.text(transform_name + params_string)
|
| 56 |
+
st.text("Press R to update")
|
| 57 |
+
exec("transform = A." + transform_name + params_string)
|
| 58 |
+
st.image(
|
| 59 |
+
[image, transform(image=image)["image"]],
|
| 60 |
+
caption=["Original image", "Transformed image"],
|
| 61 |
+
width=320,
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
st.subheader("Docstring:")
|
| 65 |
st.text(str(transform.__doc__))
|
| 66 |
|
| 67 |
|
| 68 |
+
st.text("")
|
| 69 |
+
st.text("")
|
| 70 |
+
st.subheader("Credentials:")
|
| 71 |
+
st.text("Source: https://github.com/IliaLarchenko/albumentations-demo")
|
| 72 |
+
st.text("Albumentations library: https://github.com/albumentations-team/albumentations")
|
| 73 |
+
st.text("Image Source: https://www.pexels.com/royalty-free-images/")
|