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