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

snapshot...

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