Giter VIP home page Giter VIP logo

exemplarsvm's Introduction

Welcome to the Exemplar-SVM library, a large-scale object recognition library developed at Carnegie Mellon University while obtaining my PhD in Robotics. -- Tomasz Malisiewicz

The code is written in Matlab and is the basis of the following two projects, as well as my doctoral dissertation:

Tomasz Malisiewicz, Abhinav Gupta, Alexei A. Efros. Ensemble of Exemplar-SVMs for Object Detection and Beyond. In ICCV, 2011. PDF | Project Page

Abstract

This paper proposes a conceptually simple but surprisingly powerful method which combines the effectiveness of a discriminative object detector with the explicit correspondence offered by a nearest-neighbor approach. The method is based on training a separate linear SVM classifier for every exemplar in the training set. Each of these Exemplar-SVMs is thus defined by a single positive instance and millions of negatives. While each detector is quite specific to its exemplar, we empirically observe that an ensemble of such Exemplar-SVMs offers surprisingly good generalization. Our performance on the PASCAL VOC detection task is on par with the much more complex latent part-based model of Felzenszwalb et al., at only a modest computational cost increase. But the central benefit of our approach is that it creates an explicit association between each detection and a single training exemplar. Because most detections show good alignment to their associated exemplar, it is possible to transfer any available exemplar meta-data (segmentation, geometric structure, 3D model, etc.) directly onto the detections, which can then be used as part of overall scene understanding.


Abhinav Shrivastava, Tomasz Malisiewicz, Abhinav Gupta, Alexei A. Efros. Data-driven Visual Similarity for Cross-domain Image Matching. In SIGGRAPH ASIA, December 2011. PDF | Project Page

Abstract

The goal of this work is to find visually similar images even if they appear quite different at the raw pixel level. This task is particularly important for matching images across visual domains, such as photos taken over different seasons or lighting conditions, paintings, hand-drawn sketches, etc. We propose a surprisingly simple method that estimates the relative importance of different features in a query image based on the notion of "data-driven uniqueness". We employ standard tools from discriminative object detection in a novel way, yielding a generic approach that does not depend on a particular image representation or a specific visual domain. Our approach shows good performance on a number of difficult cross-domain visual tasks e.g., matching paintings or sketches to real photographs. The method also allows us to demonstrate novel applications such as Internet re-photography, and painting2gps.


More details and experimental evaluation can be found in my PhD thesis, available to download as a PDF.

Tomasz Malisiewicz. Exemplar-based Representations for Object Detection, Association and Beyond. PhD Dissertation, tech. report CMU-RI-TR-11-32. August, 2011. PDF


This object recognition library uses some great open-source software:


MATLAB Quick Start Guide

To get started, you need to install MATLAB and download the code from Github. This code has been tested on Mac OS X and Linux. Pre-compiled Mex files for Mac OS X and Linux are included.

Download Exemplar-SVM Library source code (MATLAB and C++) and compile it

$ cd ~/projects/
$ git clone git://github.com/quantombone/exemplarsvm.git
$ cd ~/projects/exemplarsvm
$ matlab
>> esvm_compile

Download and load pre-trained VOC2007 model(s)

$ matlab
>> addpath(genpath(pwd))
>> [models, M, test_set] = esvm_download_models('voc2007-bus');

or

$ wget http://people.csail.mit.edu/~tomasz/exemplarsvm/models/voc2007-models.tar
$ tar -xf voc2007-models.tar
$ matlab
>> load voc2007_bus.mat
>> [models, M, test_set] = esvm_download_models('voc2007-bus.mat');

You can alternatively download the pre-trained models individually from http://people.csail.mit.edu/tomasz/exemplarsvm/models/ or a tar file of all models voc2007-models.tar (NOTE: tar file is 450MB)

Demo: Example of applying models to a single image or a set of images

See the demo walk-through tutorial/esvm_demo_apply.html for a step-by-step tutorial on applying Exemplar-SVMs to images. Or you can just run the demo:

>> esvm_demo_apply;

Training an Ensemble of Exemplar-SVMs

Toy Demo: Exemplar-SVM training and testing on a set of synthetic images

See the synthetic training demo walk-through tutorial/esvm_demo_train_synthetic.html for a step-by-step tutorial on how to set-up images and bounding boxes for a training experiment. Or you can run the synthetic training demo:

>> esvm_demo_train_synthetic;

