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
4a29b844
Commit
4a29b844
authored
Sep 15, 2018
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+links
parent
68b38496
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
29 deletions
+98
-29
TensorflowExamplePlugin.java
src/main/java/TensorflowExamplePlugin.java
+98
-29
No files found.
src/main/java/TensorflowExamplePlugin.java
View file @
4a29b844
...
...
@@ -7,10 +7,44 @@ import org.tensorflow.Graph;
import
org.tensorflow.Session
;
import
org.tensorflow.Tensor
;
import
org.tensorflow.TensorFlow
;
import
org.tensorflow.SavedModelBundle
;
/**
Note 0: articles & examples:
- https://divis.io/2017/11/enterprise-tensorflow-1/
- https://divis.io/2018/01/enterprise-tensorflow-code-examples/
- https://divis.io/2018/01/enterprise-tensorflow-2-saving-a-trained-model/
- https://divis.io/2018/01/enterprise-tensorflow-3-loading-a-savedmodel-in-java/
- https://divis.io/2018/01/enterprise-tensorflow-4-executing-a-tensorflow-session-in-java/
- https://www.programcreek.com/java-api-examples/?api=org.tensorflow.SavedModelBundle
- https://github.com/imagej/imagej-tensorflow
Note 1: How to feed:
a. https://divis.io/2018/01/enterprise-tensorflow-4-executing-a-tensorflow-session-in-java/
b. https://github.com/tensorflow/tensorflow/blob/master/tensorflow/java/src/main/java/org/tensorflow/examples/LabelImage.java
Note 2: https://divis.io/2018/01/enterprise-tensorflow-4-executing-a-tensorflow-session-in-java/
...
Two types of objects will need manual closing for proper resource handling:
Sessions and Tensors
...
*/
public
class
TensorflowExamplePlugin
{
public
void
run
()
public
final
static
String
EXPORTDIR
=
"/home/oleg/GIT/python3-imagej-tiff/data_sets/tf_data_5x5_main_13_heur/exportdir"
;
public
final
static
String
PB_TAG
=
"model_pb"
;
public
static
void
run
()
{
System
.
out
.
println
(
"TensorflowExamplePlugin run"
);
try
{
...
...
@@ -22,6 +56,23 @@ public class TensorflowExamplePlugin
}
public
static
void
main
()
throws
Exception
{
final
Graph
smpb
;
float
[][]
img_corr2d
=
new
float
[
78408
][
324
];
float
[][]
img_target
=
new
float
[
78408
][
1
];
int
[]
img_ntile
=
new
int
[
78408
];
// init ntile
for
(
int
i
=
0
;
i
<
img_ntile
.
length
;
i
++){
img_ntile
[
i
]
=
i
;
}
try
(
SavedModelBundle
b
=
SavedModelBundle
.
load
(
EXPORTDIR
,
PB_TAG
)){
System
.
out
.
println
(
"Alright"
);
smpb
=
b
.
graph
();
}
try
(
Graph
g
=
new
Graph
())
{
final
String
value
=
"Hello from "
+
TensorFlow
.
version
();
...
...
@@ -38,9 +89,27 @@ public class TensorflowExamplePlugin
Tensor
output
=
s
.
runner
().
fetch
(
"MyConst"
).
run
().
get
(
0
))
{
System
.
out
.
println
(
new
String
(
output
.
bytesValue
(),
"UTF-8"
));
s
.
close
();
output
.
close
();
}
}
}
}
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