Training_run.py 文件源码

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

项目:semantic-segmentation 作者: albertbuchard 项目源码 文件源码
def extract_labels(filename, num_images):
    gt_imgs = []
    for i in range(1, num_images+1):
        imageid = 'training_big/Truth/satImage_'+ '%.3d' % i
        for j in range(8):
            image_filename = imageid + "_rota"+str(np.int(j))+".png"
            if os.path.isfile(image_filename):

                img = mpimg.imread(image_filename)

                gt_imgs.append(img)
            else:
                print ('File ' + image_filename + ' does not exist')

    num_images = len(gt_imgs)
    gt_patches = [img_crop(gt_imgs[i], IMG_PATCH_SIZE, IMG_PATCH_SIZE) for i in range(num_images)]
    data = np.asarray([gt_patches[i][j] for i in range(len(gt_patches)) for j in range(len(gt_patches[i]))])
    labels = np.asarray([value_to_class(np.mean(data[i])) for i in range(len(data))])
    # Convert to dense 1-hot representation.
    return labels.astype(np.float32)

##Return the error rate based on dense predictions and 1-hot labels.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号