Labelme is a graphical image annotation tool, It is written in Python and uses Qt for its graphical interface

Overview


labelme

Image Polygonal Annotation with Python


Description

Labelme is a graphical image annotation tool inspired by http://labelme.csail.mit.edu.
It is written in Python and uses Qt for its graphical interface.


VOC dataset example of instance segmentation.


Other examples (semantic segmentation, bbox detection, and classification).


Various primitives (polygon, rectangle, circle, line, and point).

Features

Requirements

Installation

There are options:

Anaconda

You need install Anaconda, then run below:

# python2
conda create --name=labelme python=2.7
source activate labelme
# conda install -c conda-forge pyside2
conda install pyqt
pip install labelme
# if you'd like to use the latest version. run below:
# pip install git+https://github.com/wkentaro/labelme.git

# python3
conda create --name=labelme python=3.6
source activate labelme
# conda install -c conda-forge pyside2
# conda install pyqt
# pip install pyqt5  # pyqt5 can be installed via pip on python3
pip install labelme
# or you can install everything by conda command
# conda install labelme -c conda-forge

Docker

You need install docker, then run below:

# on macOS
socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\" &
docker run -it -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=docker.for.mac.host.internal:0 -v $(pwd):/root/workdir wkentaro/labelme

# on Linux
xhost +
docker run -it -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=:0 -v $(pwd):/root/workdir wkentaro/labelme

Ubuntu

# Ubuntu 14.04 / Ubuntu 16.04
# Python2
# sudo apt-get install python-qt4  # PyQt4
sudo apt-get install python-pyqt5  # PyQt5
sudo pip install labelme
# Python3
sudo apt-get install python3-pyqt5  # PyQt5
sudo pip3 install labelme

# or install standalone executable from:
# https://github.com/wkentaro/labelme/releases

Ubuntu 19.10+ / Debian (sid)

sudo apt-get install labelme

macOS

brew install pyqt  # maybe pyqt5
pip install labelme  # both python2/3 should work

brew install wkentaro/labelme/labelme  # command line interface
# brew install --cask wkentaro/labelme/labelme  # app

# or install standalone executable/app from:
# https://github.com/wkentaro/labelme/releases

Windows

Install Anaconda, then in an Anaconda Prompt run:

# python3
conda create --name=labelme python=3.6
conda activate labelme
pip install labelme

Usage

Run labelme --help for detail.
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 the save
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 with a file

For more advanced usage, please refer to the examples:

Command Line Arguments

  • --output specifies the location that annotations will be written to. If the location ends with .json, a single annotation will be written to this file. Only one image can be annotated if a location is specified with .json. If the location does not end with .json, the program will assume it is a directory. Annotations will be stored in this directory with a name that corresponds to the image that the annotation was made on.
  • The first time you run labelme, it will create a config file in ~/.labelmerc. You can edit this file and the changes will be applied the next time that you launch labelme. If you would prefer to use a config file from another location, you can specify this file with the --config flag.
  • Without the --nosortlabels flag, the program will list labels in alphabetical order. When the program is run with this flag, it will display labels in the order that they are provided.
  • Flags are assigned to an entire image. Example
  • Labels are assigned to a single polygon. Example

FAQ

Testing

pip install hacking pytest pytest-qt
flake8 .
pytest -v tests

Developing

git clone https://github.com/wkentaro/labelme.git
cd labelme

# Install anaconda3 and labelme
curl -L https://github.com/wkentaro/dotfiles/raw/main/local/bin/install_anaconda3.sh | bash -s .
source .anaconda3/bin/activate
pip install -e .

How to build standalone executable

Below shows how to build the standalone executable on macOS, Linux and Windows.

# Setup conda
conda create --name labelme python==3.6.0
conda activate labelme

# Build the standalone executable
pip install .
pip install pyinstaller
pyinstaller labelme.spec
dist/labelme --version

How to contribute

Make sure below test passes on your environment.
See .github/workflows/ci.yml for more detail.

pip install black hacking pytest pytest-qt

flake8 .
black --line-length 79 --check labelme/
MPLBACKEND='agg' pytest tests/ -m 'not gpu'

Acknowledgement

This repo is the fork of mpitid/pylabelme.

