From: Francois Fleuret Date: Sat, 11 Oct 2008 21:51:11 +0000 (+0200) Subject: automatic commit X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=ccc2785ee823c934edcededc5c6448e4f9488f8b;p=folded-ctf.git automatic commit --- diff --git a/folding.cc b/folding.cc index 34c785c..c592955 100644 --- a/folding.cc +++ b/folding.cc @@ -144,19 +144,6 @@ int main(int argc, char **argv) { } - else if(strcmp(new_argv[c], "write-target-poses") == 0) { - check(main_pool, "No pool available."); - LabelledImage *image; - for(int p = 0; p < main_pool->nb_images(); p++) { - image = main_pool->grab_image(p); - for(int t = 0; t < image->nb_targets(); t++) { - cout << "IMAGE " << p << " TARGET " << t << endl; - image->get_target_pose(t)->print(&cout); - } - main_pool->release_image(p); - } - } - ////////////////////////////////////////////////////////////////////// else if(strcmp(new_argv[c], "train-detector") == 0) { @@ -176,25 +163,6 @@ int main(int argc, char **argv) { detector->compute_thresholds(validation_pool, global.wanted_true_positive_rate); } - else if(strcmp(new_argv[c], "check-hierarchy") == 0) { - cout << "-- CHECK HIERARCHY ---------------------------------------------------" << endl; - PoseCellHierarchy *h = new PoseCellHierarchy(hierarchy_pool); - cout << "Train incompatible poses " << h->nb_incompatible_poses(train_pool) << endl; - cout << "Validation incompatible poses " << h->nb_incompatible_poses(validation_pool) << endl; - delete h; - } - - ////////////////////////////////////////////////////////////////////// - - else if(strcmp(new_argv[c], "validate-detector") == 0) { - cout << "-- VALIDATE DETECTOR -------------------------------------------------" << endl; - - check(validation_pool, "No validation pool available."); - check(detector, "No detector."); - - print_decimated_error_rate(global.nb_levels - 1, validation_pool, detector); - } - ////////////////////////////////////////////////////////////////////// else if(strcmp(new_argv[c], "test-detector") == 0) { @@ -210,18 +178,6 @@ int main(int argc, char **argv) { } } - else if(strcmp(new_argv[c], "parse-images") == 0) { - cout << "-- PARSING IMAGES -----------------------------------------------------" << endl; - check(detector, "No detector."); - while(!cin.eof()) { - char image_name[buffer_size]; - cin.getline(image_name, buffer_size); - if(strlen(image_name) > 0) { - parse_scene(detector, image_name); - } - } - } - ////////////////////////////////////////////////////////////////////// else if(strcmp(new_argv[c], "sequence-test-detector") == 0) { @@ -286,34 +242,6 @@ int main(int argc, char **argv) { write_pool_images_with_poses_and_referentials(train_pool, detector); } - else if(strcmp(new_argv[c], "produce-materials") == 0) { - cout << "-- PRODUCING MATERIALS -----------------------------------------------" << endl; - - check(hierarchy_pool, "No hierarchy pool available."); - check(test_pool, "No test pool available."); - - PoseCellHierarchy *hierarchy; - - cout << "Creating hierarchy" << endl; - - hierarchy = new PoseCellHierarchy(hierarchy_pool); - - LabelledImage *image; - for(int p = 0; p < test_pool->nb_images(); p++) { - image = test_pool->grab_image(p); - if(image->width() == 640 && image->height() == 480) { - PoseCellSet pcs; - hierarchy->add_root_cells(image, &pcs); - cout << "WE HAVE " << pcs.nb_cells() << " CELLS" << endl; - exit(0); - test_pool->release_image(p); - } - } - - delete hierarchy; - - } - ////////////////////////////////////////////////////////////////////// else { diff --git a/global.cc b/global.cc index 253733c..8016c41 100644 --- a/global.cc +++ b/global.cc @@ -101,7 +101,7 @@ void Global::init_parser(ParamParser *parser) { parser->add_association("max-head-radius", "200", false); // How many translation cell for one scale when generating the "top // level" cells for an image. - parser->add_association("root-cell-nb-xy-per-scale", "5", false); + parser->add_association("root-cell-nb-xy-per-radius", "5", false); // What is the minimum size of the windows parser->add_association("pi-feature-window-min-size", "0.1", false); @@ -162,7 +162,7 @@ void Global::read_parser(ParamParser *parser) { min_head_radius = parser->get_association_scalar("min-head-radius"); max_head_radius = parser->get_association_scalar("max-head-radius"); - root_cell_nb_xy_per_scale = parser->get_association_int("root-cell-nb-xy-per-scale"); + root_cell_nb_xy_per_radius = parser->get_association_int("root-cell-nb-xy-per-radius"); pi_feature_window_min_size = parser->get_association_scalar("pi-feature-window-min-size"); diff --git a/global.h b/global.h index a053d3d..fae2d81 100644 --- a/global.h +++ b/global.h @@ -73,7 +73,7 @@ public: int nb_scales_per_power_of_two; scalar_t min_head_radius; scalar_t max_head_radius; - int root_cell_nb_xy_per_scale; + int root_cell_nb_xy_per_radius; scalar_t pi_feature_window_min_size; diff --git a/labelled_image_pool.h b/labelled_image_pool.h index 3186dc7..6c3e5e7 100644 --- a/labelled_image_pool.h +++ b/labelled_image_pool.h @@ -16,6 +16,14 @@ // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// +/* + + A pool of images is used to avoid having too many images in memory + at the same time. It can be either a file, or a subset of another + pool of images (see the subclasses). + + */ + #ifndef LABELLED_IMAGE_POOL_H #define LABELLED_IMAGE_POOL_H @@ -26,6 +34,9 @@ class LabelledImagePool { public: virtual ~LabelledImagePool(); virtual int nb_images() = 0; + // grab_image _DOES NOT_ build the rich structure of the grabbed + // image. One has to call compute_rich_structure() explicitely for + // that! virtual LabelledImage *grab_image(int n_image) = 0; virtual void release_image(int n_image) = 0; }; diff --git a/labelled_image_pool_file.h b/labelled_image_pool_file.h index a46d781..efa7abe 100644 --- a/labelled_image_pool_file.h +++ b/labelled_image_pool_file.h @@ -34,11 +34,7 @@ class LabelledImagePoolFile : public LabelledImagePool { public: LabelledImagePoolFile(char *file_name); virtual ~LabelledImagePoolFile(); - virtual int nb_images(); - - // grab_image(n) does _NOT_ build the rich structure. One has to call - // compute_rich_structure() for that! virtual LabelledImage *grab_image(int n_image); virtual void release_image(int n_image); }; diff --git a/materials.cc b/materials.cc index bbb6cbf..21f6790 100644 --- a/materials.cc +++ b/materials.cc @@ -139,72 +139,72 @@ void write_pool_images_with_poses_and_referentials(LabelledImagePool *pool, } for(int i = 0; i < min(global.nb_images, pool->nb_images()); i++) { - image = pool->grab_image(i); - - RGBImage result(image->width(), image->height()); - image->to_rgb(&result); - RGBImageSubpixel result_sp(&result); - - int u = 0; - - // image->compute_rich_structure(); - - for(int t = 0; t < image->nb_targets(); t++) { - - image->get_target_pose(t)->draw(4, 255, 0, 0, - hierarchy->nb_levels() - 1, &result_sp); - - hierarchy->get_containing_cell(image, - hierarchy->nb_levels() - 1, - image->get_target_pose(t), &target_cell); - - target_cell.get_centroid(&p); - - p.draw(4, 0, 255, 0, hierarchy->nb_levels() - 1, &result_sp); - - PiReferential referential(&target_cell); - - sprintf(buffer, "/tmp/referential-%05d-%02d.png", i, u); - image->compute_rich_structure(); - write_referential_png(buffer, hierarchy->nb_levels() - 1, image, &referential, 0); - - if(detector) { - int nb_features = 100; - for(int f = 0; f < nb_features; f++) - if(f == 0 || f ==50 || f == 53) { - int n_family, n_feature; - if(f < nb_features/2) { - n_family = 0; - n_feature = f; - } else { - n_family = detector->_nb_classifiers_per_level; - n_feature = f - nb_features/2; - } - pf = detector->_pi_feature_families[n_family]->get_feature(n_feature); - sprintf(buffer, "/tmp/pf-%05d-%02d-%03d.png", i, u, f); - write_referential_png(buffer, - hierarchy->nb_levels() - 1, - image, - &referential, - pf); + image = pool->grab_image(i); + + RGBImage result(image->width(), image->height()); + image->to_rgb(&result); + RGBImageSubpixel result_sp(&result); + + int u = 0; + + // image->compute_rich_structure(); + + for(int t = 0; t < image->nb_targets(); t++) { + + image->get_target_pose(t)->draw(4, 255, 0, 0, + hierarchy->nb_levels() - 1, &result_sp); + + hierarchy->get_containing_cell(image, + hierarchy->nb_levels() - 1, + image->get_target_pose(t), &target_cell); + + target_cell.get_centroid(&p); + + p.draw(4, 0, 255, 0, hierarchy->nb_levels() - 1, &result_sp); + + PiReferential referential(&target_cell); + + sprintf(buffer, "/tmp/referential-%05d-%02d.png", i, u); + image->compute_rich_structure(); + write_referential_png(buffer, hierarchy->nb_levels() - 1, image, &referential, 0); + + if(detector) { + int nb_features = 100; + for(int f = 0; f < nb_features; f++) + if(f == 0 || f ==50 || f == 53) { + int n_family, n_feature; + if(f < nb_features/2) { + n_family = 0; + n_feature = f; + } else { + n_family = detector->_nb_classifiers_per_level; + n_feature = f - nb_features/2; } + pf = detector->_pi_feature_families[n_family]->get_feature(n_feature); + sprintf(buffer, "/tmp/pf-%05d-%02d-%03d.png", i, u, f); + write_referential_png(buffer, + hierarchy->nb_levels() - 1, + image, + &referential, + pf); } - u++; - } + } + u++; + } - // sprintf(buffer, "/tmp/image-%05d.png", i); - // cout << "Writing " << buffer << endl; - // result_sp.write_png(buffer); + // sprintf(buffer, "/tmp/image-%05d.png", i); + // cout << "Writing " << buffer << endl; + // result_sp.write_png(buffer); - // if(global.write_tag_images) { - // sprintf(buffer, "/tmp/image-%05d_tags.png", i); - // cout << "Writing " << buffer << endl; - // image->compute_rich_structure(); - // image->write_tag_png(buffer); - // } + // if(global.write_tag_images) { + // sprintf(buffer, "/tmp/image-%05d_tags.png", i); + // cout << "Writing " << buffer << endl; + // image->compute_rich_structure(); + // image->write_tag_png(buffer); + // } - pool->release_image(i); - } + pool->release_image(i); + } delete hierarchy; } diff --git a/parsing_pool.cc b/parsing_pool.cc index 696477a..f12a377 100644 --- a/parsing_pool.cc +++ b/parsing_pool.cc @@ -88,6 +88,7 @@ void ParsingPool::down_one_level(LossMachine *loss_machine, PoseCellHierarchy *h loss_machine->subsample(_nb_cells, labels, tmp_responses, _nb_negative_cells, sample_nb_occurences, sample_responses, 1); + c = 0; for(int i = 0; i < _nb_images; i++) { for(int d = 0; d < _parsings[i]->nb_cells(); d++) { @@ -119,6 +120,9 @@ void ParsingPool::down_one_level(LossMachine *loss_machine, PoseCellHierarchy *h delete[] sample_responses; delete[] sample_nb_occurences; + + delete[] labels; + delete[] tmp_responses; } void ParsingPool::update_cell_responses(PiFeatureFamily *pi_feature_family, @@ -200,8 +204,6 @@ void ParsingPool::weighted_sampling(LossMachine *loss_machine, s = 0; c = 0; -// global.bar.init(&cout, _nb_images); - for(int i = 0; i < _nb_images; i++) { int *to_collect = new int[_parsings[i]->nb_cells()]; @@ -221,12 +223,8 @@ void ParsingPool::weighted_sampling(LossMachine *loss_machine, delete[] to_collect; c += _parsings[i]->nb_cells(); - -// global.bar.refresh(&cout, i); } -// global.bar.finish(&cout); - delete[] tmp_responses; delete[] labels; } diff --git a/pi_feature.cc b/pi_feature.cc index c3be53a..7f9cf85 100644 --- a/pi_feature.cc +++ b/pi_feature.cc @@ -138,13 +138,6 @@ void PiFeature::draw_edge_thresholding(RGBImage *image, ®istered_window_a); referential->draw_window(image, _registration_a, ®istered_window_a, 0); - -// if(!global.pictures_for_article) { -// int tag = referential->register_edge(_registration_a, _tag); - -// referential->draw_edge_and_scale(image, _registration_a, ®istered_window_a, -// tag, _edge_scale); -// } } void PiFeature::print_edge_thresholding(ostream *os) { diff --git a/pi_referential.h b/pi_referential.h index 06995f4..8d2613e 100644 --- a/pi_referential.h +++ b/pi_referential.h @@ -46,11 +46,13 @@ class PiReferential { scalar_t _head_ux, _head_uy, _head_vx, _head_vy; scalar_t _head_ux_nopolarity, _head_uy_nopolarity, _head_vx_nopolarity, _head_vy_nopolarity; + //********************************************************************** // Useless fields, but they are necessary so that the optimized code // with g++ gives the same results as some reference // experiments. Sorry for that. scalar_t _body_xc, _body_yc; scalar_t _body_tilt; + //********************************************************************** // The belly frame is defined by the belly location and head scale scalar_t _belly_xc, _belly_yc; @@ -75,15 +77,15 @@ public: enum { // A square frame centered on the head, of size four times the - // head radius and, flipped vertically if the belly is on the left - // of the head center + // head radius and, flipped horizontally if the belly is on the + // left of the head center RM_HEAD, // Same as above, without the flipping RM_HEAD_NO_POLARITY, // A frame centered on the belly, of size eight times the head - // radius, flipped vertically if the belly is on the left of the + // radius, flipped horizontally if the belly is on the left of the // head center RM_BELLY, @@ -103,8 +105,8 @@ public: int common_scale(); // The rectangle coordinates are in the reference frames. For the - // head for instance , [-1,1] x [-1,1] corresponds to the head - // bounding box + // head for instance [-0.5, 0.5] x [-0.5, 0.5] corresponds to the + // head bounding box void register_rectangle(int registration_mode, Rectangle *original, diff --git a/pose_cell_hierarchy.cc b/pose_cell_hierarchy.cc index cecd3b3..85a843a 100644 --- a/pose_cell_hierarchy.cc +++ b/pose_cell_hierarchy.cc @@ -27,7 +27,7 @@ PoseCellHierarchy::PoseCellHierarchy(LabelledImagePool *train_pool) { _nb_levels = global.nb_levels; _min_head_radius = global.min_head_radius; _max_head_radius = global.max_head_radius; - _root_cell_nb_xy_per_scale = global.root_cell_nb_xy_per_scale; + _root_cell_nb_xy_per_scale = global.root_cell_nb_xy_per_radius; LabelledImage *image; int nb_total_targets = 0; @@ -221,7 +221,7 @@ void PoseCellHierarchy::add_root_cells(Image *image, PoseCellSet *cell_set) { scalar_t beta = log(2) / scalar_t(global.nb_scales_per_power_of_two); for(int s = 0; s < nb_scales; s++) { - scalar_t cell_xy_size = exp(alpha + scalar_t(s) * beta) / global.root_cell_nb_xy_per_scale; + scalar_t cell_xy_size = exp(alpha + scalar_t(s) * beta) / global.root_cell_nb_xy_per_radius; PoseCell cell; cell._head_radius.min = exp(alpha + scalar_t(s) * beta); cell._head_radius.max = exp(alpha + scalar_t(s+1) * beta); diff --git a/run.sh b/run.sh index 2900f5e..13f3a8e 100755 --- a/run.sh +++ b/run.sh @@ -101,12 +101,14 @@ for SEED in {0..9}; do OPTS="${OPTS} --force-head-belly-independence=yes" fi - if [[ $1 == "light" ]]; then + if [[ $1 == "valgrind" ]]; then OPTS="${OPTS} --nb-classifiers-per-level=1 --nb-weak-learners-per-classifier=10" - OPTS="${OPTS} --proportion-for-train=0.1 --proportion-for-validation=0.1 --proportion-for-test=0.1" + OPTS="${OPTS} --proportion-for-train=0.1 --proportion-for-validation=0.025 --proportion-for-test=0.01" + OPTS="${OPTS} --wanted-true-positive-rate=0.1" + DEBUGGER="valgrind --db-attach=yes --leak-check=full --show-reachable=yes" fi - ./folding \ + ${DEBUGGER} ./folding \ --niceness=15 \ --pool-name=${POOL_NAME} \ --nb-levels=2 \