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
Forza painter app with python

forza-painter Discord: A-Dawg#0001 (AE) Supports: Forza Horizon 5 Offically (OTHER v1.405.2.0, MS STORE v3.414.967.0, STEAM v1.414.967.0) Unofficially

320 Dec 31, 2022
Image2scan - a python program that can be applied on an image in order to get a scan of it back

image2scan Purpose image2scan is a python program that can be applied on an image in order to get a scan of it back. For this purpose, it searches for

Kushal Shingote 2 Feb 13, 2022
Django helper application to easily and non-destructively crop arbitrarily large images in admin and frontend.

django-image-cropping django-image-cropping is an app for cropping uploaded images via Django's admin backend using Jcrop. Screenshot: django-image-cr

Jonas und der Wolf GmbH 546 Jan 03, 2023
Snowfall - helpful image handling utils - abstracts various file and opencv and pil features into result oriented functions

snowfall helpful image handling utils - abstracts various file and opencv and pil features into result oriented functions usage examples: from image_h

Less Wright 2 Jan 09, 2022
Python scripts for semi-automated morphometric analysis of atolls from Landsat satellite Imagery.

AtollGeoMorph Python scripts for semi-automated morphometric analysis of atolls from Landsat satellite Imagery. The python scripts included allow user

1 Dec 16, 2022
Command line utility for converting images to seamless tiles

img2texture Command line utility for converting images to seamless tiles. The resulting tiles can be used as textures in games, compositing and 3D mod

Artёm IG 24 Dec 26, 2022
Program for analyzing shadows from Cassini images

Moons: An Analysis Module for Vicar Files General This packages/program was created for my bachelor's thesis for the Astronomy department at Universit

Joni 1 Jul 16, 2021
Convert a DOS Punk image to text

DOS Punk Text Inspired by MAX CAPACITY's DOS Punks & the amazing DOS Punk community. DOS Punk Text is a Python 3 script that renders a DOS Punk image

4 Jan 13, 2022
A simple programming language for manipulating images.

f-stop A simple programming language for manipulating images. Examples OPEN "image.png" AS image RESIZE image (300, 300) SAVE image "out.jpg" CLOSE im

F-Stop 6 Oct 27, 2022
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
Generates images of calendar month tables and can paste them onto suitable photos.

📆 calendizer README Generates images of calendar month tables and can paste them onto suitable photos. A quick way to make your own calendar for prin

Sean Ryan 2 Dec 14, 2022
Simple program to easily view Euler parameters in 3D.

Simple program to easily view Euler parameters in 3D.

5 Aug 20, 2021
Python Image Morpher (PIM) is a program that can take two images and blend them to whatever extent or precision that you like

Python Image Morpher (PIM) is a program that can take two images and blend them to whatever extent or precision that you like! It is designed to emulate some of Python's OpenCV image processing from

David Dowd 108 Dec 19, 2022
pix2tex: Using a ViT to convert images of equations into LaTeX code.

The goal of this project is to create a learning based system that takes an image of a math formula and returns corresponding LaTeX code.

Lukas Blecher 2.6k Dec 30, 2022
Kainat 13 Mar 07, 2022
Craft PNG files that appear completely different in Apple software

Ambiguous PNG Packer Craft PNG files that appear completely different in Apple software

David Buchanan 1k Dec 29, 2022
利用近邻法的弱点实现图片缩小后变成另一张图

这是我一个视频的配套代码。 视频是:利用近邻法的弱点实现图片缩小后变成另一张图 https://www.bilibili.com/video/BV1Lf4y1r7dZ 配套代码中,仅generate.py是核心文件,其余的图片神马的,都是赠品。 这个核心文件利用了近邻法缩放的弱点,可以将图a的像素按

偶尔有点小迷糊 182 Dec 19, 2022
This Github Action automatically creates a GIF from a given web page to display on your project README

This Github Action automatically creates a GIF from a given web page to display on your project README

Pablo Lecolinet 28 Dec 15, 2022
Simple utility to tinker with OPlus images

OPlus image utilities Prerequisites Linux running kernel 5.4 or up (check with uname -r) Image rebuilding Used to rebuild read-only erofs images into

Wiley Lau 15 Dec 28, 2022
Next-generation of the non-destructive, node-based 2D image graphics editor

Non-destructive, node-based 2D image graphics editor written in Python, focused on simplicity, speed, elegance, and usability

Gimel Studio 238 Dec 30, 2022