Skip to content

Commit

Permalink
limit blur kernel size
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenWizard2015 committed Apr 10, 2024
1 parent 54143dd commit 0531502
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
10 changes: 7 additions & 3 deletions NN/utils_bluring.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,19 @@ def f(img, points, ptR):
return blured
return f

def extractBluredOne():
def extractBluredOne(maxR=None):
if maxR is None:
getMaxR = lambda R: tf.cast(tf.reduce_max(R), tf.int32) + 1
else:
getMaxR = lambda R: maxR

def f(img, points, R):
img = img[None]
tf.assert_rank(img, 4)
B = tf.shape(points)[0]
tf.assert_equal(tf.shape(points), (B, 2))
R = tf.reshape(R, (1, ))
maxR = tf.cast(R, tf.int32) + 1
gaussians = gaussian_kernel(maxR[0], R)
gaussians = gaussian_kernel(getMaxR(R), R)
blured = applyBluring(img, gaussians)
gaussiansN = tf.shape(gaussians)[-1]
tf.assert_equal(tf.shape(blured), (gaussiansN, tf.shape(img)[1], tf.shape(img)[2], 3))
Expand Down
2 changes: 1 addition & 1 deletion Utils/CroppingAugm.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def SubsampleProcessor(target_crop_size, N, extras=[], sampler='uniform'):
blurN = tf.size(blurRange)
blurShared = blurConfig.get('shared', False)
if blurShared:
blur = extractBluredOne()
blur = extractBluredOne(maxR=blurConfig.get('max kernel', None))
else:
blur = extractBlured(blurRange)
pass
Expand Down
1 change: 1 addition & 0 deletions configs/experiments/blur/basic-shared.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"blur": {
"min": 1e-5,
"max": 8,
"max kernel": 8,
"N": 100,
"shared": true
}
Expand Down
1 change: 1 addition & 0 deletions configs/experiments/blur/basic.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"blur": {
"min": 1e-5,
"max": 8,
"max kernel": 8,
"N": 100,
"shared": false
}
Expand Down

0 comments on commit 0531502

Please sign in to comment.