Skip to main content

Simple XML file augmentation handler for segmentation based CV tasks

Project description

XML_Augment

Overview

XML_Augment is a Python library for augmenting images and their corresponding XML annotations, typically used in object detection and image segmentation tasks. It includes functionalities for visualizing annotations, brightening images, translating images, and rotating images while updating the XML annotations accordingly.

Features

  • Visualize Annotations: Display the annotated polygons and bounding boxes on the image.
  • Brighten Images: Randomly adjust the brightness of the image.
  • Translate Images: Randomly translate (shift) the image and update the annotations.
  • Rotate Images: Randomly rotate the image and update the annotations.

Installation

To use this project, ensure you have the following libraries installed:

pip install xml_augmenter

Usage

Requirements

  • Python 3.x
  • OpenCV
  • NumPy

Example

Import necessary libraries

import cv2 as cv
import xml.etree.ElementTree as ET
import numpy as np

Define the path to your image and XML annotation file

impath = "path/to/your/image.jpg"
anpath = "path/to/your/annotations.xml"

Create an instance of XML_Augment

xa = XML_Augment(anpath, impath)

Visualize annotations with custom text size

xa.visualize_annotaitons(text_size=0.3)

Apply translation augmentation with a maximum translation percent

xa.translate(0.2)

Apply brightness augmentation with a maximum brightness value

xa.brighten(100)

Apply rotation augmentation with a maximum rotation offset

xa.rotate(45)

Visualize annotations again after augmentations

xa.visualize_annotaitons(text_size=0.3)

Show the final image with augmentations

cv.imshow('image', xa.image)
cv.waitKey()
cv.destroyAllWindows()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xml_augmenter-0.0.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xml_augmenter-0.0.2-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file xml_augmenter-0.0.2.tar.gz.

File metadata

  • Download URL: xml_augmenter-0.0.2.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for xml_augmenter-0.0.2.tar.gz
Algorithm Hash digest
SHA256 598aad99d736ddb4507104d331068d9b2c55c6dc1b90019d71049c6639d82702
MD5 88e136e16acdda5f1660de4ab7a23396
BLAKE2b-256 2b16a78e8bab463edd94fc49c33d6e0367bcdf9520382480d02bbf915253df7a

See more details on using hashes here.

File details

Details for the file xml_augmenter-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: xml_augmenter-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for xml_augmenter-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ad7efc9e71b99e7d10c4314ed3d87353278822221727054c16f41ce923856b03
MD5 bbc4fbd9695ecea6e689c3c1d8336126
BLAKE2b-256 85661091f23e478bff475ec0ac8de7d1f8bb8af16518c7937ae907af7bfd39c5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page