LabelMe annotation tool source code

Overview

LabelMe annotation tool source code

Here you will find the source code to install the LabelMe annotation tool on your server. LabelMe is an annotation tool writen in Javascript for online image labeling. The advantage with respect to traditional image annotation tools is that you can access the tool from anywhere and people can help you to annotate your images without having to install or copy a large dataset onto their computers.

CITATION:

B. C. Russell, A. Torralba, K. P. Murphy, W. T. Freeman. LabelMe: a Database and Web-based Tool for Image Annotation. International Journal of Computer Vision, 77(1-3):157-173, 2008. Project page

DOWNLOAD:

You can download a zip file of the source code directly.

Alternatively, you can clone it from GitHub as follows:

$ git clone https://github.com/CSAILVision/LabelMeAnnotationTool.git

CONTENTS:

  • Images - This is where your images go.
  • Annotations - This is where the annotations are collected.
  • Masks - This is where the segmentation masks are collected (scribble mode).
  • Scribbles - This is where the scribbles are collected (scribble mode).
  • tool.html - Main web page for LabelMe annotation tool.
  • annotationTools - Directory with source code.
  • annotationCache - Location of temporary files.
  • Icons - Icons used on web page.
  • DockerFiles - Directory with Docker files for installation via Docker.

QUICK START INSTRUCTIONS:

  1. Put LabelMe annotation tool code on web server (see web server configuration requirements below).

  2. On the command line run:

    $ make

    This will set a global variable that the perl scripts need. Note If you move the location of the code, then you need to re-run "make" to refresh the global variable.

  3. Create a subfolder inside the "Images" folder and place your images there. For example: "Images/example_folder/img1.jpg". Make sure all of your images have a ".jpg" extension and the folders/filenames have alphanumeric characters (i.e. no spaces or funny characters).

  4. Point your web browser to the following URL:

    http://www.yourserver.edu/path/to/LabelMe/tool.html?collection=LabelMe&mode=f&folder=example_folder&image=img1.jpg

  5. Label your image. Press "show me another image" to go to the next image in the folder.

  6. Voila! Your annotations will appear inside of the "Annotations" folder.

WEB SERVER REQUIREMENTS:

You will need the following to set up the LabelMe tool on your web server:

  • Run an Apache server (see special configuration instructions for Ubuntu or Windows).

  • Enable authconfig in Apache so that server side includes (SSI) will work. This will allow SVG drawing capabilities. This is the most common source of errors, so make sure this step is working.

  • Allow perl/CGI scripts to run. This is the second most common source of errors.

  • Make sure the php5 and libapache2-mod-php5 libraries are installed. You can install them on Linux by running the following:

    $ sudo apt-get install php5 libapache2-mod-php5
  • (Optional) See special configuration instructions if you are installing on Ubuntu or Windows.

If you are not able to draw polygons, check to see if the page is loaded as an "application/xhtml+xml" page (you can see this in Firefox by navigating to Tools->Page Info). If it is not, be sure that SSI are enabled (see above for enabling authconfig in Apache).

Make sure that your images have read permissions on your web server and folders in the "Annotations" folder have write permissions. Also, "annotationCache/TmpAnnotations" needs to have write permissions.

