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
An python script to convert images to upscaled versions made out of one-colour emojis.

ABOUT This is an python script to convert png, jpg and gif(output isnt animated :( ) images to scaled versions made out of one-colour emojis. Please n

0 Oct 19, 2022
A python script for extracting/removing exif data from images by @AbirHasan2005

Image-Exif A Python script for extracting exif metadata from images. How to use? Using this script you can extract exif data from image and save in .c

Abir Hasan 13 Dec 16, 2022
Conversion of Image, video, text into ASCII format

asciju Python package that converts image to ascii Free software: MIT license

Aju Tamang 11 Aug 22, 2022
Python Digital Art Generator

Python Digital Art Generator The main goal of this repository is to generate all possible layers permutations given by the user in order to get unique

David Cuentas Mar 3 Mar 12, 2022
Nudity detection with Python

nude.py About Nudity detection with Python. Port of nude.js to Python. Installation from pip: $ pip install --upgrade nudepy from easy_install: $ eas

Hideo Hattori 881 Jan 06, 2023
An API that renders HTML/CSS content to PNG using Chromium

html_png An API that renders HTML/CSS content to PNG using Chromium Disclaimer I am not responsible if you happen to make your own instance of this AP

10 Aug 08, 2022
Create a static HTML/CSS image gallery from a bunch of images.

gallerize Create a static HTML/CSS image gallery from a bunch of images.

Jochen Kupperschmidt 19 Aug 21, 2022
This is the official source code of FreeCAD, a free and opensource multiplatform 3D parametric modeler.

Freedom to build what you want FreeCAD is an open-source parametric 3D modeler made primarily to design real-life objects of any size. Parametric modeling allows you to easily modify your design by g

FreeCAD 12.9k Jan 07, 2023
Make your master artistic punk avatar through machine learning world famous paintings

Master-art-punk Make your master artistic punk avatar through machine learning world famous paintings. 通过机器学习世界名画制作属于你的大师级艺术朋克头像 Nowadays, NFT is beco

蒋虎成 23 Jan 04, 2022
A tool for hiding data inside of images

Stegenography-tool a tool for hiding data inside of images Quick test: do python steg-encode.py test/message.txt test/covid19.png to generate the test

luke 2 Nov 02, 2021
Sample data for the napari image viewer.

napari-demo-data Sample data for the napari image viewer. This napari plugin was generated with Cookiecutter using @napari's cookiecutter-napari-plugi

Genevieve Buckley 1 Nov 08, 2021
Png-to-stl - Converts PNG and text to SVG, and then extrudes that based on parameters

have ansible installed locally run ansible-playbook setup_application.yml this sets up directories, installs system packages, and sets up python envir

1 Jan 03, 2022
Leshycam - Generate Inscryption styled portrait sprites from any image

Leshy's Camera Generate Inscryption styled portrait sprites from any image. Setu

3 Sep 27, 2022
A Icon Maker GUI Made - Convert your image into icon ( .ico format ).

Icon-Maker-GUI A Icon Maker GUI Made Using Python 3.9.0 . It will take any image and convert it to ICO file, for web site favicon or Windows applicati

Insanecodes 12 Dec 15, 2021
Photini - A free, easy to use, digital photograph metadata (Exif, IPTC, XMP) editing application for Linux, Windows and MacOS.

A free, easy to use, digital photograph metadata (Exif, IPTC, XMP) editing application for Linux, Windows and MacOS. "Metadata" is said to mea

Jim Easterbrook 120 Dec 20, 2022
An API which would colorize a black and white image

Image Colorization API Machine Learning Model used- https://github.com/richzhang/colorization/tree/caffe Paper - https://arxiv.org/abs/1603.08511 Step

Neelesh Ranjan Jha 4 Nov 23, 2021
Napari simpleitk image processing

napari-simpleitk-image-processing (n-SimpleITK) Process images using SimpleITK in napari Usage Filters of this napari plugin can be found in the Tools

Robert Haase 11 Dec 19, 2022
Javascript image annotation tool based on image segmentation.

JS Segment Annotator Javascript image annotation tool based on image segmentation. Label image regions with mouse. Written in vanilla Javascript, with

Kota Yamaguchi 513 Nov 15, 2022
LSB Image Steganography Using Python

Steganography is the science that involves communicating secret data in an appropriate multimedia carrier, e.g., image, audio, and video files

Mahmut Can Gönül 2 Nov 04, 2021
Kimimaro: Skeletonize Densely Labeled Images

Kimimaro: Skeletonize Densely Labeled Images # Produce SWC files from volumetric images. kimimaro forge labels.npy --progress # writes to ./kimimaro_o

92 Dec 17, 2022