cpauger.generate_coco_ann
Functions
|
|
|
Create a list of random bbox coordinates in coco format. |
|
Generate a random segmentation mask made of polygon points |
|
Create annotation for object. Represents the annotation field of coco annotation |
|
Generate and export random coco annotation file |
|
_summary_ |
|
Wrapper around save_random_imgs |
|
Generates random images |
|
Generates random images and annotations in coco format |
Module Contents
- cpauger.generate_coco_ann.generate_random_bbox(image_width: int, image_height: int, anthor=5) List[int][source]
Create a list of random bbox coordinates in coco format.
- Parameters:
image_width (int) – Width of image
image_height (int) – Height of image
- Returns:
List of bbox coordinates in coco format.
- Return type:
List[int]
- cpauger.generate_coco_ann.generate_random_segmentation(bbox) List[float][source]
Generate a random segmentation mask made of polygon points
- Parameters:
bbox (List) – Bounding box of object in coco format
- Returns:
Polygon coordinates representing segmentation mask
- Return type:
List[float]
- cpauger.generate_coco_ann.create_coco_annotation(image_id: int, category_id: int, bbox: List[int], segmentation: List[float], ann_id: int) Dict[source]
Create annotation for object. Represents the annotation field of coco annotation
- Parameters:
image_id (int) – Unique identifier for image to be used in coco annotation.
category_id (int) – Category identifier for object to be used in annotation
bbox (List[int]) – Boundry of object to be used in coco annotation format
segmentation (List[float]) – Polygon of object representing segmentation mask to be used in annotation
ann_id (int) – Unique identifier for annotation
- Returns:
Single annotation for object.
- Return type:
Dict
- cpauger.generate_coco_ann.generate_coco_annotation_file(image_width: int, image_height: int, output_path: str, img_list: List) None[source]
Generate and export random coco annotation file
- Parameters:
image_width (int) – Width of image
image_height (int) – Height of image
output_path (str) – Path to store the annotation
img_list (List) – List of image names
Returns: None
- cpauger.generate_coco_ann.save_random_imgs(img_size: Tuple[int], save_as: str) None[source]
_summary_
- Parameters:
img_size (Tuple[int]) – Image height and width
save_as (str) – Path to save the image
- cpauger.generate_coco_ann.save_random_img_wrapper(args: Dict) None[source]
Wrapper around save_random_imgs
- Parameters:
args (Dict) – arguments for save_random_imgs function where keys are the
save_random_imgs (parameter name and values are the values to assign.)
parameters. (requires img_size and save_as)
Returns: None
- cpauger.generate_coco_ann.generate_random_images(image_height: int, image_width: int, number_of_images: int, output_dir: str = 'random_images', img_ext: str = 'jpg', image_name: str = 'random_images', parallelize: bool = True) List[str][source]
Generates random images
- Parameters:
image_height (int) – Height of the image
image_width (int) – Width of the image
number_of_images (int) – Number of images to generate
output_dir (_type_, optional) – Directory to export images to. Defaults to random_images.
img_ext (str, optional) – Image extention to use to save. Defaults to jpg.
image_name (str, optional) – Prefix name to use in saving image. Defaults to random_images.
parallelize (bool, optional) – Multiprocess should be use for image generating. Defaults to True.
- Returns:
List of paths to images generated
- Return type:
List[str]
- cpauger.generate_coco_ann.generate_random_images_and_annotation(image_height: int, image_width: int, number_of_images: int, output_dir: str = 'random_images', img_ext: str = 'jpg', image_name: str = 'random_images', parallelize: bool = True, save_ann_as: str = 'generated_annotation.json', **kwargs) Tuple[List, str][source]
Generates random images and annotations in coco format
- Parameters:
image_height (int) – Height of the image
image_width (int) – Width of the image
number_of_images (int) – Number of images to generate
output_dir (_type_, optional) – Directory to export images to. Defaults to random_images.
img_ext (str, optional) – Image extention to use to save. Defaults to jpg.
image_name (str, optional) – Prefix name to use in saving image. Defaults to random_images.
parallelize (bool, optional) – Multiprocess should be use for image generating. Defaults to True.
save_ann_as (str, optional) – coco annotation file name to use for saving
- Returns:
List of images generated paths and save_ann_as
- Return type:
Tuple[List, str]