Skip to content

This efficient image augmentation pipline, which only depends on OpenCV and numpy.

Notifications You must be signed in to change notification settings

huangluyao/pipline_transfrom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pipline Transfrom

This efficient image augmentation pipline, which only depends on OpenCV and numpy.

Usage examples

  1. set up config file in json format.
{
  "train": [
    {"type": "RandomFlip", "prob": 0.5, "direction": "vertical"},
    {"type": "Resize", "height": 400, "width": 400, "always_apply": true},
    {"type": "Rotate", "limit": [-5,5], "prob": 0.5},
    {"type": "ColorJitter","brightness": 0.1, "contrast": 0.5, "saturation": 0.1, "hue": 0.05, "prob": 1}

  ],
  "no use": [
    {"type": "Normalize", "mean": [0.485,0.456,0.406], "std": [0.229,0.224,0.225], "always_apply": true}
  ]
}
  1. The code is as follows
import json
from transforms import Compose
import cv2

if __name__ == "__main__":

    json_path = "config/test.json"

    with open(json_path, 'r') as fp:
        cfg = json.load(fp)

    transform = Compose(cfg["train"])

    img = cv2.imread('images/image_0741.jpg')

    data = transform(image=img, info='image')

    cv2.imwrite('images/test.jpg', data['image'])

Documentation

Document will be released later and more image augmentation will be added later.

Usage examples

sample code like:

list_augmentations = [{"type": "RandomFlip", "prob": 1, "direction": "horizontal"}]
transform = Compose(list_augmentations)
data = transform(image=img, bboxes=bboxes, category_ids=category_ids)

RandomFlip

  1. Original image

  2. list_augmentations = [{"type": "RandomFlip", "prob": 1, "direction": "horizontal"}]

  3. list_augmentations = [{"type": "RandomFlip", "prob": 1, "direction": "vertical"}]

    RanddomFilp

Rotate

  1. Original image

  2. list_augmentations = [{"type": "Rotate", "limit": [-5,5], "prob": 1}]

    Rotate

ColorJitter

  1. Original image

  2. list_augmentations = {"type": "ColorJitter","brightness": 0.1, "contrast": 0.5, "saturation": 0.1, "hue": 0.05, "prob": 1}

    ColorJitter

About

This efficient image augmentation pipline, which only depends on OpenCV and numpy.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages