import os
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = "1"

import cv2
from LIBS.ImgPreprocess.my_image_helper import image_to_square

dir_original = '/media/ubuntu/data1/ROP项目/ROP_blood_vessel_seg/train/original'
dir_preprocess = '/media/ubuntu/data1/ROP项目/ROP_blood_vessel_seg/train/preprocess'
dir_dest = '/media/ubuntu/data1/ROP项目/ROP_blood_vessel_seg/blood_vessel_results/train'

DO_PREPROCESS = False
if DO_PREPROCESS:
    from LIBS.ImgPreprocess.my_rop import resize_rop_dir
    # (640,480)->(640,512), (1600,1200)->(640,512)
    resize_rop_dir(dir_original, dir_preprocess)

IMAGE_TO_SQUARE = False

PATCH_H = 64
PATCH_W = 64

dicts_models = []
model_file1 = '/home/ubuntu/dlp/deploy_models/ROP/vessel_segmentation/patch_based/ROP_013-0.968-013-0.571_0.724.hdf5'
dict_model1 = {
    'model_file': model_file1,
    'input_shape': (299, 299, 3),
    'model_weight': 1
}
dicts_models.append(dict_model1)
Example #2
0
from LIBS.ImgPreprocess.my_labelme import convert_json_mask

convert_json_mask(
    '/media/ubuntu/data1/公开数据集/OpticDiscDetection/ROP/original/images',
    '/media/ubuntu/data1/公开数据集/OpticDiscDetection/ROP/original/masks')

from LIBS.ImgPreprocess.my_rop import resize_rop_dir

# (640,480)->(640,512), (1600,1200)->(640,512)
resize_rop_dir('/media/ubuntu/data1/公开数据集/OpticDiscDetection/ROP/original',
               '/media/ubuntu/data1/公开数据集/OpticDiscDetection/ROP/preprocess')

from LIBS.ImgPreprocess.my_image_helper import resize_images_dir
resize_images_dir(
    source_dir='/media/ubuntu/data1/公开数据集/OpticDiscDetection/ROP/preprocess',
    dest_dir='/media/ubuntu/data1/公开数据集/OpticDiscDetection/ROP/preprocess384',
    convert_image_to_square=True,
    image_size=384)

import os
from LIBS.DataPreprocess.my_data import write_csv_img_seg

filename_csv = os.path.abspath('ROP.csv')
write_csv_img_seg(
    filename_csv,
    '/media/ubuntu/data1/公开数据集/OpticDiscDetection/ROP/preprocess384/images')

print('OK')
DO_BLOOD_VESSEL_SEG = False

DO_OPTIC_DISC_DETECTION = True
DO_DRAW_CIRCLE = True
DO_CROP_POSTERIOR = False
CROP_POSTERIOR_CIRCLE = False

DO_BLOOD_VESSEL_SEG_POSTERIOR = True

# 640 * 512
if DO_PREPROCESS:
    from LIBS.ImgPreprocess.my_rop import resize_rop_dir
    resize_rop_dir(dir_original,
                   dir_preprocess,
                   resize_shape=(640, 480),
                   padding_top=16,
                   padding_bottom=16,
                   output_shape=(640, 512))

# 384 * 384
if DO_PREPROCESS_384:
    from LIBS.ImgPreprocess.my_rop import resize_rop_dir
    resize_rop_dir(dir_original,
                   dir_preprocess384,
                   resize_shape=(640, 480),
                   image_to_square=True,
                   output_shape=(384, 384))

if DO_BLOOD_VESSEL_SEG:
    PATCH_H = 64
    PATCH_W = 64