IliaLarchenko commited on
Commit
1d02673
1 Parent(s): 75161a8

added more augmentations

Browse files
Files changed (3) hide show
  1. configs/augmentations.json +622 -0
  2. src/control.py +9 -2
  3. tests/test_utils.py +13 -1
configs/augmentations.json CHANGED
@@ -168,6 +168,89 @@
168
  "type": "rgb"
169
  }
170
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  "Equalize": [
172
  {
173
  "options_list": [
@@ -207,6 +290,55 @@
207
  "type": "num_interval"
208
  }
209
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  "HorizontalFlip": [],
211
  "HueSaturationValue": [
212
  {
@@ -246,6 +378,32 @@
246
  "type": "num_interval"
247
  }
248
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  "ImageCompression": [
250
  {
251
  "options_list": [
@@ -289,6 +447,28 @@
289
  "type": "min_max"
290
  }
291
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
  "MedianBlur": [
293
  {
294
  "defaults": [
@@ -317,6 +497,60 @@
317
  "type": "num_interval"
318
  }
319
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
  "RGBShift": [
321
  {
322
  "defaults": [
@@ -369,6 +603,37 @@
369
  "type": "num_interval"
370
  }
371
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
372
  "RandomContrast": [
373
  {
374
  "defaults": [
@@ -409,6 +674,20 @@
409
  "type": "num_interval"
410
  }
411
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
412
  "RandomGridShuffle": [
413
  {
414
  "defaults_list": [
@@ -433,6 +712,133 @@
433
  "type": "several_nums"
434
  }
435
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
436
  "RandomScale": [
437
  {
438
  "defaults": [
@@ -458,6 +864,61 @@
458
  "type": "radio"
459
  }
460
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
461
  "RandomSnow": [
462
  {
463
  "defaults_list": [
@@ -484,6 +945,167 @@
484
  "type": "num_interval"
485
  }
486
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
487
  "Solarize": [
488
  {
489
  "defaults": 128,
 
168
  "type": "rgb"
169
  }
170
  ],
171
+ "Downscale": [
172
+ {
173
+ "defaults_list": [
174
+ 0.25,
175
+ 0.25
176
+ ],
177
+ "limits_list": [
178
+ 0,
179
+ 1.0
180
+ ],
181
+ "param_name": [
182
+ "scale_min",
183
+ "scale_max"
184
+ ],
185
+ "type": "min_max"
186
+ },
187
+ {
188
+ "options_list": [
189
+ 0,
190
+ 1,
191
+ 2,
192
+ 3,
193
+ 4
194
+ ],
195
+ "param_name": "interpolation",
196
+ "type": "radio"
197
+ }
198
+ ],
199
+ "ElasticTransform": [
200
+ {
201
+ "defaults": 1.0,
202
+ "limits_list": [
203
+ 0.0,
204
+ 10.0
205
+ ],
206
+ "param_name": "alpha",
207
+ "type": "num_interval"
208
+ },
209
+ {
210
+ "defaults": 50.0,
211
+ "limits_list": [
212
+ 0.0,
213
+ 200.0
214
+ ],
215
+ "param_name": "sigma",
216
+ "type": "num_interval"
217
+ },
218
+ {
219
+ "defaults": 50.0,
220
+ "limits_list": [
221
+ 0.0,
222
+ 200.0
223
+ ],
224
+ "param_name": "alpha_affine",
225
+ "type": "num_interval"
226
+ },
227
+ {
228
+ "options_list": [
229
+ 0,
230
+ 1,
231
+ 2,
232
+ 3,
233
+ 4
234
+ ],
235
+ "param_name": "interpolation",
236
+ "type": "radio"
237
+ },
238
+ {
239
+ "options_list": [
240
+ 0,
241
+ 1,
242
+ 2,
243
+ 3,
244
+ 4
245
+ ],
246
+ "param_name": "border_mode",
247
+ "type": "radio"
248
+ },
249
+ {
250
+ "param_name": "value",
251
+ "type": "rgb"
252
+ }
253
+ ],
254
  "Equalize": [
255
  {
256
  "options_list": [
 
290
  "type": "num_interval"
291
  }
292
  ],
293
+ "GridDistortion": [
294
+ {
295
+ "defaults": 5,
296
+ "limits_list": [
297
+ 0,
298
+ 15
299
+ ],
300
+ "param_name": "shift_limit",
301
+ "type": "num_interval"
302
+ },
303
+ {
304
+ "defaults": [
305
+ -2.0,
306
+ 2.0
307
+ ],
308
+ "limits_list": [
309
+ -0.3,
310
+ 0.3
311
+ ],
312
+ "param_name": "distort_limit",
313
+ "type": "num_interval"
314
+ },
315
+ {
316
+ "options_list": [
317
+ 0,
318
+ 1,
319
+ 2,
320
+ 3,
321
+ 4
322
+ ],
323
+ "param_name": "interpolation",
324
+ "type": "radio"
325
+ },
326
+ {
327
+ "options_list": [
328
+ 0,
329
+ 1,
330
+ 2,
331
+ 3,
332
+ 4
333
+ ],
334
+ "param_name": "border_mode",
335
+ "type": "radio"
336
+ },
337
+ {
338
+ "param_name": "value",
339
+ "type": "rgb"
340
+ }
341
+ ],
342
  "HorizontalFlip": [],
343
  "HueSaturationValue": [
344
  {
 
378
  "type": "num_interval"
379
  }
380
  ],
381
+ "ISONoise": [
382
+ {
383
+ "defaults": [
384
+ 0.01,
385
+ 0.05
386
+ ],
387
+ "limits_list": [
388
+ 0.0,
389
+ 1.0
390
+ ],
391
+ "param_name": "color_shift",
392
+ "type": "num_interval"
393
+ },
394
+ {
395
+ "defaults": [
396
+ 0.1,
397
+ 0.5
398
+ ],
399
+ "limits_list": [
400
+ 0.0,
401
+ 2.0
402
+ ],
403
+ "param_name": "intensity",
404
+ "type": "num_interval"
405
+ }
406
+ ],
407
  "ImageCompression": [
408
  {
409
  "options_list": [
 
447
  "type": "min_max"
448
  }
449
  ],
450
+ "LongestMaxSize": [
451
+ {
452
+ "defaults": 512,
453
+ "limits_list": [
454
+ 1,
455
+ 1024
456
+ ],
457
+ "param_name": "max_size",
458
+ "type": "num_interval"
459
+ },
460
+ {
461
+ "options_list": [
462
+ 0,
463
+ 1,
464
+ 2,
465
+ 3,
466
+ 4
467
+ ],
468
+ "param_name": "interpolation",
469
+ "type": "radio"
470
+ }
471
+ ],
472
  "MedianBlur": [
473
  {
474
  "defaults": [
 
497
  "type": "num_interval"
498
  }
499
  ],
500
+ "MultiplicativeNoise": [
501
+ {
502
+ "defaults": [
503
+ 0.1,
504
+ 5.0
505
+ ],
506
+ "limits_list": [
507
+ 0.9,
508
+ 1.1
509
+ ],
510
+ "param_name": "multiplier",
511
+ "type": "num_interval"
512
+ },
513
+ {
514
+ "defaults": 1,
515
+ "param_name": "per_channel",
516
+ "type": "checkbox"
517
+ },
518
+ {
519
+ "defaults": 1,
520
+ "param_name": "elementwise",
521
+ "type": "checkbox"
522
+ }
523
+ ],
524
+ "Posterize": [
525
+ {
526
+ "defaults_list": [
527
+ 4,
528
+ 4,
529
+ 4
530
+ ],
531
+ "limits_list": [
532
+ [
533
+ 0,
534
+ 8
535
+ ],
536
+ [
537
+ 0,
538
+ 8
539
+ ],
540
+ [
541
+ 0,
542
+ 8
543
+ ]
544
+ ],
545
+ "param_name": "num_bits",
546
+ "subparam_names": [
547
+ "r",
548
+ "g",
549
+ "b"
550
+ ],
551
+ "type": "several_nums"
552
+ }
553
+ ],
554
  "RGBShift": [
555
  {
556
  "defaults": [
 
603
  "type": "num_interval"
604
  }
605
  ],
606
+ "RandomBrightnessContrast": [
607
+ {
608
+ "defaults": [
609
+ -0.2,
610
+ 0.2
611
+ ],
612
+ "limits_list": [
613
+ -1.0,
614
+ 1.0
615
+ ],
616
+ "param_name": "brightness_limit",
617
+ "type": "num_interval"
618
+ },
619
+ {
620
+ "defaults": [
621
+ -0.2,
622
+ 0.2
623
+ ],
624
+ "limits_list": [
625
+ -1.0,
626
+ 1.0
627
+ ],
628
+ "param_name": "contrast_limit",
629
+ "type": "num_interval"
630
+ },
631
+ {
632
+ "defaults": 1,
633
+ "param_name": "brightness_by_max",
634
+ "type": "checkbox"
635
+ }
636
+ ],
637
  "RandomContrast": [
638
  {
639
  "defaults": [
 
674
  "type": "num_interval"
675
  }
676
  ],
677
+ "RandomGamma": [
678
+ {
679
+ "defaults": [
680
+ 80,
681
+ 120
682
+ ],
683
+ "limits_list": [
684
+ 0,
685
+ 200
686
+ ],
687
+ "param_name": "gamma_limit",
688
+ "type": "num_interval"
689
+ }
690
+ ],
691
  "RandomGridShuffle": [
692
  {
693
  "defaults_list": [
 
712
  "type": "several_nums"
713
  }
714
  ],
715
+ "RandomRain": [
716
+ {
717
+ "defaults_list": [
718
+ -10,
719
+ 10
720
+ ],
721
+ "limits_list": [
722
+ -20,
723
+ 20
724
+ ],
725
+ "param_name": [
726
+ "slant_lower",
727
+ "slant_upper"
728
+ ],
729
+ "type": "min_max"
730
+ },
731
+ {
732
+ "defaults": 20,
733
+ "limits_list": [
734
+ 0,
735
+ 100
736
+ ],
737
+ "param_name": "drop_length",
738
+ "type": "num_interval"
739
+ },
740
+ {
741
+ "defaults": 1,
742
+ "limits_list": [
743
+ 1,
744
+ 5
745
+ ],
746
+ "param_name": "drop_width",
747
+ "type": "num_interval"
748
+ },
749
+ {
750
+ "param_name": "drop_color",
751
+ "type": "rgb"
752
+ },
753
+ {
754
+ "defaults": 7,
755
+ "limits_list": [
756
+ 1,
757
+ 15
758
+ ],
759
+ "param_name": "blur_value",
760
+ "type": "num_interval"
761
+ },
762
+ {
763
+ "defaults": 0.7,
764
+ "limits_list": [
765
+ 0.0,
766
+ 1.0
767
+ ],
768
+ "param_name": "brightness_coefficient",
769
+ "type": "num_interval"
770
+ },
771
+ {
772
+ "options_list": [
773
+ "None",
774
+ "drizzle",
775
+ "heavy",
776
+ "torrestial"
777
+ ],
778
+ "param_name": "rain_type",
779
+ "type": "radio"
780
+ }
781
+ ],
782
+ "RandomResizedCrop": [
783
+ {
784
+ "param_name": "height",
785
+ "placeholder": {
786
+ "defaults": "image_height",
787
+ "limits_list": [
788
+ 1,
789
+ "image_height"
790
+ ]
791
+ },
792
+ "type": "num_interval"
793
+ },
794
+ {
795
+ "param_name": "width",
796
+ "placeholder": {
797
+ "defaults": "image_width",
798
+ "limits_list": [
799
+ 1,
800
+ "image_width"
801
+ ]
802
+ },
803
+ "type": "num_interval"
804
+ },
805
+ {
806
+ "defaults": [
807
+ 0.08,
808
+ 1.0
809
+ ],
810
+ "limits_list": [
811
+ 0.01,
812
+ 1.0
813
+ ],
814
+ "param_name": "scale",
815
+ "type": "num_interval"
816
+ },
817
+ {
818
+ "defaults": [
819
+ 0.75,
820
+ 1.3333333333333333
821
+ ],
822
+ "limits_list": [
823
+ 0.1,
824
+ 10.0
825
+ ],
826
+ "param_name": "ratio",
827
+ "type": "num_interval"
828
+ },
829
+ {
830
+ "options_list": [
831
+ 0,
832
+ 1,
833
+ 2,
834
+ 3,
835
+ 4
836
+ ],
837
+ "param_name": "interpolation",
838
+ "type": "radio"
839
+ }
840
+ ],
841
+ "RandomRotate90": [],
842
  "RandomScale": [
843
  {
844
  "defaults": [
 
864
  "type": "radio"
865
  }
866
  ],
867
+ "RandomSizedCrop": [
868
+ {
869
+ "param_name": "min_max_height",
870
+ "placeholder": {
871
+ "defaults": "image_half_height",
872
+ "limits_list": [
873
+ 1,
874
+ "image_height"
875
+ ]
876
+ },
877
+ "type": "num_interval"
878
+ },
879
+ {
880
+ "param_name": "height",
881
+ "placeholder": {
882
+ "defaults": "image_height",
883
+ "limits_list": [
884
+ 1,
885
+ "image_height"
886
+ ]
887
+ },
888
+ "type": "num_interval"
889
+ },
890
+ {
891
+ "param_name": "width",
892
+ "placeholder": {
893
+ "defaults": "image_width",
894
+ "limits_list": [
895
+ 1,
896
+ "image_width"
897
+ ]
898
+ },
899
+ "type": "num_interval"
900
+ },
901
+ {
902
+ "defaults": 1.0,
903
+ "limits_list": [
904
+ 0.1,
905
+ 10.0
906
+ ],
907
+ "param_name": "w2h_ratio",
908
+ "type": "num_interval"
909
+ },
910
+ {
911
+ "options_list": [
912
+ 0,
913
+ 1,
914
+ 2,
915
+ 3,
916
+ 4
917
+ ],
918
+ "param_name": "interpolation",
919
+ "type": "radio"
920
+ }
921
+ ],
922
  "RandomSnow": [
923
  {
924
  "defaults_list": [
 
945
  "type": "num_interval"
946
  }
947
  ],
948
+ "Resize": [
949
+ {
950
+ "param_name": "height",
951
+ "placeholder": {
952
+ "defaults": "image_half_height",
953
+ "limits_list": [
954
+ 1,
955
+ "image_height"
956
+ ]
957
+ },
958
+ "type": "num_interval"
959
+ },
960
+ {
961
+ "param_name": "width",
962
+ "placeholder": {
963
+ "defaults": "image_half_width",
964
+ "limits_list": [
965
+ 1,
966
+ "image_width"
967
+ ]
968
+ },
969
+ "type": "num_interval"
970
+ },
971
+ {
972
+ "options_list": [
973
+ 0,
974
+ 1,
975
+ 2,
976
+ 3,
977
+ 4
978
+ ],
979
+ "param_name": "interpolation",
980
+ "type": "radio"
981
+ }
982
+ ],
983
+ "Rotate": [
984
+ {
985
+ "defaults": [
986
+ -90,
987
+ 90
988
+ ],
989
+ "limits_list": [
990
+ -360,
991
+ 360
992
+ ],
993
+ "param_name": "limit",
994
+ "type": "num_interval"
995
+ },
996
+ {
997
+ "options_list": [
998
+ 0,
999
+ 1,
1000
+ 2,
1001
+ 3,
1002
+ 4
1003
+ ],
1004
+ "param_name": "interpolation",
1005
+ "type": "radio"
1006
+ },
1007
+ {
1008
+ "options_list": [
1009
+ 0,
1010
+ 1,
1011
+ 2,
1012
+ 3,
1013
+ 4
1014
+ ],
1015
+ "param_name": "border_mode",
1016
+ "type": "radio"
1017
+ },
1018
+ {
1019
+ "param_name": "value",
1020
+ "type": "rgb"
1021
+ }
1022
+ ],
1023
+ "ShiftScaleRotate": [
1024
+ {
1025
+ "defaults": [
1026
+ -1.0,
1027
+ 1.0
1028
+ ],
1029
+ "limits_list": [
1030
+ -0.06,
1031
+ 0.06
1032
+ ],
1033
+ "param_name": "shift_limit",
1034
+ "type": "num_interval"
1035
+ },
1036
+ {
1037
+ "defaults": [
1038
+ -2.0,
1039
+ 2.0
1040
+ ],
1041
+ "limits_list": [
1042
+ -0.1,
1043
+ 0.1
1044
+ ],
1045
+ "param_name": "scale_limit",
1046
+ "type": "num_interval"
1047
+ },
1048
+ {
1049
+ "defaults": [
1050
+ -90,
1051
+ 90
1052
+ ],
1053
+ "limits_list": [
1054
+ -360,
1055
+ 360
1056
+ ],
1057
+ "param_name": "rotate_limit",
1058
+ "type": "num_interval"
1059
+ },
1060
+ {
1061
+ "options_list": [
1062
+ 0,
1063
+ 1,
1064
+ 2,
1065
+ 3,
1066
+ 4
1067
+ ],
1068
+ "param_name": "interpolation",
1069
+ "type": "radio"
1070
+ },
1071
+ {
1072
+ "options_list": [
1073
+ 0,
1074
+ 1,
1075
+ 2,
1076
+ 3,
1077
+ 4
1078
+ ],
1079
+ "param_name": "border_mode",
1080
+ "type": "radio"
1081
+ },
1082
+ {
1083
+ "param_name": "value",
1084
+ "type": "rgb"
1085
+ }
1086
+ ],
1087
+ "SmallestMaxSize": [
1088
+ {
1089
+ "defaults": 512,
1090
+ "limits_list": [
1091
+ 1,
1092
+ 1024
1093
+ ],
1094
+ "param_name": "max_size",
1095
+ "type": "num_interval"
1096
+ },
1097
+ {
1098
+ "options_list": [
1099
+ 0,
1100
+ 1,
1101
+ 2,
1102
+ 3,
1103
+ 4
1104
+ ],
1105
+ "param_name": "interpolation",
1106
+ "type": "radio"
1107
+ }
1108
+ ],
1109
  "Solarize": [
1110
  {
1111
  "defaults": 128,
src/control.py CHANGED
@@ -31,7 +31,7 @@ def select_several_nums(
31
  def select_min_max(param_name, limits_list, defaults_list, min_diff=0, **kwargs):
32
  assert len(param_name) == 2
33
  result = list(
34
- select_int_interval(" & ".join(param_name), limits_list, defaults_list)
35
  )
36
  if result[1] - result[0] < min_diff:
37
  diff = min_diff - result[1] + result[0]
@@ -54,10 +54,17 @@ def select_RGB(param_name, **kwargs):
54
  return tuple(result)
55
 
56
 
 
 
 
 
 
 
 
57
  def select_radio(param_name, options_list, **kwargs):
58
  st.sidebar.subheader(param_name)
59
  result = st.sidebar.radio("", options_list)
60
- return result
61
 
62
 
63
  def select_checkbox(param_name, defaults, **kwargs):
 
31
  def select_min_max(param_name, limits_list, defaults_list, min_diff=0, **kwargs):
32
  assert len(param_name) == 2
33
  result = list(
34
+ select_num_interval(" & ".join(param_name), limits_list, defaults_list)
35
  )
36
  if result[1] - result[0] < min_diff:
37
  diff = min_diff - result[1] + result[0]
 
54
  return tuple(result)
55
 
56
 
57
+ def replace_none(string):
58
+ if string == "None":
59
+ return None
60
+ else:
61
+ return string
62
+
63
+
64
  def select_radio(param_name, options_list, **kwargs):
65
  st.sidebar.subheader(param_name)
66
  result = st.sidebar.radio("", options_list)
67
+ return replace_none(result)
68
 
69
 
70
  def select_checkbox(param_name, defaults, **kwargs):
tests/test_utils.py CHANGED
@@ -36,8 +36,20 @@ def test_load_augmentations_config():
36
  )
37
 
38
  for transform_name in augmentations.keys():
39
- if transform_name in ["CenterCrop", "RandomCrop"]:
 
 
 
 
 
40
  param_values = {"p": 1.0, "height": 10, "width": 10}
 
 
 
 
 
 
 
41
  elif transform_name in ["Crop"]:
42
  param_values = {"p": 1.0, "x_max": 10, "y_max": 10}
43
  else:
 
36
  )
37
 
38
  for transform_name in augmentations.keys():
39
+ if transform_name in [
40
+ "CenterCrop",
41
+ "RandomCrop",
42
+ "RandomResizedCrop",
43
+ "Resize",
44
+ ]:
45
  param_values = {"p": 1.0, "height": 10, "width": 10}
46
+ elif transform_name in ["RandomSizedCrop"]:
47
+ param_values = {
48
+ "p": 1.0,
49
+ "height": 10,
50
+ "width": 10,
51
+ "min_max_height": (50, 50),
52
+ }
53
  elif transform_name in ["Crop"]:
54
  param_values = {"p": 1.0, "x_max": 10, "y_max": 10}
55
  else: