Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tensorflow 1 Interface
Manage
Activity
Members
Labels
Plan
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
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bioimage Analysis
Tensorflow 1 Interface
Commits
8263cc73
Commit
8263cc73
authored
2 years ago
by
carlosuc3m
Browse files
Options
Downloads
Patches
Plain Diff
identify different data types
parent
3a046a7a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/bioimageanalysis/icy/deeplearning/tensorflow/v1/tensor/MappedFileBuilder.java
+34
-4
34 additions, 4 deletions
.../deeplearning/tensorflow/v1/tensor/MappedFileBuilder.java
with
34 additions
and
4 deletions
src/main/java/org/bioimageanalysis/icy/deeplearning/tensorflow/v1/tensor/MappedFileBuilder.java
+
34
−
4
View file @
8263cc73
...
@@ -4,6 +4,7 @@ import java.nio.ByteBuffer;
...
@@ -4,6 +4,7 @@ import java.nio.ByteBuffer;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
org.jcp.xml.dsig.internal.dom.Utils
;
import
org.tensorflow.Tensor
;
import
org.tensorflow.Tensor
;
import
net.imglib2.Cursor
;
import
net.imglib2.Cursor
;
...
@@ -14,6 +15,8 @@ import net.imglib2.type.Type;
...
@@ -14,6 +15,8 @@ import net.imglib2.type.Type;
import
net.imglib2.type.numeric.RealType
;
import
net.imglib2.type.numeric.RealType
;
import
net.imglib2.type.numeric.integer.ByteType
;
import
net.imglib2.type.numeric.integer.ByteType
;
import
net.imglib2.type.numeric.integer.IntType
;
import
net.imglib2.type.numeric.integer.IntType
;
import
net.imglib2.type.numeric.integer.LongType
;
import
net.imglib2.type.numeric.integer.UnsignedByteType
;
import
net.imglib2.type.numeric.real.DoubleType
;
import
net.imglib2.type.numeric.real.DoubleType
;
import
net.imglib2.type.numeric.real.FloatType
;
import
net.imglib2.type.numeric.real.FloatType
;
import
net.imglib2.util.Util
;
import
net.imglib2.util.Util
;
...
@@ -186,7 +189,8 @@ public final class MappedFileBuilder
...
@@ -186,7 +189,8 @@ public final class MappedFileBuilder
createFileHeader
(
org
.
bioimageanalysis
.
icy
.
deeplearning
.
tensor
.
Tensor
<
T
>
tensor
)
{
createFileHeader
(
org
.
bioimageanalysis
.
icy
.
deeplearning
.
tensor
.
Tensor
<
T
>
tensor
)
{
String
dimsStr
=
String
dimsStr
=
tensor
.
getData
()
!=
null
?
Arrays
.
toString
(
tensor
.
getData
().
dimensionsAsLongArray
())
:
"[]"
;
tensor
.
getData
()
!=
null
?
Arrays
.
toString
(
tensor
.
getData
().
dimensionsAsLongArray
())
:
"[]"
;
String
descriptionStr
=
"{'dtype':'"
+
tensor
.
getDataType
()
+
"','axes':'"
String
descriptionStr
=
"{'dtype':'"
+
getDataTypeString
(
Util
.
getTypeFromInterval
(
tensor
.
getData
()))
+
"','axes':'"
+
tensor
.
getAxesOrderString
()
+
"','name':'"
+
tensor
.
getName
()
+
"','shape':'"
+
tensor
.
getAxesOrderString
()
+
"','name':'"
+
tensor
.
getName
()
+
"','shape':'"
+
dimsStr
+
"'}"
;
+
dimsStr
+
"'}"
;
...
@@ -205,6 +209,32 @@ public final class MappedFileBuilder
...
@@ -205,6 +209,32 @@ public final class MappedFileBuilder
return
byteHeader
;
return
byteHeader
;
}
}
/**
* Method that returns a Sting representing the datatype of T
* @param <T>
* @param type
* @return
*/
public
static
<
T
extends
RealType
<
T
>
&
NativeType
<
T
>
>
String
getDataTypeString
(
T
type
)
{
if
(
type
instanceof
ByteType
)
{
return
"byte"
;
}
else
if
(
type
instanceof
IntType
)
{
return
"int32"
;
}
else
if
(
type
instanceof
FloatType
)
{
return
"float32"
;
}
else
if
(
type
instanceof
DoubleType
)
{
return
"float64"
;
}
else
if
(
type
instanceof
LongType
)
{
return
"int64"
;
}
else
if
(
type
instanceof
UnsignedByteType
)
{
return
"ubyte"
;
}
else
{
throw
new
IllegalArgumentException
(
"Unsupported data type. At the moment the only "
+
"supported dtypes are: "
+
IntType
.
class
+
", "
+
FloatType
.
class
+
", "
+
DoubleType
.
class
+
", "
+
LongType
.
class
+
" and "
+
UnsignedByteType
.
class
);
}
}
/**
/**
* Get the total byte size of the temp file that is oging to be created to do interprocess
* Get the total byte size of the temp file that is oging to be created to do interprocess
* communication for MacOSX
* communication for MacOSX
...
...
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