Ejemplo n.º 1
0
def main():

    ext = '.nii.gz'
    search_pattern = '*'
    dataset = 'test'

    # local
    main_dir = f'/home/anatielsantos/mestrado/datasets/dissertacao/{dataset}/image/lung_extracted/teste_clahe'
    model_path = '/home/anatielsantos/mestrado/models/dissertacao/unet/unet_exp1_200epc_best.h5'

    # remote
    # main_dir = f'/data/flavio/anatiel/datasets/dissertacao/{dataset}/image'
    # model_path = '/data/flavio/anatiel/models/dissertacao/unet_500epc_last.h5'

    src_dir = '{}'.format(main_dir)
    dst_dir = '{}/UnetExp1PredsBest'.format(main_dir)

    nproc = mp.cpu_count()
    print('Num Processadores = ' + str(nproc))

    model = unet()
    model.load_weights(model_path)

    execExecPredictByUnet(src_dir,
                          dst_dir,
                          ext,
                          search_pattern,
                          model,
                          reverse=False,
                          desc=project_name,
                          parallel=False)
Ejemplo n.º 2
0
from io import BytesIO
import skimage.io as io

from tensorflow.python.client import device_lib
#print(device_lib.list_local_devices())
import keras.backend.tensorflow_backend as K
from sklearn import metrics
from keras.preprocessing.image import *

from train import find_patches_from_slide, read_test_data_path, predict_from_model, simple_model, unet

print(
    '****************************INFERENCE FILE*******************************'
)
#model = simple_model(pretrained_weights ='/data/model/u_1.h5')
model = unet(pretrained_weights='/data/model/unet555.h5')
#model = unet(pretrained_weights ='u_1.h5')
PATCH_SIZE = 256
NUM_CLASSES = 2  # not_tumor, tumor

file_handles = []


def gen_imgs_test(slide_path,
                  truth_path,
                  samples,
                  batch_size,
                  patch_size=PATCH_SIZE,
                  num_epoch=1,
                  shuffle=True):
    """This function returns a generator that