es = EarlyStopping(monitor="val_loss", min_delta=1e-4, patience=10, verbose=1, mode='auto') callbacks_list = [checkpoint, tb, es] ######### PREPROCESS TRAINING DATA ######### DATA_DIR = os.path.join("data", "train") PREPROCESSED_DIR = os.path.join(DATA_DIR, "preprocessed") SKULLSTRIP_SCRIPT_PATH = os.path.join("utils", "CT_BET.sh") preprocess.preprocess_dir( DATA_DIR, PREPROCESSED_DIR, SKULLSTRIP_SCRIPT_PATH, ) ######### DATA IMPORT ######### ct_patches, mask_patches = patch_ops.CreatePatchesForTraining( atlasdir=PREPROCESSED_DIR, plane=plane, patchsize=PATCH_SIZE, max_patch=num_patches, num_channels=num_channels) print("Individual patch dimensions:", ct_patches[0].shape) print("Num patches:", len(ct_patches)) print("ct_patches shape: {}\nmask_patches shape: {}".format( ct_patches.shape, mask_patches.shape))
PREPROCESSED_DIR = os.path.join(VAL_DIR, "preprocess") if not os.path.exists(PREPROCESSED_DIR): os.makedirs(PREPROCESSED_DIR) ############### MODEL SELECTION ############### with open(results.model) as json_data: model = model_from_json(json.load(json_data)) model.load_weights(results.weights) ############### PREPROCESSING ############### classes = results.classes.replace(" ", "").split(',') preprocess_dir(VAL_DIR, PREPROCESSED_DIR, classes, results.numcores) # get class encodings class_encodings = get_classes(classes) print(class_encodings) ############### DATA IMPORT ############### patch_size = tuple([int(x) for x in results.patch_size.split('x')]) X, y, filenames, num_classes, img_shape = load_patch_data( PREPROCESSED_DIR, patch_size=patch_size, num_patches=results.num_patches, classes=classes) ############### PREDICT ###############