step1_preprocess_train.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:TC-Lung_nodules_detection 作者: Shicoder 项目源码 文件源码
def process_images(delete_existing=False, only_process_patient=None):
    if delete_existing and os.path.exists(settings.TRAIN_EXTRACTED_IMAGE_DIR):
        print("Removing old stuff..")
        if os.path.exists(settings.TRAIN_EXTRACTED_IMAGE_DIR):
            shutil.rmtree(settings.TRAIN_EXTRACTED_IMAGE_DIR)

    if not os.path.exists(settings.TRAIN_EXTRACTED_IMAGE_DIR):
        os.mkdir(settings.TRAIN_EXTRACTED_IMAGE_DIR)
        os.mkdir(settings.TRAIN_EXTRACTED_IMAGE_DIR + "_labels/")

    for subject_no in range(settings.TRAIN_SUBSET_START_INDEX, settings.TRAIN_SUBSET_TRAIN_NUM):
        src_dir = settings.RAW_SRC_DIR + "train_subset0" + str(subject_no) + "/"
        src_paths = glob.glob(src_dir + "*.mhd")

        if only_process_patient is None and True:
            pool = multiprocessing.Pool(6)
            pool.map(process_image, src_paths)
        else:
            for src_path in src_paths:
                print(src_path)
                if only_process_patient is not None:
                    if only_process_patient not in src_path:
                        continue
                process_image(src_path)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号