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
0452a446
Commit
0452a446
authored
Jul 13, 2018
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. packing type 2
2. epochs, batches changes
parent
45a473f0
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
276 additions
and
110 deletions
+276
-110
pack_tile.py
pack_tile.py
+134
-3
test_nn_feed.py
test_nn_feed.py
+120
-104
test_nn_infer.py
test_nn_infer.py
+22
-3
No files found.
pack_tile.py
View file @
0452a446
...
@@ -6,7 +6,8 @@ __email__ = "oleg@elphel.com"
...
@@ -6,7 +6,8 @@ __email__ = "oleg@elphel.com"
import
numpy
as
np
import
numpy
as
np
# pack from 9x9x4 to 25x1
# pack from 9x9x4 to 100x1
# type 1, all the same
def
pack_tile_type1
(
tile
):
def
pack_tile_type1
(
tile
):
out
=
np
.
empty
(
100
)
out
=
np
.
empty
(
100
)
...
@@ -125,13 +126,143 @@ def pack_tile_type1(tile):
...
@@ -125,13 +126,143 @@ def pack_tile_type1(tile):
return
out
return
out
# pack from 9x9x4 to 104x1
# type 1, all the same
def
pack_tile_type2
(
tile
):
out
=
np
.
empty
(
104
)
# pack diagm-pair (not tested)
l
=
np
.
ravel
(
tile
[:,:,
0
])
out
[
0
]
=
1.0
*
l
[
0
]
+
1.0
*
l
[
1
]
+
1.0
*
l
[
2
]
+
1.0
*
l
[
9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
*
l
[
55
]
+
1.0
*
l
[
63
]
out
[
20
]
=
1.0
*
l
[
48
]
out
[
21
]
=
1.0
*
l
[
49
]
out
[
22
]
=
1.0
*
l
[
53
]
+
1.0
*
l
[
61
]
+
1.0
*
l
[
69
]
+
1.0
*
l
[
77
]
out
[
23
]
=
1.0
*
l
[
56
]
+
1.0
*
l
[
64
]
+
1.0
*
l
[
72
]
out
[
24
]
=
1.0
*
l
[
57
]
+
1.0
*
l
[
65
]
+
1.0
*
l
[
73
]
out
[
25
]
=
1.0
*
l
[
62
]
+
1.0
*
l
[
70
]
+
1.0
*
l
[
71
]
+
1.0
*
l
[
78
]
+
1.0
*
l
[
79
]
+
1.0
*
l
[
80
]
out
[
26
]
=
1.0
*
l
[
66
]
+
1.0
*
l
[
74
]
+
1.0
*
l
[
75
]
# pack diago-pair (not tested)
l
=
np
.
ravel
(
tile
[:,:,
1
])
out
[
27
]
=
1.0
*
l
[
0
]
+
1.0
*
l
[
10
]
+
1.0
*
l
[
20
]
out
[
28
]
=
1.0
*
l
[
1
]
+
1.0
*
l
[
11
]
+
1.0
*
l
[
21
]
out
[
29
]
=
1.0
*
l
[
2
]
+
1.0
*
l
[
3
]
+
1.0
*
l
[
12
]
out
[
30
]
=
1.0
*
l
[
4
]
+
1.0
*
l
[
14
]
+
1.0
*
l
[
24
]
+
1.0
*
l
[
34
]
+
1.0
*
l
[
44
]
out
[
31
]
=
1.0
*
l
[
5
]
+
1.0
*
l
[
15
]
+
1.0
*
l
[
25
]
+
1.0
*
l
[
35
]
out
[
32
]
=
1.0
*
l
[
6
]
+
1.0
*
l
[
7
]
+
1.0
*
l
[
8
]
+
1.0
*
l
[
16
]
+
1.0
*
l
[
17
]
+
1.0
*
l
[
26
]
out
[
33
]
=
1.0
*
l
[
9
]
+
1.0
*
l
[
19
]
+
1.0
*
l
[
29
]
out
[
34
]
=
1.0
*
l
[
13
]
+
1.0
*
l
[
23
]
+
1.0
*
l
[
43
]
out
[
35
]
=
1.0
*
l
[
18
]
+
1.0
*
l
[
27
]
+
1.0
*
l
[
28
]
out
[
36
]
=
1.0
*
l
[
22
]
+
1.0
*
l
[
32
]
+
1.0
*
l
[
42
]
out
[
37
]
=
1.0
*
l
[
30
]
out
[
38
]
=
1.0
*
l
[
31
]
out
[
39
]
=
1.0
*
l
[
36
]
+
1.0
*
l
[
46
]
+
1.0
*
l
[
56
]
+
1.0
*
l
[
66
]
+
1.0
*
l
[
76
]
out
[
40
]
=
1.0
*
l
[
37
]
+
1.0
*
l
[
47
]
+
1.0
*
l
[
57
]
+
1.0
*
l
[
67
]
out
[
41
]
=
1.0
*
l
[
38
]
+
1.0
*
l
[
48
]
+
1.0
*
l
[
58
]
out
[
42
]
=
1.0
*
l
[
39
]
out
[
43
]
=
1.0
*
l
[
40
]
out
[
44
]
=
1.0
*
l
[
41
]
out
[
45
]
=
1.0
*
l
[
45
]
+
1.0
*
l
[
55
]
+
1.0
*
l
[
65
]
+
1.0
*
l
[
75
]
out
[
46
]
=
1.0
*
l
[
49
]
out
[
47
]
=
1.0
*
l
[
50
]
out
[
48
]
=
1.0
*
l
[
51
]
+
1.0
*
l
[
61
]
+
1.0
*
l
[
71
]
out
[
49
]
=
1.0
*
l
[
52
]
+
1.0
*
l
[
53
]
+
1.0
*
l
[
62
]
out
[
50
]
=
1.0
*
l
[
54
]
+
1.0
*
l
[
63
]
+
1.0
*
l
[
64
]
+
1.0
*
l
[
72
]
+
1.0
*
l
[
73
]
+
1.0
*
l
[
74
]
out
[
51
]
=
1.0
*
l
[
59
]
+
1.0
*
l
[
69
]
+
1.0
*
l
[
79
]
out
[
52
]
=
1.0
*
l
[
60
]
+
1.0
*
l
[
70
]
+
1.0
*
l
[
80
]
out
[
53
]
=
1.0
*
l
[
68
]
+
1.0
*
l
[
77
]
+
1.0
*
l
[
78
]
# pack hor-pairs
l
=
np
.
ravel
(
tile
[:,:,
2
])
out
[
54
]
=
1.0
*
l
[
0
]
+
1.0
*
l
[
1
]
+
1.0
*
l
[
9
]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
=
1.0
*
l
[
39
]
out
[
69
]
=
1.0
*
l
[
40
]
out
[
70
]
=
1.0
*
l
[
41
]
out
[
71
]
=
1.0
*
l
[
48
]
out
[
72
]
=
1.0
*
l
[
49
]
out
[
73
]
=
1.0
*
l
[
50
]
out
[
74
]
=
1.0
*
l
[
56
]
+
1.0
*
l
[
65
]
+
1.0
*
l
[
74
]
out
[
75
]
=
1.0
*
l
[
57
]
+
1.0
*
l
[
66
]
+
1.0
*
l
[
75
]
out
[
76
]
=
1.0
*
l
[
58
]
+
1.0
*
l
[
67
]
+
1.0
*
l
[
76
]
out
[
77
]
=
1.0
*
l
[
59
]
+
1.0
*
l
[
68
]
+
1.0
*
l
[
77
]
out
[
78
]
=
1.0
*
l
[
60
]
+
1.0
*
l
[
69
]
+
1.0
*
l
[
78
]
# pack vert-pairs
l
=
np
.
ravel
(
tile
[:,:,
3
])
out
[
79
]
=
1.0
*
l
[
0
]
+
1.0
*
l
[
1
]
+
1.0
*
l
[
2
]
+
1.0
*
l
[
3
]
+
1.0
*
l
[
4
]
+
1.0
*
l
[
5
]
+
1.0
*
l
[
6
]
+
1.0
*
l
[
7
]
+
1.0
*
l
[
8
]
+
1.0
*
l
[
9
]
+
1.0
*
l
[
10
]
+
1.0
*
l
[
11
]
+
1.0
*
l
[
16
]
+
1.0
*
l
[
17
]
out
[
80
]
=
1.0
*
l
[
11
]
+
1.0
*
l
[
12
]
+
1.0
*
l
[
13
]
+
1.0
*
l
[
14
]
+
1.0
*
l
[
15
]
out
[
81
]
=
1.0
*
l
[
18
]
+
1.0
*
l
[
19
]
+
1.0
*
l
[
20
]
out
[
82
]
=
1.0
*
l
[
21
]
+
1.0
*
l
[
22
]
+
1.0
*
l
[
23
]
out
[
83
]
=
1.0
*
l
[
24
]
+
1.0
*
l
[
25
]
+
1.0
*
l
[
26
]
out
[
84
]
=
1.0
*
l
[
27
]
+
1.0
*
l
[
28
]
+
1.0
*
l
[
29
]
out
[
85
]
=
1.0
*
l
[
30
]
out
[
86
]
=
1.0
*
l
[
31
]
out
[
87
]
=
1.0
*
l
[
32
]
out
[
88
]
=
1.0
*
l
[
33
]
+
1.0
*
l
[
34
]
+
1.0
*
l
[
35
]
out
[
89
]
=
1.0
*
l
[
36
]
+
1.0
*
l
[
37
]
+
1.0
*
l
[
38
]
out
[
90
]
=
1.0
*
l
[
39
]
out
[
91
]
=
1.0
*
l
[
40
]
out
[
92
]
=
1.0
*
l
[
41
]
out
[
93
]
=
1.0
*
l
[
42
]
+
1.0
*
l
[
43
]
+
1.0
*
l
[
44
]
out
[
94
]
=
1.0
*
l
[
45
]
+
1.0
*
l
[
46
]
+
1.0
*
l
[
47
]
out
[
95
]
=
1.0
*
l
[
48
]
out
[
96
]
=
1.0
*
l
[
49
]
out
[
97
]
=
1.0
*
l
[
50
]
out
[
98
]
=
1.0
*
l
[
51
]
+
1.0
*
l
[
52
]
+
1.0
*
l
[
53
]
out
[
99
]
=
1.0
*
l
[
54
]
+
1.0
*
l
[
55
]
+
1.0
*
l
[
56
]
out
[
100
]
=
1.0
*
l
[
57
]
+
1.0
*
l
[
58
]
+
1.0
*
l
[
59
]
out
[
101
]
=
1.0
*
l
[
60
]
+
1.0
*
l
[
61
]
+
1.0
*
l
[
62
]
out
[
102
]
=
1.0
*
l
[
63
]
+
1.0
*
l
[
64
]
+
1.0
*
l
[
70
]
+
1.0
*
l
[
71
]
+
1.0
*
l
[
72
]
+
1.0
*
l
[
73
]
+
1.0
*
l
[
74
]
+
1.0
*
l
[
75
]
+
1.0
*
l
[
76
]
+
1.0
*
l
[
77
]
+
1.0
*
l
[
78
]
+
1.0
*
l
[
79
]
+
1.0
*
l
[
80
]
out
[
103
]
=
1.0
*
l
[
65
]
+
1.0
*
l
[
66
]
+
1.0
*
l
[
67
]
+
1.0
*
l
[
68
]
+
1.0
*
l
[
69
]
return
out
# pack single
# pack single
def
pack_tile
(
tile
):
def
pack_tile
(
tile
):
return
pack_tile_type1
(
tile
)
return
pack_tile_type1
(
tile
)
# pack all tiles
# pack all tiles
def
pack
(
tiles
):
def
pack
(
tiles
,
ptype
=
1
):
output
=
np
.
array
([[
pack_tile
(
tiles
[
i
,
j
])
for
j
in
range
(
tiles
.
shape
[
1
])]
for
i
in
range
(
tiles
.
shape
[
0
])])
if
ptype
==
1
:
pack_func
=
pack_tile_type1
elif
ptype
==
2
:
pack_func
=
pack_tile_type2
output
=
np
.
array
([[
pack_func
(
tiles
[
i
,
j
])
for
j
in
range
(
tiles
.
shape
[
1
])]
for
i
in
range
(
tiles
.
shape
[
0
])])
return
output
return
output
...
...
test_nn_feed.py
View file @
0452a446
This diff is collapsed.
Click to expand it.
test_nn_infer.py
View file @
0452a446
...
@@ -44,6 +44,7 @@ def print_time():
...
@@ -44,6 +44,7 @@ def print_time():
VALUES_LAYER_NAME
=
'other'
VALUES_LAYER_NAME
=
'other'
LAYERS_OF_INTEREST
=
[
'diagm-pair'
,
'diago-pair'
,
'hor-pairs'
,
'vert-pairs'
]
LAYERS_OF_INTEREST
=
[
'diagm-pair'
,
'diago-pair'
,
'hor-pairs'
,
'vert-pairs'
]
RADIUS
=
1
RADIUS
=
1
TILE_PACKING_TYPE
=
1
try
:
try
:
src
=
sys
.
argv
[
1
]
src
=
sys
.
argv
[
1
]
...
@@ -83,7 +84,11 @@ def network(input):
...
@@ -83,7 +84,11 @@ def network(input):
sess
=
tf
.
Session
()
sess
=
tf
.
Session
()
in_tile
=
tf
.
placeholder
(
tf
.
float32
,[
None
,
101
])
if
TILE_PACKING_TYPE
==
1
:
in_tile
=
tf
.
placeholder
(
tf
.
float32
,[
None
,
101
])
elif
TILE_PACKING_TYPE
==
2
:
in_tile
=
tf
.
placeholder
(
tf
.
float32
,[
None
,
105
])
gt
=
tf
.
placeholder
(
tf
.
float32
,[
None
,
2
])
gt
=
tf
.
placeholder
(
tf
.
float32
,[
None
,
2
])
out
=
network
(
in_tile
)
out
=
network
(
in_tile
)
...
@@ -143,7 +148,11 @@ for item in tlist:
...
@@ -143,7 +148,11 @@ for item in tlist:
# tiles and values
# tiles and values
# might not need it because going to loop through anyway
# might not need it because going to loop through anyway
packed_tiles
=
pile
.
pack
(
tiles
)
if
TILE_PACKING_TYPE
==
1
:
packed_tiles
=
pile
.
pack
(
tiles
)
elif
TILE_PACKING_TYPE
==
2
:
packed_tiles
=
pile
.
pack
(
tiles
,
TILE_PACKING_TYPE
)
packed_tiles
=
np
.
dstack
((
packed_tiles
,
values
[:,:,
0
]))
packed_tiles
=
np
.
dstack
((
packed_tiles
,
values
[:,:,
0
]))
print
(
packed_tiles
.
shape
)
print
(
packed_tiles
.
shape
)
...
@@ -168,11 +177,12 @@ for item in tlist:
...
@@ -168,11 +177,12 @@ for item in tlist:
packed_tiles_flat
=
packed_tiles
[
i
]
packed_tiles_flat
=
packed_tiles
[
i
]
values_flat
=
values
[
i
]
values_flat
=
values
[
i
]
# whole row at once
output
=
sess
.
run
(
out
,
feed_dict
=
{
in_tile
:
packed_tiles_flat
})
output
=
sess
.
run
(
out
,
feed_dict
=
{
in_tile
:
packed_tiles_flat
})
output_image
[
i
]
=
output
output_image
[
i
]
=
output
# so, let's print
# so, let's print
for
j
in
range
(
output
.
shape
[
0
]):
for
j
in
range
(
packed_tiles
.
shape
[
0
]):
p
=
output
[
j
,
0
]
p
=
output
[
j
,
0
]
pc
=
output
[
j
,
1
]
pc
=
output
[
j
,
1
]
fv
=
values_flat
[
j
,
0
]
fv
=
values_flat
[
j
,
0
]
...
@@ -204,6 +214,15 @@ for item in tlist:
...
@@ -204,6 +214,15 @@ for item in tlist:
tif
=
np
.
dstack
((
im1
,
im2
,
im3
))
tif
=
np
.
dstack
((
im1
,
im2
,
im3
))
im3
=
np
.
ravel
(
im3
)
print
(
im3
.
shape
)
im4
=
im3
[
~
np
.
isnan
(
im3
)]
rms
=
np
.
sqrt
(
np
.
mean
(
np
.
square
(
im4
)))
print
(
"RMS = "
+
str
(
rms
))
imagej_tiffwriter
.
save
(
'prediction_results.tiff'
,
tif
)
imagej_tiffwriter
.
save
(
'prediction_results.tiff'
,
tif
)
#sys.exit(0)
#sys.exit(0)
...
...
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