@@ -36,6 +36,7 @@ def SubsampleProcessor(target_crop_size, N, extras=[], sampler='uniform'):
36
36
withBlur = blurConfig is not None
37
37
if withBlur :
38
38
blurRange = blurConfig ['min' ] + tf .linspace (0.0 , blurConfig ['max' ], blurConfig ['N' ])
39
+ minR = tf .reduce_min (blurRange )
39
40
blurN = tf .size (blurRange )
40
41
blurShared = blurConfig .get ('shared' , False )
41
42
if blurShared :
@@ -60,20 +61,21 @@ def _FF(img):
60
61
sobel = extractInterpolated (sobel , positions )
61
62
res ['sobel' ] = tf .reshape (sobel , [N , 6 ])
62
63
63
- if withBlur and blurShared :
64
- idx = tf .random .uniform ((1 ,), minval = 0 , maxval = blurN , dtype = tf .int32 )
65
- R = tf .gather (blurRange , idx )
66
- R = tf .reshape (R , (1 ,))
64
+ if withBlur :
65
+ if blurShared :
66
+ idx = tf .random .uniform ((1 ,), minval = 0 , maxval = blurN , dtype = tf .int32 )
67
+ R = tf .gather (blurRange , idx )
68
+ R = tf .reshape (R , (1 ,))
69
+ R = tf .fill ([N , 1 ], R [0 ])
70
+ else :
71
+ idx = tf .random .uniform ((N ,), minval = 0 , maxval = blurN , dtype = tf .int32 )
72
+ R = tf .gather (blurRange , idx )
73
+ R = tf .reshape (R , (N , 1 ))
74
+ pass
75
+
76
+ tf .assert_equal (tf .shape (R ), (N , 1 ))
67
77
res ['blured' ] = blur (src , positions [0 ], R )
68
- res ['blur R' ] = tf .fill ([N , 1 ], R [0 ])
69
- pass
70
-
71
- if withBlur and not blurShared :
72
- idx = tf .random .uniform ((N ,), minval = 0 , maxval = blurN , dtype = tf .int32 )
73
- R = tf .gather (blurRange , idx )
74
- R = tf .reshape (R , (N , 1 ))
75
- res ['blured' ] = blur (src , positions [0 ], R )
76
- res ['blur R' ] = R
78
+ res ['blur R' ] = R - minR # ensure that R is starting from 0.0
77
79
pass
78
80
return res
79
81
return _FF
0 commit comments