Skip to main content

mpl-image-labeller

Binder Documentation Status

License PyPI Python Version

Use Matplotlib to label images for classification. Works anywhere Matplotlib does - from the notebook to a standalone gui!

For more see the documentation.

Install

pip install mpl-image-labeller

Key features

  • Simple interface
  • Uses keys instead of mouse
  • Only depends on Matplotlib
    • Works anywhere - from inside Jupyter to any supported GUI framework
  • Displays images with correct aspect ratio
  • Easily configurable keymap
  • Smart interactions with default Matplotlib keymap
  • Callback System (see examples/callbacks.py)

single class per image

gif of usage for labelling images of cats and dogs

multiple classes per image

gif of usage for labelling images of cats and dogs

Usage

import matplotlib.pyplot as plt
import numpy as np

from mpl_image_labeller import image_labeller

images = np.random.randn(5, 10, 10)
labeller = image_labeller(
    images, classes=["good", "bad", "meh"], label_keymap=["a", "s", "d"]
)
plt.show()

accessing the axis You can further modify the image (e.g. add masks over them) by using the plotting methods on axis object accessible by labeller.ax.

Lazy Loading Images If you want to lazy load your images you can provide a function to give the images. This function should take the integer idx as an argument and return the image that corresponds to that index. If you do this then you must also provide N_images in the constructor to let the object know how many images it should expect. See examples/lazy_loading.py for an example.

Controls

  • <- move one image back
  • -> move one image forward

To label images use the keys defined in the label_keymap argument - default 0, 1, 2...

Get the labels by accessing the labels property.

Overwriting default keymap

Matplotlib has default keybindings that it applied to all figures via rcparams.keymap that allow for actions such as s to save or q to quit. If you inlcude one of these keys as a shortcut for labelling as a class then that default keymap will be disabled for that figure.

Related Projects

This is not the first project to implement easy image labelling but seems to be the first to do so entirely in Matplotlib. The below projects implement varying degrees of complexity and/or additional features in different frameworks.

Release files for mpl-image-labeller 1.1.2

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

Source distribution (sdist)

Source distribution for mpl-image-labeller 1.1.2
File Size Uploaded
mpl_image_labeller-1.1.2.tar.gz 1.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for mpl-image-labeller 1.1.2
File Interpreter ABI Platform
mpl_image_labeller-1.1.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 1.1 MB

Release files / mpl_image_labeller-1.1.2.tar.gz

Download URL mpl_image_labeller-1.1.2.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
b858ad13b6fc822ce6ef5319f16cfb81c48af12eeef571d81afb612d05b03181
BLAKE2b-256 checksum
How to use checksums
b2a4147e4bc6074e648908c10cf6b39ebd6dcd176752715825be2056c86efc01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.0

Release files / mpl_image_labeller-1.1.2-py2.py3-none-any.whl

Download URL mpl_image_labeller-1.1.2-py2.py3-none-any.whl
Size 11.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
e541208d47253cf337799fa788249aaa9f4088ee75504d847954a8d52e19620a
BLAKE2b-256 checksum
How to use checksums
95372a15676e22fd00beb62368886eb47b18de42c89a40d6c279eb5429e37a9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.0

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

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