Skip to content

Commit ccc7d34

Browse files
committed
keep tracking the output
1 parent 06d6e9a commit ccc7d34

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

src/main/java/io/bioimage/modelrunner/tensorflow/v1/Tensorflow1Interface.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import io.bioimage.modelrunner.engine.EngineInfo;
3535
import io.bioimage.modelrunner.exceptions.LoadModelException;
3636
import io.bioimage.modelrunner.exceptions.RunModelException;
37+
import io.bioimage.modelrunner.numpy.DecodeNumpy;
3738
import io.bioimage.modelrunner.system.PlatformDetection;
3839
import io.bioimage.modelrunner.tensor.Tensor;
3940
import io.bioimage.modelrunner.tensor.shm.SharedMemoryArray;
@@ -63,6 +64,7 @@
6364
import java.util.LinkedList;
6465
import java.util.List;
6566
import java.util.Map;
67+
import java.util.UUID;
6668
import java.util.stream.Collectors;
6769

6870
import org.tensorflow.SavedModelBundle;
@@ -394,7 +396,8 @@ else if (task.status == TaskStatus.CRASHED) {
394396
shm = SharedMemoryArray.read(name);
395397
shmaOutputList.add(shm);
396398
}
397-
RandomAccessibleInterval<?> rai = shm.getSharedRAI();
399+
RandomAccessibleInterval<T> rai = shm.getSharedRAI();
400+
DecodeNumpy.saveNpy("/home/carlos/git/out_" + UUID.randomUUID().toString() + ".npy", rai);
398401
outputTensors.get(i).setData(Tensor.createCopyOfRaiInWantedDataType(Cast.unchecked(rai), Util.getTypeFromInterval(Cast.unchecked(rai))));
399402
}
400403
} catch (Exception e) {

src/main/java/io/bioimage/modelrunner/tensorflow/v1/shm/ShmBuilder.java

-15
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@
2424
import io.bioimage.modelrunner.tensor.shm.SharedMemoryArray;
2525
import io.bioimage.modelrunner.utils.CommonUtils;
2626

27-
import java.io.FileOutputStream;
2827
import java.io.IOException;
2928
import java.nio.ByteBuffer;
30-
import java.nio.channels.FileChannel;
3129
import java.util.Arrays;
32-
import java.util.UUID;
3330

3431
import org.tensorflow.Tensor;
3532
import org.tensorflow.types.UInt8;
@@ -124,18 +121,6 @@ private static void buildFromTensorFloat(Tensor<Float> tensor, String memoryName
124121
SharedMemoryArray shma = SharedMemoryArray.readOrCreate(memoryName, arrayShape, new FloatType(), false, true);
125122
ByteBuffer buff = shma.getDataBufferNoHeader();
126123
tensor.writeTo(buff);
127-
try (FileOutputStream fos = new FileOutputStream("/home/carlos/git/interp_out" + UUID.randomUUID().toString() + ".npy");
128-
FileChannel fileChannel = fos.getChannel()) {
129-
ByteBuffer buffer = shma.getDataBuffer();
130-
// Write the buffer's content to the file
131-
while (buffer.hasRemaining()) {
132-
fileChannel.write(buffer);
133-
}
134-
buffer.rewind();
135-
} catch (IOException e) {
136-
// TODO Auto-generated catch block
137-
e.printStackTrace();
138-
}
139124
if (PlatformDetection.isWindows()) shma.close();
140125
}
141126

0 commit comments

Comments
 (0)