Skip to content

Commit

Permalink
continue tune some parameters for release
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliu committed Jun 18, 2012
1 parent c6e9e3a commit 3cfead3
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,6 +3,7 @@
*.swp
tags
gh-pages
site
*.tests
test/*_test
test/*.jpg
Expand Down
14 changes: 7 additions & 7 deletions bin/dpmcreate.c
Expand Up @@ -17,12 +17,12 @@ void exit_with_help()
"\t--symmetric : 0 or 1, whether to exploit symmetric property of the object\n\n"
"\033[1mOTHER OPTIONS\033[0m\n"
"\t--base-dir : change the base directory so that the program can read images from there\n"
"\t--iterations : how many iterations needed for stochastic gradient descent [DEFAULT TO 10]\n"
"\t--iterations : how many iterations needed for stochastic gradient descent [DEFAULT TO 15]\n"
"\t--relabels : how many relabel procedure needed [DEFAULT TO 5]\n"
"\t--alpha : the step size for stochastic gradient descent [DEFAULT TO 0.1]\n"
"\t--alpha-ratio : decrease the step size for each iteration [DEFAULT TO 0.85]\n"
"\t--alpha-ratio : decrease the step size for each iteration [DEFAULT TO 0.9]\n"
"\t--margin-c : the famous C in SVM [DEFAULT TO 0.002]\n"
"\t--balance : to balance the weight of positive examples and negative examples [DEFAULT TO 1.75]\n"
"\t--balance : to balance the weight of positive examples and negative examples [DEFAULT TO 1.5]\n"
"\t--negative-cache-size : the cache size for negative examples it should be smaller than negative-count and larger than 100 [DEFAULT TO 1000]\n"
"\t--include-overlap : the percentage of overlap between expected bounding box and the bounding box from detection. Beyond this threshold, it is ensured to be the same object [DEFAULT TO 0.7]\n"
"\t--exclude-overlap : the percentage of overlap between expected bounding box and the bounding box from detection. Below this threshold, it is ensured to not be the same object [DEFAULT TO 0.5]\n"
Expand Down Expand Up @@ -73,9 +73,9 @@ int main(int argc, char** argv)
.max_area = 5000,
.symmetric = 1,
.alpha = 0.1,
.balance = 1.75,
.alpha_ratio = 0.85,
.iterations = 10,
.balance = 1.5,
.alpha_ratio = 0.9,
.iterations = 15,
.relabels = 5,
.negative_cache_size = 1000,
.C = 0.002,
Expand Down Expand Up @@ -217,7 +217,7 @@ int main(int argc, char** argv)
free(posfiles[i]);
ccfree(posfiles);
ccfree(bboxes);
for (i = 0; i < posnum; i++)
for (i = 0; i < bgnum; i++)
free(bgfiles[i]);
ccfree(bgfiles);
ccv_disable_cache();
Expand Down
2 changes: 1 addition & 1 deletion bin/dpmdetect.c
Expand Up @@ -17,7 +17,7 @@ int main(int argc, char** argv)
ccv_dense_matrix_t* image = 0;
ccv_read(argv[1], &image, CCV_IO_ANY_FILE);
ccv_dpm_mixture_model_t* model = ccv_load_dpm_mixture_model(argv[2]);
ccv_dpm_param_t params = { .interval = 8, .min_neighbors = 1, .flags = 0, .threshold = 0.5 };
ccv_dpm_param_t params = { .interval = 8, .min_neighbors = 1, .flags = 0, .threshold = -0.3 };
if (image != 0)
{
unsigned int elapsed_time = get_current_time();
Expand Down
2 changes: 1 addition & 1 deletion bin/dpmvldtr.rb
Expand Up @@ -44,7 +44,7 @@
opx_max = [obj[:x] + obj[:width], x + width].min
opy_max = [obj[:y] + obj[:height], y + height].min
r0 = [opx_max - opx_min, 0].max * [opy_max - opy_min, 0].max
r1 = obj[:width] * obj[:height] * 0.5
r1 = obj[:width] * obj[:height] * 0.6
if r0 > r1
outlier = false
break
Expand Down
2 changes: 1 addition & 1 deletion doc/bbf.md
Expand Up @@ -78,7 +78,7 @@ information, for me, it is:

Suppose you have copied the ground truth to truth.txt file, run the validator:

./validator.rb truth.txt result.txt
./bbfvldr.rb truth.txt result.txt

My result for bbfdetect is:

Expand Down
31 changes: 27 additions & 4 deletions doc/dpm.md
Expand Up @@ -22,10 +22,33 @@ Checkout output.png, see what happens?
What about performance?
-----------------------

DPM is not known for its speed. Its ability to identify difficult objects, that's
the winning point. However, this implementation tries to optimize for speed as
well. For a 640x480 photo, this mplementation will be done in about one seconds,
no multi-threading cheat.
DPM is not known for its speed. Its ability to identify difficult objects, is
the selling point. However, this implementation tries to optimize for speed as
well. For a 640x480 photo, this implementation will be done in about one second,
without multi-thread support.

Accuracy-wise:

There are two off-the-shelf implementations. One is the DPM in matlab from author,
the other is HOG detector from OpenCV. Fo the task to detect pedestrians in a
given image, we use INTRA 2008 dataset, and it provides both training and testing
data. With OpenCV stock peopledetect sample program, we get:

65.7% (156)

The former one is the detection rate (how many objects have been detected), the
later is the number of false alarms (the detected region doesn't contain the
expected object)

Our implementation?

80.14% (74)

Looks pretty good!

Speed-wise:



How to train my own detector?
-----------------------------
Expand Down
8 changes: 4 additions & 4 deletions lib/ccv_dpm.c
Expand Up @@ -773,8 +773,8 @@ static ccv_dpm_feature_vector_t* _ccv_dpm_collect_best(ccv_dense_matrix_t* image
for (j = next; j < scale_upto + next * 2; j++)
{
ccv_size_t size = ccv_size((int)(root_classifier->root.w->cols * CCV_DPM_WINDOW_SIZE * scale_x + 0.5), (int)(root_classifier->root.w->rows * CCV_DPM_WINDOW_SIZE * scale_y + 0.5));
if ((double)(size.width * size.height) / (double)(bbox.width * bbox.height) < overlap ||
(double)(bbox.width * bbox.height) / (double)(size.width * size.height) < overlap)
if (ccv_min((double)(size.width * size.height), (double)(bbox.width * bbox.height)) /
ccv_max((double)(bbox.width * bbox.height), (double)(size.width * size.height)) < overlap)
{
scale_x *= scale;
scale_y *= scale;
Expand All @@ -795,7 +795,7 @@ static ccv_dpm_feature_vector_t* _ccv_dpm_collect_best(ccv_dense_matrix_t* image
ccv_rect_t rect = ccv_rect((int)((x - rww) * CCV_DPM_WINDOW_SIZE * scale_x + 0.5), (int)((y - rwh) * CCV_DPM_WINDOW_SIZE * scale_y + 0.5), (int)(root_classifier->root.w->cols * CCV_DPM_WINDOW_SIZE * scale_x + 0.5), (int)(root_classifier->root.w->rows * CCV_DPM_WINDOW_SIZE * scale_y + 0.5));
if ((double)(ccv_max(0, ccv_min(rect.x + rect.width, bbox.x + bbox.width) - ccv_max(rect.x, bbox.x)) *
ccv_max(0, ccv_min(rect.y + rect.height, bbox.y + bbox.height) - ccv_max(rect.y, bbox.y))) /
(double)ccv_min(rect.width * rect.height, bbox.width * bbox.height) >= overlap && f_ptr[x] > best)
(double)ccv_max(rect.width * rect.height, bbox.width * bbox.height) >= overlap && f_ptr[x] > best)
{
// initialize v
if (v == 0)
Expand Down Expand Up @@ -870,7 +870,7 @@ static ccv_array_t* _ccv_dpm_collect_all(gsl_rng* rng, ccv_dense_matrix_t* image
for (k = 0; k < bnum; k++)
if ((double)(ccv_max(0, ccv_min(rect.x + rect.width, bboxes[k].x + bboxes[k].width) - ccv_max(rect.x, bboxes[k].x)) *
ccv_max(0, ccv_min(rect.y + rect.height, bboxes[k].y + bboxes[k].height) - ccv_max(rect.y, bboxes[k].y))) /
(double)ccv_min(rect.width * rect.height, bboxes[k].width * bboxes[k].height) >= overlap)
(double)ccv_max(rect.width * rect.height, bboxes[k].width * bboxes[k].height) >= overlap)
{
flag = 1;
break;
Expand Down

0 comments on commit 3cfead3

Please sign in to comment.