computer_vision.mosaic_augmentation

Source: https://github.com/jason9075/opencv-mosaic-data-aug

Attributes

FILTER_TINY_SCALE

IMG_DIR

LABEL_DIR

NUMBER_IMAGES

OUTPUT_DIR

OUTPUT_SIZE

SCALE_RANGE

Functions

get_dataset(→ tuple[list, list])

main(→ None)

Get images list and annotations list from input dir.

random_chars(→ str)

Automatic generate random 32 characters.

update_image_and_anno(→ tuple[list, list, str])

Module Contents

computer_vision.mosaic_augmentation.get_dataset(label_dir: str, img_dir: str) tuple[list, list]
  • label_dir <type: str>: Path to label include annotation of images

  • img_dir <type: str>: Path to folder contain images

Return <type: list>: List of images path and labels

computer_vision.mosaic_augmentation.main() None

Get images list and annotations list from input dir. Update new images and annotations. Save images and annotations in output dir.

computer_vision.mosaic_augmentation.random_chars(number_char: int) str

Automatic generate random 32 characters. Get random string code: ‘7b7ad245cdff75241935e4dd860f3bad’ >>> len(random_chars(32)) 32

computer_vision.mosaic_augmentation.update_image_and_anno(all_img_list: list, all_annos: list, idxs: list[int], output_size: tuple[int, int], scale_range: tuple[float, float], filter_scale: float = 0.0) tuple[list, list, str]
  • all_img_list <type: list>: list of all images

  • all_annos <type: list>: list of all annotations of specific image

  • idxs <type: list>: index of image in list

  • output_size <type: tuple>: size of output image (Height, Width)

  • scale_range <type: tuple>: range of scale image

  • filter_scale <type: float>: the condition of downscale image and bounding box

Return:
  • output_img <type: narray>: image after resize

  • new_anno <type: list>: list of new annotation after scale

  • path[0] <type: string>: get the name of image file

computer_vision.mosaic_augmentation.FILTER_TINY_SCALE = 0.01
computer_vision.mosaic_augmentation.IMG_DIR = ''
computer_vision.mosaic_augmentation.LABEL_DIR = ''
computer_vision.mosaic_augmentation.NUMBER_IMAGES = 250
computer_vision.mosaic_augmentation.OUTPUT_DIR = ''
computer_vision.mosaic_augmentation.OUTPUT_SIZE = (720, 1280)
computer_vision.mosaic_augmentation.SCALE_RANGE = (0.4, 0.6)