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.[ROTATION NOT SUPPORTED YET VERSION<=0.0.2]

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 [ROTATION NOT SUPPORTED AS OF VERSION 0.0.2]

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.1.0.tar.gz (5.4 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.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for xml_augmenter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dff89a3c05cb1c1d922ff453b56e2e6530ff88601de75de0ee5388899ebcd8db
MD5 32b8a1192b12dc09127bbe806d8eb7e7
BLAKE2b-256 1867a1dac240040d035b244d6f402cc3ec5a3c6313db89f70a06126700555f7e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for xml_augmenter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c60d0ba675d11ed20da89116eef6a775b97bbaf3ea5928e15fbbd32b10a164de
MD5 52c3670ea9f32f9d857f9bd2d38de369
BLAKE2b-256 001ec008f0a9c66aee01ddbaa1694ca6c7d9976223623b0a5090909232da63af

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