Comments
  • An error occurred while aiming at the boundary

    An error occurred while aiming at the boundary

    Traceback (most recent call last): File "D:\ProgramData\Anaconda3\lib\site-packages\labelme-3.14.1-py3.6.egg\labelme\widgets\canvas.py", line 216, in mouseMoveEvent self.boundedMoveVertex(pos) File "D:\ProgramData\Anaconda3\lib\site-packages\labelme-3.14.1-py3.6.egg\labelme\widgets\canvas.py", line 415, in boundedMoveVertex pos = self.intersectionPoint(point, pos) File "D:\ProgramData\Anaconda3\lib\site-packages\labelme-3.14.1-py3.6.egg\labelme\widgets\canvas.py", line 560, in intersectionPoint d, i, (x, y) = min(self.intersectingEdges((x1, y1), (x2, y2), points)) ValueError: min() arg is an empty sequence

    opened by dawin2015 43
  • [BUG] labelme does not read jpg images

    [BUG] labelme does not read jpg images

    Describe the bug In version 4.2.9, it still reads the jpg images. But after I upgraded to >=4.3, it stops reading the jpg images. You can see clearly this issue by trying to open an image and in the list of image types, you won't find the jpg in there.

    To Reproduce Steps to reproduce the behavior:

    1. Install labelme 4.3 using pip install labelme==4.3 or any latest version
    2. Try to open the image with Open button.
    3. You will find out that you won't see jpg images.

    Expected behavior The jpg images must be seen.

    Screenshots This is an example of version 4.2.9 (which have jpg type in the list) image

    This is version 4.5.1 (does not have jpg in the list) image

    Desktop (please complete the following information):

    • OS: Windows 10
    • Labelme Version > 4.3

    Additional context Maybe this is an intended feature because it cannot be a mistake that some guys decided to remove jpg and other extensions from the list. But then why do this? It causes a backward compatibility issue.

    opened by off99555 23
  • I cannot set the file as .jpg

    I cannot set the file as .jpg

    labelme_json_to_dataset An_Zhong_Left_1.json -o An_Zhong_Left_1_json lvelvelve:~ beauty$ labelme_json_to_dataset An_Zhong_Left_1.json -o An_Zhong_Left_1_json /Users/beauty/anaconda3/lib/python3.7/site-packages/labelme/cli/json_to_dataset.py:15: UserWarning: This script is aimed to demonstrate how to convert the JSON file to a single image dataset, and not to handle multiple JSON files to generate a real-use dataset. warnings.warn("This script is aimed to demonstrate how to convert the\n" Traceback (most recent call last): File "/Users/beauty/anaconda3/bin/labelme_json_to_dataset", line 11, in sys.exit(main()) File "/Users/beauty/anaconda3/lib/python3.7/site-packages/labelme/cli/json_to_dataset.py", line 34, in main data = json.load(open(json_file)) FileNotFoundError: [Errno 2] No such file or directory: 'An_Zhong_Left_1.json'

    my mistakes are above , what should I do?

    opened by Ashlyn0628 20
  • Easy way to change color of a label [Feature]

    Easy way to change color of a label [Feature]

    Is your feature request related to a problem? Please describe. To the best of my knowledge, the graphical user interface does not provide an easy way to change the color of a label.

    Describe the solution you'd like My suggestion is to have a context menu that opens up if the user clicks on a label in the 'Label List' on the right. The context menu could have an entry that is called 'change color'. This opens up a color selection dialog or at least lets you enter the RGB or HEX code of a color.

    Describe alternatives you've considered An alternative option could be to add an entry in the context menu that opens up if you right click on a polygon (or circle, or rectangle) and provide the color change option in there.

    Additional context labelme-screeny

    opened by beyse 17
  • Zooming fix

    Zooming fix

    3 main changes:

    1. Fixes scroll wheel zooming in my Ubuntu setup.
    2. Zoom shortcut adjusted to be more similar to browsers: Ctrl+0 to zoom to 100%, Ctrl+= to zoom in, Ctrl+- to zoom out.
    3. Zoom into the cursor location instead of towards (0,0).

    Regarding the Ubuntu setup: pixelDelta() is always 0 in my case, this is mentioned in the Qt documentation as a X11 specific issue: https://doc.qt.io/qt-5/qwheelevent.html#pixelDelta. I now changed it to angleDelta() instead, which based on the documentation I would expect to work on all platforms. However I don't have a Mac to test it.

    opened by mbuijs 16
  • Question about group ID

    Question about group ID

    I'm labeling for a instances segmentation project. The number of my class is one. And the class is cow. I notice that there is a new option group ID. I know I need to fill the object label with cow-1, cow-2... But the group ID of them should be the same or not?

    opened by Coconut443 15
  • Display polygon labels in the image itself.

    Display polygon labels in the image itself.

    Right now to know the label assigned to a polygon we have to check by de-selecting that particular instance of the label. This is a trail and error method and takes considerable amount of to recheck which label a particular polygon has been assigned. Is there a way to display label names around each polygon?

    opened by krishvishal 15
  • an error caused by non-latin label

    an error caused by non-latin label

    hi, I try to use the labelme tool to annotate the ocr dataset, and someone annotated some Chinese to the label in his computer, I use the json files and open the labelme tool, the error encountered like the following pic. How to fix this error, please help me, thanks.

    1556279866317

    the json file looks like this:

    1556279943371

    opened by passion3394 14
  • decode image string embedded in json

    decode image string embedded in json

    labelme saves everything (image and labels/polygons) in json files. I am trying to decode the image string that is stored along with the polygon-points in the json files in python, so I can convert both to a numpy-array and use the points to draw a binary mask (some models like mask rcnn don't use json, but require numpy-arrays for training).

    What type of encoding is used to store the image in the json files? (under "imageData")

    opened by mluerig 14
  • Aborted (core dumped)

    Aborted (core dumped)

    @latticetower @wkentaro

    when running labelme the following error pops up

    image following this stack I installed open-cv by pip3 install opencv-python==4.1.2.30 but it didnt fix the problem either.

    bug 
    opened by mfaramarzi 13
  • How to label a single category with labelme?

    How to label a single category with labelme?

    How to label a single category with labelme? After looking at the user-defined data set, there is no annotation naming method. For example, there is only one category in a graph: cat, cat, cat or cat1, cat2, Cat3 or cat-0, cat-1, cat-2, https://github.com/dbolya/yolact/issues/141

    opened by seawater668 12
  • Application shutdowns when sliding shapes out of bixmap

    Application shutdowns when sliding shapes out of bixmap

    When sliding the shape out of bixmap, the application stops and complains that the parameters of QtCore.QPoint methods need to be int instead of float.

    pos += QtCore.QPoint( TypeError: arguments did not match any overloaded call: QPoint(): too many arguments QPoint(int, int): argument 1 has unexpected type 'float' QPoint(QPoint): argument 1 has unexpected type 'float'

    opened by mhannani 0
  • This application failed to start because no Qt platform plugin could be initialized

    This application failed to start because no Qt platform plugin could be initialized

    Provide environment information

    qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/pidl/.local/lib/python3.9/site-packages/cv2/qt/plugins" even though it was found. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

    Available platform plugins are: xcb, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl.

    What OS are you using?

    Ubuntu 20.04

    Describe the Bug

    When I run labelme Folder. The bug happens

    Expected Behavior

    No response

    To Reproduce

    No response

    bug 
    opened by haithienld 2
  • Support High DPI Displays

    Support High DPI Displays

    Add new feature that supporting high DPI displays.

    When I switch position of labelme window from 4K display to FHD one and vice versa, scale of labels on 'Polygon Labels' does not match OS setting. So I add this feature, and it looks well.

    opened by pelennor 0
  • Mark lines for training but get areas

    Mark lines for training but get areas

    Provide environment information

    Python 3.7.13 labelme 5.0.0

    What OS are you using?

    Ubuntu 20.04.4

    Describe the Bug

    I use labelme to label linestrip SogouScreenshot_select-area_20221112102938 and use labelme2coco.py to get the coco data set of linestrip. SogouScreenshot_select-area_20221112103127

    But when I use this coco data for training, the predicted result is red region instead of linestrip. SogouScreenshot_select-area_20221112122202

    Why is that?

    Expected Behavior

    No response

    To Reproduce

    No response

    bug 
    opened by 1215232494 3
  • labelme2coco.py crash when just contines __ignore__ label

    labelme2coco.py crash when just contines __ignore__ label

    Provide environment information

    (DET2) D:\FPCs>python --version Python 3.9.13

    (DET2) D:\FPCs>pip list labelme Package Version Editable project location


    labelme 5.0.5

    What OS are you using?

    windows11

    Describe the Bug

    (DET2) D:\FPCs>python D:/DeepLearning/labelme/examples/instance_segmentation/labelme2coco.py --labels classes.txt 000003 labels Creating dataset: labels Generating dataset from: 000003\dog.json Traceback (most recent call last): File "D:\DeepLearning\labelme\examples\instance_segmentation\labelme2coco.py", line 209, in main() File "D:\DeepLearning\labelme\examples\instance_segmentation\labelme2coco.py", line 184, in main labels, captions, masks = zip( ValueError: not enough values to unpack (expected 3, got 0)

    Expected Behavior

    Skip the label file

    To Reproduce

    1. Just set ignore label of an image
    2. Create classes.txt file
    3. run labelme2coco.py
    bug 
    opened by withkun 1
Releases(v5.1.1)
Owner
Kentaro Wada
I'm a final-year PhD student at Imperial College London working on computer vision and robotics.
Kentaro Wada
Graphical tool to make photo collage posters

PhotoCollage Graphical tool to make photo collage posters PhotoCollage allows you to create photo collage posters. It assembles the input photographs

Adrien Vergé 350 Jan 2, 2023
Raven is a tool written in Python3 allowing you to generate an unique image with some text.

?? Raven is a tool written in Python3 allowing you to generate an unique image with some text. It does it by searching the text on Google, do

Billy 39 Dec 20, 2022
TRREASURE_IMAGE is python lib by which you can hide anything in a .jpg image with Command-Line Interface[cli] feature

TRREASURE_IMAGE TRREASURE_IMAGE is a python third-party library with Command-Line Interface[cli] feature. Table of Contents General Info Python librar

Fatin Shadab 3 Jun 7, 2022
Nanosensor Image Processor (NanoImgPro), a python-based image analysis tool for dopamine nanosensors

NanoImgPro Nanosensor Image Processor (NanoImgPro), a python-based image analysis tool for dopamine nanosensors NanoImgPro.py contains the main class

null 1 Mar 2, 2022
Seaborn-image is a Python image visualization library based on matplotlib and provides a high-level API to draw attractive and informative images quickly and effectively.

seaborn-image: image data visualization Description Seaborn-image is a Python image visualization library based on matplotlib and provides a high-leve

null 48 Jan 5, 2023
Image Reading, Metadata Conversion, and Image Writing for Microscopy Images in Python

AICSImageIO Image Reading, Metadata Conversion, and Image Writing for Microscopy Images in Pure Python Features Supports reading metadata and imaging

Allen Institute for Cell Science - Modeling 137 Dec 14, 2022
GTK and Python based, simple multiple image editor tool

System Monitoring Center GTK3 and Python3 based, simple multiple image editor tool. Note: Development of this application is not completed yet. The ap

Hakan Dündar 1 Feb 2, 2022
A drop-in replacement for django's ImageField that provides a flexible, intuitive and easily-extensible interface for quickly creating new images from the one assigned to the field.

django-versatileimagefield A drop-in replacement for django's ImageField that provides a flexible, intuitive and easily-extensible interface for creat

Jonathan Ellenberger 490 Dec 13, 2022
A pure python implementation of the GIMP XCF image format. Use this to interact with GIMP image formats

Pure Python implementation of the GIMP image formats (.xcf projects as well as brushes, patterns, etc)

FHPyhtonUtils 8 Dec 30, 2022
Image-Viewer is a Windows image viewer based on Python 3.

Image-Viewer Hi! Image-Viewer is a Windows image viewer based on Python 3. Using You must download Image-Viewer.exe from the root of the repository. T

null 2 Apr 18, 2022
A Python Script to convert Normal PNG Image to Apple iDOT PNG Image.

idot-png-encoder A Python Script to convert Normal PNG Image to Apple iDOT PNG Image (Multi-threaded Decoding PNG). Usage idotpngencoder.py -i <inputf

Lrdcq 2 Feb 17, 2022
Anaglyph 3D Converter - A python script that adds a 3D anaglyph style effect to an image using the Pillow image processing package.

Anaglyph 3D Converter - A python script that adds a 3D anaglyph style effect to an image using the Pillow image processing package.

Kizdude 2 Jan 22, 2022
Pyconvert is a python script that you can use to convert image files to another image format! (eg. PNG to ICO)

Pyconvert is a python script that you can use to convert image files to another image format! (eg. PNG to ICO)

null 1 Jan 16, 2022
Simple Python package to convert an image into a quantized image using a customizable palette

Simple Python package to convert an image into a quantized image using a customizable palette. Resulting image can be displayed by ePaper displays such as Waveshare displays.

Luis Obis 3 Apr 13, 2022
OctoPrint is the snappy web interface for your 3D printer!

OctoPrint OctoPrint provides a snappy web interface for controlling consumer 3D printers. It is Free Software and released under the GNU Affero Genera

OctoPrint 7.1k Jan 3, 2023
Easily turn large sets of image urls to an image dataset. Can download, resize and package 100M urls in 20h on one machine.

img2dataset Easily turn large sets of image urls to an image dataset. Can download, resize and package 100M urls in 20h on one machine. Also supports

Romain Beaumont 1.4k Jan 1, 2023
Goddard Image Analysis and Navigation Tool

Copyright 2021 United States Government as represented by the Administrator of the National Aeronautics and Space Administration. No copyright is clai

NASA 12 Dec 23, 2022
An open source image editor which can manipulate an image in many ways!

Image Editor - An open source image editor which can manipulate an image in many ways! If you need any more modes in repo or I

TroJanzHEX 44 Nov 17, 2022
Image enhancing model for making a blurred image to be somehow clearer than before

This is a very small prject which helps in enhancing the images by taking a Input images. This project has many features like detcting the faces and enhaning the faces itself and also a feature which enhances the whole image

null 3 Dec 3, 2021