libHIK-1.5

所属分类:matlab编程
开发工具:matlab
文件大小:367KB
下载次数:106
上传日期:2010-06-04 18:03:27
上 传 者sjtushentong
说明:  SVM分类器,包括训练和测试,实用的matlab包。
(SVM classifiers, including training and testing, practical matlab package.)

文件列表:
libHIK-1.5\libHIK\libsvm-2.89\java\libsvm\svm.java (61627, 2009-08-11)
libHIK-1.5\libHIK\libsvm-2.89\java\libsvm\svm.m4 (60994, 2009-08-11)
libHIK-1.5\libHIK\libsvm-2.89\java\libsvm\svm_model.java (664, 2009-08-11)
libHIK-1.5\libHIK\libsvm-2.89\java\libsvm\svm_node.java (115, 2009-08-11)
libHIK-1.5\libHIK\libsvm-2.89\java\libsvm\svm_parameter.java (1288, 2009-08-11)
libHIK-1.5\libHIK\libsvm-2.89\java\libsvm\svm_print_interface.java (87, 2009-08-11)
libHIK-1.5\libHIK\libsvm-2.89\java\libsvm\svm_problem.java (136, 2009-08-11)
libHIK-1.5\libHIK\libsvm-2.89\svm-toy\gtk\callbacks.cpp (9702, 2009-08-11)
libHIK-1.5\libHIK\libsvm-2.89\svm-toy\gtk\callbacks.h (1765, 2009-08-11)
libHIK-1.5\libHIK\libsvm-2.89\svm-toy\gtk\interface.c (6457, 2009-08-11)
libHIK-1.5\libHIK\libsvm-2.89\svm-toy\gtk\interface.h (203, 2009-08-11)
libHIK-1.5\libHIK\libsvm-2.89\svm-toy\gtk\main.c (398, 2009-08-11)
libHIK-1.5\libHIK\libsvm-2.89\svm-toy\gtk\Makefile (530, 2009-08-11)
libHIK-1.5\libHIK\libsvm-2.89\svm-toy\gtk\svm-toy.glade (6402, 2009-08-11)
libHIK-1.5\libHIK\libsvm-2.89\svm-toy\qt\Makefile (367, 2009-08-11)
libHIK-1.5\libHIK\libsvm-2.89\svm-toy\qt\svm-toy.cpp (9133, 2009-08-11)
libHIK-1.5\libHIK\libsvm-2.89\svm-toy\windows\svm-toy.cpp (10787, 2009-08-11)
libHIK-1.5\libHIK\libsvm-2.89\windows\python\.nonemty (0, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\dtron\dbreakpt.c (2169, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\dtron\dcauchy.c (4777, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\dtron\dgpnrm.c (1146, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\dtron\dgpstep.c (1513, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\dtron\dprecond.c (973, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\dtron\dprsrch.c (4295, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\dtron\dspcg.c (7210, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\dtron\dtron.c (7633, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\dtron\dtrpcg.c (6573, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\dtron\dtrqsol.c (1703, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\dtron\Makefile (361, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\dtron\misc.c (363, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\f2c\blas.h (702, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\f2c\blasp.h (16491, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\f2c\dasum.c (1081, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\f2c\daxpy.c (1201, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\f2c\dcopy.c (928, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\f2c\ddot.c (1203, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\f2c\dgemv.c (7234, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\f2c\dnrm2.c (1302, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\f2c\dpotf2.c (5964, 2009-08-11)
libHIK-1.5\libHIK\bsvm-2.06\f2c\dscal.c (1031, 2009-08-11)
... ...

0. Pre-requisite 0.0 Read our licence file! Please. 0.1 OpenCV -- http://sourceforge.net/projects/opencvlibrary/ OpenCV packages are also available in many Linux distributions (e.g. Ubuntu) 0.2 OpenMP -- You compiler needs to support OpenMP gcc 4.3+ or Microsoft VS 2008, more details at http://openmp.org/wp/openmp-compilers/ If your compiler does not support OpenMP, remove all "#include " (use a search) 0.3 Memory requirements -- This package trades time and memory, 1G memory at least Be careful not to exceed memory limit If you have only 1 CPU (core) and limited memory, remove OpenMP support Or, change "#pragma omp parallel for" to "#pragma omp parallel for num_threads(2)" 0.4 LIBSVM and BSVM LIBSVM 2.89 and BSVM 2.06 are included in this package libHIK includes methods that make testing of histogram intersection kernel SVM much faster but the training still needs to be done by either LIBSVM or BSVM When you have lots of classes (e.g. Caltech 101), BSVM is a better choice (I think). Please look at their README and licence for installation and licensing information After version 1.5, a VS2008 project is provided to build bsvm in Windows 0.5 Please refer to our ICCV 2009 paper for technical details. Beyond the Euclidean distance: Creating effective visual codebooks\\using the histogram intersection kernel Jianxin Wu and James M. Rehg ICCV 2009 1. Build the program 1.0 There are two directories: "libHIK/" and "Data/", make sure they are parallel to each other e.g. both directories are sub-directory of "libHIK-1.0/" 1.1 For Linux, it's simple, just type "make" in the "libHIK/" directory 1.1.0 first run "make depend", then "make" 1.1.1 Programs will appear in "libHIK/" 1.1.2 Run "make clean" to cleanup 1.1.3 After version 1.5, the make file also make libsvm and bsvm executables are also copied to the "libHIK/" directory. 1.2 For Windows, follow these steps 1.2.0 Setup the environment Install OpenCV, open the OpenCV project in VS2008 If you are running 32 bit windows, build the win32 platform project If you are running *** bit windows, building the x*** platform project 1.2.1 Make sure nmake, cl, link are in system path Start from "Start Menu" Choose "Microsoft Visual Studio 2008" Choose "Visual Stuio Tools" If you are running 32 bit windows, choose "Visual Studio 2008 Command Prompt" else choose "Visual Studio 2008 x*** Win*** Command Prompt" Change the current directory to the "libHIK/" directory in the command line Edit "libHIK\Makefile.win32" file, change OPENCV_??? to directory name in your computer edit "libHIK\Makefile.win***" file if the target is *** bit system 1.2.2 Run "nmake -f Makefile.win32" if you are targeting 32 bit windows Instead, run "nmake -f Makefile.win***" for *** bit windows 1.2.3 Programs will appear in "libHIK/windows/" 1.2.4 Run "nmake -f Makefile.win32 clean" to cleanup 1.2.5 You may also want to make LIBSVM. Follow the README there. Copy the executables to where you want them to be. You may choose to build a 32 or *** bit version, as shown in step 1.2.1 1.2.6 Open the bsvm solution in the BSVM directory. Choose the right platform (win32 or x***) Choose Release mode or Debug mode Build Copy the executables to where you want them to be. 1.2.7 Find the executables in these directories If Win32: Release or Debug If x***: x***\Release or x***\Debug 2. Usage of the programs These programs have two functions: A) You can use them directly; B) Please use the source code of these executables are examples of how to use libHIK APIs! Please note that the Windows version is not throughly tested as the Linux version. 2.0 Histogram Intersection Kernel (HIK) for LIBSVM and BSVM 2.0.1 Both software are revised by me to support HIK, use '-t 5' in both to use HIK as your kernel 2.0.2 You can still use svm-predict or bsvm-predict to test with HIK, although that's slow. 2.0.3 A script Ceasy.py is added to find best parameter only for 'C' It is useful for both linear kernel and HIK, see LIBSVM readme for usage information 2.0.4 A script train_test.py is used to perform training and testing together Read the comments in this new script to learn how to use These scripts are also added to BSVM, in "libsvm-2.89/tools/" and "bsvm-2.06/tools/" 2.1 hik-predict (hik-predict.exe for windows) 2.1.1 Fast testing method for HIK SVM produced by LIBSVM It should work with all methods in LIBSVM, when kernel is HIK 2.1.2 Usage: hik-predict -D dimension -u upper_bound [options] test_file model_file output_file -D dimension: specify the dimension of your feature vector -u upper_bound: make sure all your feature values are integers between 0 and upper_bound-1 model_file: an SVM model trained by LIBSVM with HIK kernel test_file: testing dataset, written in sparse SVM format output_file: result for one data point per line 2.2 hik-bsvm-predict (hik-bsvm-predict.exe for window -- NOTE that BSVM is not available for Windows) 2.2.1 Fast testing method for trained by BSVM, ONLY for the Crammer-Singer formulation (-s 2) Requires histogram intersection kernel (-t 5) and integer feature values 2.2.2 Usage: hik-bsvm-predict -D dimension -u upper_bound test_file model_file output_file The parameters are the same as hik-predict (2.1) make sure all your feature values are integers between 0 and upper_bound-1 2.3 hik-cluster (hik-cluster.exe for windows) 2.3.1 Usage: hik-cluster [options] train_filename [test_filename] 2.3.1.1 train_filename: specify the training set Format: first line contains the number of data points, and dimension of feature vector Each line afterwards is a data point in dense format i.e. write each feature value in text format sequentially 2.3.1.2 Options: -t 1|2|3: 1 for HIK clustering, 2 for k-means, 3 for k-median -u xxx: only for HIK clustering, specify the upper_bound -k xxx: how many clusters to generate? -m xxx: maximum iteration in the clustering process -o 0|1: use one-class SVM if set to 1 (refer to our ICCV 2009 paper) Default options: -t 1 -k 200 -m 10 -o 0 2.3.1.3 Clustering results in train_filename_clusters 2.3.1.4 If test_filename exists, then data in that file will be clustered 2.4 transform (transform.exe for windows) 2.4.0 What if your histogram feature vectors are real-valued? or integers with large upper_bound? Use "transform" to turn them into integers with a reasonable upper_bound 2.4.1 Usage: transform train_filename test_filename [upper_bound] where upper_bound is the same as above, set to 128 if not specified 2.4.2 We only use the information in the training set (train_filename) to transform 2.4.2.1 No information from the test set is used to determine transform parameter 2.4.2.2 Make sure your feature values are positive real numbers 2.4.2.3 Output are in train_filename.int & test_filename.int 2.4.2.4 Both input and output are in sparse SVM format 2.4.3 (At least in our experiments) quantzing real-valued histograms does NOT hurt And in many cases improves accuracy! 2.4.4 Caveat! If your feature value distribution is heavy tailed, what I use (97.5 percentile) maybe too large If you look at the output and find most feature values are small integers you may want to change the 0.975 parameter in source code to smaller values 3. Repeat the results in our ICCV 2009 paper (And how to use our method for new datasets) 3.0 NOTE: Our method is randomized, so results on these datasets varies each run, and may well be (slightly) different to those reported in our ICCV 2009 paper. Usage: generate_data dataset descriptor codebook (or use windows\generate-data.exe instead) dataset: caltech | scene | sports for caltech 101, 15 class scene, and 8 class sports event datasets. descriptor: CENTRIST | SIFT codebook: HIK | kmeans | kmedian 3.1 Fifteen class Scene recognition dataset 3.1.1 Download http://www-cvr.ai.uiuc.edu/ponce_grp/data/scene_categories/scene_categories.zip to "Data/scene/" directory. 3.1.2 Unzip the file in the "Data/scene/" directory (run 'unzip scene_categories.zip" in Linux) so that you will have "Data/scene/bedroom/", ..., etc 3.1.3 run "./generate-data scene CENTRIST HIK" from libHIK/ to generate data (train1.txt, test1.txt, ..., train5.txt, test5.txt) in SVM format (or "windows\generate-data.exe scene CENTRIST HIK" in Windows By default, the scene recognition dataset are randomly split into train set/test set. The spliting is repeated 5 times (i.e. until train5.txt, test5.txt) (refer to the ICCV paper) Be patient, this is not fast. use "transform" to convert to train1.txt.int, test1.txt.int, ..., etc 3.1.4 Testing, e.g. using the following commands (LIBSVM and libHIK) ./svm-train -c 0.03125 -t 5 train1.txt.int ./svm-predict test1.txt.int train1.txt.int.model out.txt or, ./hik-predict -D 6200 -u 128 test1.txt.int train1.txt.int.model out.txt (You need to change -D or -u parameters if you used different ones) 3.2 Eight class sports event dataset 3.2.1 Download http://vision.stanford.edu/lijiali/event_dataset/event_dataset.rar to "Data/" directory 3.2.2 Unzip the file in the "Data/" directory (run 'unrar x event_dataset.rar" in Linux) so that you will have "Data/event_dataset/badminton/", ..., etc 3.2.3 run "./generate-data sports CENTRIST HIK" from libHIK/ to generate data (train1.txt, test1.txt, ...) 3.2.4 Testing, refer to 3.1.4 3.3 Caltech 101 3.3.1 Download http://www.vision.caltech.edu/Image_Datasets/Caltech101/101_ObjectCategories.tar.gz to "Data/" directory 3.3.2 Unzip the file in the "Data/" directory (run "tar xzvf 101_ObjectCategories.tar.gz" in Linux) so that you will have "Data/101_ObjectCategories/accordion/", ..., etc 3.3.3 run "./generate-data caltech SIFT HIK" from libHIK/ to generate data (train1.txt, test1.txt, ...) 3.3.4 Testing, refer to 3.1.4 3.4 Adjust parameters 3.4.1 Please refer to Datasets.cpp for parameters that can be changed 3.4.2 Find corresponding function for the dataset 3.4.3 Main parameters: (refer to our ICCV 2009 paper and Datasets.cpp) K -- codebook size splitlevel -- level in the hierarchy stepSize -- grid size in dense sampling useBoth -- whether concatenate features from Sobel image oneclassSVM -- whether use one-class SVM to create visual code words 3.5 How about a different dataset? Please use the three functions for the above three datasets as example Or you can use the libHIK APIs and write your own code Before calling GenerateDatasetsSeparateCodebook(), make sure the following fields are properly filled totalsize, numClass, trainsize, testsize -- see comments in Datasets.cpp filenames -- std:vector, one cell is a path name for an image labels -- std::vector, class label for images, one-to-one correspondence with filenames classSizes -- std::vector, classizes[i] is number of images in class i classStartings -- std::vector, classStartings[i] to classStartings[i+1]-1 all from class i

近期下载者

相关文件


收藏者