在tensorflow目标检测中使用photoshop完成欠采样?

在tensorflow目标检测中使用photoshop完成欠采样?,tensorflow,machine-learning,object-detection,photoshop,Tensorflow,Machine Learning,Object Detection,Photoshop,我目前正在使用Tensorflow训练一个目标检测模型,我遇到了一个问题。我没有足够的样本来有效地训练我的模型,我需要很长时间才能获得更多的样本。我想知道使用photoshop完成剩下的样本是否是一个好主意,或者使用这种方法我会遇到问题吗?您有很多选择: OpenCV: 我以前使用的示例代码: 其他: 你可以用tensorflow做DA!更多信息请访问此博客: 样品还不够吗?您是否使用了数据增强?这可以很容易地用pythonNo完成,我不熟悉这种技术。你有一个好的模块或脚本我可

我目前正在使用Tensorflow训练一个目标检测模型,我遇到了一个问题。我没有足够的样本来有效地训练我的模型,我需要很长时间才能获得更多的样本。我想知道使用photoshop完成剩下的样本是否是一个好主意,或者使用这种方法我会遇到问题吗?

您有很多选择:

  • OpenCV:

    我以前使用的示例代码:

  • 其他:

    你可以用tensorflow做DA!更多信息请访问此博客:


  • 样品还不够吗?您是否使用了数据增强?这可以很容易地用pythonNo完成,我不熟悉这种技术。你有一个好的模块或脚本我可以使用吗?好的,谢谢,伙计。我的数据集的性质将使我不太可能使用数据增强,因为我真的不需要增加亮度或扭曲图像,但我肯定会在将来检查它。你的答案确实让我相信使用photoshop或类似的技术是个好主意。@MauriceBekambo没问题,希望你实现你想要的| |::)
    import numpy as np
    import cv2 as cv
    import imutils
    
    def data_augmentation(img, min_rot_angle=-180, max_rot_angle=180, crop_ratio=0.2, smooth_size=3, sharp_val=3, max_noise_scale=10):
        (H, W) = img.shape[:2]
        img_a = img
    
        all_func = ['flip', 'rotate', 'crop', 'smooth', 'sharp', 'noise']
        do_func = np.random.choice(all_func, size=np.random.randint(1, len(all_func)), replace=False)
        #do_func = ['crop']
        # Filp image, 0: vertically, 1: horizontally
        if 'flip' in do_func:
            img_a = cv.flip(img_a, np.random.choice([0, 1]))
        # Rotate image
        if 'rotate' in do_func:
            rot_ang = np.random.uniform(min_rot_angle, max_rot_angle)
            img_a = imutils.rotate_bound(img_a, rot_ang)
        # Crop image
        if 'crop' in do_func:
            (H_A, W_A) = img_a.shape[:2]
            start_x = np.random.randint(0, int(H_A * crop_ratio))
            start_y = np.random.randint(0, int(W_A * crop_ratio))
            end_x = np.random.randint(int(H_A * (1-crop_ratio)), H_A)
            end_y = np.random.randint(int(W_A * (1-crop_ratio)), W_A)
    
            img_a = img_a[start_x:end_x, start_y:end_y]
        # Smoothing
        if 'smooth' in do_func:
            img_a = cv.GaussianBlur(img_a, (smooth_size, smooth_size), 0)
        # Sharpening
        if 'sharp' in do_func:
            de_sharp_val = -(sharp_val - 1) / 8
            kernel = np.array([[de_sharp_val]*3, [de_sharp_val, sharp_val, de_sharp_val], [de_sharp_val]*3])
            img_a = cv.filter2D(img_a, -1, kernel)
        # Add the Gaussian noise to the image
        if 'noise' in do_func:
            noise_scale = np.random.uniform(0, max_noise_scale)
            gauss = np.random.normal(0, noise_scale, img_a.size)
            gauss = np.float32(gauss.reshape(img_a.shape[0],img_a.shape[1],img_a.shape[2]))
            img_a = cv.add(img_a,gauss)
        # Keep shape
        img_a = cv.resize(img_a, (W, H))
        return np.float32(img_a)