Skip to content
Snippets Groups Projects
Commit 7923d289 authored by tomrink's avatar tomrink
Browse files

snapshot...

parent 8b626a24
Branches
No related tags found
No related merge requests found
......@@ -37,6 +37,7 @@ NOISE_STDDEV = 0.01
DO_AUGMENT = True
DO_ZERO_OUT = False
DO_ESPCN = False # Note: If True, cannot do mixed resolution input fields (Adjust accordingly below)
# setup scaling parameters dictionary
mean_std_dct = {}
......@@ -98,10 +99,11 @@ elif KERNEL_SIZE == 5:
y_2 = np.arange(68)
# ----------------------------------------
# Exp for ESPCN version
# slc_x_2 = slice(0, 132, 2)
# slc_y_2 = slice(0, 132, 2)
# x_128 = slice(2, 130)
# y_128 = slice(2, 130)
if DO_ESPCN:
slc_x_2 = slice(0, 132, 2)
slc_y_2 = slice(0, 132, 2)
x_128 = slice(2, 130)
y_128 = slice(2, 130)
def build_residual_conv2d_block(conv, num_filters, block_name, activation=tf.nn.relu, padding='SAME',
......@@ -127,6 +129,13 @@ def build_residual_conv2d_block(conv, num_filters, block_name, activation=tf.nn.
return conv
def upsample(tmp):
tmp = tmp[:, slc_y_2, slc_x_2]
tmp = resample_2d_linear(x_2, y_2, tmp, t, s)
tmp = tmp[:, y_k, x_k]
return tmp
class SRCNN:
def __init__(self):
......@@ -259,10 +268,10 @@ class SRCNN:
tmp = tmp.copy()
tmp = np.where(np.isnan(tmp), 0, tmp)
# tmp = smooth_2d(tmp, sigma=1.0)
# Half res upsampled to full res:
if DO_ESPCN:
tmp = tmp[:, slc_y_2, slc_x_2]
tmp = resample_2d_linear(x_2, y_2, tmp, t, s)
tmp = tmp[:, y_k, x_k]
else: # Half res upsampled to full res:
tmp = upsample(tmp)
tmp = normalize(tmp, param, mean_std_dct)
if DO_ADD_NOISE:
tmp = add_noise(tmp, noise_scale=NOISE_STDDEV)
......@@ -285,9 +294,10 @@ class SRCNN:
tmp = tmp.copy()
tmp = np.where(np.isnan(tmp), 0, tmp)
# tmp = smooth_2d(tmp, sigma=1.0)
if DO_ESPCN:
tmp = tmp[:, slc_y_2, slc_x_2]
tmp = resample_2d_linear(x_2, y_2, tmp, t, s)
tmp = tmp[:, y_k, x_k]
else: # Half res upsampled to full res:
tmp = upsample(tmp)
if label_param != 'cloud_probability':
tmp = normalize(tmp, label_param, mean_std_dct)
if DO_ADD_NOISE:
......@@ -432,9 +442,16 @@ class SRCNN:
conv = conv + conv_b
print(conv.shape)
if not DO_ESPCN:
# This is effectively a Dense layer
self.logits = tf.keras.layers.Conv2D(1, kernel_size=1, strides=1, padding=padding, name='regression')(conv)
else:
conv = tf.keras.layers.Conv2D(num_filters * (factor ** 2), 3, padding=padding, activation=activation)(conv)
print(conv.shape)
conv = tf.nn.depth_to_space(conv, factor)
print(conv.shape)
self.logits = tf.keras.layers.Conv2D(IMG_DEPTH, kernel_size=3, strides=1, padding=padding, name='regression')(conv)
print(self.logits.shape)
def build_training(self):
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment