] slide_list_3 = [ 95, 120, 81, 77, 97, 96, 110, 83, 152, 128, 149, 155, 153, 111, 57, 138, 134, 135, 114, 76, 123, 90, 121, 61, 147, 148, 119, 142, 66, 137, 63, 80, 70, 79, 115, 133, 129, 141 ] # ALL SAMPLE DATA data_start_time = datetime.now() all_samples = pd.DataFrame(columns=columns) # negative samples add for i in range(len(slide_list_1)): image_path = image_paths[slide_list_1[i]] mask_path = tumor_mask_paths[slide_list_1[i]] samples = find_patches_from_slide(image_path, mask_path) samples = samples.sample(2000, random_state=42, replace=True) all_samples = all_samples.append(samples) for i in range(len(slide_list_2)): image_path = image_paths[slide_list_2[i]] mask_path = tumor_mask_paths[slide_list_2[i]] samples = find_patches_from_slide(image_path, mask_path) tumor_samples = samples[samples.is_tumor == True] tumor_samples = tumor_samples.sample(1000, random_state=42, replace=True) non_tumor_samples = samples[samples.is_tumor == False] non_tumor_samples = non_tumor_samples.sample(1000, random_state=42, replace=True) samples = tumor_samples.append(non_tumor_samples) all_samples = all_samples.append(samples) for i in range(len(slide_list_3)):
PATCH_SIZE = 256 BATCH_SIZE = 128 test_image_paths = read_test_data_path_2() print(test_image_paths) start_x = 64 start_y = 64 pred_size = 128 slide_id = list() slide_pred = list() for id_test in range(len(test_image_paths)): print(id_test, 'th inference\n') image_path = test_image_paths[id_test] test_samples = find_patches_from_slide(image_path, 'test') NUM_SAMPLES = len(test_samples) if NUM_SAMPLES > 5000: NUM_SAMPLES = 5000 samples = test_samples.sample(NUM_SAMPLES, random_state=42) samples.reset_index(drop=True, inplace=True) test_generator = gen_imgs_test(image_path, 'test', samples, BATCH_SIZE) test_steps = np.ceil(len(samples) / BATCH_SIZE) preds = [] for i in range(int(test_steps)): X, Y = next(test_generator) for j in range(len(X)):