Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
imagej-elphel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
imagej-elphel
Commits
03e238e2
Commit
03e238e2
authored
Sep 19, 2018
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more testing
parent
682c12fe
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
42 deletions
+31
-42
TensorflowExamplePlugin.java
src/main/java/TensorflowExamplePlugin.java
+31
-42
No files found.
src/main/java/TensorflowExamplePlugin.java
View file @
03e238e2
...
...
@@ -53,7 +53,7 @@ public class TensorflowExamplePlugin
public
final
static
String
EXPORTDIR
=
"/home/oleg/GIT/python3-imagej-tiff/data_sets/tf_data_5x5_main_13_heur/exportdir"
;
// tf.saved_model.tag_constants.SERVING = "serve"
public
final
static
String
PB_TA
G
=
"serve"
;
public
final
static
String
SERVIN
G
=
"serve"
;
public
static
void
run
()
...
...
@@ -118,39 +118,20 @@ public class TensorflowExamplePlugin
final
Graph
smpb
;
// init for variable?
float
[][]
rv_stage1_out
=
new
float
[
78408
][
32
];
// from
:
infer_qcds_01.py
// from infer_qcds_01.py
float
[][]
img_corr2d
=
new
float
[
78408
][
324
];
float
[][]
img_target
=
new
float
[
78408
][
1
];
int
[]
img_ntile
=
new
int
[
78408
];
// init ntile
// init ntile
for testing?
for
(
int
i
=
0
;
i
<
img_ntile
.
length
;
i
++){
img_ntile
[
i
]
=
i
;
}
/*
* for feed:
* "ph_corr2d": img_corr2d
* "ph_target_disparity": img_target
* "ph_ntile": img_ntile
*
* so it will look like:
*
* https://divis.io/2018/01/enterprise-tensorflow-code-examples/ ->
* https://github.com/DIVSIO/tensorflow_java_cli_example/blob/master/src/main/java/divisio/example/tensorflow/cli/RunRegression.java
*
* sess.runner()
* .feed("ph_corr2d",img_corr2d)
* .feed("ph_target_disparity",img_target)
* .feed("ph_ntile",img_ntile)
* .fetch("Disparity_net/stage1done:0")
* .run()
* .get(0)
*/
final
SavedModelBundle
bundle
=
SavedModelBundle
.
load
(
EXPORTDIR
,
PB_TAG
);
final
SavedModelBundle
bundle
=
SavedModelBundle
.
load
(
EXPORTDIR
,
SERVING
);
final
List
<
Tensor
<?>>
tensorsToClose
=
new
ArrayList
<
Tensor
<?>>(
5
);
...
...
@@ -158,31 +139,39 @@ public class TensorflowExamplePlugin
try
{
//bundle.session().runner().fetch("Disparity_net/stage1done:0").run();
System
.
out
.
println
(
"S0:"
);
// read Variable info test
Operation
opr
=
bundle
.
graph
().
operation
(
"rv_stage1_out"
);
System
.
out
.
println
(
opr
.
toString
());
System
.
out
.
println
(
"S1:"
);
// init variable via constant
Tensor
<
Float
>
t
=
toTensor2DFloat
(
rv_stage1_out
,
tensorsToClose
);
Output
builder_init
=
bundle
.
graph
().
opBuilder
(
"Const"
,
"rv_stage1_out_init"
).
setAttr
(
"dtype"
,
t
.
dataType
()).
setAttr
(
"value"
,
t
).
build
().
output
(
0
);
// init variable via constant?
Tensor
<
Float
>
tsr
=
toTensor2DFloat
(
rv_stage1_out
,
tensorsToClose
);
Output
builder_init
=
bundle
.
graph
()
.
opBuilder
(
"Const"
,
"rv_stage1_out_init"
)
.
setAttr
(
"dtype"
,
tsr
.
dataType
())
.
setAttr
(
"value"
,
tsr
)
.
build
()
.
output
(
0
);
// variable
OperationBuilder
builder2
=
bundle
.
graph
().
opBuilder
(
"Variable"
,
"rv_stage1_out"
);
builder2
.
addInput
(
builder_init
);
System
.
out
.
println
(
builder_init
);
//Tensor<Float> tensorVal = t;
//Output oValue = graph.opBuilder("Const", "rv_stage1_out").setAttr("dtype", tensorVal.dataType()).setAttr("value", tensorVal).build().output(0);
// variable
OperationBuilder
builder2
=
bundle
.
graph
().
opBuilder
(
"Variable"
,
"rv_stage1_out_extra_variable"
);
//.addInput(builder_init);
//bundle.graph().opBuilder("Assign", "Assign/rv_stage1_out").setAttr("value", t).build();
//builder2.
//bundle.graph().opBuilder("Assign", "Assign/" + builder2.op().name()).addInput(variable).addInput(value).build().output(0);
Operation
ooyoo
=
bundle
.
graph
().
operation
(
"rv_stage1_out"
);
System
.
out
.
println
(
ooyoo
.
toString
());
System
.
out
.
println
(
ooyoo
.
type
());
//Tensor<Float> tensorVal = tsr;
//Output oValue = bundle.graph().opBuilder("Const", "rv_stage1_out_2").setAttr("dtype", tensorVal.dataType()).setAttr("value", tensorVal).build().output(0);
//System.out.println(oValue);
//Output oValue = bundle.graph().opBuilder("Variable", "rv_stage1_out").setAttr("value", tensorVal).build().output(0);
//bundle.graph().opBuilder("Assign", "Assign/rv_stage1_out").setAttr("value", tsr).build();
System
.
out
.
println
(
"DONE"
);
//Tensor<Float> t = toTensor2DFloat(rv_stage1_out, tensorsToClose);
//builder.setAttr("dtype", t.dataType()).setAttr("shape",t.shape()).build().output(0);
// stage 1
bundle
.
session
().
runner
()
.
feed
(
"ph_corr2d"
,
toTensor2DFloat
(
img_corr2d
,
tensorsToClose
))
...
...
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