train.py 文件源码

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

项目:RacingRobot 作者: sergionr2 项目源码 文件源码
def augmentDataset(in_folder='cropped', out_folder='augmented_dataset'):
    """
    Data augmentation (horizontal mirror)
    :param in_folder: (str)
    :param out_folder: (str)
    """
    images = [name for name in os.listdir(in_folder)]
    for idx, name in enumerate(images):
        r = name.split('.jpg')[0][-2:]  # Retrieve the ROI name
        cx, cy = map(int, name.split('_')[0].split('-'))
        image_path = '{}/{}'.format(in_folder, images[idx])
        image = cv2.imread(image_path)
        height, width, n_channels = image.shape
        horizontal_flip = cv2.flip(image, 1)
        cv2.imwrite('{}/{}-{}_{}-{}.jpg'.format(out_folder, cx, cy, idx, r), image)
        cv2.imwrite('{}/{}-{}_hori_{}-{}.jpg'.format(out_folder, width - cx, cy, idx, r), horizontal_flip)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号