Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
python3-imagej-tiff
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Elphel
python3-imagej-tiff
Commits
eeee0fcf
Commit
eeee0fcf
authored
Aug 09, 2018
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding 2-stage nn
parent
c64289c7
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1263 additions
and
19 deletions
+1263
-19
explore_data.py
explore_data.py
+20
-19
nn_ds_inmem5.py
nn_ds_inmem5.py
+531
-0
nn_ds_neibs.py
nn_ds_neibs.py
+712
-0
No files found.
explore_data.py
View file @
eeee0fcf
...
@@ -377,18 +377,6 @@ class ExploreData:
...
@@ -377,18 +377,6 @@ class ExploreData:
num_batch_tiles
=
np
.
empty
((
data_ds
.
shape
[
0
],
self
.
hist_to_batch
.
max
()
+
1
),
dtype
=
int
)
num_batch_tiles
=
np
.
empty
((
data_ds
.
shape
[
0
],
self
.
hist_to_batch
.
max
()
+
1
),
dtype
=
int
)
bb
=
self
.
getBB
(
data_ds
)
bb
=
self
.
getBB
(
data_ds
)
use_neibs
=
not
((
disp_var
is
None
)
or
(
disp_neibs
is
None
)
or
(
min_var
is
None
)
or
(
max_var
is
None
)
or
(
min_neibs
is
None
))
use_neibs
=
not
((
disp_var
is
None
)
or
(
disp_neibs
is
None
)
or
(
min_var
is
None
)
or
(
max_var
is
None
)
or
(
min_neibs
is
None
))
'''
bb = np.empty((data_ds.shape[0],data_ds.shape[1],data_ds.shape[2]),int)
for findx in range(data_ds.shape[0]):
ds = data_ds[findx]
gt = ds[...,1] > 0.0 # all true - check
db = (((ds[...,0] - self.disparity_min_clip)/disp_step).astype(int))*gt
sb = (((ds[...,1] - self.strength_min_clip)/ str_step).astype(int))*gt
np.clip(db, 0, self.disparity_bins-1, out = db)
np.clip(sb, 0, self.strength_bins-1, out = sb)
bb[findx] = (self.hist_to_batch[sb.reshape(self.num_tiles),db.reshape(self.num_tiles)]) .reshape(db.shape[0],db.shape[1]) + (gt -1)
pass
'''
list_of_file_lists
=
[]
list_of_file_lists
=
[]
for
findx
in
range
(
data_ds
.
shape
[
0
]):
for
findx
in
range
(
data_ds
.
shape
[
0
]):
foffs
=
findx
*
self
.
num_tiles
foffs
=
findx
*
self
.
num_tiles
...
@@ -606,20 +594,33 @@ class ExploreData:
...
@@ -606,20 +594,33 @@ class ExploreData:
#$ files_list = [self.files_train, self.files_test][test_set]
#$ files_list = [self.files_train, self.files_test][test_set]
seed_list
=
np
.
arange
(
len
(
files_list
))
seed_list
=
np
.
arange
(
len
(
files_list
))
np
.
random
.
shuffle
(
seed_list
)
np
.
random
.
shuffle
(
seed_list
)
cluster_size
=
(
2
*
radius
+
1
)
*
(
2
*
radius
+
1
)
for
nscene
,
seed_index
in
enumerate
(
seed_list
):
for
nscene
,
seed_index
in
enumerate
(
seed_list
):
corr2d_batch
,
target_disparity_batch
,
gt_ds_batch
=
ex_data
.
prepareBatchData
(
ml_list
,
seed_index
,
min_choices
=
None
,
max_files
=
None
,
ml_num
=
None
,
set_ds
=
set_ds
,
radius
=
radius
)
corr2d_batch
,
target_disparity_batch
,
gt_ds_batch
=
ex_data
.
prepareBatchData
(
ml_list
,
seed_index
,
min_choices
=
None
,
max_files
=
None
,
ml_num
=
None
,
set_ds
=
set_ds
,
radius
=
radius
)
#shuffles tiles in a batch
#shuffles tiles in a batch
tiles_in_batch
=
len
(
target_disparity_batch
)
# tiles_in_batch = len(target_disparity_batch)
permut
=
np
.
random
.
permutation
(
tiles_in_batch
)
tiles_in_batch
=
corr2d_batch
.
shape
[
0
]
corr2d_batch_shuffled
=
corr2d_batch
[
permut
]
.
reshape
((
corr2d_batch
.
shape
[
0
],
corr2d_batch
.
shape
[
1
]
*
corr2d_batch
.
shape
[
2
]))
clusters_in_batch
=
tiles_in_batch
//
cluster_size
target_disparity_batch_shuffled
=
target_disparity_batch
[
permut
]
.
reshape
((
tiles_in_batch
,
1
))
# permut = np.random.permutation(tiles_in_batch)
gt_ds_batch_shuffled
=
gt_ds_batch
[
permut
]
permut
=
np
.
random
.
permutation
(
clusters_in_batch
)
corr2d_clusters
=
corr2d_batch
.
reshape
((
clusters_in_batch
,
-
1
))
target_disparity_clusters
=
target_disparity_batch
.
reshape
((
clusters_in_batch
,
-
1
))
gt_ds_clusters
=
gt_ds_batch
.
reshape
((
clusters_in_batch
,
-
1
))
# corr2d_batch_shuffled = corr2d_batch[permut].reshape((corr2d_batch.shape[0], corr2d_batch.shape[1]*corr2d_batch.shape[2]))
# target_disparity_batch_shuffled = target_disparity_batch[permut].reshape((tiles_in_batch,1))
# gt_ds_batch_shuffled = gt_ds_batch[permut]
corr2d_batch_shuffled
=
corr2d_clusters
[
permut
]
.
reshape
((
tiles_in_batch
,
-
1
))
target_disparity_batch_shuffled
=
target_disparity_clusters
[
permut
]
.
reshape
((
tiles_in_batch
,
-
1
))
gt_ds_batch_shuffled
=
gt_ds_clusters
[
permut
]
.
reshape
((
tiles_in_batch
,
-
1
))
if
nscene
==
0
:
if
nscene
==
0
:
dtype_feature_corr2d
=
_dtype_feature
(
corr2d_batch_shuffled
)
dtype_feature_corr2d
=
_dtype_feature
(
corr2d_batch_shuffled
)
dtype_target_disparity
=
_dtype_feature
(
target_disparity_batch_shuffled
)
dtype_target_disparity
=
_dtype_feature
(
target_disparity_batch_shuffled
)
dtype_feature_gt_ds
=
_dtype_feature
(
gt_ds_batch_shuffled
)
dtype_feature_gt_ds
=
_dtype_feature
(
gt_ds_batch_shuffled
)
for
i
in
range
(
tiles_in_batch
):
for
i
in
range
(
tiles_in_batch
):
x
=
corr2d_batch_shuffled
[
i
]
.
astype
(
np
.
float32
)
x
=
corr2d_batch_shuffled
[
i
]
.
astype
(
np
.
float32
)
y
=
target_disparity_batch_shuffled
[
i
]
.
astype
(
np
.
float32
)
y
=
target_disparity_batch_shuffled
[
i
]
.
astype
(
np
.
float32
)
z
=
gt_ds_batch_shuffled
[
i
]
.
astype
(
np
.
float32
)
z
=
gt_ds_batch_shuffled
[
i
]
.
astype
(
np
.
float32
)
...
@@ -629,7 +630,7 @@ class ExploreData:
...
@@ -629,7 +630,7 @@ class ExploreData:
example
=
tf
.
train
.
Example
(
features
=
tf
.
train
.
Features
(
feature
=
d_feature
))
example
=
tf
.
train
.
Example
(
features
=
tf
.
train
.
Features
(
feature
=
d_feature
))
writer
.
write
(
example
.
SerializeToString
())
writer
.
write
(
example
.
SerializeToString
())
if
(
self
.
debug_level
>
0
):
if
(
self
.
debug_level
>
0
):
print
(
"Scene
%
d of
%
d
"
%
(
nscene
,
len
(
seed_list
)
))
print
(
"Scene
%
d of
%
d
->
%
s"
%
(
nscene
,
len
(
seed_list
),
tfr_filename
))
writer
.
close
()
writer
.
close
()
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
...
...
nn_ds_inmem5.py
0 → 100644
View file @
eeee0fcf
This diff is collapsed.
Click to expand it.
nn_ds_neibs.py
0 → 100644
View file @
eeee0fcf
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment