Exemple #1
0
    def test_stitcher(self):
        # Stitch a test TIFF dataset
        inputDataset = TiffVolume(
            os.path.join(IMAGE_PATH, "inputs.tif"),
            BoundingBox(Vector(0, 0, 0), Vector(1024, 512, 50)))
        outputDataset = Array(
            np.zeros(inputDataset.getBoundingBox().getNumpyDim()))
        inputDataset.__enter__()
        for data in inputDataset:
            outputDataset.blend(data)

        self.assertTrue(
            (inputDataset[20].getArray() == outputDataset[20].getArray()).all,
            "Blending output does not match input")

        tif.imsave(os.path.join(IMAGE_PATH, "test_stitch.tif"),
                   outputDataset[100].getArray().astype(np.uint16))
Exemple #2
0
    def test_prediction(self):
        if not os.path.isdir('./tests/checkpoints'):
            os.mkdir('tests/checkpoints')

        net = RSUNet()

        checkpoint = './tests/checkpoints/iteration_10.ckpt'
        inputs_dataset = TiffVolume(
            os.path.join(IMAGE_PATH, "inputs.tif"),
            BoundingBox(Vector(0, 0, 0), Vector(1024, 512, 50)))
        inputs_dataset.__enter__()
        predictor = Predictor(net, checkpoint, gpu_device=1)

        output_volume = Array(
            np.zeros(inputs_dataset.getBoundingBox().getNumpyDim()))

        predictor.run(inputs_dataset, output_volume, batch_size=5)

        tif.imsave(os.path.join(IMAGE_PATH, "test_prediction.tif"),
                   output_volume.getArray().astype(np.float32))