run_FCN.py 文件源码

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

项目:semantic-segmentation 作者: albertbuchard 项目源码 文件源码
def get_images(images_directory, groundtruths_directory, num_images): 
    #
    #   DESCRIPTION 
    #       Loads each training image and its ground truth and creates tensors [numImages, 400, 400, 3]
    #   
    #   INPUTS 
    #       images_directory path to training images directory  
    #       groundtruths_directory path to the groundtruth images directory
    #       num_images number of images to load 
    #       
    #   OUTPUTS
    #       images, ground_truth two tensors 
    #
    images = []
    ground_truth = [] 
    for i in num_images:
        image_id = "satImage_%.3d" % i
        image_filename = image_id + ".png"
        image_path = images_directory + image_filename;
        groundtruth_image_path = groundtruths_directory + image_filename;

        if ((os.path.isfile(image_path))&(os.path.isfile(groundtruth_image_path))):
            print ('Loading ' + image_filename) 
            loaded_image = mpimg.imread(image_path)
            loaded_gt_image = mpimg.imread(groundtruth_image_path) 

            if ordering == "th":
                loaded_image = np.rollaxis(loaded_image,2) 

            images.append(loaded_image) 
            ground_truth.append(loaded_gt_image)
        else:
            print ('File ' + image_path + ' does not exist')

    return images, ground_truth
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号