Skip to main content

Text annotation utilities for computer vision pipelines.

Project description

Text Annotation Utilities

This project supports buildling datasets for downstream tasks using many open-source text-spotting datasets. It includes a number of classes and tools to quickly and easily build text spotting datasets with many annotation types, including

  • Dot
  • 2-point bounding boxes
  • Quadrilateral bounding boxes
  • Polygons
  • Bezier Curves

Additionally, this library makes converting between types extremely easy through an intuitive and extensible interface.

example

Setup

Use pip to install:

pip install textmark

TextAnnotation

TextAnnotation is a base class that can be easily extended to support other annotation formats. This library includes several formats already. Of particular note is that TextAnnotation includes a class level conversion registry. Subclasses can be registered like so:

# Add your subclass name:
TextAnnotation.register_name(name, "My_Class")
# Add any relevant conversions
# you only need to convert to the "closest" next annotation type
TextAnnotation.register_conversion(BoxAnnotation, QuadAnnotation, BoxAnnotation.to_quad)
TextAnnotation.register_conversion(QuadAnnotation, BoxAnnotation, QuadAnnotation.to_box)

Now, a user can easily convert between Box and Quad annotations through the use of

my_quad_annotation.to("Box")

If there are additional registries, such as Quad <--> Polygon, the user can convert all the way from a Box to a Polygon annotation (or vice versa) in a single command:

my_polygon_annotation.to("Box")

This system works by constructing a graph of all registered conversions. When a user calls the .to method, the graph is searched for the target class, and then applies all conversions on that path. This library implements the following simple conversions, which can be automatically chained together:

Polygon <--> Quad
Quad <--> Box
Box <--> Dot

Note that moving up through the chain is a lossy process!!

In addition, Bezier Curves can be converted to Polygons.

Visualizing

This library also includes an easy visualization system. See the example below:

from textmark import TextAnnotation, Visualizer

img_path = ...

my_annotation = TextAnnotation.factory(
    "Poly", scene_text, language, *list_of_points
)

my_second_annotation = TextAnnotation.factory(
    ...
)

# Can visualize an arbitrary number of annotations
vis = Visualizer(img_path, [my_annotation, my_second_annotation, ...])
visualization = vis.visualize()
visualize.show()  # uses PIL

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

textmark-0.2.0.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

textmark-0.2.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file textmark-0.2.0.tar.gz.

File metadata

  • Download URL: textmark-0.2.0.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for textmark-0.2.0.tar.gz
Algorithm Hash digest
SHA256 35a5035c7c2b80e07a4ec4c2fbed4658b88e411cda9e8b2454b606d3e00f5044
MD5 1037e14d39cc0df73ab35b73550fdc44
BLAKE2b-256 92b93dd0c531778f22b7500bb018060a343fd9a910f5b6a94b15f4df6c69cb05

See more details on using hashes here.

File details

Details for the file textmark-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: textmark-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for textmark-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f24e17aacd99e78d4655528e766f1c449ad1f05fe89ba93e903811d6866ccf3
MD5 97e8d73bcef89a686701bfedc69c78eb
BLAKE2b-256 0b790ffce95fc9af4a594190222c48a6d33881ad2e90b36ed272867847edc69c

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