图像增强库imgaug的目标检测数据使用笔记

from imgaug import augmenters as iaa
import imgaug as ia
import matplotlib.pyplot as plt 

augmentation = iaa.SomeOf((0, 3), [
    iaa.Fliplr(0.5),
    iaa.Flipud(0.5),
    iaa.OneOf([iaa.Affine(rotate=90),
               iaa.Affine(rotate=90),
               iaa.Affine(rotate=270),
               iaa.Affine(rotate=180),
               iaa.Affine(rotate=180),
               iaa.Affine(rotate=270)]),
    iaa.Multiply((0.8, 1.5)),
    iaa.GaussianBlur(sigma=(0.0, 3.0))
])

temp_aug_bbox = []
for bbox in bboxes_resize1:
    temp_aug_bbox.append(ia.BoundingBox(x1=bbox[1], 
                                        x2=bbox[3], 
                                        y1=bbox[0], 
                                        y2=bbox[2]))
bbs = ia.BoundingBoxesOnImage(temp_aug_bbox, shape=image.shape)
#        if debug:
#            pass
#            plt.figure()
#            plt.imshow(bbs.draw_on_image(image, thickness=2))


seq_det = augmentation.to_deterministic()

image = seq_det.augment_image(image)
bbs_aug = seq_det.augment_bounding_boxes([bbs])[0]
#        plt.figure()
#        plt.imshow(bbs_aug.draw_on_image(image_aug, thickness=2))    

bboxes_resize1 = []
for one in bbs_aug.bounding_boxes:
    bboxes_resize1.append([ one.y1, one.x1, one.y2, one.x2])
if debug:
    pass
    debug_show(image, bboxes_resize1)

 分割任务

from imgaug import augmenters as iaa
import imgaug as ia
import matplotlib.pyplot as plt

def img_aug2(image, mask_img):
    image = np.array(image)
    mask_img = np.a
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值