在保留现有标签的同时进行数据扩充

data Augmentation while preserving existing label

问题陈述

我正在做一个项目,使用 YOLO 模型来检测给定的工具形式 picture.i。例如锤子、螺丝刀、螺栓等。我只有 100 张图片作为训练数据集,我用多边形标记了它们。我决定使用下面给出的代码来扩充数据。我有 500 张新图像,但问题是我不想再次标记它们。我正在寻找使用新闻增强图像调整(保留)标签边界框(多边形)的任何方法,这样我就可以在不再次标记的情况下获取多边形数据。简而言之,我想在图像增强过程中保留标签。

用于增强的代码

Brightness=[0.7,0.8,1] # Different brightness Levels
Rotation=[10,-10]    # Different rotation Levels

# Main link source
main_path=r"./Augmentation"
# Directoy from main path
dir=os.listdir(main_path)[1:]
# Read and iterate all images from directory
for name in dir:

    image = Image.open(os.path.join(main_path,name))
# Apply rotation from image

    for j in Rotation:             # Different rotation Levels
        rotated = image.rotate(j)
        ransImageRGBA = rotated.convert("RGB")
        apply_br = ImageEnhance.Brightness(ransImageRGBA)
# Apply values for brightness in rotated images
        for i in Brightness:         # Different rotation Levels
             Lightness =apply_br.enhance(i)
             # below line for output
             Lightness = apply_br.enhance(i).save((os.path.join(main_path, 'augmented_Images',str(i)+str(j))+name))
             print('image has been augmented successfully')

调查imaug。这个模块的扩充也扩充了标签。还有一件事,你现在正在做的是离线增强。您可能想看看在线扩充。然后每个时代图片都以不同的方式增强,你只训练增强图片。这样你就不必有很多磁盘空间了。

如果您将 Yolov4 与 darknet 一起使用,图像增强会自动执行。