Skip to content
Snippets Groups Projects
Commit 283778e7 authored by tomrink's avatar tomrink
Browse files

snapshot...

parent f1274950
No related branches found
No related tags found
No related merge requests found
...@@ -12,19 +12,18 @@ from util.setup import home_dir ...@@ -12,19 +12,18 @@ from util.setup import home_dir
target_param = 'cld_opd_dcomp' target_param = 'cld_opd_dcomp'
# SAVED_MODEL_PATH = "https://tfhub.dev/captain-pool/esrgan-tf2/1" # SAVED_MODEL_PATH = "https://tfhub.dev/captain-pool/esrgan-tf2/1"
# SAVED_MODEL_PATH = '/Users/tomrink/Downloads/esrgan-tf2_1' SAVED_MODEL_PATH = home_dir + '/esrgan-tf2_1'
SAVED_MODEL_PATH = home_dir+'/esrgan-tf2_1'
model = hub.load(SAVED_MODEL_PATH) model = hub.load(SAVED_MODEL_PATH)
def get_image(in_file): def get_image_from_file(in_file):
h5f = h5py.File(in_file, 'r') h5f = h5py.File(in_file, 'r')
# s_x = slice(2622, 3134) # s_x = slice(2622, 3134)
# s_y = slice(2622, 3134) # s_y = slice(2622, 3134)
s_x = slice(2238, 3518) s_x = slice(2110, 3646)
s_y = slice(2238, 3518) s_y = slice(2110, 3646)
# s_x = slice(1854, 3902) # s_x = slice(1854, 3902)
# s_y = slice(1854, 3902) # s_y = slice(1854, 3902)
...@@ -51,6 +50,24 @@ def get_image(in_file): ...@@ -51,6 +50,24 @@ def get_image(in_file):
return data return data
def get_image(data):
shape = data.shape
data = data.flatten()
lo = 0.0
hi = 160.0
data -= lo
data /= (hi - lo)
not_valid = np.isnan(data)
data[not_valid] = 0
data = np.reshape(data, shape)
return data
def preprocess_image(hr_image): def preprocess_image(hr_image):
""" Loads image from path and preprocesses to make it model ready """ Loads image from path and preprocesses to make it model ready
Args: Args:
...@@ -79,7 +96,8 @@ def preprocess_image(hr_image): ...@@ -79,7 +96,8 @@ def preprocess_image(hr_image):
def run(in_file, out_file): def run(in_file, out_file):
# model = hub.load(SAVED_MODEL_PATH) # model = hub.load(SAVED_MODEL_PATH)
t0 = time.time() t0 = time.time()
hr_image = get_image(in_file) hr_image = get_image_from_file(in_file)
# hr_image = get_image(in_file)
hr_image = preprocess_image(hr_image) hr_image = preprocess_image(hr_image)
t1 = time.time() t1 = time.time()
print('processing time: ', (t1-t0)) print('processing time: ', (t1-t0))
...@@ -93,4 +111,4 @@ def run(in_file, out_file): ...@@ -93,4 +111,4 @@ def run(in_file, out_file):
if out_file is not None: if out_file is not None:
np.save(out_file, fake_image) np.save(out_file, fake_image)
else: else:
return fake_image return fake_image, hr_image
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment