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
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)

1 Jan 16, 2022
HTML2Image is a lightweight Python package that acts as a wrapper around the headless mode of existing web browsers to generate images from URLs and from HTML+CSS strings or files.

A package acting as a wrapper around the headless mode of existing web browsers to generate images from URLs and from HTML+CSS strings or files.

176 Jan 01, 2023
Gallery written in Python to manage your photos

GalleryMan Gallery written in Python to manage your photos Installation

Asian Cat 24 Dec 18, 2022
missing-pixel-filler is a python package that, given images that may contain missing data regions (like satellite imagery with swath gaps), returns these images with the regions filled.

Missing Pixel Filler This is the official code repository for the Missing Pixel Filler by SpaceML. missing-pixel-filler is a python package that, give

SpaceML 11 Jul 19, 2022
Plots is a graph plotting app for GNOME.

Plots is a graph plotting app for GNOME. Plots makes it easy to visualise mathematical formulae. In addition to basic arithmetic operations, it supports trigonometric, hyperbolic, exponential and log

Alex Huntley 138 Dec 14, 2022
Water marker for images.

watermarker linux users: To fix this error,please add truetype font path File "watermark.py", line 58, in module font = ImageFont.truetype("Dro

13 Oct 27, 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
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 01, 2023
SimpleITK is an image analysis toolkit with a large number of components supporting general filtering operations, image segmentation and registration

SimpleITK is an image analysis toolkit with a large number of components supporting general filtering operations, image segmentation and registration

672 Jan 05, 2023
ProsePainter combines direct digital painting with real-time guided machine-learning based image optimization.

ProsePainter Create images by painting with words. ProsePainter combines direct digital painting with real-time guided machine-learning based image op

Morphogen 276 Dec 17, 2022
NFT collection generator. Generates layered images

NFT collection generator Generates layered images, whole collections. Provides additional functionality. Repository includes three scripts generate.py

Gleb Gonchar 10 Nov 15, 2022
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
QR-code Generator with a basic GUI.

Qr_generator_python Qr code generator with a basic GUI. ❔ About the QR-Code-Generator This project Generates QR codes to sites, e-mails and plain text

Tecixck 2 Oct 11, 2021
QR Code Generator

In this project, we'll be using some libraries to instantly generate authentic QR Codes and export them in various formats

Hassan Shahzad 3 Jun 02, 2022
QR fixer part is standalone but for image to FQR conversion

f-qr-fixer QR fixer part is standalone but for image to FQR conversion it requires Pillow (can be installed with easy_install), qrtools (on ubuntu the

2 Nov 22, 2022
Pure Python bindings for the pure C++11/OpenCL Qrack quantum computer simulator library

pyqrack Pure Python bindings for the pure C++11/OpenCL Qrack quantum computer simulator library (PyQrack is just pure Qrack.) IMPORTANT: You must buil

vm6502q 6 Jul 21, 2022
A simple programme for converting url into a qr code (.png file)

QrTk A simple lightweight programme for converting url into a qr code (.png file) Pre-Requisites Before installing the programme , you need to run the

Juss Patel 4 Nov 08, 2021
Image generation API.

Image Generator API This is an api im working on Currently its just a test project Im trying to make custom readme images with your discord account pr

Siddhesh Zantye 2 Feb 19, 2022
An add to make adding screenshots and copied images to the scene easy

Blender Clipboard to Scene It doesn't work with version 2.93 and higher (I tested it on 2.91 and 2.83) There is an issue with importing the Pillow mod

Mohammad Mehdi Afkhami 3 Dec 29, 2021