From 5b78a555f6c7ff20a71d0520db63bc43e69e1f41 Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Mon, 13 Oct 2008 11:50:22 +0200 Subject: [PATCH] automatic commit --- README.txt | 2 +- boosted_classifier.h | 2 +- classifier.h | 8 +++---- classifier_reader.cc | 3 --- classifier_reader.h | 9 +++++++- decision_tree.h | 10 +++++++++ detector.h | 3 ++- error_rates.cc | 29 ------------------------- error_rates.h | 8 +++++-- fusion_sort.h | 6 ++++++ gaussian.h | 6 ++++++ global.h | 7 +++++- image.h | 7 ++++++ interval.h | 6 ++++++ labelled_image.h | 7 ++++++ labelled_image_pool_file.h | 6 ++++++ labelled_image_pool_subset.h | 9 ++++++++ loss_machine.cc | 41 ------------------------------------ loss_machine.h | 8 +++++++ materials.h | 6 ++++++ misc.h | 6 ++++++ param_parser.h | 6 ++++++ parsing.h | 9 ++++---- parsing_pool.h | 10 ++++----- pi_feature.h | 6 +++--- pi_feature_family.h | 8 +++++++ pose.h | 8 +++++++ pose_cell.h | 6 ++++++ pose_cell_hierarchy.h | 9 ++++++++ pose_cell_hierarchy_reader.h | 7 ++++++ pose_cell_scored_set.h | 7 ++++++ pose_cell_set.h | 6 ++++++ rgb_image.h | 7 +++++- rgb_image_subpixel.h | 7 +++++- rich_image.h | 7 +++--- sample_set.h | 8 +++++++ shared.h | 11 ++++++---- shared_responses.h | 8 +++++++ storable.h | 7 ++++++ tools.h | 7 ++++++ 40 files changed, 228 insertions(+), 105 deletions(-) diff --git a/README.txt b/README.txt index ddf43b0..75fae3e 100644 --- a/README.txt +++ b/README.txt @@ -28,7 +28,7 @@ INSTALLATION * Compile the source code entirely * Generate the "pool file" containing the uncompressed images - converted to gray levels, labeled with the ground truth. + converted to gray levels, labelled with the ground truth. * Run 20 rounds of training / test (ten rounds for each of HB and H+B detectors with different random seeds) diff --git a/boosted_classifier.h b/boosted_classifier.h index bf86fca..dc43811 100644 --- a/boosted_classifier.h +++ b/boosted_classifier.h @@ -21,7 +21,7 @@ /* This class is an implementation of the Classifier with a boosting of - tree. It works with samples from R^n and has no concept of the + trees. It works with samples from R^n and has no concept of the pi-features. */ diff --git a/classifier.h b/classifier.h index 7a93642..695f3cc 100644 --- a/classifier.h +++ b/classifier.h @@ -20,10 +20,10 @@ /* - This class is mostly able to learn a classifier from a SampleSet and - to provide a scalar response on any test sample. Additional methods - are required for persistence and select the possibly very few used - features. + This class is almost purely virtual. It represents a classifier that + can be trained from a SampleSet and able to provide a scalar + response on any test sample. Additional methods are required for + persistence and select the possibly very few used features. */ diff --git a/classifier_reader.cc b/classifier_reader.cc index 85c9408..ee79a52 100644 --- a/classifier_reader.cc +++ b/classifier_reader.cc @@ -32,9 +32,6 @@ Classifier *read_classifier(istream *is) { case CLASSIFIER_BOOSTED: result = new BoostedClassifier(); break; -// case CLASSIFIER_BAYESIAN: -// result = new BayesianClassifier(); -// break; default: cerr << "Unknown classifier ID " << id << endl; exit(1); diff --git a/classifier_reader.h b/classifier_reader.h index 374c576..d123f53 100644 --- a/classifier_reader.h +++ b/classifier_reader.h @@ -18,12 +18,19 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + Function to read classifiers, so that we can deal with different + type of classifiers. + + */ + #ifndef CLASSIFIER_READER_H #define CLASSIFIER_READER_H #include "classifier.h" -enum { CLASSIFIER_BOOSTED, CLASSIFIER_BAYESIAN }; +enum { CLASSIFIER_BOOSTED }; Classifier *read_classifier(istream *is); diff --git a/decision_tree.h b/decision_tree.h index 70fdcad..1601836 100644 --- a/decision_tree.h +++ b/decision_tree.h @@ -18,6 +18,16 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + An implementation of the classifier with a decision tree. Each node + simply thresholds one of the component, and is chosen for maximum + loss reduction locally during training. The leaves are labelled with + the classifier response, which is chosen again for maximum loss + reduction. + + */ + #ifndef DECISION_TREE_H #define DECISION_TREE_H diff --git a/detector.h b/detector.h index 86d13e6..11f128d 100644 --- a/detector.h +++ b/detector.h @@ -20,7 +20,8 @@ /* - This is the main class, a folded hierarchy of classifiers. + This is the main class, a detector as a folded hierarchy of + classifiers. */ diff --git a/error_rates.cc b/error_rates.cc index 6d429e6..f028f17 100644 --- a/error_rates.cc +++ b/error_rates.cc @@ -107,32 +107,3 @@ void print_decimated_error_rate(int level, LabelledImagePool *pool, Detector *de << "INFO TOTAL_SURFACE " << total_surface << endl; ; } - -void parse_scene(Detector *detector, const char *image_name) { - RGBImage tmp; - tmp.read_jpg(image_name); - RichImage image(tmp.width(), tmp.height()); - - for(int y = 0; y < tmp.height(); y++) { - for(int x = 0; x < tmp.width(); x++) { - image.set_value(x, y, int(scalar_t(tmp.pixel(x, y, 0)) * 0.2989 + - scalar_t(tmp.pixel(x, y, 1)) * 0.5870 + - scalar_t(tmp.pixel(x, y, 2)) * 0.1140)); - } - } - - image.compute_rich_structure(); - - PoseCellScoredSet cell_set; - detector->parse(&image, &cell_set); - cell_set.decimate_hit(detector->nb_levels() - 1); - - cout << "RESULT " << image_name << endl; - for(int c = 0; c < cell_set.nb_cells(); c++) { - cout << "ALARM " << c << endl; - Pose alarm; - cell_set.get_cell(c)->get_centroid(&alarm); - alarm.print(&cout); - } - cout << "END_RESULT" << endl; -} diff --git a/error_rates.h b/error_rates.h index 1e4d8a0..abc5f70 100644 --- a/error_rates.h +++ b/error_rates.h @@ -18,6 +18,12 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + Two functions to compute a detector error rate on a pool of scenes. + + */ + #ifndef ERROR_RATES_H #define ERROR_RATES_H @@ -27,6 +33,4 @@ void print_decimated_error_rate(int level, LabelledImagePool *pool, Detector *detector); -void parse_scene(Detector *detector, const char *image_name); - #endif diff --git a/fusion_sort.h b/fusion_sort.h index c01dea9..f7bbf70 100644 --- a/fusion_sort.h +++ b/fusion_sort.h @@ -18,6 +18,12 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + My very own implementation of the fusion sort. + + */ + #ifndef FUSION_SORT_H #define FUSION_SORT_H diff --git a/gaussian.h b/gaussian.h index 3f510af..15e6622 100644 --- a/gaussian.h +++ b/gaussian.h @@ -18,6 +18,12 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + A simple representation of a Gaussian distribution. + + */ + #ifndef GAUSSIAN_H #define GAUSSIAN_H diff --git a/global.h b/global.h index d19596d..8a1978f 100644 --- a/global.h +++ b/global.h @@ -18,6 +18,12 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + We stuff all the global values in there. + + */ + #ifndef GLOBAL_H #define GLOBAL_H @@ -30,7 +36,6 @@ using namespace std; #include "progress_bar.h" enum { LOSS_EXPONENTIAL, - LOSS_EV_REGULARIZED, LOSS_HINGE, LOSS_LOGISTIC }; diff --git a/image.h b/image.h index 770750c..4559d40 100644 --- a/image.h +++ b/image.h @@ -18,6 +18,13 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + An implementation of a gray-scale image with a minimum set of + methods. + + */ + #ifndef IMAGE_H #define IMAGE_H diff --git a/interval.h b/interval.h index 619a496..879cc74 100644 --- a/interval.h +++ b/interval.h @@ -18,6 +18,12 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + An interval class. + + */ + #ifndef INTERVAL_H #define INTERVAL_H diff --git a/labelled_image.h b/labelled_image.h index bac7c6c..09967f8 100644 --- a/labelled_image.h +++ b/labelled_image.h @@ -18,6 +18,13 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + A LabelledImage is a RichImage labelled with the ground truth, + i.e. the target poses. + + */ + #ifndef LABELLED_IMAGE_H #define LABELLED_IMAGE_H diff --git a/labelled_image_pool_file.h b/labelled_image_pool_file.h index e83566e..90a543c 100644 --- a/labelled_image_pool_file.h +++ b/labelled_image_pool_file.h @@ -18,6 +18,12 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + This is a LabelledImagePool that corresponds physically to a file. + + */ + #ifndef LABELLED_IMAGE_POOL_FILE_H #define LABELLED_IMAGE_POOL_FILE_H diff --git a/labelled_image_pool_subset.h b/labelled_image_pool_subset.h index fa986b2..294eb06 100644 --- a/labelled_image_pool_subset.h +++ b/labelled_image_pool_subset.h @@ -18,6 +18,15 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + This is a LabelledImagePool which corresponds to a subset of another + pool. We use that to extract the training, validation and test pool + from the global pool. It is mainly necessary to have such a class to + avoid unnecessary memory usage. + + */ + #ifndef LABELLED_IMAGE_POOL_SUBSET_H #define LABELLED_IMAGE_POOL_SUBSET_H diff --git a/loss_machine.cc b/loss_machine.cc index c596de6..63a65cc 100644 --- a/loss_machine.cc +++ b/loss_machine.cc @@ -40,47 +40,6 @@ void LossMachine::get_loss_derivatives(SampleSet *samples, } break; - case LOSS_EV_REGULARIZED: - { - scalar_t sum_pos = 0, sum_sq_pos = 0, nb_pos = 0, m_pos, v_pos; - scalar_t sum_neg = 0, sum_sq_neg = 0, nb_neg = 0, m_neg, v_neg; - - for(int n = 0; n < samples->nb_samples(); n++) { - if(samples->label(n) > 0) { - sum_pos += responses[n]; - sum_sq_pos += sq(responses[n]); - nb_pos += 1.0; - } - else if(samples->label(n) < 0) { - sum_neg += responses[n]; - sum_sq_neg += sq(responses[n]); - nb_neg += 1.0; - } - } - - m_pos = sum_pos / nb_pos; - v_pos = sum_sq_pos/(nb_pos - 1) - sq(sum_pos)/(nb_pos * (nb_pos - 1)); - - scalar_t loss_pos = nb_pos * exp(v_pos/2 - m_pos); - - m_neg = sum_neg / nb_neg; - v_neg = sum_sq_neg/(nb_neg - 1) - sq(sum_neg)/(nb_neg * (nb_neg - 1)); - - scalar_t loss_neg = nb_neg * exp(v_neg/2 + m_neg); - - for(int n = 0; n < samples->nb_samples(); n++) { - if(samples->label(n) > 0) { - derivatives[n] = - ( - 1/nb_pos + (responses[n] - m_pos)/(nb_pos - 1)) * loss_pos; - } else if(samples->label(n) < 0) { - derivatives[n] = - ( 1/nb_neg + (responses[n] - m_neg)/(nb_neg - 1)) * loss_neg; - } - } - } - - break; - case LOSS_HINGE: { for(int n = 0; n < samples->nb_samples(); n++) { diff --git a/loss_machine.h b/loss_machine.h index 0b84adc..96f0a59 100644 --- a/loss_machine.h +++ b/loss_machine.h @@ -18,6 +18,14 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + A LossMachine provides all the methods necessary to do boosting with + a certain loss. Note that only the LOSS_EXPONENTIAL has been really + tested. Using the others may result in unexpected effects. + + */ + #ifndef LOSS_MACHINE_H #define LOSS_MACHINE_H diff --git a/materials.h b/materials.h index 0756e56..34d7081 100644 --- a/materials.h +++ b/materials.h @@ -18,6 +18,12 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + Functions to produce the figures for the paper. + + */ + #ifndef MATERIALS_H #define MATERIALS_H diff --git a/misc.h b/misc.h index b52317e..93f070f 100644 --- a/misc.h +++ b/misc.h @@ -18,6 +18,12 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + A bunch of useful little functions. + + */ + #ifndef MISC_H #define MISC_H diff --git a/param_parser.h b/param_parser.h index 53a6893..f13bf1f 100644 --- a/param_parser.h +++ b/param_parser.h @@ -18,6 +18,12 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + A class to parse the arguments from the command line. + + */ + #ifndef PARAM_PARSER_H #define PARAM_PARSER_H diff --git a/parsing.h b/parsing.h index 8e3ee3c..d971b1e 100644 --- a/parsing.h +++ b/parsing.h @@ -18,16 +18,17 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// -#ifndef PARSING_H -#define PARSING_H - /* A Parsing is associated to a LabelledImage and stores responses over - cells. + cells. We use it during training to remember the responses over all + the negative samples. */ +#ifndef PARSING_H +#define PARSING_H + #include "fusion_sort.h" #include "pose_cell_hierarchy.h" #include "classifier.h" diff --git a/parsing_pool.h b/parsing_pool.h index 0a73ddf..1453885 100644 --- a/parsing_pool.h +++ b/parsing_pool.h @@ -18,16 +18,16 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// -#ifndef PARSING_POOL_H -#define PARSING_POOL_H - /* - A ParsingPool is a family of Parsing associated to all the images of - a LabelledImagePool. + A ParsingPool is a family of Parsings associated to all the images + of a LabelledImagePool. */ +#ifndef PARSING_POOL_H +#define PARSING_POOL_H + #include "parsing.h" #include "pi_feature_family.h" #include "classifier.h" diff --git a/pi_feature.h b/pi_feature.h index f6186be..c1c92a0 100644 --- a/pi_feature.h +++ b/pi_feature.h @@ -20,9 +20,9 @@ /* - This class implement the notion of pi-feature, that is a feature - which can be evaluated on a pair image / referential, where the - referential is computed from a pose cell. + A PiFeatures is the central new idea of this approach. It is a + feature which can be evaluated on a pair image / referential, where + the referential is computed from a pose cell. */ diff --git a/pi_feature_family.h b/pi_feature_family.h index d7f2dd3..ad0999b 100644 --- a/pi_feature_family.h +++ b/pi_feature_family.h @@ -18,6 +18,14 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + A PiFeatureFamily is simply a set of pi-features, with a method to + extract a subfamily, so that we can forget all the features not used + by a classifier when the learning is over. + + */ + #ifndef PI_FEATURE_FAMILY_H #define PI_FEATURE_FAMILY_H diff --git a/pose.h b/pose.h index 8949269..d509d04 100644 --- a/pose.h +++ b/pose.h @@ -18,6 +18,14 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + This the pose of a target. In the case of cats, we have a bounding + box, the head location and scale, and the body location. All are + given in the image coordinate system. + + */ + #ifndef POSE_H #define POSE_H diff --git a/pose_cell.h b/pose_cell.h index 4f96baa..f75af88 100644 --- a/pose_cell.h +++ b/pose_cell.h @@ -18,6 +18,12 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + A PoseCell is a 5d rectangle in the pose space. + + */ + #ifndef POSE_CELL_H #define POSE_CELL_H diff --git a/pose_cell_hierarchy.h b/pose_cell_hierarchy.h index f89512d..a9461b2 100644 --- a/pose_cell_hierarchy.h +++ b/pose_cell_hierarchy.h @@ -18,6 +18,15 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + A PoseCellHierarchy provides the necessary methods to visit a + recursive partitioning of the pose space. The two main methods can + give you an root partitioning, or compute a finer partitioning from + an existing one. + + */ + #ifndef POSE_CELL_HIERARCHY_H #define POSE_CELL_HIERARCHY_H diff --git a/pose_cell_hierarchy_reader.h b/pose_cell_hierarchy_reader.h index ad082d6..22865ec 100644 --- a/pose_cell_hierarchy_reader.h +++ b/pose_cell_hierarchy_reader.h @@ -18,6 +18,13 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + A function to read a hierarchy. We have in mind to have different + kind of hierarchies later. + + */ + #ifndef POSE_CELL_HIERARCHY_READER_H #define POSE_CELL_HIERARCHY_READER_H diff --git a/pose_cell_scored_set.h b/pose_cell_scored_set.h index 8e6d4fb..a5689ee 100644 --- a/pose_cell_scored_set.h +++ b/pose_cell_scored_set.h @@ -18,6 +18,13 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + A set of PoseCells each paired with a detector response. This is + what the parsing of a scene produces. + + */ + #ifndef POSE_CELL_SCORED_SET_H #define POSE_CELL_SCORED_SET_H diff --git a/pose_cell_set.h b/pose_cell_set.h index 68471a3..81e7a22 100644 --- a/pose_cell_set.h +++ b/pose_cell_set.h @@ -18,6 +18,12 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + A set of PoseCell. + + */ + #ifndef POSE_CELL_SET_H #define POSE_CELL_SET_H diff --git a/rgb_image.h b/rgb_image.h index 5921c23..5c886a9 100644 --- a/rgb_image.h +++ b/rgb_image.h @@ -18,7 +18,12 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// -// A simple color image class +/* + + A simple image class to either load color images, or produce + materials. + + */ #ifndef RGB_IMAGE_H #define RGB_IMAGE_H diff --git a/rgb_image_subpixel.h b/rgb_image_subpixel.h index 778f084..931fa7c 100644 --- a/rgb_image_subpixel.h +++ b/rgb_image_subpixel.h @@ -18,7 +18,12 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// -// A simple color image class +/* + + Same as RGBImage, but with sub-pixel resolution to produce nifty + smoothing in the drawings. + + */ #ifndef RGB_IMAGE_SUBPIXEL_H #define RGB_IMAGE_SUBPIXEL_H diff --git a/rich_image.h b/rich_image.h index eb2d162..1ceb169 100644 --- a/rich_image.h +++ b/rich_image.h @@ -20,9 +20,10 @@ /* - This class implements the multi-scale basic edge features on the - images. The heavy machinery and ugly coding style is motivated by - performance. + A RichImage is an Image with all the necessary pre-computation to + compute the feature responses: Edge detection and local variance + thresholding at multiple scale, with integral images. The heavy + machinery and ugly coding style is motivated by performance. */ diff --git a/sample_set.h b/sample_set.h index 9841d66..c007f34 100644 --- a/sample_set.h +++ b/sample_set.h @@ -18,6 +18,14 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + A SampleSet stands for a set of samples from R^d with their + labels. It abstracts the notion features and is what the machine + learning techniques of this software see. + + */ + #ifndef SAMPLE_SET_H #define SAMPLE_SET_H diff --git a/shared.h b/shared.h index 020ab58..3d90c8d 100644 --- a/shared.h +++ b/shared.h @@ -18,11 +18,14 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// -// A tiny class to implement shared objects and lazy deletion +/* -// When you create a reference to such an object, call grab(), and -// when you destroy that reference, call release() which will delete -// it if no reference remains. Never delete it yourself! + A tiny class to implement shared objects and lazy deletion. When you + create a reference to such an object, call grab(), and when you + destroy that reference, call release() which will delete it if no + reference remains. Never delete it yourself! + + */ #ifndef SHARED_H #define SHARED_H diff --git a/shared_responses.h b/shared_responses.h index 2f88cb3..b144b66 100644 --- a/shared_responses.h +++ b/shared_responses.h @@ -18,6 +18,14 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + A SharedResponses object is used to avoid duplicating the data when + we create several LabelledImagePoolSubset which look at the same + LabelledImagePool. + + */ + #ifndef SHARED_RESPONSES_H #define SHARED_RESPONSES_H diff --git a/storable.h b/storable.h index 7bdf5ee..6b6e6c4 100644 --- a/storable.h +++ b/storable.h @@ -18,6 +18,13 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + This class is only used to provide the read/write methods from a + char *, given that the class implements read/write from streams. + + */ + #ifndef STORABLE_H #define STORABLE_H diff --git a/tools.h b/tools.h index 902879a..ddaa3dd 100644 --- a/tools.h +++ b/tools.h @@ -18,6 +18,13 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + Two handy functions to sample in a very large weighted sample set, + and to generate a ROC curve given a very large sample set. + + */ + #ifndef TOOLS_H #define TOOLS_H -- 2.39.5