0

I have tried to modify existig augument.py code in yolov8 repository but it is still implementing the default albumentations while training. Is there any method to add additonal albumentations.

This is what i have tried to add additonal albumentations.

def __init__(self, p=1.0):
    """Initialize the transform object for YOLO bbox formatted params."""
    self.p = p
    self.transform = None
    prefix = colorstr('albumentations: ')
    try:
        import albumentations as A

        check_version(A.__version__, '1.0.3', hard=True)  # version requirement

        T = [
            A.Blur(p=0.01),
            A.MedianBlur(p=0.01),
            A.ToGray(p=0.01),
            A.CLAHE(p=0.01),
            A.RandomBrightnessContrast(p=0.5),
            A.RandomGamma(p=0.5),
            A.ImageCompression(quality_lower=75, p=0.5),
            A.MotionBlur(p=0.5, blur_limit=(3,9), always_apply=False)]  # transforms
        self.transform = A.Compose(T, bbox_params=A.BboxParams(format='yolo', label_fields=['class_labels']))

        LOGGER.info(prefix + ', '.join(f'{x}'.replace('always_apply=False, ', '') for x in T if x.p))
    except ImportError:  # package not installed, skip
        pass
    except Exception as e:
        LOGGER.info(f'{prefix}{e}')

But i don't see "ImageCompression" and "MotionBlur" albumentation in training process.

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36

1 Answers1

0
T = [
        A.Blur(p=0.01),
        A.MedianBlur(p=0.01),
        A.ToGray(p=0.01),
        A.CLAHE(p=0.01),
        A.RandomBrightnessContrast(p=0.5),
        A.RandomGamma(p=0.5),
        A.ImageCompression(quality_lower=75, p=0.5),
        A.MotionBlur(p=0.5, blur_limit=(3,9), always_apply=False)]  # transforms
]

Try changing the code above to the following.

T = [
         A.ImageCompression(quality_lower=75, p=0.5),
         A.MotionBlur(p=0.5, blur_limit=(3, 9), always_apply=False)
]
            
T += [
          A.Blur(p=0.01),
          A.MedianBlur(p=0.01),
          A.ToGray(p=0.01),
          A.CLAHE(p=0.01),
          A.RandomBrightnessContrast(p=0.5),
          A.RandomGamma(p=0.5)
]
  • that moves the ImageCompression and MotionBlur to *before* the other operations, rather than *after* them. – Christoph Rackwitz Aug 11 '23 at 18:48
  • I have updated the existing code with the above changes but the model training logs show default argumentations only. albumentations: Blur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01), CLAHE(p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8)) – bhavesh wadibhasme Aug 12 '23 at 19:01
  • Inside your YOLOv8 training code, you would have a data loader responsible for loading images and applying augmentations. You'll need to modify this part to use your custom augmentations. – James Moore Aug 13 '23 at 16:22