数据增强——水平镜像、高斯模糊

https://blog.csdn.net/qq_29462849/article/details/83241797

import os
from PIL import Image
import cv2
import random
from numpy import *

fall_root = '/home/xu/datasets/Le2i_trim/datasets/fall/'
for parent, dirnames, filenames in os.walk(fall_root):
    if filenames:
        for filename in filenames:
            offset = parent.split('/')[-1].split('fall')[-1]
            new_name = str(int(offset) + 130 + 130)
            new_parent = fall_root + 'fall' + new_name
            #print(new_parent)
            if os.path.exists(new_parent) == False:
                os.mkdir(new_parent)
            currentPath = os.path.join(parent, filename)
            newPath = os.path.join(new_parent, filename)
            print(newPath)

            img = Image.open(currentPath)
            #out = img.transpose(Image.FLIP_LEFT_RIGHT)     # 水平镜像
            #out = img.filter(ImageFilter.GaussianBlur(radius=2))    # 高斯模糊
            out = 
            out.save(newPath)

你可能感兴趣的:(数据增强)