|
25 | 25 | import io.bioimage.modelrunner.utils.CommonUtils;
|
26 | 26 | import net.imglib2.util.Cast;
|
27 | 27 |
|
| 28 | +import java.io.FileOutputStream; |
| 29 | +import java.io.IOException; |
28 | 30 | import java.nio.ByteBuffer;
|
29 | 31 | import java.nio.DoubleBuffer;
|
30 | 32 | import java.nio.FloatBuffer;
|
31 | 33 | import java.nio.IntBuffer;
|
32 | 34 | import java.nio.LongBuffer;
|
| 35 | +import java.nio.channels.FileChannel; |
33 | 36 | import java.util.Arrays;
|
| 37 | +import java.util.UUID; |
34 | 38 |
|
35 | 39 | import org.tensorflow.Tensor;
|
36 | 40 | import org.tensorflow.types.UInt8;
|
@@ -133,6 +137,19 @@ private static Tensor<Float> buildFloat(SharedMemoryArray tensor)
|
133 | 137 | + " is too big. Max number of elements per ubyte tensor supported: " + Integer.MAX_VALUE);
|
134 | 138 | if (!tensor.isNumpyFormat())
|
135 | 139 | throw new IllegalArgumentException("Shared memory arrays must be saved in numpy format.");
|
| 140 | + try (FileOutputStream fos = new FileOutputStream("/home/carlos/git/interp_inp" + UUID.randomUUID().toString() + ".npy"); |
| 141 | + FileChannel fileChannel = fos.getChannel()) { |
| 142 | + ByteBuffer buffer = tensor.getDataBuffer(); |
| 143 | + // Write the buffer's content to the file |
| 144 | + while (buffer.hasRemaining()) { |
| 145 | + fileChannel.write(buffer); |
| 146 | + } |
| 147 | + buffer.rewind(); |
| 148 | + } catch (IOException e) { |
| 149 | + // TODO Auto-generated catch block |
| 150 | + e.printStackTrace(); |
| 151 | + } |
| 152 | + |
136 | 153 | ByteBuffer buff = tensor.getDataBufferNoHeader();
|
137 | 154 | FloatBuffer floatBuff = buff.asFloatBuffer();
|
138 | 155 | Tensor<Float> ndarray = Tensor.create(ogShape, floatBuff);
|
|
0 commit comments