Registry / ai-ml / labelme

labelme

JSON →
library6.3.1pypypi✓ verified 84d ago

Labelme is a graphical image annotation tool written in Python. Current version 6.3.1 (requires Python >=3.10). It provides a polygon-based annotation interface for segmentation, classification, and other labeling tasks. Development is active but with occasional long gaps between releases.

pip install labelme
INSTALL
IMPORT
SIG · LABELME
L
labelme
ai-mlpythonv6.3.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

labelme
import labelme
import labelme as lm
Aliasing is unnecessary; labelme is the canonical import.

Basic usage: launch the GUI and convert annotations to label images.

import labelme from labelme import utils import os.path as osp # Launch the annotation GUI labelme.main() # Example: convert JSON annotations to label images json_file = 'example.json' if osp.isfile(json_file): data = labelme.LabelFile.load_json(json_file) label_img, label_names = utils.labelme_shapes_to_label( img_shape=(data['imageHeight'], data['imageWidth']), shapes=data['shapes'] ) print(f'Label image shape: {label_img.shape}') print(f'Label names: {label_names}')
Debug
Known issues
gotchalabelme.LabelFile.load_json returns a dict-like object, not a class instance. Access data fields as dict keys (e.g., data['imageHeight']), not attributes.
fix
Use data['imageHeight'] instead of data.imageHeight.
affects: >=6.0.0
deprecatedThe function labelme.utils.image_data_from_file is deprecated and may be removed in future versions.
fix
Use labelme.LabelFile.load_image_file instead.
affects: >=6.0.0
breakingIn version 6.0.0, the minimum Python version was raised to 3.10. Installations on older Python will fail.
fix
Upgrade Python to 3.10+ or pin labelme to 5.x.
affects: >=6.0.0, <7.0.0
gotchaLabelme saves annotations in JSON format, but the image file paths are stored as relative paths from the JSON location. Moving files after annotation breaks the links.
fix
Keep image and JSON in the same directory or use absolute paths when opening.
affects: All
gotchaWhen using labelme from a headless environment (no display), the GUI will crash. The library does not provide a CLI batch mode without display.
fix
Run labelme on a machine with a display or use an alternative like labelme2coco for headless conversion.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'labelme'
Labelme is not installed.
fix
pip install labelme
ImportError: cannot import name 'LabelFile' from 'labelme'
In older versions (<=4.x), the class was 'LabelFile' but in newer versions it's 'labelme.LabelFile'. Also check case sensitivity.
fix
Use 'from labelme import LabelFile' in current versions.
NameError: name 'labelme' is not defined
The module was not imported properly or the import statement is missing.
fix
Add 'import labelme' at the top of your script.
AttributeError: 'dict' object has no attribute 'imageHeight'
labelme.LabelFile.load_json returns a dict, not an object. Accessing attributes fails.
fix
Use data['imageHeight'] instead of data.imageHeight.
Upgrade
Version history
6.3.1latest on PyPI · released May 27, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
52 hits · last 30 days
node
52
Resources

No resource links recorded.

labelme — pip install labelme · libregistry