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, only when --index-json-dir is provided

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.5},
  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.5.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.5-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: polyaug-0.1.5.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for polyaug-0.1.5.tar.gz
Algorithm Hash digest
SHA256 b7cf952b88f65be348f1b71cc0d83b075b1c7a1a1f49495acc201878da33f154
MD5 449c544c2855d0bec87c0b79b71463d0
BLAKE2b-256 5ef284cddccd28bb594f3aa83b36cef3297e5ff39af2b1e52ef4e38b003081ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for polyaug-0.1.5.tar.gz:

Publisher: publish.yml on Laudarisd/polyaug

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: polyaug-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for polyaug-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f05485e35cfd8997128aca6c74b42e5cf8595bcf6433859b953682ee68ce8d9d
MD5 329296b66e2501aee9f91a70c3e0f62f
BLAKE2b-256 bb7d1378f16cf5a43b3e488765dc015863b23b066152a655c764b883dac46b1f

See more details on using hashes here.

Provenance

The following attestation bundles were made for polyaug-0.1.5-py3-none-any.whl:

Publisher: publish.yml on Laudarisd/polyaug

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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