# it: iterator for different resolutions
                    # start to augment the rest
                    if AUGMENT and prob < it[0] and MINOR_CLASS_FLAG == False:

                        for extra in range(3):
                            center = np.array([
                                int(image.shape[0] / 2),
                                int(image.shape[1] / 2)
                            ])
                            deg = np.random.randint(-10, 10)
                            #deg = np.random.normal()*30
                            # changed
                            # remove and gaussian blur

                            newimg = aug.gaussian_blur(image)
                            #newimg = image

                            #.3 probability for each of shifting vs rotating vs shift(rotate(image))
                            p = np.random.randint(0, 3)
                            # debug
                            # modified to use the removed cloud version of bboxes
                            # image, new_coords, new_classes
                            if p == 0:
                                newimg, nb = aug.shift_image(
                                    newimg, new_coords)
                                #newimg,nb = aug.shift_image(newimg,box[idx])
                            elif p == 1:
                                newimg, nb = aug.rotate_image_and_boxes(
                                    newimg, deg, center, new_coords)
                                #newimg,nb = aug.rotate_image_and_boxes(newimg,deg,center,box[idx])
Пример #2
0
                    #Make augmentation probability proportional to chip size.  Lower chip size = less chance.
                    #This makes the chip-size imbalance less severe.
                    prob = np.random.randint(0, np.max(res))
                    #for 200x200: p(augment) = 200/500 ; for 300x300: p(augment) = 300/500 ...

                    if AUGMENT and prob < it[0]:

                        for extra in range(3):
                            center = np.array([
                                int(image.shape[0] / 2),
                                int(image.shape[1] / 2)
                            ])
                            deg = np.random.randint(-10, 10)
                            #deg = np.random.normal()*30
                            newimg = aug.salt_and_pepper(
                                aug.gaussian_blur(image))

                            #.3 probability for each of shifting vs rotating vs shift(rotate(image))
                            p = np.random.randint(0, 3)
                            if p == 0:
                                newimg, nb = aug.shift_image(newimg, box[idx])
                            elif p == 1:
                                newimg, nb = aug.rotate_image_and_boxes(
                                    newimg, deg, center, box[idx])
                            elif p == 2:
                                newimg, nb = aug.rotate_image_and_boxes(
                                    newimg, deg, center, box[idx])
                                newimg, nb = aug.shift_image(newimg, nb)

                            newimg = (newimg).astype(np.uint8)
Пример #3
0
                        train_chips += 1
     
                    ind_chips +=1

                    #Make augmentation probability proportional to chip size.  Lower chip size = less chance.
                    #This makes the chip-size imbalance less severe.
                    prob = np.random.randint(0,np.max(res))
                    #for 200x200: p(augment) = 200/500 ; for 300x300: p(augment) = 300/500 ...

                    if AUGMENT and prob < it[0]:
                        
                        for extra in range(3):
                            center = np.array([int(image.shape[0]/2),int(image.shape[1]/2)])
                            deg = np.random.randint(-10,10)
                            #deg = np.random.normal()*30
                            newimg = aug.salt_and_pepper(aug.gaussian_blur(image))

                            #.3 probability for each of shifting vs rotating vs shift(rotate(image))
                            p = np.random.randint(0,3)
                            if p == 0:
                                newimg,nb = aug.shift_image(newimg,box[idx])
                            elif p == 1:
                                newimg,nb = aug.rotate_image_and_boxes(newimg,deg,center,box[idx])
                            elif p == 2:
                                newimg,nb = aug.rotate_image_and_boxes(newimg,deg,center,box[idx])
                                newimg,nb = aug.shift_image(newimg,nb)
                                

                            newimg = (newimg).astype(np.uint8)

                            if idx%1000 == 0 and SAVE_IMAGES: