Skip to main content

Polygon topology augmentation CLI for segmentation datasets.

Project description

PolyAug

PyPI version Python Augmentation Albumentations Topology-Aware

PolyAug is a Python package and CLI for topology-aware polygon augmentation for segmentation datasets.

Generating augmented datasets is common with existing libraries such as Albumentations and Augmentor; however, they do not reliably preserve polygon structure when the polygon forms a ring or path-like shape. Such structures are common in raster-to-vector tasks and datasets such as floorplans.

See the paper for more details: Topology-Preserving Data Augmentation for Ring-Type Polygon Annotations.

This package addresses this gap by mitigating the topology inconsistency in such processes.

For installation, usage, and development instructions, see the sections below.


Features

  • Augments images and LabelMe JSON together
  • Choose augmentation parameters and ranges, or use defaults
  • Supports cropping, rotation, scaling, translation, brightness, contrast
  • CLI and Python API for flexibility
  • Generates LabelMe JSON annotations in standard and indexed formats

Installation

We recommend installing inside a virtual environment to avoid dependency conflicts.

Supports windows, macOS, and Linux.

Install from PyPI

python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install polyaug

Quick CLI Check

After installation, verify the CLI is available:

polyaug --help

Basic CLI Usage

polyaug \
  --img-dir ./dataset/images \
  --json-dir ./dataset/json \
  --save-dir ./output \
  --num-per-image 2 \
  --crop 0.8 0.9 \
  --rotation -30 30 \
  --scale 0.7 1.3 \
  --translate -0.1 0.1 \
  --brightness -0.1 0.1 \
  --contrast -0.1 0.1

Inputs

  • --img-dir: directory containing source images
  • --json-dir: directory containing matching LabelMe JSON files

Outputs

Inside --save-dir, PolyAug writes:

  • images/ → augmented images
  • json/ → standard LabelMe JSON annotations
  • augmented_index_json/ → indexed/debug JSON annotations

CLI Arguments

Required

  • --img-dir
  • --json-dir

Optional

  • --save-dir
  • --index-json-dir
  • --num-per-image
  • --crop MIN MAX
  • --rotation MIN MAX
  • --scale MIN MAX
  • --translate MIN MAX
  • --brightness MIN MAX
  • --contrast MIN MAX
  • --p-rotate
  • --p-flip-h
  • --p-flip-v
  • --p-affine
  • --p-crop
  • --p-brightness
  • --contour-simplify-epsilon
  • --min-component-area
  • --min-mask-pixel-area
  • --random-aug-per-image
  • --debug

To see the latest CLI options:

polyaug --help

Project Structure for Building the Package

A clean structure for the package is:

polyaug/
├── LICENSE
├── README.md
├── pyproject.toml
├── src/
│   └── polyaug/
│       ├── __init__.py
│       ├── augmentor.py
│       ├── cli.py
│       └── helper.py
└── tests/
    └── test_imports.py

Citation / Research Use

You can cite PolyAug as:

@software{laudari2026polyaug,
  title={PolyAug: Topology-Aware Polygon Augmentation for Segmentation Datasets},
  author={Laudari, Sudip},
  year={2026},
  version={0.1.0},
  url={https://pypi.org/project/polyaug/}
}

License

MIT License. See LICENSE for details.

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

polyaug-0.1.1.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

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

polyaug-0.1.1-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file polyaug-0.1.1.tar.gz.

File metadata

  • Download URL: polyaug-0.1.1.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for polyaug-0.1.1.tar.gz
Algorithm Hash digest
SHA256 15d3537b50bc4c0c424112fef9d9519dc8543ae8b4d1b049a35f12916db77875
MD5 2f277d8f3c0ec24651e41ee952e0e14b
BLAKE2b-256 3b9370f26be24c4a865d4f890eaec356e3cfd0d9914db70b9baf96d7d5bd2dd5

See more details on using hashes here.

File details

Details for the file polyaug-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: polyaug-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for polyaug-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9cf7faf2a5d237aeda29ad0832d46bfe8a54d4ce4a7def09918bb65c34753c8d
MD5 c30bf8591e1224b040cf97665ca4060c
BLAKE2b-256 078778f8c8c586ceeb6934b81237ef20bc58c06a490194fe07ca66db94e1bd87

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