A Comprehensive Guide to Labelme

Description
Labelme is a graphical image annotation tool inspired by MIT’s labelme. It is written in Python and utilizes Qt for its graphical interface.





VOC dataset example of instance segmentation.



Other examples (semantic segmentation, bbox detection, and classification).
Features
- [x] Image annotation for polygon, rectangle, circle, line, and point. ([tutorial](examples/tutorial))
- [x] Image flag annotation for classification and cleaning. ([#166](https://github.com/labelme/ai/pull/166))
- [x] Video annotation. ((examples/video_annotation))
- [x] GUI customization (predefined labels & flags, auto-saving, label validation, etc). ([#144](https://github.com/labelme/ai/pull/144))
- [x] Exporting VOC-format dataset for semantic instance segmentation. ([semantic segmentation](examples/semantic_segmentation), [instance segmentation](examples/instance_segmentation))
- [x] Exporting COCO-format dataset for instance segmentation. ([instance segmentation](examples/instance_segmentation))
Starter Guide
If you’re new to Labelme, you can get started with Labelme Starter (FREE), which contains:
- Installation guides for all platforms: Windows, macOS, and Linux.
- Step-by-step tutorials: from first annotation to editing, exporting, and integrating with other programs.
- A compilation of valuable resources for further exploration.
Installation
There are several options for installation:
- Platform agnostic installation: Anaconda
- Platform specific installation: Ubuntu, macOS, Windows
- Pre-build binaries from the release section
Installing via Anaconda
You need to install Anaconda, then run the following commands:
python3
conda create --name=labelme python=3
source activate labelme
conda install -c conda-forge pyside2
conda install pyqt
pip install pyqt5 # pyqt5 can also be installed via pip on python3
pip install labelme # or you can install everything by conda command
conda install labelme -c conda-forge
Installing on Ubuntu
sudo apt-get install labelme
# or
sudo pip3 install labelme
# or install standalone executable from:
# https://github.com/labelme/ai/releases
# or install from source
pip3 install git+https://github.com/labelme/ai
Installing on macOS
brew install pyqt # maybe pyqt5
pip install labelme
# or install standalone executable app from:
# https://github.com/labelme/ai/releases
# or install from source
pip3 install git+https://github.com/labelme/ai
Installing on Windows
Install Anaconda, then in an Anaconda Prompt run:
conda create --name=labelme python=3
conda activate labelme
pip install labelme # or install standalone executable app from:
# https://github.com/labelme/ai/releases
# or install from source
pip3 install git+https://github.com/labelme/ai
Usage
Run labelme --help
for details. The annotations are saved as a JSON file.
labelme # just open GUI
# tutorial (single image example)
cd examples/tutorial
labelme apc2016_obj3.jpg # specify image file
labelme apc2016_obj3.jpg -O apc2016_obj3.json # close window after saving
labelme apc2016_obj3.jpg --nodata # not include image data but relative image path in JSON file
labelme apc2016_obj3.jpg --labels highland_6539_self_stick_notes,mead_index_cards,kong_air_dog_squeakair_tennis_ball # specify label list
# semantic segmentation example
cd examples/semantic_segmentation
labelme data_annotated # Open directory to annotate all images in it
labelme data_annotated --labels labels.txt # specify label list using a file
Command Line Arguments
--output
specifies the location for annotations to be written. If the location ends with .json, it writes a single annotation; otherwise, the program assumes a directory.- The first time you run labelme, a config file is created in
~/.labelmerc
, which you can edit to apply changes next launch. - Without
--nosortlabels
, labels are listed alphabetically. Use the flag to display them as provided. - Flags are assigned to an entire image while labels are specific to a polygon.
FAQ
- How to convert JSON file to numpy array? See tutorial.
- How to load a label PNG file? See tutorial.
- How to get annotations for semantic segmentation? See semantic segmentation.
- How to get annotations for instance segmentation? See instance segmentation.
Examples
- Image Classification
- Bounding Box Detection
- Semantic Segmentation
- Instance Segmentation
- Video Annotation
How to Develop
git clone https://github.com/labelme/ai.git
cd labelme
# Install anaconda3 and labelme
curl -L https://github.com/wkentarodotfiles/raw/main/local/bin/install_anaconda3.sh | bash -s .
source ~/.anaconda3/bin/activate
pip install -e .
How to Build a Standalone Executable
Below shows how to build the standalone executable on macOS, Linux, and Windows.
# Setup conda
conda create --name labelme python=3.9
conda activate labelme
# Build the standalone executable
pip install .
pip install matplotlib==3.3
pip install pyinstaller
pyinstaller labelme.spec
dist/labelme --version
Troubleshooting Ideas
In case you run into issues while installing or using Labelme, here are a few troubleshooting tips:
- Ensure that your Python version is compatible with the Labelme version you’re trying to install.
- Check if all required packages like PyQt and Conda are installed correctly.
- If the GUI does not launch, make sure your graphic drivers are updated.
- Refer to the community forum for additional support.
- For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
Conclusion
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.