Download LabelMe Source

Here you will find the source code to install the LabelMe annotation tool on your server (if you are looking for code to interact with the images and annotations, then please download the Matlab toolbox instead). 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.

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 Windows or Ubuntu).
  • 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.
  • INSTALLATION FOR LINUX/WINDOWS

    1. Download the LabelMe annotation tool source code.

    2. (Optional) See special configuration instructions if you are installing on Windows or Ubuntu.

    3. You will need to make the following directories:

      a. Images/
      b. Annotations/
      c. TmpAnnotations/

    4. Insert the images that you wish to label in "Images". The images must be organized into subdirectories (e.g., Images/folder1/*.jpg). The corresponding subdirectories should also be created in the Annotations folder.

    5. Set the images to have read permissions on your web server and folders in the "Annotations" folder to have write permissions. Also, "TmpAnnotations" needs to have write permissions.

    6. Modify the "Makefile" variables "IMAGES_DIR", "ANNOTATIONS_DIR", and "TMP_ANNOTATIONS_DIR" to point to the above directories. Now, run "make". This will set up LabelMe.

    7. To use the tool, open in your browser: http://yourserver.edu/tool.html

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

    WINDOWS CONFIGURATION (thanks to Juan Wachs and Mathias Kolsch for these instructions)

    1. Install "Apache" for windows.

    2. Install "Active Perl".

    3. Install Cygwin.

    4. Make sure that all of the above (except LabelMe) works OK first.

    5. Change the config file of Apache (httpd.conf) by adding the following:

    # Added by Juan from line 194
    Options FollowSymLinks SymLinksIfOwnerMatch Indexes +Includes +ExecCGI
    AllowOverride AuthConfig
    AllowOverride All
    Order allow,deny
    Allow from all
    
    # Added by Juan in line 325
    Alias /LabelMe/ "C:/POSTDOC/LabelMe/"		
    
    # Added and changed by Juan (line 338)
    #ScriptAlias /cgi-bin/ "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/"
    ScriptAlias /cgi-bin/ "C:/POSTDOC/LabelMe/" 
    
    # Changed line 406
    AddHandler cgi-script .cgi .pl
    
    # Added and changed in line 417
    AddType text/html .shtml
    AddHandler server-parsed .shtml
    AddOutputFilter INCLUDES .shtml
    

    6. Add the module "mod_rewrite" to the Active Perl version.

    7. Change and add to the file "Makefile" the following:

    #IMAGES_DIR=/afs/csail/group/vision/www/data/LabelMe/Test/Images
    #ANNOTATIONS_DIR=/afs/csail/group/vision/www/data/LabelMe/Test/Annotations
    
    IMAGES_DIR=/cygdrive/c/POSTDOC/LabelMe/Images/
    ANNOTATIONS_DIR=/cygdrive/c/POSTDOC/LabelMe/Annotations/
    

    8. Run the command "make" on Cygwin, under the folder "LabelMe".

    9. Change all the "#! /usr/bin/.." by "#!c:/Perl/bin/perl.exe" in all the scripts under LabelMe.

    10. Add/change the scipt "fetch_image.cgi". See below all the file after the changes

    #!c:/Perl/bin/perl.exe
    # Get STDIN:
    
    read(STDIN,$collection,$ENV{'CONTENT_LENGTH'});
    
    $fname = "DirLists/$collection.txt";
    
    # Juan add:
    if(!open(xFP,$fname)) {
        print "Status: 404\n\n";
        return;
    }
    $numlines = 0;
    @lines = readline(xFP);
    foreach $i (@lines) {
        $numlines = $numlines + 1;
    };
    close(xFP);
    # end Juan add
    
    if(!open(FP,$fname)) {
        print "Status: 404\n\n";
        return;
    }
    
    # Juan remove:
    #open(NUMLINES,"wc -l $fname |");
    #$numlines = ;
    #($numlines,$bar) = split(" DirLists",$numlines);
    #close(NUMLINES);
    # end Juan remove
    
    $line = int(rand($numlines))+1;
    
    for($i=1; $i $im_dir$im_file";
    

    UBUNTU CONFIGURATION (thanks to Daniel Munoz for these instructions)

    1. Install "Apache" and "Perl" and configure.

    apt-get install apache2
    apt-get install libapache2-mod-perl2
    a2enmod include
    a2enmod rewrite
    

    2. Edit /etc/apache2/sites-available/default so that the following is the only <Directory> element in the file (change REPLACE_WITH_YOUR_LOCATION with the directory location of the LabelMe annotation tool code, e.g. /var/www/LabelMe-1-113):

    <Directory "REPLACE_WITH_YOUR_LOCATION">
      Options Indexes FollowSymLinks MultiViews +Includes
      AllowOverride all
      Order allow,deny
      allow from all
      AddType text/html .shtml
      AddOutputFilter INCLUDES .shtml
      DirectoryIndex index.shtml
    
    </Directory>
    

    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, pages 157-173, Volume 77, Numbers 1-3, May, 2008. PDF

    © 2005, MIT Computer Science and Artificial Intelligence Laboratory
    With contributions from Samuel Davies, Erica Cooper, Juventino Mejia, Anna Ayuso