コード例 #1
0
def augment_label(label, base_tag, path):
    label = np.asarray([label])
    
    
    flip_rot_label = data.flip_and_rotate(label, discard_original = True)
    save_list(flip_rot_label, base_tag + '_flip_rotate', path)
    
    desat_label = label
    save_list(desat_label, base_tag + '_desat', path)
    
    flip_rot_desat_label = flip_rot_label
    save_list(flip_rot_desat_label, base_tag + '_flip_rotate_desat', path)
    
    
    rand_rot_label = data.random_rotate(label, num_rotations = 3, seed = None, discard_original = True, sharpen = True)
    save_list(rand_rot_label, base_tag + '_rand_rot', path)
    
    flip_rot_rand_rot_label = data.random_rotate(flip_rot_label, num_rotations = 3, seed = None, discard_original = True, sharpen = True)
    save_list(flip_rot_rand_rot_label, base_tag + '_flip_rot_rand_rot', path)
    
    desat_rand_rot_label = data.random_rotate(desat_label, num_rotations = 3, seed = None, discard_original = True, sharpen = True)
    save_list(desat_rand_rot_label, base_tag + '_desat_rand_rot', path)
    
    flip_rot_desat_rand_rot_label = data.random_rotate(flip_rot_desat_label, num_rotations = 3, seed = None, discard_original = True, sharpen = True)
    save_list(flip_rot_desat_rand_rot_label, base_tag + '_flip_rot_desat_rand_rot', path)
コード例 #2
0
def augment_image(image, base_tag, path):
        image = np.asarray([image])
        
        
        flip_rot = data.flip_and_rotate(image, discard_original = True)
        save_list(flip_rot, base_tag + '_flip_rotate', path)
        
        desat = data.saturate(image, 0.5, discard_original = True)
        save_list(desat, base_tag + '_desat', path)
        
        flip_rot_desat = data.saturate(flip_rot, 0.5, discard_original = True)
        save_list(flip_rot_desat, base_tag + '_flip_rotate_desat', path)
        
        
        rand_rot = data.random_rotate(image, num_rotations = 3, seed = None, discard_original = True, sharpen = True)
        save_list(rand_rot, base_tag + '_rand_rot', path)
        
        flip_rot_rand_rot = data.random_rotate(flip_rot, num_rotations = 3, seed = None, discard_original = True, sharpen = True)
        save_list(flip_rot_rand_rot, base_tag + '_flip_rot_rand_rot', path)
        
        desat_rand_rot = data.random_rotate(desat, num_rotations = 3, seed = None, discard_original = True, sharpen = True)
        save_list(desat_rand_rot, base_tag + '_desat_rand_rot', path)
        
        flip_rot_desat_rand_rot = data.random_rotate(flip_rot_desat, num_rotations = 3, seed = None, discard_original = True, sharpen = True)
        save_list(flip_rot_desat_rand_rot, base_tag + '_flip_rot_desat_rand_rot', path)
def augment_label(label, base_tag):
    label = np.asarray([label])
    
    flip_rot_label = data.flip_and_rotate(label, discard_original = True)
    save_list(flip_rot_label, base_tag + '_flip_rotate', path_small[1])
def augment_image(image, base_tag):
    image = np.asarray([image])
    
    flip_rot = data.flip_and_rotate(image, discard_original = True)
    save_list(flip_rot, base_tag + '_flip_rotate', path_small[0])                   # flip + 90-rotate for all datasets
