Skip to main content

Use interactive matplotlib to label images for classification

Project description

mpl-image-labeller

License PyPI Python Version

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

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
  • Easily configurable keymap
  • Smart interactions with default Matplotlib keymap

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.

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

mpl_image_labeller-0.2.0.tar.gz (578.3 kB view details)

Uploaded Source

Built Distribution

mpl_image_labeller-0.2.0-py2.py3-none-any.whl (6.8 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: mpl_image_labeller-0.2.0.tar.gz
  • Upload date:
  • Size: 578.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for mpl_image_labeller-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e2acd6db429b9ffa612253bdcf65cd25dff10f896b1d5667d9f77d183891d436
MD5 d73f05764eb3accc7308acd460009cf6
BLAKE2b-256 c66290999de2a9a10a249ebe6e95fe2310555555d557e45ebe6366001a23acaf

See more details on using hashes here.

Provenance

File details

Details for the file mpl_image_labeller-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: mpl_image_labeller-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for mpl_image_labeller-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fd359de178496636585ea54769169530484d2bb6b0a9fce770b47bf97902ab4e
MD5 3aa075f1b920a38f24a194276c6a6f5e
BLAKE2b-256 fde78d89775bf4c62f75d3f25107582a6ace002d5d75e0f2bfd7abcc5cc862c7

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page