Skip to main content

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

Metadata

Release files for textmark 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for textmark 0.5.0
File Size Uploaded
textmark-0.5.0.tar.gz 13.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for textmark 0.5.0
File Interpreter ABI Platform
textmark-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.5 kB

Release files / textmark-0.5.0.tar.gz

Download URL textmark-0.5.0.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
cc1777be960cc0aa4802735c57161410245b0ba9c19ea9c542adc763421ded78
BLAKE2b-256 checksum
How to use checksums
dfd95d194c2a261108570d353ecd1be60d767b6bdd534693d4f34bee9a3a3baf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19

Release files / textmark-0.5.0-py3-none-any.whl

Download URL textmark-0.5.0-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55cd02c7f1961e40067d216f63a1717097a660475598630066b5657dcb9cf8cb
BLAKE2b-256 checksum
How to use checksums
061ab4e037ceb9eaec90f17978c4c52049ddc617f228a3e21a3d14c9d14ac216
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.7

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page