コード例 #5
0
def augment_image(image, base_tag):
    image = np.asarray([image])

    flip_rot = data.flip_and_rotate(image, discard_original=True)
    save_list(flip_rot, base_tag + '_flip_rotate',
              path_small[0])  # flip + 90-rotate for all datasets
    save_list(flip_rot, base_tag + '_flip_rotate', path_large[0])
    save_list(flip_rot, base_tag + '_flip_rotate', path_intermediate[0])

    desat = data.saturate(image, 0.5, discard_original=True)
    save_list(desat, base_tag + '_desat',
              path_large[0])  # desaturated for large and intermediate datasets
    save_list(desat, base_tag + '_desat', path_intermediate[0])

    flip_rot_desat = data.saturate(flip_rot, 0.5, discard_original=True)
    save_list(
        flip_rot_desat, base_tag + '_flip_rotate_desat', path_large[0]
    )  # flip + 90-rotate + desaturated for large and intermediate datasets
    save_list(flip_rot_desat, base_tag + '_flip_rotate_desat',
              path_intermediate[0])

    rand_rot = data.random_rotate(image,
                                  num_rotations=3,
                                  seed=None,
                                  discard_original=True,
                                  sharpen=True)
    rand_rot_intermediate = data.random_rotate(image,
                                               num_rotations=1,
                                               seed=None,
                                               discard_original=True,
                                               sharpen=True)
    save_list(rand_rot, base_tag + '_rand_rot',
              path_large[0])  # 3 rotations for large dataset only
    save_list(rand_rot_intermediate, base_tag + '_rand_rot',
              path_intermediate[0])  # 1 roation for intermediate dataset only

    flip_rot_rand_rot = data.random_rotate(flip_rot,
                                           num_rotations=3,
                                           seed=None,
                                           discard_original=True,
                                           sharpen=True)
    flip_rot_rand_rot_intermediate = data.random_rotate(flip_rot,
                                                        num_rotations=1,
                                                        seed=None,
                                                        discard_original=True,
                                                        sharpen=True)
    save_list(flip_rot_rand_rot, base_tag + '_flip_rot_rand_rot',
              path_large[0])
    save_list(flip_rot_rand_rot_intermediate, base_tag + '_flip_rot_rand_rot',
              path_intermediate[0])

    desat_rand_rot = data.random_rotate(desat,
                                        num_rotations=3,
                                        seed=None,
                                        discard_original=True,
                                        sharpen=True)
    desat_rand_rot_intermediate = data.random_rotate(desat,
                                                     num_rotations=1,
                                                     seed=None,
                                                     discard_original=True,
                                                     sharpen=True)
    save_list(desat_rand_rot, base_tag + '_desat_rand_rot', path_large[0])
    save_list(desat_rand_rot_intermediate, base_tag + '_desat_rand_rot',
              path_intermediate[0])

    flip_rot_desat_rand_rot = data.random_rotate(flip_rot_desat,
                                                 num_rotations=3,
                                                 seed=None,
                                                 discard_original=True,
                                                 sharpen=True)
    flip_rot_desat_rand_rot_intermediate = data.random_rotate(
        flip_rot_desat,
        num_rotations=1,
        seed=None,
        discard_original=True,
        sharpen=True)
    save_list(flip_rot_desat_rand_rot, base_tag + '_flip_rot_desat_rand_rot',
              path_large[0])
    save_list(flip_rot_desat_rand_rot_intermediate,
              base_tag + '_flip_rot_desat_rand_rot', path_intermediate[0])
コード例 #6
0
def augment_label(label, base_tag):
    label = np.asarray([label])

    flip_rot_label = data.flip_and_rotate(label, discard_original=True)
    save_list(flip_rot_label, base_tag + '_flip_rotate', path_small[1])
    save_list(flip_rot_label, base_tag + '_flip_rotate', path_large[1])
    save_list(flip_rot_label, base_tag + '_flip_rotate', path_intermediate[1])

    desat_label = label
    save_list(desat_label, base_tag + '_desat', path_large[1])
    save_list(desat_label, base_tag + '_desat', path_intermediate[1])

    flip_rot_desat_label = flip_rot_label
    save_list(flip_rot_desat_label, base_tag + '_flip_rotate_desat',
              path_large[1])
    save_list(flip_rot_desat_label, base_tag + '_flip_rotate_desat',
              path_intermediate[1])

    rand_rot_label = data.random_rotate(label,
                                        num_rotations=3,
                                        seed=None,
                                        discard_original=True,
                                        sharpen=True)
    rand_rot_label_intermediate = data.random_rotate(label,
                                                     num_rotations=1,
                                                     seed=None,
                                                     discard_original=True,
                                                     sharpen=True)
    save_list(rand_rot_label, base_tag + '_rand_rot', path_large[1])
    save_list(rand_rot_label_intermediate, base_tag + '_rand_rot',
              path_intermediate[1])

    flip_rot_rand_rot_label = data.random_rotate(flip_rot_label,
                                                 num_rotations=3,
                                                 seed=None,
                                                 discard_original=True,
                                                 sharpen=True)
    flip_rot_rand_rot_label_intermediate = data.random_rotate(
        flip_rot_label,
        num_rotations=1,
        seed=None,
        discard_original=True,
        sharpen=True)
    save_list(flip_rot_rand_rot_label, base_tag + '_flip_rot_rand_rot',
              path_large[1])
    save_list(flip_rot_rand_rot_label_intermediate,
              base_tag + '_flip_rot_rand_rot', path_intermediate[1])

    desat_rand_rot_label = data.random_rotate(desat_label,
                                              num_rotations=3,
                                              seed=None,
                                              discard_original=True,
                                              sharpen=True)
    desat_rand_rot_label_intermediate = data.random_rotate(
        desat_label,
        num_rotations=1,
        seed=None,
        discard_original=True,
        sharpen=True)
    save_list(desat_rand_rot_label, base_tag + '_desat_rand_rot',
              path_large[1])
    save_list(desat_rand_rot_label_intermediate, base_tag + '_desat_rand_rot',
              path_intermediate[1])

    flip_rot_desat_rand_rot_label = data.random_rotate(flip_rot_desat_label,
                                                       num_rotations=3,
                                                       seed=None,
                                                       discard_original=True,
                                                       sharpen=True)
    flip_rot_desat_rand_rot_label_intermediate = data.random_rotate(
        flip_rot_desat_label,
        num_rotations=1,
        seed=None,
        discard_original=True,
        sharpen=True)
    save_list(flip_rot_desat_rand_rot_label,
              base_tag + '_flip_rot_desat_rand_rot', path_large[1])
    save_list(flip_rot_desat_rand_rot_label_intermediate,
              base_tag + '_flip_rot_desat_rand_rot', path_intermediate[1])