The training scripts are designed to work with the PASCAL VOC 2007 dataset, so we need to download that first.

Prerequsite: Install PASCAL VOC 2007 trainval/test sets

$ mkdir /nfs/baikal/tmalisie/pascal #Make a directory for the PASCAL VOC data
$ cd /nfs/baikal/tmalisie/pascal
$ wget http://pascallin.ecs.soton.ac.uk/challenges/VOC/voc2007/VOCtrainval_06-Nov-2007.tar
$ wget http://pascallin.ecs.soton.ac.uk/challenges/VOC/voc2007/VOCtest_06-Nov-2007.tar
$ tar xf VOCtest_06-Nov-2007.tar 
$ tar xf VOCtrainval_06-Nov-2007.tar 

You can also get the VOC 2007 dataset tar files manually, VOCtrainval_06-Nov-2007.tar and VOCtest_06-Nov-2007.tar

Demo: Training and Evaluating an Ensemble of "bus" Exemplar-SVMs quick-demo

>> data_dir = '/your/directory/to/pascal/VOCdevkit/';
>> dataset = 'VOC2007';
>> results_dir = '/your/results/directory/';
>> [models,M] = esvm_demo_train_voc_class_fast('car', data_dir, dataset, results_dir);
# All output (models, M-matrix, AP curve) has been written to results_dir

See the file tutorial/esvm_demo_train_voc_class_fast.html for a step-by-step tutorial on what esvm_demo_train_voc_class_fast.m produces

Script: Training and Evaluating an Ensemble of "bus" Exemplar-SVMs full script

>> data_dir = '/your/directory/to/pascal/VOCdevkit/';
>> dataset = 'VOC2007';
>> results_dir = '/your/results/directory/';
>> [models,M] = esvm_script_train_voc_class('bus', data_dir, dataset, results_dir);
# All output (models, M-matrix, AP curve) has been written to results_dir

Extra: How to run the Exemplar-SVM framework on a cluster

This library was meant to run on a cluster with a shared NFS/AFS file structure where all nodes can read/write data from a common data source/target. The PASCAL VOC dataset must be installed on such a shared resource and the results directory as well. The idea is that results are written as .mat files and intermediate work is protected via lock files. Lock files are temporary files (they are directories actually) which are deleted once something has finished process. This means that the entire voc training script can be replicated across a cluster, you can run the script 200x times and the training will happen in parallel.

To run ExemplarSVM on a cluster, first make sure you have a cluster, use an ssh-based launcher such as my warp_scripts github project. I have used warp_starter.sh at CMU (using WARP cluster) and sc.sh at MIT (using the continents).

Here is the command I often use at MIT to start Exemplar-SVM runs, where machine_list.sh contains computer names

$ cd ~
$ git clone [email protected]:quantombone/warp_scripts.git
$ cd ~/warp_scripts/
$ cp machine_list.sh-example machine_list.sh
$ nano machine_list.sh #now edit the file to point to your cluster CPUs
$ ./sc.sh "cd ~/projects/exemplarsvm; addpath(genpath(pwd)); esvm_script_train_voc_class('train');"

Frequently Asked Questions

  1. If you change the parameters, you will need to delete parameters files that are written to disk. You should first try the training scripts with an empty output directory before emailing me with questions!

Copyright (C) 2011 by Tomasz Malisiewicz

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

exemplarsvm's People

Contributors

quantombone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

exemplarsvm's Issues

MAXITER

MAXITER is assigned in the mining_parameters, but it seems that it is not used being used in the training process as an upper cap of iterations. I just saw that even if my upper limit was 10 for iterations, I had mat files from 25-30th iterations.

I even couldn't find a check using MAXITER in train_all_exemplars. Though an an easy fix, but am I missing something?

betas for NN need special files

NOTE: the files written do not indicate whether we are in NN mode or not
nn mode should have something appended to the end, just as '-nn-cosine or '-nn-normalizedhog'

during mining, #seen being displayed is #seen in current iteration

During mining, when we look at the console output, we see something like #seen=0001/0010 being shown. However, this is only for the current iteration, so when we walk away from the computer and take a look at the console, it is not clear what iteration we are on.

I think a better alternative is to show the TOTAL number of mined images across all iterations. I think because we have the mining_queue (which tells us what images are left) and the train_set (which shows us the total number of images), we should be able to do this easily.

How long should the computer run the voc_demo_esvm to train a classifier?

