Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tom Rink
python
Commits
60c682b2
Commit
60c682b2
authored
2 years ago
by
tomrink
Browse files
Options
Downloads
Patches
Plain Diff
snapshot...
parent
8cad6ef4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/deeplearning/espcn_l1b_l2.py
+9
-6
9 additions, 6 deletions
modules/deeplearning/espcn_l1b_l2.py
with
9 additions
and
6 deletions
modules/deeplearning/espcn_l1b_l2.py
+
9
−
6
View file @
60c682b2
...
@@ -72,6 +72,8 @@ y_134_2 = y_134[2:133:2]
...
@@ -72,6 +72,8 @@ y_134_2 = y_134[2:133:2]
slc_x
=
slice
(
3
,
131
)
slc_x
=
slice
(
3
,
131
)
slc_y
=
slice
(
3
,
131
)
slc_y
=
slice
(
3
,
131
)
slc_x_2
=
slice
(
3
,
131
,
2
)
slc_y_2
=
slice
(
3
,
131
,
2
)
def
build_residual_conv2d_block
(
conv
,
num_filters
,
block_name
,
activation
=
tf
.
nn
.
leaky_relu
,
padding
=
'
SAME
'
,
scale
=
None
):
def
build_residual_conv2d_block
(
conv
,
num_filters
,
block_name
,
activation
=
tf
.
nn
.
leaky_relu
,
padding
=
'
SAME
'
,
scale
=
None
):
...
@@ -214,17 +216,19 @@ class ESPCN:
...
@@ -214,17 +216,19 @@ class ESPCN:
data_norm
=
[]
data_norm
=
[]
for
k
,
param
in
enumerate
(
data_params
):
for
k
,
param
in
enumerate
(
data_params
):
tmp
=
input_data
[:,
k
,
:,
:]
# tmp = input_data[:, k, :, :]
tmp
=
input_data
[:,
k
,
slc_y_2
,
slc_x_2
]
tmp
=
normalize
(
tmp
,
param
,
mean_std_dct
,
add_noise
=
add_noise
,
noise_scale
=
noise_scale
)
tmp
=
normalize
(
tmp
,
param
,
mean_std_dct
,
add_noise
=
add_noise
,
noise_scale
=
noise_scale
)
tmp
=
resample_2d_linear
(
x_134
,
y_134
,
tmp
,
x_134_2
,
y_134_2
)
#
tmp = resample_2d_linear(x_134, y_134, tmp, x_134_2, y_134_2)
data_norm
.
append
(
tmp
)
data_norm
.
append
(
tmp
)
tmp
=
input_data
[:,
label_idx
,
:,
]
# tmp = input_data[:, label_idx, :, ]
tmp
=
input_data
[:,
label_idx
,
slc_y_2
,
slc_x_2
]
if
label_param
!=
'
cloud_fraction
'
:
if
label_param
!=
'
cloud_fraction
'
:
tmp
=
normalize
(
tmp
,
label_param
,
mean_std_dct
,
add_noise
=
add_noise
,
noise_scale
=
noise_scale
)
tmp
=
normalize
(
tmp
,
label_param
,
mean_std_dct
,
add_noise
=
add_noise
,
noise_scale
=
noise_scale
)
else
:
else
:
tmp
=
np
.
where
(
np
.
isnan
(
tmp
),
0
,
tmp
)
tmp
=
np
.
where
(
np
.
isnan
(
tmp
),
0
,
tmp
)
tmp
=
resample_2d_linear
(
x_134
,
y_134
,
tmp
,
x_134_2
,
y_134_2
)
#
tmp = resample_2d_linear(x_134, y_134, tmp, x_134_2, y_134_2)
data_norm
.
append
(
tmp
)
data_norm
.
append
(
tmp
)
data
=
np
.
stack
(
data_norm
,
axis
=
3
)
data
=
np
.
stack
(
data_norm
,
axis
=
3
)
...
@@ -336,7 +340,6 @@ class ESPCN:
...
@@ -336,7 +340,6 @@ class ESPCN:
print
(
'
num test samples:
'
,
tst_idxs
.
shape
[
0
])
print
(
'
num test samples:
'
,
tst_idxs
.
shape
[
0
])
print
(
'
setup_pipeline: Done
'
)
print
(
'
setup_pipeline: Done
'
)
def
setup_test_pipeline
(
self
,
test_data_files
):
def
setup_test_pipeline
(
self
,
test_data_files
):
self
.
test_data_files
=
test_data_files
self
.
test_data_files
=
test_data_files
tst_idxs
=
np
.
arange
(
len
(
test_data_files
))
tst_idxs
=
np
.
arange
(
len
(
test_data_files
))
...
@@ -389,7 +392,7 @@ class ESPCN:
...
@@ -389,7 +392,7 @@ class ESPCN:
conv
=
conv_b
conv
=
conv_b
print
(
conv
.
shape
)
print
(
conv
.
shape
)
conv
=
tf
.
keras
.
layers
.
Conv2D
(
IMG_DEPTH
*
(
factor
**
2
),
3
,
padding
=
'
same
'
)(
conv
)
conv
=
tf
.
keras
.
layers
.
Conv2D
(
IMG_DEPTH
*
(
factor
**
2
),
3
,
padding
=
'
same
'
,
activation
=
activation
)(
conv
)
print
(
conv
.
shape
)
print
(
conv
.
shape
)
conv
=
tf
.
nn
.
depth_to_space
(
conv
,
factor
)
conv
=
tf
.
nn
.
depth_to_space
(
conv
,
factor
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment