import os import numpy as np from tqdm import tqdm from skimage import io from skimage import transform from paths import root_dir, mkdir_if_not_exist import pandas as pd ISIC2018_dir = os.path.join(root_dir, 'datasets', 'ISIC2018') data_dir = ISIC2018_dir cached_data_dir = os.path.join(ISIC2018_dir, 'cache') mkdir_if_not_exist(dir_list=[cached_data_dir]) task12_img = 'ISIC2018_Task1-2_Training_Input' task12_validation_img = 'ISIC2018_Task1-2_Validation_Input' task12_test_img = 'ISIC2018_Task1-2_Test_Input' task3_img = 'ISIC2018_Task3_Training_Input' task3_validation_img = 'ISIC2018_Task3_Validation_Input' task3_test_img = 'ISIC2018_Task3_Test_Input' task1_gt = 'ISIC2018_Task1_Training_GroundTruth' task2_gt = 'ISIC2018_Task2_Training_GroundTruth_v3' task3_gt = 'ISIC2018_Task3_Training_GroundTruth' MEL = 0 # Melanoma NV = 1 # Melanocytic nevus BCC = 2 # Basal cell carcinoma AKIEC = 3 # Actinic keratosis / Bowen's disease (intraepithelial carcinoma) BKL = 4 # Benign keratosis (solar lentigo / seborrheic keratosis / lichen planus-like keratosis)
run_name = 'task%d_%s_k%d_v%s' % (task_idx, backbone_name, k_fold, version) model = backbone(backbone_name).segmentation_model(load_from=run_name) if use_tta: y_pred += inv_sigmoid(task1_tta_predict(model=model, img_arr=images))[:, :, :, 0] else: y_pred += inv_sigmoid(model.predict(images))[:, :, :, 0] print('Done predicting -- now doing post-processing') y_pred = y_pred / num_folds y_pred = sigmoid(y_pred) y_pred = task1_post_process(y_prediction=y_pred, threshold=0.5, gauss_sigma=2.) output_dir = submission_dir + '/task1_' + pred_set mkdir_if_not_exist([output_dir]) for i_image, i_name in enumerate(image_names): current_pred = y_pred[i_image] current_pred = current_pred * 255 resized_pred = sk_resize(current_pred, output_shape=image_sizes[i_image], preserve_range=True, mode='reflect', anti_aliasing=True) resized_pred[resized_pred > 128] = 255 resized_pred[resized_pred <= 128] = 0
import os import sys sys.path.append('/home/LiZhongYu/data/jht/BaiDuBigData2019/') import numpy as np from skimage import io from tqdm import tqdm from paths import mkdir_if_not_exist from paths import data_path, data_train_path, data_test_path from paths import train_image_path, test_image_path from paths import train_file_pre_npy_path, test_file_pre_npy_path from paths import train_images_npy_path, train_labels_npy_path, test_images_npy_path # 不存在则创建 mkdir_if_not_exist(dir_list=[data_path, data_train_path, data_test_path]) # 定义标签 label_001 = [1, 0, 0, 0, 0, 0, 0, 0, 0] label_002 = [0, 1, 0, 0, 0, 0, 0, 0, 0] label_003 = [0, 0, 1, 0, 0, 0, 0, 0, 0] label_004 = [0, 0, 0, 1, 0, 0, 0, 0, 0] label_005 = [0, 0, 0, 0, 1, 0, 0, 0, 0] label_006 = [0, 0, 0, 0, 0, 1, 0, 0, 0] label_007 = [0, 0, 0, 0, 0, 0, 1, 0, 0] label_008 = [0, 0, 0, 0, 0, 0, 0, 1, 0] label_009 = [0, 0, 0, 0, 0, 0, 0, 0, 1] # 定义对应关系 id_label_map = { '001': label_001,