hi, I download the code, and wanna train the voc2007 classifiers for myself, such as bus, bicycle etc.
my computer is intel i5(2 cores, 4 threads), and memory is 6GB, OS is linux federal.
I have run the voc_demo_esvm for almost 10 hours, but it seems that it is still training.
So, How long do you think my computer should run for just a class, such as bus in VOC 2007 dataset?

Build memex browser

the browser will have to be mostly javascript based, since we cannot generate all of the images beforehand

remove pascal references

Some functions, such as input streams refer to pascal, but are actually pascal-free now. They should be updated.

fast detect

When there is a large number of exemplars, it is better to use chunk matching as opposed to independently-ran slides...

semantics of fg/bg sets

During mining and testing, we should make sure that fg is used for "foreground" sets and bg for "background" sets. It might be confusing for a new user if they see bg used instead of fg.

strip_model and strip_models issue..

The naming is confusing because the function is called "strip_model" but it actually strips a cell array of models.. This needs to be updated.

32-dim hog descriptor?

if we use the most recent hog descriptor code, it will be 32 numbers because there is the 'outside' image bin present.
should we go with it?

init_params missing.

init_params is missing in function signature while calling init_function in exemplar_initialize (line 90).

P.S: Is this right place to report and track bugs?

initialized NN models should not have NN in their name

initialized raw models based on fixedframe "f" framing, or goalsize "g" framing can be one of:

  • raw models (normalized HOG)
  • NN models (nnmode = 1), which uses cosine angle NN measure
  • trained to produced "-svm" models

Thus, there is no need to append NN to the name.. in fact, initialization doesn't know anything about

nms is not performed across LR flips

Since LR flips are now inside the main code execution loop and NMS is done right after localization, localizemeHOG will not do NMS across original/LR detections.

Not sure this is a problem, since the final NMS across all exemplar will take care of this.

M matrix is not giving me good results.

It seems that something is messed up during calibration and M-estimation, because the final results aren't giving me the boost I was seeing before. I changed a few things for the NIPS submission, and perhaps I introduced a bug.

draw lines in bus transfers....

for some reason the line drawing is broken in the bus transfers.. I can display them on the exemplar (left pane) just fine, but either the xform or the logic is messed up on the right hand side....!

Ports?

I've actually come across your paper before, but while searching for orange SVM on github I came across this.

Do you ever have plans to port it to something outside of matlab?

Issue with esvm_demo_apply_exemplars

Hi,

When trying to run your code, I get an error saying

"Undefined function or variable 'features' "

Error in esvm_detect>esvm_detectdriverBLOCK (line 255)
templates = zeros(S(1),S(2),features,length(models));

"features" looks like an integer value which has not been initialized. Can you tell me what value it should take?

I am running this code on Windows XP.

Running Demos

I have downloaded the most recent code from the git repository into matlab 2011 added everything to the path and have been unable to run any of the demos. Would it be possible to get some setup documentation?

Thank you,
Bryan

easy learning API

This has been requested by multiple people, a simple API to train from your own data source.

exemplar initialize simplification

both the VOC exemplar initialize, and the manual initialize from a sequence are both near-duplicate functions.. they should be merged or internal functions shared...

It is also desirable to have the infrastructure not be dependent on VOC data.

Exemplar initialization should have a dataset-dependent part which creates a sequence of (I,bb,name) triplets, and an algorithm-dependent part which uses a specific exemplar framing algorithm.

create sub-directory abhi

Just create a directory, and place hopefully meaning-ful files in it. Or better yet, you can remove what is inside the directory sketches (old code interface anyways) and place something in it that at least over the sketches.
-T

where is the voc_demo_apply.m?

Hi, I have download the code and wanna test the result on VOC2007 . after that I want to use Exemplar SVM in my research work. BUT I do not find the demo code as in the read me file says: For evaluating the PASCAL VOC 2007 pre-trained exemplars, see the notes ...and the main evaluation function in [exemplarsvm/demos/voc_demo_apply.m] .

would you please give me the apply demo code or just tell me how to use the code to detect an object(such as bus) in a image?

Thanks very much!

Generalize to: get_bg.m and get_fg.m

These functions are application specific and should be a part of your application, and not hard-coded in the codebase. Our codebase provides bg functions for common datasets such as:
PASCAL VOC: get_pascal_bg
SUNS: get_suns_bg
SUN09: get_sun09_bg
raw_directory: get_directory_bg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.