Use interactive matplotlib to label images for classification
Project description
mpl-image-labeller
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
multiple classes per image
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mpl_image_labeller-1.1.1.tar.gz
.
File metadata
- Download URL: mpl_image_labeller-1.1.1.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16346bbd53e5e3997d8242eba6dc3853317ebd5fcebefe58cc58beb53d63b100 |
|
MD5 | 56ca2ea830fca5ab20caeeafdd6a76fa |
|
BLAKE2b-256 | 8dc85975df4d69bb5a36d8c06ec29b4a756dfc91eee8811f2e72e5fe1625fe5d |
File details
Details for the file mpl_image_labeller-1.1.1-py2.py3-none-any.whl
.
File metadata
- Download URL: mpl_image_labeller-1.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15aab0f287a2060ca68443e4ae31379494dff1858832d1bec06c124a81783e06 |
|
MD5 | da196ed25251d420c21bbf8ed5bc9272 |
|
BLAKE2b-256 | a5b8b108a534c4a8ec2f072ba613fc0279626758621fd35d83a65c6a5b9e7145 |