Beispiel #1
0
from __future__ import print_function
import cv2
import numpy as np
import sys

from matplotlib import pyplot as plt

from svsutils import Slide

s = Slide(
    slide_path=
    '/home/nathan/data/ccrcc/TCGA_KIRC/TCGA-A3-3346-01Z-00-DX1.95280216-fd71-4a03-b452-6e3d667f2542.svs',
    process_mag=5,
    process_size=512,
    oversample_factor=1.25)
s.initialize_output(n_classes=3)
s.print_info()

for idx, img in enumerate(s.generator()):
    s.place(img[:, :, ::-1], idx)

reconstruction = s.output_img
print(reconstruction.shape)

plt.imshow(reconstruction)
plt.show()
Beispiel #2
0
config.gpu_options.allow_growth = True

"""
https://stackoverflow.com/questions/47086599/parallelising-tf-data-dataset-from-generator
https://www.tensorflow.org/programmers_guide/datasets
https://www.tensorflow.org/api_docs/python/tf/data/Dataset
"""

slide_path = '/media/ing/D/svs/TCGA_KIRC/TCGA-A3-3306-01Z-00-DX1.bfd320d3-f3ec-4015-b34a-98e9967ea80d.svs'

preprocess_fn = lambda x: ((x * (2/255.)) - 1).astype(np.float32)
svs = Slide(slide_path    = slide_path,
          process_mag   = 5,
          process_size  = 512,
          preprocess_fn = preprocess_fn )
svs.print_info()
svs.initialize_output('features', dim=3, mode='tile')


def wrapped_fn(idx):
    coords = svs.tile_list[idx]
    img = svs._read_tile(coords)
    return img, idx

def read_region_at_index(idx):
    return tf.py_func(func     = wrapped_fn,
                      inp      = [idx],
                      Tout     = [tf.float32, tf.int64],
                      stateful = False)

def feature_fn(img):