FEATURES OF THE ANNOTATION TOOL:

  • The following are URL variables you can pass to the annotation tool:

    • mode=im - Only show the image and drawing canvas (do not show anything outside of the image.
    • mode=mt - Mechanical Turk mode.
    • mode=f - Pressing "next image" button goes to next image in the folder.
    • mode=i - Pressing "next image" button goes to random image in the default LabelMe collection.
    • mode=c - Go to next image in the collection (set via the dirlist).
    • username=johndoe - Sets username for labeling session.
    • collection=LabelMe - Uses the default LabelMe collection list. See below for setting up a new collection list.
    • folder=MyLabelMeFolder - LabelMe folder where the image lives.
    • image=image.jpg - LabelMe image to annotate.
    • objects=car,person,building - When popup bubble appears asking the user for the object name, the user selects one of these objects appearing as a drop-down list.
    • scribble=false - Turns off scribble mode.
    • objlist=visible - This controls whether the object list on the right side is visible or not. Use "objlist=hidden" to make it hidden.
    • actions=n - Control what actions the user is allowed to do. To set the desired actions, use any combination of the letters below. For example, to allow renaming, modify control points, and delete actions, then set "actions=rmd". By default, "actions=n". The following are possible actions:
      • n - create and edit new polygons
      • r - rename existing objects
      • m - modify control points on existing objects
      • d - delete existing objects
      • a - allow all actions
      • v - view polygons only (do not allow any editing)
    • viewobj=e - Control which objects the user sees. Use one of the following possible options below. By default, "viewobj=e". Note that for deleted objects, these will be shown in gray and the object name in the object list will be italicized.
      • e - view new and previously labeled objects
      • n - view new objects only
      • d - view new and deleted objects
      • a - view all objects (new, existing, deleted)

    The following are for Mechanical Turk mode:

    • mt_sandbox=true - Use Mechanical Turk sandbox mode. This mode is used for debugging on Mechanical Turk. You may want to start with this variable set to make sure everything works.
    • N=5 - The worker is required to label at least 5 polygons. Use N=inf to allow the worker to label as many as they want.
    • mt_intro=http://yourpage.com - You may customize the instructions that the worker sees. By default, the following instructions are given to the workers.
    • mt_instructions=Place your instructions here - You may customize the one-line instructions that the worker sees at the top of the labeling task. By default, the instructions are: Please label as many objects as you want in this image.
  • You can create a collection of images to label by running the following on the command line:

    $ cd ./annotationTools/sh/
    $ ./populate_dirlist.sh

    This will create a list of all images inside the "./Images" folder, and will appear inside the file "./annotationCache/DirLists/labelme.txt".

    You can then label images inside the collection using the following URL:

    http://www.yourserver.edu/path/to/LabelMe/tool.html?collection=labelme&mode=i

    You can create a collection consisting of a particular folder by running the following from the command line:

    $ cd ./annotationTools/sh/
    $ ./populate_dirlist.sh my_collection.txt example_folder

    The list will appear inside "./annotationCache/DirLists/my_collection.txt". You can then label images inside the collection using the following URL:

    http://www.yourserver.edu/path/to/LabelMe/tool.html?collection=my_collection&mode=i

  • You can change the layout of the annotation files for your collection by modifying the XML file template inside of "./annotationCache/XMLTemplates/your_collection.xml". The default template is "./annotationCache/XMLTemplates/labelme.xml".

  • A log file of the annotation tool actions are recorded in "./annotationCache/Logs/logfile.txt". Make sure that this file has write permissions.

CODE API

The following is a brief overview of the source code. Please see the Javascript code API for more details.

  • tool.html - This is the entry point for the annotation tool. The main functionality is to insert all of the javascript code and lay down the drawing canvases.

  • annotationTools/js/ - This folder contains all of the javascript code for the annotation tool functionalities. We provide the code API for the Javascript source code, which has been automatically extracted from the source code comments.

  • annotationTools/perl/ - This folder contains all of the Perl scripts used for communication with the server back-end.

  • annotationTools/css/ - This folder contains all of the CSS style definitions.

  • annotationTools/html/ - This folder contains auxillary HTML files (e.g. for Mechanical Turk instructions, etc.).


(c) 2015, MIT Computer Science and Artificial Intelligence Laboratory

Comments
  • added tested Dockerfile

    added tested Dockerfile

    Thought this was missing a Dockerfile and #17 seemed to have some interest so decided to create one. Currently using this for some quick annotations.

    from docker hub

    mkdir -p ~/Desktop/annotate/Images
    mkdir -p ~/Desktop/annotate/Annotations
    docker run -d --name annotate -p 1337:80 -v ~/Desktop/annotate/Images:/var/www/html/Images -v ~/Desktop/annotate/Annotations:/var/www/html/Annotations jungleai/annotate:latest
    

    from dockerfile You can also build your own image from this Dockerfile and do the following

    docker build -t yourorganisation/yourimagename:latest .
    mkdir -p ~/Desktop/annotate/Images
    mkdir -p ~/Desktop/annotate/Annotations
    docker run -d --name annotate -p 1337:80 -v ~/Desktop/annotate/Images:/var/www/html/Images -v ~/Desktop/annotate/Annotations:/var/www/html/Annotations yourorganisation/yourimagename:latest
    

    In either case use local folders as you like but running works with attaching host folders the container. In this way if you were to follow the example above and place a folder called logos in ~/Desktop/annotate/Images and you dump .jpg files in that folder. Then when running the container navigate to http://localhost:1337/tool.html?mode=f&folder=logos to start annotating. You will find the xml's in ~/Desktop/annotate/Annotations/logos.

    opened by timkock 19
  • Click Next Image but URL remains the same

    Click Next Image but URL remains the same

    I am running LabelMeAnnotationTool on Ubuntu 14.04 with Apache 2.4. Everything seems perfect except when I finish annotating one image and click the ''Next Image''. The web page updates and the next image shows up correctly. However, it seems that the url remains the same. For example, I have a starting url pointing to 1.jpg (http://mywebsite.com/tool.html?collection=LabelMe&mode=f&folder=example_images&image=1.jpg). After I click next image, the second image shows up on the web page but the url indicates that it still points to 1.jpg (http://mywebsite.com/tool.html?collection=LabelMe&mode=f&folder=example_images&image=1.jpg) instead of (http://mywebsite.com/tool.html?collection=LabelMe&mode=f&folder=example_images&image=2.jpg). In this case, the annotations of different images are crammed into one file, which is difficult to process. Has anyone got any clues on this?

    opened by niuqun 11
  • Display problems in Chrome 69

    Display problems in Chrome 69

    It seems that from the Chrome 69 the images do not show well, load correctly but you can barely see a square of 1px where the image should be

    Has anyone else found this same problem? With Chrome 68 and Firefox 47 it is displayed correctly...

    Thanks in advance

    opened by atekoa 6
  • Mode C even after merging #33 doesn't seem to work as given in documentation

    Mode C even after merging #33 doesn't seem to work as given in documentation

    In reference to #33

    The documentation says: mode=c - Go to next image in the collection (set via the dirlist).

    But the code in fetch_image.cgi

    elsif($mode eq "c") {
        opendir(DIR,$LM_HOME . "Images/$collection") || die("Cannot read collections");
        my @all_images = readdir(DIR);
        closedir(DIR);
    
        my $c = 0;
        foreach my $i (@all_images) {
    	if($i eq $image) {
    	    goto next_section;
    	}
    	$c = $c+1;
        }
      next_section:
        if($c == scalar(@all_images)-1) {
    	$c = 1;
        }
        $im_file = $all_images[$c+1];
        $im_dir = $folder;
    

    Doesn't seem to read the foo.txt file which is created using populate_dirlist.sh

    From my guess the code for mode = "c" should be similar to code for mode = "i" with the random part removed.

    So, I think the code for mode = "c" should loook something like this:

    if($mode eq "c") {
        my $fname = $LM_HOME . "annotationCache/DirLists/$collection.txt";
        
        if(!open(FP,$fname)) {
    	print "Status: 404\n\n";
    	return;
        }
        
        open(NUMLINES,"wc -l $fname |");
        my $numlines = <NUMLINES>;
        ($numlines,my $bar) = split(" DirLists",$numlines);
        close(NUMLINES);
        
        my $line = int(rand($numlines))+1; # this should be in series and not a random integer. 
        
        for(my $i=1; $i < $line; $i++) {
    	my $garbage = readline(FP);
        }
        
        my $fileinfo = readline(FP);
        ($im_dir,$im_file) = split(",",$fileinfo);
        $im_file =~ tr/"\n"//d; # remove trailing newline
        
        close(FP);
    

    @brianabrams could you please look at this? Basically what I feel is, It should read the foo.txt file created by populate_dirlist.sh and display the images in order given in the text file

    opened by Abhijit-2592 5
  • Online version no new collection?

    Online version no new collection?

    Hello, I have accessed the web online version but I don't see the option to create a new collection and add new images? any workaround this? pls advise thanks

    opened by MoWizsubhi84 4
  • Web based Tool, New collection isn't showing.

    Web based Tool, New collection isn't showing.

    Hi, Few days back I signed up on http://labelme2.csail.mit.edu and created a new collection, uploaded images and labelled them. It well smoothly. Today I wanted to do the same, but when I created a new collection I saw the message "New collection created" but the collection didn't show up. I tried with another account and got same thing. Any idea about this?

    opened by salman-ghauri 3
  • Can't run dirlist

    Can't run dirlist

    I run

    (general) root@ubuntu-1:/var/www/html/LabelMeAnnotationTool/annotationTools/sh# ./populate_dirlist.sh

    And this is the output:

    [all my image files]
    ls: cannot access '../../VLMFrames': No such file or directory
    

    Running ./populate_dirlist.sh my_collection.txt example_folder fails similarly. What is VLMFrames supposed to be?

    opened by anchpop 3
  • Fatal: there are problems with fetch_image.cgi

    Fatal: there are problems with fetch_image.cgi

    I installed LabelMe on AWS based on the instructions given on github.

    However, whenever I am trying to call

    /tool.html?collection=LabelMe&model=f&folder=example_folder&image=img1.jpg

    I am facing this box: Fatal: there are problems with fetch_image.cgi.

    I tried other modes, but the result was the same.

    When I try to access images individually, I can do that. When I annotate, annotations field reflects the xml image of that image.

    opened by ghost 3
  • Mode

    Mode "c" doesn't seem to work as documented

    The documentation say:

    mode=c - Go to next image in the collection (set via the dirlist). But if we look at the code here, we can see that it actually tries to read the contents of a specific folder:

    elsif($mode eq "c") {
        opendir(DIR,$LM_HOME . "Images/users/$username/$collection") || die("Cannot read collections");
        my @all_images = readdir(DIR);
        closedir(DIR);
    
        my $c = 0;
        foreach my $i (@all_images) {
    	if($i eq $image) {
    	    goto next_section;
    	}
    	$c = $c+1;
        }
      next_section:
        if($c == scalar(@all_images)-1) {
    	$c = 1;
        }
        $im_file = $all_images[$c+1];
        $im_dir = $folder;
    }
    
    opened by sirotenko 3
  • Error message: Second argument must be either

    Error message: Second argument must be either "get" or "post".

    Hi all, I followed the instructions from the website and input the following commands.

    HOMEIMAGES = 'http://people.csail.mit.edu/brussell/research/LabelMe/Images'; HOMEANNOTATIONS = 'http://people.csail.mit.edu/brussell/research/LabelMe/Annotations'; D = LMdatabase(HOMEANNOTATIONS);

    But I constantly got the error messages shown below.

    ??? Error using ==> urlread at 43 Second argument must be either "get" or "post".

    Error in ==> urldir at 44 [webpage, status] = urlread(page, 'Timeout', 5);

    Error in ==> LMdatabase at 103 files = urldir(HOMEANNOTATIONS);

    Any help?

    Best, Kai

    opened by leetcodersd 3
  • Parameter `image` not updated in URL

    Parameter `image` not updated in URL

    When I press the button [Next Image], the new image is loaded but the URL is not updated in the browser address field. Which makes it difficult to track where I have stopped annotating the images, and consequence, difficult to resume next when I am back to annotation task.

    If it is difficult to update the URL, it would be at least possible to display the image file name somewhere in the UI.

    Can it be fixed?

    UPDATE It turns out, there is a way to show the image filename in web UI, by editing the source code

    // file: annotationTools/js/globals.js
    var showImgName = true;
    
    opened by nkrot 2
  • a cgi error 'Scalar found where operator expected at '

    a cgi error 'Scalar found where operator expected at '

      when deploy on windows,after requesting tool.html, i get an error "Fatal: there are problems with fetch_image.cgi", i see the error info in apache's error.log as follows:
      Scalar found where operator expected at D:/Software/Apache24/htdocs/annotationTools/perl/fetch_image.cgi line 35, near "$i $im_dir"\r: D:/Software/Apache24/htdocs/annotationTools/perl/fetch_image.cgi,.
    
      by the way ,my website location is "D:\Software\Apache24\htdocs",it don't work follow the below configation :
      Alias /LabelMe/ "C:/POSTDOC/LabelMe/"
      ScriptAlias /cgi-bin/ "C:/POSTDOC/LabelMe/" 
    
      i don't know how to change this 2 items?
    
      could anyone give me some suggestion,thank you !
    
    opened by kinglong198404 1
  • Labelme crashes when deleting some points

    Labelme crashes when deleting some points

    When annotating an image, labelme will sometimes crash if I delete a point on a polygon/linestrip/etc. It doesn't always happen but happens enough that it is noticeable.

    opened by azhangmn 0
  • Empty white screen in a browser

    Empty white screen in a browser

    After pasting the example URL that in my case is

    file:///Users/dasm/projects/LabelMeAnnotationTool/tool.html?collection=0&mode=f&folder=example_folder&image=img1.jpg

    I see the empty white screen in a browser.

    Am I missing something?

    opened by smolendawid 0
  • PROBLEM WITH RESOLUTION IMAGES 1944x27136 pixels (30596 KB)

    PROBLEM WITH RESOLUTION IMAGES 1944x27136 pixels (30596 KB)

    Hello everyone!

    We are working with research on image annotations at the university (UEFS/BR).

    In COCO Annotation, CVAT Annotation and LabelMe Annotation, we can upload and annotate images up to 1910x8815 px (20,322 KB).

    However, we are unable to load high resolution images, for example: 1944x27136 px (30,596 KB).

    Can you tell us something about it? Today, what would be the tool's resolution limit?

    We appreciate your cooperation!

    Marcos Morais Computer Science master’s degree, Information Technology post-graduate and Bachelor in Information Systems linktr.ee/marcosmoraisjr

    Teaching is the highest form of understanding. Aristotle, Greek philosopher (384 - 322 BC)

    opened by mmstec 0
  • fetch_image.cgi: Can't return outside a subroutine ...

    fetch_image.cgi: Can't return outside a subroutine ...

    I am looking at the code in https://github.com/CSAILVision/LabelMeAnnotationTool/blob/master/annotationTools/perl/fetch_image.cgi and keep seeing return statement being used outside of a function, like this

    if(!open(FP,$fname)) {
        print "Status: 404\n\n";
        return;    # <--- this one o_O
    }
    

    it repeats over an over again, e.g. at lines 24, 49, 74, etc

    Perl would throw an error in such cases Can't return outside a subroutine .... Which is expected, because return is used to return from a subroutine and there are no subroutines defined in the whole script. Indeed, you will see the error message appear in apache error log if you try with a faked URL (note collection=empty that corresponds to no file)

    tool.html?mode=c&collection=empty
    

    What am I missing? Is it just a joke?

    opened by nkrot 0
Owner
MIT CSAIL Computer Vision
MIT CSAIL Computer Vision
3D Model files and source code for rotating turntable. Raspberry Pi, DC servo and PWM modulator required.

3DSimpleTurntable 3D Model files and source code for rotating turntable. Raspberry Pi, DC servo and PWM modulator required. Preview Construction Print

Thomas Boyle 1 Feb 13, 2022
thumbor is an open-source photo thumbnail service by globo.com

Survey If you use thumbor, please take 1 minute and answer this survey? It's only 2 questions and one is multiple choice!!! thumbor is a smart imaging

Thumbor (by @globocom) 9.3k Dec 31, 2022
thumbor is an open-source photo thumbnail service by globo.com

Survey If you use thumbor, please take 1 minute and answer this survey? It's only 2 questions and one is multiple choice!!! thumbor is a smart imaging

Thumbor (by @globocom) 8.2k Feb 23, 2021
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
kikuchipy is an open-source Python library for processing and analysis of electron backscatter diffraction (EBSD) patterns

kikuchipy is an open-source Python library for processing and analysis of electron backscatter diffraction (EBSD) patterns. The library builds on the

pyxem 53 Dec 29, 2022
Fast Image Retrieval is an open source image retrieval framework

Fast Image Retrieval is an open source image retrieval framework release by Center of Image and Signal Processing Lab (CISiP Lab), Universiti Malaya. This framework implements most of the major binary hashing methods, together with both popular backbone networks and public datasets.

CISiP Lab 39 Nov 25, 2022
Fast Image Retrieval (FIRe) is an open source image retrieval project

Fast Image Retrieval (FIRe) is an open source image retrieval project release by Center of Image and Signal Processing Lab (CISiP Lab), Universiti Malaya. This project implements most of the major binary hashing methods to date, together with different popular backbone networks and public datasets.

CISiP Lab 39 Nov 25, 2022
Open source software for image correlation, distance and analysis

Douglas-Quaid Project Open source software for image correlation, distance and analysis. Strongly related to : Carl-Hauser Problem statement (@CIRCL)

Dominik Dancs 2 May 1, 2022
Gaphor is the simple modeling tool

Gaphor Gaphor is a UML and SysML modeling application written in Python. It is designed to be easy to use, while still being powerful. Gaphor implemen

Gaphor 1.3k Dec 31, 2022
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
Deep Illuminator is a data augmentation tool designed for image relighting.

Deep Illuminator Deep Illuminator is a data augmentation tool designed for image relighting. It can be used to easily and efficiently genera

George Chogovadze 52 Nov 29, 2022
Depix is a tool for recovering passwords from pixelized screenshots.

This implementation works on pixelized images that were created with a linear box filter. In this article I cover background information on pixelization and similar research.

null 23.1k Jan 4, 2023
Rembg is a tool to remove images background.

Rembg is a tool to remove images background.

Daniel Gatis 7.8k Jan 5, 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
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
This tool allows the user to convert a 16 by 16 image into a list with numbers representing an object/character.

Room Formatter This tool allows the user to convert a 16 by 16 image into a list with numbers representing an object/character. There is cur

Thomas Landstra 1 Nov 13, 2021
A tool for making simple-style text posters or wallpapers with high resolution.

PurePoster PurePoster is a fancy tool for making arbitrary-resolution, simple-style posters or wallpapers with text in center. Functionality PurePoste

Renyang Guan 4 Jul 9, 2022
ScreenTeX is a tool that grabs all text when taking a screenshot rather than getting an image.

The ScreenTeX project By: Seanpm2001 / ScreenTeX, Et; Al. Top README.md Read this article in a different language ?? List of languages Sorted by: A-Z

Sean P. Myrick V19.1.7.2 3 Oct 25, 2022